42 Astoundingly Useful Scripts and Automations for the Macintosh

The Star-Spangled Banner in MIDI

What could be more appropriate for the fireworks of the Fourth of July than a song about bombs bursting in air, illuminating a great flag rippling defiantly to a hostile world?

Jerry Stratton, June 30, 2021

Flag behind the ramparts of Fort McHenry: From the National Park Service for Fort McHenry, a large flag (but not THE large flag) flying over the fort.; history; American flag

This is not the large flag, but it is a large flag flying over Fort McHenry, viewed from “over the ramparts”.

Everyone knows the story. Francis Scott Key, negotiating the release of American prisoners taken by the British, watches the British bombardment of Fort McHenry from one of the British ships. Fort McHenry’s flag was the John Hancock of flags: a signature bigger than any other, “a flag so large that the British would have no difficulty seeing it”.

It was so big that the fort had two flags: the large one, and a smaller one for normal use better able to withstand the fickle east coast weather. It was probably also easier to lower and raise. From what we know, they were flying the smaller one at the beginning of the fight. After the bombardment, in the dark of the morning, Major George Armistead ordered the big one raised for the British to see. It was an act of defiance deserving of a song. Key obliged. After seeing the great flag rippling in the sea wind over Fort McHenry at dawn, Key was inspired to write a four-stanza poem in honor of the bold gesture, The Defense of Fort M’Henry.

    • O! say can you see by the dawn’s early light,
    • ⁠What so proudly we hailed at the twilight’s last gleaming,
    • Whose broad stripes and bright stars through the perilous fight,
    • ⁠O’er the ramparts we watch’d, were so gallantly streaming?
    • And the Rockets’ red glare, the Bombs bursting in air,
    • Gave proof through the night that our Flag was still there;
    • O! say does that star-spangled Banner yet wave,
    • O’er the Land of the free and the home of the brave?
    • On the shore dimly seen through the mists of the deep,
    • ⁠Where the foe’s haughty host in dread silence reposes,
    • What is that which the breeze, o’er the towering steep,
    • ⁠As it fitfully blows, half conceals, half discloses?
    • Now it catches the gleam of the morning’s first beam,
    • In full glory reflected now shines on the stream,
    • ‘Tis the star-spangled banner, O! long may it wave
    • O’er the land of the free and the home of the brave.
    • And where is that band who so vauntingly swore
    • ⁠That the havoc of war and the battle’s confusion,
    • A home and a country should leave us no more?
    • ⁠Their blood has washed out their foul footsteps pollution.
    • No refuge could save the hireling and slave,
    • From the terror of flight, or the gloom of the grave,
    • And the star-spangled banner in triumph doth wave,
    • O’er the Land of the Free and the Home of the Brave.
    • O! thus be it ever, when freemen shall stand,
    • ⁠Between their lov’d home and the war’s desolation,
    • Blest with vict’ry and peace, may the Heav’n rescued land,
    • ⁠Praise the Power that hath made and preserv’d us a nation!
    • Then conquer we must, when our cause it is just,
    • And this be our motto—”In God is our Trust;”
    • And the star-spangled Banner in triumph shall wave,
    • O’er the Land of the Free and the Home of the Brave.
Washington Monument flags: Flags around the Washington Monument, and a full moon.; American flag; George Washington

There’s something stirring about a flag at dusk or dawn.

It’s beautiful poetry, and like Amazing Grace is an example of how beautiful music can come from flawed people. On the one hand, Key is not as flawed as some of the era. He fought a decade-long fight to free 400 slaves in a contested will, defended individual slaves seeking their freedom, and publicly criticized the cruelty of slavery. But he also owned slaves himself and opposed full abolition of slavery. As District Attorney in DC he used the power of government to prosecute abolitionists on the grounds that according freedom of speech to abolitionists encouraged insurrection.

There’s a lesson for us there, today.

On the other, other hand, the furor over the phrase “hireling and slave” is a modern one.1 “Slave” is a half-anachronistic term nowadays. We see it in times past and think only of chattel slavery—and only one kind of chattel slavery—yet we still use the phrase today for many other meanings. It held these meanings well back in and before Key’s time, at least back to Shakespeare’s.

The phrase “hireling and slave” was often used against the British forces, because the British employed mercenaries, unwilling conscripts, and subjects of the King. The latter two were slaves both in modern usage2 and even more so in Key’s time, when conscripts could literally be conscripted at the point of a sword. Everyone listening to Key’s song when it was written knew exactly what he meant, part and parcel. He was contrasting a tyrannical Crown that couldn’t force enough of its subjects to fight and had to hire mercenaries, to a Democracy whose people fought willingly for the ideal of freedom and that land where freedom might best be built.

The United States didn’t have to hire mercenaries, nor did they have to force their people to defend their country. It was a contrast that resonated at the time, and still does down through the ages. From Senators to singers to soldiers to stadium crowds, it’s always been an ideal worth striving for.

The poem was immediately put to music—the publisher added a well-known drinking song melody, which while difficult to sing is very rousing, and, in my opinion, very forgiving of mistakes. It is very easy to imagine a tavern-full of drinkers raising steins of beer and belting out this melody, linking arms and shoulders with the other singers in the bar, Marseillaise-style.

I think people miss an important point when they talk about how difficult it is to sing “The Star-Spangled Banner” perfectly. It isn’t meant to be sung perfectly. It’s meant to be sung in crowds and half-drunk with joy. In the words of Joni Mitchell3, “the more voices on it, the better, and the more out-of-tune voices on it, the better”.

It was made for out-of-tune singing, this song.

Here’s the melody for use in the piano script in 42 Astoundingly Useful Scripts and Automations for the Macintosh:

# The Star-Spangled Banner
# Francis Scott Key, John Stafford Smith, Arrangement Samuel Stokes

--tempo 98
--key G

- 8 D. 16 B    | 4 G B D         | + 2 G 8 B. 16 A | 4 G - B C+    | 2 D 8 D D

+ 4 B. 8 A 4 G | 2 F 8 E F       | 4 G G - D       | B G 8 D. 16 B

4 G B D        | + 2 G 8 B. 16 A | 4 G - B C+      | 2 D 8 D D

+ 4 B. 8 A 4 G | 2 F 8 E F       | 4 G G - D       | B G 8 + B. 16 B

4 B C D        | 2 D 8 C B       | 4 A B C         | 2 C 4 C

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

+ G G 8 G F    | 4 E E E         | 8 A B C B A G   | 4 G F. 8 -D -D

4 G. 8 A B C   | 2 D 8 G A       | 4 B. 8 C 4 A    | 2 G..


This is a very simple version of the melody. The song is known for being hard to sing, and there are some very intricate arrangements out there. I’ve included one moderately intricate arrangement, from the 1922 “Hymns of Praise”, in the archive (Zip file, 7.0 MB). It has both a treble and bass clef, and two voices per clef. That’s the version that I used in the video. I pulled the MIDI files into GarageBand and used a trumpet for the treble clef and tuba for the bass clef, which gives it, to my ear, a traditional feel.

Both the piano melody files and the MIDI files are in the archive, and an MP3 of both the simple melody and the more intricate arrangement.

“We’re captive on a carousel of time.”

  1. There were abolitionists who attacked Francis Scott Key—justifiably, in my view—for writing a song about freedom while owning slaves and defending slavery. They used the phrase to do this. But they were attacking Key, not the phrase.

  2. Even today, “slaves to the king” specifically means people who are not slaves but are subject to the King’s authority. It’s another example of how an iron horse is not a horse.

  3. She was talking about “Circle Game”, on her great live album “Miles of Aisles”.

  1. <- O Little Town
  2. Merry Command Line ->