# blog.humaneguitarist.org

discoveries in digital audio, music notation, and information encoding

## object oriented smoothies … mmm.

I'm at the coffee shop and it's raining like cats and dogs … which is a happy situation considering that it wasn't "supposed" to rain for another three hours or so and I like rainy Sunday mornings especially while reading or writing.

Anyway, I was talking to someone the other day about object oriented programming. Also, at work we're likely to start a project for which I'll be coding most of the backend and I've been asking myself "more OO or more functional?".

Given that I really don't write in OO (neither does anyone on staff) even though I understand the concepts, I decided the best way to decide was really to do some light OO scripting in Python to help me decide.

For the project at work, this little Python experiment – as well as the light readings I've done the last two days – has led me to decide on a more functional style. I'll be able to get the job done faster and test easier. The speed thing is very much an issue since we'll be on a very tight deadline. Moreover, the project's not the time for me to learn new things unless I have to in order to get the job done effectively.

Anyway, the hardest part of this Python experiment was to think of a situation where OO would clearly be the better choice. So I started thinking about changing states of things. That's another reason I think OO is bad for the work project – I just need to do one-time input/output operations; things won't be changing states – at least not in the backend.

As I was thinking, I was thinking about food. Because I was hungry at the time (like I am now).

I eat a lot. And yes, I do exercise and lift weights regularly so my eating is quite intentional. I have two protein smoothies a day and so … I started thinking about my blender as an object with properties.

By attributing state … and providing methods for changing that state, the object remains in control of how the outside world is allowed to use it.

source: What Is an Object? (The Java™ Tutorials > Learning the Java Language > Object-Oriented Programming Concepts. Retrieved July 27, 2014, from docs.oracle.com/javase/tutorial/java/concepts/object.html

My blend is either "on" or "off".

It consumes wattage to run, etc.

And with a digital blender, I can record "usage" and, knowing the wattage used per second, calculate how much the blender has cost me to run both over time and, if I wanted, each individual time. This "usage" can be reset, too. If you have a ball point pen, that is.

So "usage" and "cost" are other properties – although as I'm writing I could see how "cost", being based on a variable (cost per watt) and "usage", should perhaps not be a method but rather a function, especially given how cost per watt is going to change over time. But for now, it is watt (pun!) it is.

So, I created a "blender" class which has some simple specification metadata and I created an "appliance" class which "blender" inherits.

The code is below as are the IDLE ouput results of me "using" the blender.

In the IDLE shell, I also created a "toaster" class as that, too, inherits the "appliance" class.

p.p.p.s: If you think smoothies suck, your comment will not get published.

#########################
# smOOthie.py (Object Oriented smoothie).

##### appliance class.
class appliance():

# establish the state of the appliance.
def __init__(self):
self.state = "off"
self.reset()

# toggle the power state of the appliance,
# record the on/off times as "start"/"stop",
# return the new state of the appliance.
def toggle(self):

from time import time
now = time()

# if toggled "on", set the "start" time.
if self.state == "off":
self.state = "on"
self._start = now

# if toggled "off", set the "stop" time and record "start"/"stop" times.
else:
self.state = "off"
self._stop = now
self.usage.append({"start": self._start,
"stop": self._stop})
return

# return usage cost for appliance since last reset.
def cost(self):

total_seconds = 0

for use in self.usage:
if len(use) == 2: # make sure there is a "start" and "stop" time.
subtotal_seconds = use["stop"] - use["start"]
total_seconds = total_seconds + subtotal_seconds

total_watts = total_seconds * self.specifications["watts_used_per_second"]
total_cost_in_cents = total_watts * .012 # cost per watt based on "http://www.eia.gov/electricity/monthly/update/end_use.cfm#tabs_prices-3"
total_cost_in_cents = round(total_cost_in_cents, 2)

# reset usage counter.
def reset(self):
self.usage = []

#########################
##### blender class.
class blender(appliance):
kind = "blender"
specifications  = {"manufacturer": "generic",
"model": "generic",
"price": "n/a",
"watts_used_per_second": .0834}
# "watts_used_per_second" based on "http://www.indoorgenerator.com/0p/Power-Consumption-Table.pdf" for a blender.

#########################
##### use the blender appliance - i.e. make a smoothie.
from time import sleep

myBlender = blender()

# setting specifications (especially watts used) for Acme blender.
myBlender.specifications = {"manufacturer": "Acme Corporation",
"model": "Illudium Q-36",
"price": "$1,000,000.00 (space dollars)", "watts_used_per_second": 1000} # this is a VERY expensive blender to buy AND use! def useBlender(duration=5): print "\nMy blender was: " + myBlender.state myBlender.toggle() print "\nMy blender is now: " + myBlender.state print "\n\t... using blender for this many seconds: " + str(duration) sleep(duration) # making a smoothie usually takes a little longer ... myBlender.toggle() print "\nMy blender is now: " + myBlender.state print "\nMy blender has been used this many times: " + \ str(len(myBlender.usage)) print "\nMy blender has been used during the following times (UNIX):" for i in myBlender.usage: print "\t", i print "\nUsing my blender has cost this (cents): " + \ str(myBlender.cost()) print "_" * 25 useBlender() # blend smoothie. useBlender(2) # just a quick pulse. # fin. And here's the output … Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> ================================ RESTART ================================ >>> My blender was: off My blender is now: on ... using blender for this many seconds: 5 My blender is now: off My blender has been used this many times: 1 My blender has been used during the following times (UNIX): {'start': 1406470729.349, 'stop': 1406470734.357} Using my blender has cost this (cents): 60.1 _________________________ My blender was: off My blender is now: on ... using blender for this many seconds: 2 My blender is now: off My blender has been used this many times: 2 My blender has been used during the following times (UNIX): {'start': 1406470729.349, 'stop': 1406470734.357} {'start': 1406470734.388, 'stop': 1406470736.416} Using my blender has cost this (cents): 84.43 _________________________ >>> class toaster(appliance): kind = "toaster" specifications = {"manufacturer": "?", "model": "?", "price": "?", "watts_used_per_second": .4167} >>> myToaster = toaster() >>> myToaster.toggle(); sleep(10), myToaster.toggle() (None, None) >>> myToaster.cost() 0.05 >>> myToaster.state 'off' >>> myToaster.toggle(); sleep(10), myToaster.toggle() (None, None) >>> myToaster.cost() 0.1 July 27th, 2014 at 11:19 am ## three by Rafa and the greatest quote ever leave a comment I've recently finished reading three novels by Rafael Sabatini. They happen to be the basis for three of my favorite films as well. That, of course, is why I read them. Starting with Captain Blood – Colonel, darling – I moved on to The Sea-Hawk and Scaramouche – the same order in which the 1935, 1940, and 1952 films were respectively made but not in the order of publication. Anyone who's read the novels and seen the films knows that the Errol Flynn iteration of The Sea Hawk has nothing to do with the book. Still, it's a great film with a great duel. Better – if memory serves – than the duel in Caption Blood though perhaps not as fine as the duel in Scaramouche with Stewart Granger. That duel – again, if memory serves – is argued by more than one, if not many, to be the finest in cinematic history. The justly famous eight-minute climactic duel in the theatre between Granger and Mel Ferrer (as Noel, the Marquis de Maynes) required eight weeks of training in which both stars had to memorize eighty-seven individual sword passes and perform twenty-eight stunts. source: Scaramouche (1952) – Articles – TCM.com. Retrieved June 28, 2014, from www.tcm.com/tcmdb/title/2053/Scaramouche/articles.html Naturally, both Flynn films are all the more majestic thanks to one Erich Wolfang Korngold. Not since I read Lloyd Alexander's Chronicles of Prydain has reading been so laden with a sense of adventure. And while the Prydain books have depth that I could only glimpse as a youth, Sabatini's work has truth and wisdom. This, despite the fact that the protagonists in this unofficial trilogy appear on the outset to be men who are lived by life, simply making the most of the unfortunate hands they've been dealt, or as Flynn's Blood muses, "Desperate men, we go to seek a desperate fortune." As epic as those words are, they don't match the words apparently spoken by Flynn's Flynn … "I intend to live the first half of my life. I don't care about the rest." – Errol Flynn. -------------- #### Related Content: June 28th, 2014 at 12:34 pm ## goodbye to the Guitar Foundation of America leave a comment My GFA membership has expired and I won't be renewing. Despite all the "great" benefits membership entails (see below), the Soundboard has been in a steady state of decline since they long ago stopped accepting letters to the editor. Its latest incarnation – embarrassing content aside – is less a journal and more a website printed on glossy paper. As a member I'd liked to have known what the printing costs are for doing that as opposed to before – maybe it's a better deal in terms of print production, but it's just another way in which I felt, more and more, like a customer than a real member. This is a reminder that your Guitar Foundation of America membership has expired. We hope you will take a moment to renew your membership for another year to ensure that you will continue to enjoy all of the great GFA benefits including Soundboard magazine, discounts at retailers such as Mel Bay Publications, Editions Doberman-Yppan, Guitar Solo Publications, Guitar Salon International, Colorado Case Company, a discount on Acoustic Guitar magazine subscription, and up to a 60% discount on instrument insurance through Clarion & Associates, Inc. Members are involved in their organizations growth – or at least have the opportunity to do so. The Soundboard doesn't lend itself to discussion, the website seems to have virtually no discussions, the Soundboard Scholar was supposed to be out a year ago and yet there appears to be nothing going on or at least nothing being communicated on the website, and whatever happened to the old forums that were on the old Drupal site? As a member I should be a co-owner of that discussion content. I don't really see that the organization has any digital strategy let alone a print one (well, at least not a good one in my opinion). It's so easy these days to do online surveys, but as a member I don't recall ever being asked my opinion on anything. Curiously though, I was asked to rewrite this post to be less "negative". I didn't. That, boys and girls, is what we call a "red flag". Anyway … I could go on but there's no point. The music will live and that's what matters to me. The GFA no longer does. a postscript: I wrote this post on April 6, 2014 and only published it today, April 29. The reason being is that after reading my words I thought it only fair to first inquire with the GFA about the status of Soundboard Scholar. So I sent an email with the subject "Soundboard Scholar" (copied below) on April 6th. It's been over three weeks with no reply and the webpage, as of this date, still says "Summer 2013" as the launch date. Perhaps the email address isn't even being checked any more. So like I said before … I could go on but there's no point. nitin arora Sun, Apr 6, 2014 at 10:29 AM To: peerreview@guitarfoundation.org Hello, It's been a year since this was supposed to first come out. Is there any progress? Can something at least be posted here: http://www.guitarfoundation.org/?page=SBScholarly for the sake of some transparency? thanks, -- Nitin Arora nitaro74 (at) gmail (dot) com "Hope always, expect never."  -------------- #### Related Content: April 29th, 2014 at 5:00 pm Posted in music,opinion Tagged with , , , ## Four fur Marv: some new old music for solo guitar leave a comment This is a just a short post to provide a link to some new compositions for solo guitar I completed this week – after starting in September 2012. While I don't expect anyone but myself to take the time to learn these properly, I do know a few folks that I think would at least give them a read through. If I had to provide some overview of them it would be that they are written in a 19th century/Romantic style and hopefully provide enough variance in texture to provide interest from piece to piece. While these are a set, each piece is certainly independent of the other although the cadential endings of the first and last piece share some deliberate similarities – a sort of tying up of loose ends. I might, at some point, post a brief analysis of some of the harmonic structure of the last piece, which at times provided me with quite a headache, but ultimately I let the music go where it wanted to. I simply needed to understand how it was doing so and had, in particular, to know this is order to try and provide coherent spellings of accidentals/enharmonics, etc. Below are links to the PDF of the music and the textual "liner notes" as well as a ZIP archive with the PDF, liner notes, and source LilyPond files, etc. Oh, and by the way, the work is dedicated to a friend of mine. He happens to be a cat. If kitty-inspiration is seemingly good enough for Domenico Scarlatti, it's surely good enough for me. -------------- #### Related Content: March 29th, 2014 at 11:20 am Posted in music,news Tagged with , , , , ## trying to do a better job of image security leave a comment Just a quick post. I've been thinking of image security lately, within the context on reading ebooks online. Nothing online's going to be totally safe, but I have been thinking of better things I can do to protect an image on a website. I've seen some sites that use image servers to protect access to the direct image, but if the image is called via the <img> tag, then all one has to do is use their browser's "Save web page complete" function. I haven't investigated why, but calling an image via CSS' background-image property doesn't result in the image being downloaded via the browser. I found a nice tutorial on "shrink wrapping" an image at http://skinnyartist.com/how-to-shrink-wrap-your-images/. On top of that I used an image proxy script to read and return the data for a given referring URL only and used htaccess to block ALL HTTP requests to images within a given folder. Here's the link to the "demo": http://blog.humaneguitarist.org/uploads/simijh/index.php. If you can download the image by hook or crook, I'd appreciate a comment below on how it was done. So far, using just Firefox, I can go to "View Page Info>Media>Save As" and get it although that's hopefully a bit of a pain and, therefore, a deterrent. The PHP image proxy script and .htaccess file codes are below. image.php <?php function return_image($image_url, $referring_url,$url_prefix="", $fallback_image="") { /* Takes an image located at ($url_prefix + $image_url) and returns the image data provided the HTTP_REFERER is equal to$referring_url.

If the image does not exist it will fallback to the $fallback_image. For the basic code related to proxying data in this way, see: "http://www.php.net/manual/en/function.fpassthru.php". */ // restrict access to image to$referring_url only.
if ($_SERVER["HTTP_REFERER"] !=$referring_url) {
echo "You aren't allowed to see this image directly.";
exit;
}

$image_url =$url_prefix . $image_url;$binary = Null;

// open the file only for .jpg. .gif, and .png files.
if (stripos($image_url, ".jpg") == True || stripos($image_url, ".gif") == True
|| stripos($image_url, ".png") == True) {$binary = @fopen($image_url, "rb"); } // use the fallback image if opening the file failed. if (!$binary) {
$image_url =$fallback_image;
$binary = fopen($image_url, "rb");
}

// set the MIME type; send the image; stop the script.
$extension = substr($image_url, -3); //will not work with extensions over 3 characters: i.e. "jpeg".
header("Content-Type: image/$extension"); fpassthru($binary);
exit;
}

// execute return_image().
if (isset($_GET["q"])) { return_image($_GET["q"], "http://blog.humaneguitarist.org/uploads/simijh/index.php", "", "");
}

?>

.htaccess

<FilesMatch "\.(?:jpg|gif|png)\$">
Order allow,deny
Deny from all
</FilesMatch>

February 8th, 2014 at 10:37 am

Posted in technophilia

## metadata is like the Muppets and Italian film

A couple of years ago, I was – against the better judgment of a friend – asked to give a guest class lecture at NC Central University on OAI, metadata harvesting, etc. for her metadata class at their school of library and information sciences.

Apparently, it went badly enough that I was asked the next year to try and get it right by that year's instructor.

I'm not sure if I did get it right after all, but I wanted to post the presentation slides all the same. They're here.

It's a little silly – using a Muppet motif throughout, but I think my main points got across. I think people are much more likely to get something if looked at in real-world terms (as if the Muppets are real). A little sense of humor doesn't hurt either.

I'd like to say that the "splash" page, a movie poster for Michelangelo Antonioni's film Blow Up, is the best part. It's all downhill from there, no doubt.

To me, the film made no "sense" until the last, surreal scene of people playing tennis without a ball put it all together for me. It was as if the entire film was a Subject and a string of Adverbs until the last scene, the Verb.

I let the class know this … and asked them to remember that while putting up with my presentation.

--------------

#### Related Content:

January 11th, 2014 at 11:20 am

## Monster Serials: listening to old radio plays while working on music notation

There are a lot of things I can do while having music, mostly classical, on in the background.

Working on music notation is not one of them. I don't mean composing the notes themselves – for that I need silence, but rather entering notes and performance indications into notation software.

So instead I like to listen to old time radio plays. Lately, I've had one of the following two playing in the background while I work:

Both are hosted on Archive.org.

Interestingly, the actor who portrays the monster in the Frankenstein piece mispronounces "Frankenstein" as "Franken-steen" initially, it seems. I had thought this was a subtle way of showing the monster getting smarter as he later learns to pronounce it correctly, but I believe some of the other actors made the same error here and there. So it might likely be just from the reality of reading a script and recording with limited time for checking for continuity errors.

I'll also mention that in trying to come up with a clever title (a play on Monster Cereals – get it?) I learned about Franken Berry Stool.

That is all.

--------------

#### Related Content:

January 4th, 2014 at 1:06 pm

## humaneguitarist.org enters the 21st century and some background information

I started my site (humaneguitarist.org) around 1996 after I thought it would be a good idea to share what I learned with regard to classical guitar posture.

After some major surgery in 1995, I tried to resume my studies with Christopher Berg at the University of South Carolina but I was simply too weak to do it. The telling moment came when I was in a practice room and dropped some sheet music. When I bent my knees to get down to pick the papers up, I was barely able to get back up.

On top of that, my back started to hurt like hell from practicing. I was using a footstool at the time because I found the A-Frame guitar support – widely used within our guitar program at the time – to be far too unstable for my tastes. The combination of a footstool and not being physically up to the task made for the perfect combination for a bad back. I'd wake up each morning feeling somewhat OK, but after a couple hours of practicing the pain became too great to continue.

Being too young to drink, I hit the books instead of the bottle.

And that's when the research that gave birth to this website began.

After some 17 years, I finally updated the HTML code … I don't even think CSS was around when I first created the site.

Now, of course it still looks the same but the code is much cleaner and easier to read. Mostly, it's not as annoying to me personally to know that it was messy under the hood.

Anyway, that's my story and I'm sticking to it.

Happy New Year.

Update, later in the day: Actually, thinking back the "humaneguitarist.org" domain probably goes back to only 1999. The main content has been online since about 1996 using America Online, GeoCities, tripod.com and whatever else until I got sick of changing URLs and finally started using my own domain name.

--------------

#### Related Content:

December 31st, 2013 at 12:40 pm

Posted in music,news

Tagged with , , , , ,

## discourteous accidentals

Earlier today I was proofreading the four pieces I'm writing to make sure I place courtesy accidentals where appropriate – as in where I deem them appropriate.

As the name implies, courtesy accidentals are just, well, a courtesy to the performer and technically aren't necessary.

In more chromatic sections, I think their importance rises. But I also think one has to try and combat instances where a musician might legitimately not know what to play – perhaps because the altered note is more ornamental in nature – or where that person might not know enough to make an informed decision as to what to play if there is a slight hint of ambiguiity.

In the excerpt below I was about to place a courtesy natural sign on the "g" in the bass voice of measure 3 as the "g" in measure 2 was a "g-sharp".

But then I realized I had already stated it was "g-natural" by specifying it would be played as an open string – considering that I didn't specify an alternate tuning. There are actually a few instances throughout the pieces where I think the fingering or implied fret position makes it clear what to play without the need for courtesy accidentals.

Of course, one could argue that I should place a courtesy accidental on the "f-natural" in measure 2 given that it was an "f-sharp" in measure one – albeit in a different voice.

But the guitarists in the audience already knew the correct note to play … right?

December 28th, 2013 at 1:23 pm

## LilyPond: explicit initial durations for a second voice and thanks to Frescobaldi

Happy Holidays, humbug, and stuff.

I'm in a coffee shop working on finalizing some pitches and durations for some pieces I'm working on for solo guitar. I'm hoping I can have the fingerings and dynamics all punched in by the end of the year – as I've got a nice amount of vacation built into the school year (one of the best advantages of working in academia). I started composing these last September (2012) so I'm behind schedule in that I wanted to be all done by September, 2013. Good intentions and all.

Anyway, I'm using the mighty Frescobaldi editor to make Lilypond scores after I'd done the initial notation in MuseScore and exported it to LilyPond format. And yesterday I was struggling with something I'd never come across before.

Basically I had thought that the first note defaults to a quarter note if no duration is specified. According to the LilyPond documentation here, that is indeed the case:

If the duration is omitted, it is set to the previously entered duration. The default for the first note is a quarter note.

The last measure of my first voice part ended with a half-note rest and the first note of my second voice part started with a quarter note, which I failed to explicitly notate because I thought a quarter note was the default per voice. My bad.

Well, it seems that the first note of the second voice was actually inheriting the half note from the end of the first voice so after getting a bit frustrated as to why my score was compiling all wonkily I stumbled upon the need to set the duration for the first note of the second voice explicitly as below.

  <g e' c'>4 r <b f' g> r |
<g c e>2\fermata r\bar "|." |
}

% voice 2.
basso = \relative c {
\voiceTwo
\stemDown
\set fingeringOrientations = #'(left)

c4 e r e | % 1
--------------

#### Related Content:

December 24th, 2013 at 10:55 am