42 Astoundingly Useful Scripts and Automations for the Macintosh

Piano notation reference sheet

The “piano” script from 42 Astounding Scripts has several options. You can see them via the --help argument, of course, but here’s a cheat sheet you can print to card stock for easy reference.

Jerry Stratton, August 7, 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.

Yankee Doodle Dandy (249.5 KB MP3 file)

I’ve also used GarageBand to convert the file into a Yankee Doodle MP3 file for your listening pleasure, using the flute; in GarageBand you can find it under woodwinds.

What might be even more interesting, if you want to play around, would be to create the bass clef as a separate MIDI file and then add it as a separate instrument in GarageBand. GarageBand is an extraordinarily useful app for working with MIDI files. You can import as many as you want, and assign different instruments to each. GarageBand doesn’t care where the MIDI input came from, instrument or file.

If you’ve customized the piano script, you can add your own options to the reference sheet by downloading the RTF file (Zip file, 24.7 KB). I created the RTF file in Nisus, of course, but you can edit it in Open Office, Word, or any word processor that reads RTF, which is most if not all of them.