42 Astoundingly Useful Scripts and Automations for the Macintosh

Music Hall

Source files for the Astounding Scripts player piano.

Jerry Stratton

Piano notation reference sheet—Wednesday, August 7th, 2019

One of the scripts I wrote specially for 42 Astoundingly Useful Scripts was the piano script. Being able to reproduce songs from the command line is something I’ve wanted for a while. Having finished the ASCII art generator, I thought it’d be nice to include a corresponding script for music.

Being able to generate MIDI files from it was a bonus.

The script grew rapidly as I added more songs to it. One of the things I quickly discovered I needed was a quick reference to where notes change octave. Having the help text on screen while I work up a song was easy enough done by opening a new Terminal window, but getting the treble/bass clef on screen meant also opening the ebook. This tended to mean four windows: the window I’m using to work the piano, the window with piano’s help text, the window with the treble/bass clef octave graphic, and the window with the sheet music.

It turns out to be a lot easier to put two of those onto cardstock and keep them handy off-screen. This PDF for piano (PDF File, 76.5 KB) reproduces the help text a bit more verbosely as well as the octaves graphic. It also provides a simple example, using the chorus to “Yankee Doodle Dandy”.

  • ~/bin/piano --key A 8 "-D. F." 16 "E G" 8 "-D F" "-C E" "-D F" "E G" 4 "F A" 8 "-C. E." 16 "-D F" 8 "-C E" "-B -D" "-A -C" "-B -D" "-C E" R "-D. F." 16 "E G" 8 "-D F" "-C E" "-D F" "E G" "F A" "-D F" "-C E" "-C A" "-D G" "-D B" 4 "-C A" 8 "-C A"

As you can see, it relies heavily on two-note harmonic intervals. The source I used for the melody, I Hear America Singing, also used them. If you want to make the example even more complex, it looks like each interval could be buffed up to four notes to include the bass clef in that sheet music. This would likely make for a better melody but definitely a worse example.

Older posts