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”.
[toggle code]
- ~/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.
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.
- 42 Astoundingly Useful Scripts and Automations for the Macintosh•: Jerry Stratton at Amazon.com (paperback)
- If you have a Macintosh and you want to get your retro on, take a look at 42 Astoundingly Useful Scripts and Automations for the Macintosh. These modern scripts will help you work faster and more reliably, and inspire your own custom scripts for your own workflow.
- Piano reference document (Zip file, 24.7 KB)
- Here’s the RTF file for the piano script reference card, in case you want to modify it.
- Piano script reference (PDF File, 76.5 KB)
- A reference card for the “piano” script from 42 Astounding Scripts.
- Yankee Doodle Dandy
- The chorus to Yankee Doodle Dandy on flute.
- Yankee Doodle from I Hear America Singing at Wikipedia
- I Hear America Singing: 55 Songs and Choruses for Community Singing, 1917.