Skip to content
Mixed Nuts
Go back

Prosody - a poem is the source code

· 6 min read

I wrote poetry as an angsty teenager, like so many before me. I even continued into my twenties and beyond (if you are looking to cringe at it - here is a sample).

The thought of using a poem as code has been pinging around my brain for years, but time, time has not been on my side on this one. Then, agents became a thing. And like so many of my endless free-time projects lately, this one came about through my thoughts and an agent’s “fingers”.

A note on who wrote what

This entry has two voices. The diagrams, their captions, and the summary are Claude Code’s work, drawn from what the compiler actually did with these two stanzas. The rest is me. That’s why the captions sound far more sure of themselves than I do; they’re as much an explanation to me as to you.

The idea

I wanted the music to reflect the poem’s structure, the poet writing a score unknowingly. The meter defines the rhythm, the rhyme becomes the melody, every repetition defines the arrangement and the rarity of the words defines the timbre - uniqueness laid bare.

We do need to be able to alter the outcome a bit, so the poem can define a style in the header, which will result in a change of sound, but the timings are bound to the form itself.

poem.txt Tyger Tyger, burning bright, In the forests of the night; What immortal hand or eye, Could frame thy fearful symmetry? plain text; a TOML header may set the palette only syllables TY · ger T AY1 · G ER0 CMU dictionary, spelling rules for words it lacks passes meter → rhythm stress → accent rhyme → melody vowel height → bass sound + rarity → timbre repetition → arrangement score → pattern every event carries the span of poem bytes it came from: “bright” is line 1, col 22–27 stack( s("<[bd bd]…>"), note("<62 …>") ).cpm(128) Strudel or OSC --explain walks it back: any sound → the word that made it poem.txt Tyger Tyger, burning bright, In the forests of the night; What immortal hand or eye, Could frame thy fearful symmetry? plain text; a TOML header may set the palette only TY · ger T AY1 · G ER0 CMU dictionary; spelling rules for words it lacks passes meter → rhythm stress → accent rhyme → melody vowel height → bass sound + rarity → timbre repetition → arrangement every event carries its span back to the poem: “bright” is line 1, col 22–27 stack( s("<[bd bd]…>"), note("<62 …>") ).cpm(128) Strudel or OSC --explain walks it back: any sound → the word that made it
The compiler reads the poem once and runs independent passes over it. Each pass owns one musical dimension, and every event it emits keeps a pointer back to the bytes of the poem it came from.

The test subject: The Tyger

Tyger Tyger, burning bright,
In the forests of the night;
What immortal hand or eye,
Could frame thy fearful symmetry?

In what distant deeps or skies.
Burnt the fire of thine eyes?
On what wings dare he aspire?
What the hand, dare seize the fire?

Why choose Blake? In all honesty, why not? The poem is a test subject - it is the source code.

What will the next steps make it into? Beats me if I am honest. I used iteration to get to something I found even slightly satisfying. I listened to it quite a bit, unsure now if I enjoy it because of the number of times I listened to it, or because it is really good.

Meter becomes rhythm

Reading what came out, I learned words like ‘trochee’ and ‘syncopation’. Learned is generous; read is closer. The main point is, taking what poetry theory says about a poem and treating it as data, then slowly massaging the result into something listenable. Pretty much it.

beat 1 beat 2 beat 3 beat 4 bar 1 Tyger Tyger, burning bright, Ty ger Ty ger burn ing bright bar 2 In the forests of the night; rest In the for ests of the night bar 3 What immortal hand or eye, What im mor tal hand or eye bar 4 Could frame thy fearful symmetry? Could frame thy fear ful sym me try kick, height = stress (full · ⅔ · ⅓) rhyme word: also sounds the melody note beat 1 beat 2 beat 3 beat 4 1 · Tyger Tyger, burning bright, Ty ger Ty ger burn ing bright 2 · In the forests of the night; rest In the for ests of the night 3 · What immortal hand or eye, What im mor tal hand or eye 4 · Could frame thy fearful symmetry? Could frame thy fear ful sym me try kick, height = stress (full · ⅔ · ⅓) rhyme word: also sounds the melody note
Line → bar, foot → beat, syllable → subdivision, stress → how hard the kick is struck. A foot of three syllables splits its beat in three; a line with only three feet rests on its fourth beat.

Rhyme becomes melody

The rhyme defines melody, the absence of it defines silence.

A4 69 G4 67 F♯4 66 E♭4 63 D4 62 bar 1 bright A bar 2 night A bar 3 eye no rhyme bar 4 symmetry no rhyme bar 5 skies B bar 6 eyes B bar 7 aspire C bar 8 fire C — silence — D phrygian dominant, from the style header · stanza 2 starts at bar 5 stanza 1 A4 69 G4 67 F♯4 66 E♭4 63 D4 62 bar 1 bright A bar 2 night A bar 3 eye no rhyme bar 4 symmetry no rhyme — silence — stanza 2 A4 69 G4 67 F♯4 66 E♭4 63 D4 62 bar 5 skies B bar 6 eyes B bar 7 aspire C bar 8 fire C D phrygian dominant, from the style header
The melody is the rhyme words and nothing else. Each rhyme class takes the next free degree of the scale, in order of first appearance: bright/night → D, skies/eyes → E♭, aspire/fire → F♯. eye and symmetry do not rhyme by the dictionary, so bars 3 and 4 have no tune at all.

Vowels become the bass

Here we start getting close to grasping at straws. The bass must come from somewhere, so it comes from the vowels.

close vowels UH IH A2 fifth · 45 Could UH fearful IH symmetry IH mid vowels ER AH EY F♯2 third · 42 burning ER of AH What AH frame EY open vowels AY AO AE D2 root · 38 Tyger AY Tyger AY forests AO immortal AO hand AE or AO eye AY thy AY close vowels UH IH A2 fifth Could UH fearful IH symmetry IH mid vowels ER AH EY F♯2 third burning ER of AH What AH frame EY open vowels AY AO AE D2 root Tyger AY Tyger AY forests AO immortal AO hand AE or AO eye AY thy AY
Every stressed vowel of a foundation line plays a bass note picked by how open the mouth is: open vowels sit on the root, mid vowels on the third, close vowels on the fifth. The rhyme words are left out because they carry the melody instead.

Sound becomes timbre

Some words are used more often than others, but these are generally not interesting. So the most common words go dull (“the” turns up again and again and sounds muffled every time), while “symmetry” comes out bright enough to cut through.

stanza 1 stanza 2 Tyger Tyger, burning bright, In the forests of the night; What immortal hand or eye, Could frame thy fearful symmetry? In what distant deeps or skies. Burnt the fire of thine eyes? On what wings dare he aspire? What the hand, dare seize the fire? sharpness (rarity + phonetic novelty) T · Tyger Tyger B · burning bright F · frame, fearful D · distant deeps W · what wings AY · fire, eyes a bank shared by function words (DH: the, thine · AH: of, What · IH: In, symmetry) stanza 1 stanza 2 Tyger Tyger, burning bright, In the forests of the night; What immortal hand or eye, Could frame thy fearful symmetry? In what distant deeps or skies. Burnt the fire of thine eyes? On what wings dare he aspire? What the hand, dare seize the fire? sharpness (rarity + phonetic novelty) T · Tyger Tyger B · burning bright F · frame, fearful D · distant deeps W · what wings AY · fire, eyes a bank shared by function words (DH: the, thine · AH: of, What · IH: In, symmetry)
Two passes shape how each word sounds rather than when. The bar above a word is its sharpness: rarer, more phonetically novel words get a brighter filter and a harder attack, so “forests” and “symmetry” cut through and every “the” is dull. The underline is its bank: words that alliterate or share a vowel share an instrument, so “Tyger Tyger” is one timbre and “burning bright” another.

Repetition becomes arrangement

The sound was initially quite boring, monotonous, and it would also end up being short and without any repeating elements. So I poked and prodded, working with the agent to define what else we could use to put some meat on the bones.

stanza 1 stated pass 1 pass 2 pass 3 pass 4 outro 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 A1 Tyger Tyger, burning … A1 Tyger Tyger, A2 In the forests of … A3 What immortal hand … A4 Could frame thy … B1 In what distant … B2 Burnt the fire of … B3 On what wings dare … B4 What the hand, dare … B4 What the hand, stated arriving: replaces a bar of the loop the old loop, not yet replaced held until its rhyme is answered call: the half-line before a comma outro: one more pass A1 call A2 A3 A4 B1 B2 B3 B4 call stated pass 1 pass 2 pass 3 pass 4 outro 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 A1 Tyger Tyger, burning bright, A2 In the forests of the night; A3 What immortal hand or eye, A4 Could frame thy fearful symmetry? B1 In what distant deeps or skies. B2 Burnt the fire of thine eyes? B3 On what wings dare he aspire? B4 What the hand, dare seize the fire? call “Tyger Tyger,” under A1 call “What the hand,” under B4 stated arriving: replaces a bar of the loop the old loop, not yet replaced held until its rhyme is answered call: the half-line before a comma outro: one more pass
Eight lines become 24 bars. Stanza 1 is stated, then keeps looping. Stanza 2 doesn't follow it, it takes it over, one line per pass, until the loop is entirely stanza 2. The comma in “Tyger Tyger,” makes that half-line a call that loops underneath the whole time. “skies” and “aspire” are open rhymes, so the first time through, their lines keep sounding under the bars that follow while they wait for “eyes” and “fire” to answer them.

Hear it

Try it at prosody.rocks - you can play with knobs, use presets and see how the poem lights up as the score plays, showing you what came from where. The code is at mpecan/prosody-experiment.

What doesn’t work yet

Much of it doesn’t work well. The algorithm needs work. Some settings will make it sound like a cat being tortured. But that is what makes it fun for me, so if you want it to be different, play with it, alter the code, and if you feel like it - send me a pull request.


Share this post:

Next Post
Share the Mark - pointing instead of describing

Comments

Loading comments...