42 Astoundingly Useful Scripts and Automations for the Macintosh

Hark! The Herald Angels Sing

A glorious song for Christmas. And a glorious bug fixed.

Jerry Stratton, December 11, 2019

Time to get ready for Christmas! There are a lot of amazing Christmas songs in the public domain. Among my favorite—and many others’ as well, especially gospel singers—is Hark! The Herald Angels Sing. It’s an uplifting song as befits a song about angels heralding the birth of the Son of God.

I pulled this from song 213 in Hymns of Praise, Number Two, which I pulled from my mother’s yard sale pile several years ago. I modified two notes: on the line “with angelic hosts proclaim”, in the treble clef, I turned the first two quarter notes into a quarter and a half plus an eighth. It’s more in line with what I remember, for one, and computerized music is too even when it comes to repeated notes of the same value and duration.

I typed this into two files. One for the treble clef, and one for the bass clef. That way, it’s even easier to create separate MIDI files for use with GarageBand.

Save these files as “Herald treble.txt” and “Herald bass.txt”.

The treble clef:

# Hark! the Herald Angels Sing
# Charles Wesley/Mendelssohn

#treble clef

--key G

4 "-D -D" "-D G"     | "-D. G." 8 "-D F" 4 "-D G" "G B" |
  "G B" "F A" "G D" "F D"    | [D. 8 C] E A "G B" "F A" |
2 "G B"

4 "-D -D" "-D G"     | "-D. G." 8 "-D F" 4 "-B G" "G B" | 
   [2 G] B A "F D" "E A"      | "F. A." 8 "-D F" 4 "-d F" "-C+ E" |
2 "-D -D"

4 "-D D" "-D D"      | "-D D" "G G" "A C" "G B"         |
  "G B" "F A" "-D D" "-D D"  | "-D D" "G G" "A C" "G B" |
  "G B" "F A"

4 "C. +E." 8 "C +E"  | 4 "C +E" "B D" "A C" "G+ B"      |
2 "A C" 4 "F A" [8 B C] F  | "G. D." 8 "-D G" 4 "-D G" "F A"   |
2 "G B"

4  [+ E. 8 E] C C    | "C +E" "B D" "A C" "G+ B"        |
2 "A C" 4 "-D A" [8 B C] F | "G. D." 8 "-D G" 4 "-D G" "F A"   |
2 "-D G"

R

And the bass:

# Hark! the Herald Angels Sing
# Charles Wesley/Mendelssohn

#bass clef

--key G

4 - "G B" "G B"     | [B. 8 A] G -D "-B G" "-G D"           |
2 "-D D" 4 "-B D" "-B D"    | "-C +E" "-C +E" "-D D" "-D D" |
2 "-G D"

4 "G B" "G B"       | [B. 8 A] G D "E G" "-D D"             |
2 "-C+ +E" 4 "-B B" "-C+ A" | [A. 8 A] D -F "-G B" "-A G"   |
2 "D F"

4 "D D" "D D"     | "D D" "B D" "F D" "G D"                 |
2 "-D D" 4 "D D" "D D"      | "D D" "B D" "F D" "G D"       |
2 "-D D"

4 "-C +C" "-C +C" | "-C +C" "-C +C" "-C +C" "E +C"          |
2 "A +C" 4 "C D" "C D"      | [D. 8 B] B G "-D B" "-D C"    |
2 "-G B"

4  [2 -C] "C +E" "C +E" | [2 -C] "C +E" "B D" "-C A C" "E G+ B" |
   [2 C] A G "F D" "C D"       | [D. 8 B] B G "-D B" "-D C"     |
2 "G B"

R

Turn them into midi files using the piano script from the book:

  • ~/bin/piano Herald\ treble.txt --save treble
  • ~/bin/piano Herald\ bass.txt --save bass

And you’ve got two files, treble.midi and bass.midi.

In GarageBand, I considered some of the orchestral organs first, but eventually went for simpler instruments and chose the Classical Acoustic Guitar for the treble clef, and the Steinway Grand Piano for the bass clef. I exported to iTunes and then made a simple slideshow in Photos using some Christmas photos I have. Don’t worry, there’s only one verse, so it’s short.

I did run into one problem in my piano script. Combining these two files to play them on the command line should have been easy. I designed the program to use a file just as if it were typed on the command line. So, surrounding one file with brackets should have played it at exactly the same time as the file after the brackets:

  • ~/bin/piano [ Herald\ bass.txt ] Herald\ treble.txt

Imagine my surprise when it played the treble clef, and then followed up with the bass clef. In other words, while working on the song I discovered a bug in the code. I’ve fixed it for the next release of the book. If you want to fix it before then, it’s in the line:

  • arguments += splitTextToNotes(text:fileText)

That line should be replaced with:

  • arguments = splitTextToNotes(text:fileText) + arguments

The former puts any included file at the end of the list of arguments; the latter inserts the included file at the point where it appears on the command line.

  1. <- America, the Beautiful
  2. Satan’s power ->