♪Music, Built

Act II · Notes

Part 10 of 68

Writing It Down

Foundationsstarts at this level46 min of film12 chaptersprerequisites: none

What does each way of writing music down keep, what does it throw away, and how much of a piece of music is on its page?

A clay tablet from Ugarit, about 1400 BCE, holds the oldest nearly complete piece of written music: the names of pairs of lyre strings, each followed by a number. Nobody knows how it goes, because the scribe left out what every musician of the city knew. That is the problem of notation, and the part follows a thousand years of answers. Neumes record only whether a melody rises or falls: 85 melodies on six notes fit the signs over the Tune's first phrase. Guido of Arezzo's lines, about 1025, turn pitch into height on a page, a graph three centuries before Oresme, though one that counts the steps of a scale and hides which of them are small. Franco of Cologne's shapes give notes their lengths; dots and ties write any length that halvings reach; bar lines and scores let many read together. Tablature and figured bass write what to do instead of what will sound, and each stands for millions of choices that the staff, or the player, must make. Gongche and jianpu write a note's place in its scale, and guqin tablature a gesture with no rhythm at all. A piano roll and a MIDI file keep one performance to the millisecond and forget how its notes are spelled, which in meantone is a difference of 41 cents; MusicXML and MEI keep the page. Then the count: the Tune's page is 168 bits and its sound 127,000 times as many, and a performance by four measured rules shows where some of the difference lies. The frontier is the way back, from a page of pixels to notes. The Tune is read from ten notations, and its last phrase is played as none of them says.

What you need. Part 1 for ratios and the Tune; Part 6 for meantone and why G sharp is not A flat; Part 7 for why one note sounds different on different strings. Logarithms to base two for counting bits; nothing else.

Ideas, mathematics and history
the Hurrian hymn, neumes, Guido's staff, mensural notation, tablature, jianpu and gongche, piano roll, MIDI, MusicXML; what notation leaves out
What we build, compute and hear
the series' score format and engraver; the Tune in ten notations

What you will be able to do

Foundations

  • Read a melody from a staff, from numbered notation and from tablature, and say what each tells you.
  • Explain how note shapes, dots and ties write duration, and what a bar line is for.
  • Say what neumes, tablature, figured bass and a MIDI file each leave out.

Full course

  • Count the melodies that fit a contour, and the tablatures of a melody, by dynamic programming.
  • Write any length k/2^n with dots and ties, and prove the rule for dots.
  • Compute the bits in a score and in its sound, and what a round trip through a format loses.

Research

  • Describe the pipeline of optical music recognition and why a tilted or speckled page breaks it.
  • Say what is solved and open in reading music by machine, and where the encoding standards stand.

Practice

  • Choose a notation or a file format for a task by what it must keep.
  • Keep spelled pitches and exact durations in software, and convert at the edges.
  • Read and realize a figured bass or a chord chart, knowing what is left to you.

Contents

Each chapter has a home level. Choose a track to see what to read and watch: Foundations 35 min · Full course 42 min · Research 46 min · Practice 42 min.

  1. 0A song nobody can readFoundations4 min
  2. 1A reminderFoundations3 min
  3. 2Guido's linesFoundations4 min
  4. 3How long?Foundations5 min
  5. 4Bars and scoresFoundations3 min
  6. 5What to doPractice4 min
  7. 6Numbers and charactersFoundations4 min
  8. 7Holes and bytesFoundations4 min
  9. 8The page as dataPractice3 min
  10. 9How many bits?Foundations4 min
  11. 10Frontier: reading the page backResearch4 min
  12. Variation 10, recap and problemsAll tracks4 min

Also on this page: Lecture · Key results · Try it · Lab · Problems · Notes and sources · Build the film.

Lecture

The text of each chapter is the film's narration, as it is spoken, so you can read along or revise without the film. The pictures are in the film. A dashed box stands for a number the film computes when it is rendered (hover over it to see what is computed); the README's figures for each chapter, where it lists them, follow the chapter's text.

A song nobody can readFoundations4 min

This is a clay tablet. It was dug up in the nineteen fifties from the ruins of Ugarit, a port on the coast of Syria, and it was written about fourteen hundred years before the common era. Above the double line are the words of a hymn to Nikkal, the goddess of orchards. Below the line is something else: words, each followed by a number. Three. One. Three. One. Ten. The technical terms are usually related to named string pairs or intervals, informed by other tablets; their musical interpretation remains debated. This is written music, one of the oldest substantially complete surviving musical notations. And nobody knows how it goes.

Here is that first line, read by Monochord in two ways. In the first, the two strings are struck together, as many times as the number says. In the second, one string is struck and then the other, and the strings are counted from the other end of the lyre.

The same marks. Neither of those is a claim about what was sung in Ugarit, and that is the point. At least five scholars have published reconstructions of this hymn, and no two of them sound alike. Is a pair of strings played together, or one after the other? Does the number count notes, or beats, or repeats? Which end of the lyre is string one? The tablet does not say, because it did not need to. The notation relies on conventions its original users shared, many of which we no longer know. Then the musicians died.

Two thousand years later, around the year 630, Isidore, the bishop of Seville, set out to write down everything that was known. On music he wrote this: unless sounds are held in the memory of man, they perish, for they cannot be written down. He was wrong. The Greeks had written melodies with letters, and a song carved on a tombstone in their notation can still be sung. Such notation was not the basis of Isidore's chant practice. Singers transmitted a large repertory by memory; later writers describe training that could take years. So what would writing a tune down take? A tune is a list of events: which note, when, and for how long. That is a picture with two axes. Four centuries after Isidore, somebody drew it.

Welcome to Act Two. For nine parts we made sounds. Now we have to say which ones, and when, to somebody who is not in the room. Every way of doing that keeps some things and throws the rest away, and this part asks, of each notation: what did it keep? We begin with signs that only remind a singer of a tune already learned. Then four lines that turn pitch into height on a page. Shapes that say how long a note lasts, and the bar lines and scores that let many people read together. Notations that say what to do with your hands instead of what you will hear. Numbers, characters, holes in paper and bytes. And at the end we count: how many bits are in a score, how many in its sound, and where the difference goes.

1A reminderFoundations3 min

What is the least you can write down?

In the ninth century, in monasteries such as Saint Gall, scribes who were copying out the words of chants began to add small signs above the syllables. They are called neumes. Here is the first phrase of our Tune, marked in that way; This is a contour toy, not a transcription of Saint Gall notation; real neumes also convey articulation and rhythmic nuances. A rising stroke says: this note is higher than the last one. A dash: the same note again. A dot: lower.

Here are three melodies. Which one do these signs describe? All three. Each of them stays, rises, stays, rises, stays, and falls, exactly as the signs say. The second one is the Tune. The first leaps a fourth where the Tune leaps a fifth; the third ends by dropping a fourth where the Tune drops a step. The signs say which way the melody goes. These simplified contour signs do not say how far.

How many melodies fit? Monochord counted. If a singer has six notes to choose from, different melodies fit these seven signs. With eight notes, . And for the whole Tune, forty-two notes on the eight notes of an octave, more than three hundred million. Measured in bits, the signs for this phrase carry about ; naming its notes would take . These are code budgets under a chosen alphabet, not measurements of historical information. Early unheighted neumes often supported oral learning. They reminded a singer of a tune already learned by ear, from another singer. The page helped the memory. It could not replace it.

Then, around the year 1000, some scribes began to do something that seems obvious now. They wrote a sign higher on the page when its note was higher. Then someone scratched a line into the parchment to keep the heights honest, and inked it red, and wrote a letter beside it: this line is F. Now the height of a sign means something. One line fixes one note, and the notes near it can be judged by eye. Guido of Arezzo helped systematize the use of staff lines and pitch letters, building on earlier practices.

2Guido's linesFoundations4 min

How do you write how high?

The man was Guido, a monk who taught choirboys in the town of Arezzo, and the year was about 1025. Rule four lines. Every line, and every space between two lines, is one step of the scale. Then write a letter at the start of a line, to say which note that line is. Here the letter C sits on the bottom line. So the bottom line is C, the space above it D, the next line E, and so on up. And here is the Tune: C, C, up to G on the third line, G, the space above for A, A, and back to G.

That letter is the clef; the word means key. We still use Guido's letters. Centuries of penmanship have disguised them, but these three signs are a G, an F and a C, and each still marks the line that carries its note.

Guido was not modest about it. In the preface to his chant book he claimed that with lines and letters a singer could be trained in a year, or two at most, where ten had been needed. And in a letter to a friend he reported that his choirboys could sing, correctly, chants they had never heard. That is Guido's report of his teaching method, rather than proof that no earlier culture could learn from notation. A tune could now travel without a singer to carry it.

Now look at what this is. From left to right is time. From bottom to top is pitch. It resembles a graph, but horizontal spacing here primarily orders events; it does not measure elapsed time uniformly. Vertical position counts diatonic steps, not hertz. Nicole Oresme, who is often given the credit for the first graphs of a quantity that changes in time, drew his in the thirteen fifties. By then choirs all over Europe had been reading one for three hundred years.

How did Guido's boys find their notes? He taught them a hymn they already knew, to Saint John, and pointed out something about it. Listen to where each line begins. The singer is the voice we built in Part 8.

Each of the first six lines starts one step higher than the line before. So the first syllables of those lines became the names of the six notes: ut, re, mi, fa, sol, la. Six centuries later, in Italy, ut was changed to do, which is easier to sing. And a seventh name, si, was made from the initials of the last line: Sancte Iohannes, Saint John. A boy who knew the hymn could find any of the six notes by singing the start of its line.

The hymn taught one more thing, and it is the thing the staff does not show. Those six steps are not equal. From mi up to fa is the smaller interval: a semitone. Tone, tone, semitone, tone, tone. Now look at the same six notes on Guido's lines. Line, space, line, space: every step looks the same. The staff counts diatonic steps, not equal acoustic intervals. In equal temperament a semitone is half a tone in cents; medieval tunings differ in detail. Which of its steps are the small ones is not written anywhere on the page; the singer has to know. That is why the staff later needed sharps, flats and key signatures, and we will come to those in Part 12. For now, notice that even Guido's page is written for someone who already knows something: the scale.

3How long?Foundations5 min

When did a written note get a length?

Guido's notes say which pitch. They say nothing about how long. For chant, sung by everyone together, that was enough. But by the year 1200, at Notre Dame in Paris, singers were singing different melodies at the same time. One voice has eleven notes, the other four. Which ones sound together? The page cannot say. For a while the answer was a set of fixed rhythmic patterns that the singers had to recognize. Then, about 1280, a treatise by Franco of Cologne made the proposal that every later system has kept: let the shape of each note show how long it lasts.

Here are shapes from the mensural tradition, with the minim added later. A square with a tail is the long. A plain square is the breve, which means short. A lozenge is the semibreve, the half short. And the next century added the minim, the least, because composers wanted something quicker still. They are with us yet. Round off the lozenge and it is our whole note; give the minim a round head and it is our half note. In Britain they still go by the old names. And notice what happened: composers kept reaching for shorter notes, the old ones were sung slower and slower, and the note once called the half short is now the longest one in everyday use.

How many semibreves make a breve? Either three or two. Three was called perfect, two imperfect, and a sign at the start of the music said which. A whole circle: perfect time, a breve is worth three. A broken circle: imperfect time, a breve is worth two. That broken circle is still printed at the start of music today. The C that stands for common time was never a letter.

Here are the first two phrases of the Tune in Franco's marks: six semibreves and a breve, twice. Above, under the broken circle. Below, the very same marks under the later mensuration circle. This teaching reader uses a restricted rule set, not a complete historical notation engine. Listen to what the sign does.

Under the broken circle the phrase takes beats, and it is our Tune. Under the whole circle the breves stretch to three, each phrase takes , and the Tune turns into a dance in triple time. Nothing on the staff changed but the sign.

And here is the price. Under the whole circle a breve is worth three semibreves, unless a single semibreve follows it. Then the two of them together make the three, and the breve shrinks to two. What if two semibreves stand between two breves? They have to fill a group of three, so the second one is doubled. Look at those two. They are the same shape, and one lasts twice as long as the other. With three, each is worth one. To know how long a note lasts, you have to read its neighbours. Singers learned pages of rules like these, and Monochord's reader implements them. It was a notation for experts.

In modern note values the base hierarchy divides in twos, while triple groupings continue through metre and tuplets: a whole note is two halves, four quarters, eight eighths. A dot is one way to extend those binary base values. A dot after a note adds half its length. And a tie, a curved line between two notes of the same pitch, joins them into one.

So try this. How would you write a note that lasts five eighths of a whole note? And one that lasts seven eighths? Pause, and work it out.

Five eighths is a half and an eighth: a half note tied to an eighth note. Seven eighths is a half, a quarter and an eighth. A dot adds the quarter, and a second dot adds half of that, the eighth: one half note with two dots.

In general, each dot adds half of what the dot before it added. So a note with n dots lasts one, plus a half, plus a quarter, down to one over two to the n, times its plain length. That sum is two, minus one over two to the n. However many dots you write, a note never quite doubles. And a third of a note? No finite sum of those binary fractions equals a third. The system's patch for that is the triplet, three notes in the time of two, marked with a small figure three. Rhythm has all of Part 11 to itself.

4Bars and scoresFoundations3 min

How do many people read together?

Once notes had lengths, voices could be written apart and still fit together. And for long periods, partbooks and separate voice areas were common ways to write polyphony: each voice by itself, in its own book or its own corner of a large one. A singer saw one line, and counted. There were no bar lines; nothing on your page told you what anyone else was doing. If you lost your place, the page could not help you find it.

The cure was to stack the voices on one page, so that notes sounded together are written one above the other. That is a score. And then to rule lines down through all the staves every few beats: bar lines, a ruler for the eye. Organists and lute players, who had to play several voices with their own two hands, wrote this way first. Printed scores became more common in the late sixteenth century, with important publications in the fifteen seventies; aligned scores had earlier precedents. Bar lines spread widely during the seventeenth century. Guido's graph had gained grid lines.

Here are the two voices together. One line, crossing both staves, shows where we are.

The bar line has a cost, and Monochord's score model pays it the way an engraver does. Inside Monochord a note's length is an exact fraction of a whole note: a half, three quarters, three quarters. But in four-four time a bar line falls after one whole note, in the middle of the second note. So on the page that note is cut in two, a half and a quarter, and the pieces are tied across the line. Three notes are played; four are written. The page is no longer a list of the notes. It is a drawing of them, fitted to a grid.

By 1650, then, the page said which notes and how long. Composers had already begun adding instructions for speed and loudness. Those conventions continued to develop. Italian words for the speed. Letters for soft and loud. Hairpins, for growing louder. And, once Maelzel's metronome was on sale in 1815, a number of beats to the minute. Every one of those additions is an admission that something was missing. Hold on to that thought; we will count what is still missing at the end.

5What to doPractice4 min

Why write the action instead of the sound?

A staff tells you what you will hear. There is another idea entirely: write down what to do. This is tablature. There are six lines, but they are not Guido's lines. They are the six strings of a guitar, the lowest at the bottom. A number on a line tells you which fret to press on that string, and zero is the open string. Lute players wrote like this from the fourteen hundreds; the first printed books of lute music, in 1507, are in tablature; guitarists read it every day. In 1958 Charles Seeger gave the two kinds of writing their names. He distinguished writing that prescribes a performance from writing that describes one. Both scores and tablature can be prescriptive; tablature makes the hand action especially explicit.

Why would anyone want that? Because on a guitar the staff leaves a question open. Take the first note, middle C. It is on the second string at the first fret. It is also on the third string at the fifth fret, and on the fourth string at the tenth. One note on the staff, three places for the hand, and three slightly different sounds, as Part 7 would tell you.

So one page of staff notation stands for many tablatures. For the fourteen notes of these two phrases, Monochord counts more than two million. For the whole Tune, about twenty billion billion. It picks one by dynamic programming: for every note, and every place that note could be played, it keeps only the cheapest way of arriving there, where cheap means that the hand travels little along the neck. The winner never leaves the first five frets. Playing the same notes along one string costs about twice as much under this travel-distance metric, which omits much of real fingering technique. A tablature records that choice, which is why players like it. And what becomes less visible? The melodic contour and spelling. With the tuning known, pitches can be recovered and transferred to a flute, but the action notation is instrument specific.

Around 1600, in Italy, musicians invented another way of writing what to do, for the player who accompanies a singer. Write only the bass line, and under some of its notes a small figure. In this elementary context, no figure defaults to a third and fifth above the bass, with accidentals and style supplying further rules. A six means the third and the sixth. A seven means the third, the fifth and the seventh. In which octave? How many notes, and which one on top? That is left to the player, who decides while playing. It is called figured bass, and for a hundred and fifty years it was central to many European Baroque accompaniment practices.

Here is that bass line, played twice. Two players read the same eight notes and the same four figures.

Both are correct. Every chord in each has the notes its figure asks for; the players only chose different octaves and different notes on top. Monochord counted more than six million ways to fill these eight chords within the reach of a hand, and chose two in which the upper voices move smoothly. The rules for choosing well are the subject of Parts 16 and 17. And the bargain itself never went away: a jazz musician's lead sheet, a melody with chord symbols over it, offers an analogous bargain, with different conventions.

6Numbers and charactersFoundations4 min

Does a notation need a staff at all?

A staff is one answer to the question of pitch. China had found a different one at least a thousand years ago: give every note of the scale a character. Their names are shang, cheh, gong, fahn, lee-oh, woo and ee. In the convention illustrated here they correspond to do, re, mi, fa, sol, la and ti; pitch mappings and rhythmic signs vary by tradition. The system is named gongche, after two of them. Here are the first two phrases of the Tune. They read from the top down, and the columns run from right to left. A small mark beside a character shows where the beat is held. Otherwise, how long each note lasts is shown only roughly. A singer learned the rhythm from a teacher, with the page as a guide.

And Europe produced a staffless notation too. In 1742 a young music copyist named Jean-Jacques Rousseau, who was not yet a philosopher, stood before the Academy of Sciences in Paris with a proposal: write the seven notes of the scale as the numbers one to seven. The Academy was polite, and unconvinced. But French schoolteachers made a singing method out of it; from France it went to Japan; and from Japan, soon after 1900, to China. There it is called jianpu, simple notation, and it became the everyday way to write music down. In this major-key example, one is the tonic; other jianpu conventions, including minor pieces based on six, require context. A dash holds a note for another beat. A line under a number halves it, and a dot above or below moves it by an octave.

And this notation makes a common transposition especially easy. To sing the Tune in another key, change one sign: one equals F. Nothing else on the page moves. On a staff, every note would have to be redrawn three diatonic positions higher, an interval of a fourth, with a flat added. Jianpu does not write where a note is on the keyboard. It writes the note's place in the scale, which is what a singer needs.

One more, and the most radical. The goo-chin, China's seven-string zither, has had its own tablature for more than a thousand years. Each sign is put together from fragments of characters. The top says: an open string. The hook says: pull inward with the middle finger. And the strokes inside say: the third string. A whole gesture in one sign. Precise durations are largely left to oral teaching and interpretation, although gestures and some signs imply temporal relationships. The player works the timing out; two masters' versions of the same old piece can differ throughout. It is the tablet from Ugarit again: the page holds the actions, and a living tradition holds the rest.

Every notation so far kept as much as its makers could manage. In the twentieth century some composers went the other way, on purpose. In 1950 Morton Feldman wrote pieces as boxes on a grid: play something high here, something low there, for this long. Which notes is the player's business. And Cornelius Cardew's Treatise is a hundred and ninety-three pages of lines and shapes without a fixed symbol-to-sound key attached to the score. A notation is a contract between the writer and the reader, and these contracts leave nearly everything to the reader.

7Holes and bytesFoundations4 min

What does a machine need to be told?

In the eighteen nineties a new kind of reader appeared: the player piano. Its music is a roll of paper with holes punched in it. Where there is a hole, air rushes through and a key goes down, and the longer the hole, the longer the note. Time runs along the paper and pitch runs across it. This is Guido's graph with everything else stripped away: no staff, no clef, no shapes. The graph itself has become a machine part. In 1904 the Welte company went one step further and recorded pianists straight onto rolls: when each key went down, when it came up, and expression controls for a reproducing mechanism. Such rolls preserve aspects of performance and can be edited; they are not exact records of every hammer velocity.

In 1983 the makers of synthesizers agreed on a way for one instrument to tell another what is being played. They called it MIDI, and its note messages resemble a piano roll sent down a wire. The Standard MIDI File, developed later, stores events with timing metadata. Here is the start of the Tune as a MIDI file, byte by byte. First a header, and the tempo, the metre and the key. Then the notes. A zero: wait no time. Three bytes: note on, key number sixty, which is middle C, struck with a velocity of eighty. Two bytes: wait four hundred and eighty ticks, which this file defines as one quarter note. Three bytes: note off, key sixty. Nine bytes for this note in our file, and for the whole Tune. Which key, when down, when up, how hard. MIDI also supports controllers, pedals, programs, pitch bends and more; this example only shows note events.

So what does a key number forget? Monochord wrote these four notes into a MIDI file: E flat, G, B flat, E flat. The file holds four key numbers. And when Monochord reads the file back, it gets D sharp, G, A sharp, D sharp. The same four keys of the piano. Not the same notes on the page. A reader has to guess the spelling, and a file of key numbers does not encode a per-note enharmonic spelling; key-signature metadata and musical context can nevertheless help, any more than a piano keyboard does.

Does the spelling matter? Listen. Two notes, X and Y. On a piano they are the same key. Are they the same note?

They are not the same. Y is higher than X by cents, about a fifth of a tone. X is G sharp: a pure major third above E, with the frequencies five to four from Part 5. Y is A flat: a pure major third below the C above. With E, the G sharp is calm. With E, the A flat is the wolf we met in Part 6, when we tuned an organ in meantone. The piano's one key sits between the two and is neither. These pitches belong to this quarter-comma meantone example; spelling alone does not uniquely fix intonation in every style. Bare key numbers lose the distinction, but bends and tuning messages can represent it.

8The page as dataPractice3 min

Can a file hold the page itself?

MIDI was built for instruments. People who print music, and people who study it, needed the opposite: a file that holds the page. Two widely used formats are MusicXML and MEI. MusicXML version one, released in 2004 after earlier development, lets one notation program hand a page to another. MEI, the Music Encoding Initiative, was built by scholars and librarians, and it can also say the things an editor has to say: this note is unclear in the manuscript; this source reads differently. Here is the first note of the Tune, three ways. In MIDI, key sixty and a time. In MusicXML: step C, octave four. That is a spelling; a C is not a B sharp here. Type: quarter. That is the look of the note on the page. And a syllable to print beneath it. MEI holds the same facts more compactly.

Monochord can write all of these and read two of them back, so we can test what survives. Take the Tune with its words. Out to MusicXML and back again: all forty-two notes return identical, with their spellings, their lengths and their syllables. Our restricted MIDI writer and reader return keys and lengths but omit these lyrics and spellings. The MIDI file format can carry lyric and key-signature metadata; that differs from our implementation. A conversion between notations is a channel, and some channels lose information that no program can restore. Turning a MIDI file, or a recording, back into a readable page means guessing what was lost. That guessing is a research field, and we will reach it in Part 61.

So here is the whole part on one page. Each row is a notation. Each column is something a notation might keep: which note, how long, how it is spelled, how to play it, and exactly when and how loud. Neumes keep the notes only in part. Guido's staff keeps the notes and their names. Mensural notes add how long. Tablature and figured bass say what to do, and give up something else for it. Gongche and jianpu keep the note's place in its scale. The modern staff keeps the most, with a little about how to play and how loud. The roll and the MIDI file keep quantized performance events within the mechanism or message format's limits, and forget the spelling. And notation formats preserve structured score content and layout instructions, not necessarily identical rendering in every program. Now look for a row with every mark filled in. There is not one.

9How many bits?Foundations4 min

How much of the music is on the page?

Now let us count. One tune, forty-two notes. How many bytes does it take? Written as text, in gongche or in jianpu, about . As a MIDI file, . As MusicXML, more than five thousand, because XML spells everything out. And as sound? The Tune played once on our piano lasts seconds. Stored as this example's mono sixteen-bit PCM at forty-eight kilohertz, rather than a CD's forty-four point one kilohertz stereo, that is million bytes. Packed without any loss, thousand. As an MP3, thousand. The axis here is logarithmic: every grid line is ten times the one before it.

Those are files, with their overheads. Here is one compact code, assuming the decoder already knows the pitch vocabulary, duration unit and tempo. The Tune uses six different pitches, which takes three bits, and two lengths, which takes one. Four bits a note, forty-two notes: bits. Twenty-one bytes. And the Tune repeats itself. It has only three distinct phrases, A, A-prime and B, used as A, A-prime, B, B, A, A-prime. Describe it that way and bits are enough. The sound, at forty-eight thousand samples a second and sixteen bits a sample, is million bits. So the sound holds about thousand times as many bits as the page. Compare our chosen codec settings. An MP3 shrinks this sound six times; a modern codec, sixteen. The symbolic code is much smaller, but this is not lossless audio compression. It omits the waveform and assumes a decoder with an instrument or synthesis model; parametric algorithms can use such prior knowledge too. And that tells you where the other bits are. They are not on the page. The player supplies them.

How much does the player supply? Here are the same fourteen notes, twice. Both are synthesized; one uses mechanically regular timing and levels. Which?

B was the mechanically regular version. A was the same page played by four rules that researchers have measured in real performances. Each phrase speeds up into its middle and relaxes at its end. The faster, the louder. The ending slows the way a runner comes to a stop. And a repeated note is separated from the one before. Here is how far A strayed from the page. Against a steady beat its notes come up to milliseconds early or late. Their levels range over decibels. And the last note is held times its written length. None of this is on the page. To write it down, for every note quantized onset, duration and level, takes about nineteen more bits a note in an illustrative quantized budget, with two-millisecond onset bins, ten-millisecond duration-correction bins, and thirty-two level bins: bits, five times what the notes themselves took. This is a toy budget, not an exact performance record or MIDI file-size prediction. And it is still about thousand times smaller than the sound. Much of the remaining waveform detail comes from the instrument, rendering and room, which was Act One.

10Frontier: reading the page backResearch4 min

Can a machine read music?

Everything so far wrote music down. The frontier is the trip back: a machine that reads a page of music as a musician does. It is called optical music recognition. The first programs were written in the nineteen sixties, and the problem is still open. To see why, here is the textbook method, built into Monochord as a toy. This is a page of the Tune as a scanner sees it: pixels. Step one: add up the ink in every row. Staff lines run the whole width of the page, so each staff shows up as five spikes. Step two: erase the lines. Step three: in this deliberately restricted raster, candidate blobs can be treated as note heads. How high it sits among the lines gives its pitch, and whether it is hollow distinguishes the two durations used here; general notation also needs stems, beams, flags and context. On this clean page the toy reads all forty-two notes correctly.

Now turn the page by one degree, as any hand-fed scanner will. The staff lines no longer lie along the rows of pixels. The spikes smear out, the reader finds no staff, and it reads nothing at all. Here is its accuracy against the tilt. Up to three tenths of a degree it is fine. At of a degree it reads nothing. That fault can be repaired: turn the image until its rows are as unequal as they can be, and then read. The green line. But sprinkle the page with specks, as on an old photocopy, and the accuracy falls away again. Each repair handles one kind of damage. A real page has warped paper, ink showing through from the other side, handwriting, slurs crossing stems, two voices sharing a staff, and words among the notes.

Here is what the toy makes of a speckled scan of the Tune's first four phrases. Listen to what it read. How many mistakes do you hear?

. One note that is not on the page at all: a cluster of specks that looked like a note head. And quarter notes read as half notes, because flipped pixels confused the filled-versus-hollow test. Familiarity with the Tune may help you recognize those errors. Your ear knows the Tune; the toy knows only blobs.

Real systems are far better than the toy. Since about 2018, neural networks trained from end to end have learned to read a clean, printed, single line of music with very few errors. Accuracy and coverage still vary on harder material: a dense orchestral page, handwriting, and the older notations we met in this part. Different tasks and representations use different metrics; no single score captures every kind of error. What counts as one mistake, on a page where a wrong clef makes every note wrong? The encodings are still moving as well. MusicXML reached its fourth version in 2021 and MEI its fifth in 2023; MNX explores another approach to common notation; and a standard called SMuFL standardizes names and code points for a large repertoire of musical glyphs. And scholars are using these formats to make a new kind of edition: not one text chosen by an editor, but every source and every variant, encoded, so that a reader can ask what each manuscript says. The tablet from Ugarit was written for people who shared its writer's knowledge. Every one of these standards is an attempt to write that knowledge down too, so that future readers have more explicit information, while still needing format documentation and musical conventions.

Variation 10, recap and problemsAll tracks4 min

Every part ends by doing something to the Tune with what it has built. This part built ways of writing. So here is the Tune played off the page, exactly as written, while the page changes: each phrase in two notations, from the neumes of the ninth century to the files of this one. Five phrases, ten notations. And then the sixth phrase, played with expressive deviations absent from these particular score examples. MIDI and notation formats can encode many of those details when explicitly supplied.

Row ten of the ledger. seconds. The measurement is this part's count: the page of the Tune is bits, and its sound is about thousand times as many.

What did we find? Our contour toy keeps direction without exact intervals: dozens of melodies fit the same signs. Guido's staff is a graph of pitch against time, counted in steps of a scale that the reader must already know. Shapes gave notes their lengths; dots and ties write any length that halvings can reach; and bar lines let many people read together. Tablature and figured bass write actions instead of sounds, and each stands for millions of choices. A MIDI file keeps the key and the moment, and forgets the spelling, which selects pitches a fifth of a tone apart in our meantone example. And the page of a tune is a few hundred bits, against millions for its sound. The decoder supplies instrument and performance assumptions; the byte counts are not a lossless audio-compression comparison.

Five problems. One to compute, one to prove, one for your ears, one to build, and a research problem, marked with a star. Solutions are in this part's notes. Pause here.

Where does this come back? At once: the next part is about rhythm, and its note values and bars are the ones we met today. Key signatures and the spelling of notes return with scales and keys. The figures under a bass line grow into the theory of harmony. Neumes and mensural notes return in the centuries that used them. What a performer adds to the page gets a part of its own. And MIDI comes back with the sequencer, and again when we ask a machine to turn sound into notes.

And in practice. An engraver gives a long note more room than a short one, but much less than in proportion, because a page spaced by the clock is hard to read. A session player reads a chart of chord symbols at sight, which is analogous to figured bass, with different conventions. An editor compares every source and marks which notes are guesses. And a programmer who writes music software keeps spelled pitches and exact fractions inside the program, as Monochord does, and turns them into key numbers and seconds only on the way out.

The books and papers this part follows. The full list, with notes, is in the README.

We can now write down which note, and for how long. But a length on a page is only a ratio: this note is twice that one. What makes a row of lengths into a rhythm? Play a row of clicks, every one identical, and many listeners impose a grouping, often in pairs: tick, tock, tick, tock. Nothing in the sound says so. The grouping is something the listener adds. Next time: where the beat comes from, how bars and meters organize it, and what happens when a rhythm is played so fast that it turns into a pitch. Part 11: Rhythm and Meter.

Where it goes next. Part 11 takes the note values and bars of this part and asks where rhythm and metre come from. Key signatures and the spelling of notes return with scales and keys (Parts 12 and 15); figured bass grows into harmony (Parts 17 and 18); neumes and mensural notes return in their own centuries (Parts 23 and 24); what a performer adds is Part 43; MIDI returns with the sequencer (Part 53) and when machines transcribe sound (Part 61).

Key results

The part's results in one place, for revision.

Melodies that fit a contour\(\displaystyle W_k(s) = \sum_{s' \text{ allowed by sign } k} W_{k+1}(s'),\qquad\allowbreak W_n(s) = 1\)
A dotted note\(\displaystyle 1 + \tfrac12 + \tfrac14 + \cdots + \tfrac{1}{2^n} = 2 - \tfrac{1}{2^n}\)
Perfect time\(\displaystyle \text{breve, }\allowbreak \text{semibreve, }\allowbreak \text{semibreve, }\allowbreak \text{breve} \;=\; 3,\ 1,\ 2,\ 3\)
A sharp and its flat, in meantone\(\displaystyle \frac{8/5}{25/16} = \frac{128}{125} \approx 41 \text{ cents}\)
The Tune's page\(\displaystyle 42 \times (\log_2 6 \to 3 \;+\; \log_2 2 = 1) = 168 \text{ bits}\)
Sound against page\(\displaystyle \frac{27.7\ \text{s} \times 48000 \times 16}{168} \approx 1.3 \times 10^{5}\)

Try it

Lab 10 · Notation, measured: what each way of writing keeps

Count the melodies that fit a row of neumes, write any length with dots and ties, let dynamic programming choose a guitar fingering, send the Tune through MusicXML and MIDI and see what comes back, count its bits against its sound, and watch a simple reader fail on a tilted page.

Figure produced by Lab 10: Notation, measured: what each way of writing keeps
Produced by the lab below, seed 0, in 2.9 s.
python -m videos.music.labs 10 needs numpy, scipy, matplotlib · download lab10.py · source on GitHub
melodies on 7 notes with the contour (1, 1, -1, -1, 1)  1799  (ways to finish from each first note: 686, 511, 342, 190, 70, 0, 0)
one of them, drawn at random                            D E F D C B
11/16 of a whole note, written                          a half note tied to a dotted eighth note
a note with 1, 2, 3 dots lasts                          3/2, 7/4, 15/8 times its plain length
tablatures of the whole Tune                            2.16e+19
the cheapest, as string/fret (first phrase)             B1 B1 e3 e3 e5 e5 e3
frets used                                              0 to 5; open strings: 8
the Tune through MusicXML and back                      identical
E flat, G, B flat through MIDI and back                 D#4, G4, A#4
bytes: jianpu, ABC, MIDI, MEI, MusicXML                 130, 172, 425, 2946, 5862
bits the notes need                                     168 spelled out; 124 coded by frequency
the sound of the page, as on a CD                       20.3 million bits: 120,786 times the page
a performance by four rules strays from the page by     up to 62 ms and 7.0 dB
a clean page: notes read                                42 of 42
the reader fails at a tilt of                           0.4 degrees
ear problem, the six pairs (listen first)               different; different; different; the same; the same; the same
G sharp and A flat in quarter-comma meantone            408.8 and 418.6 Hz: 41 cents apart

Every notation is a code that keeps some of the music and leaves the rest to a reader who knows the tradition. Counting makes the bargain visible: neumes fit hundreds of melodies, a staff fits billions of fingerings, a key number fits two spellings, and a whole page is a hundred-thousandth of its sound.
The code (130 lines; it asserts its own result)
"""Lab 10: what a notation keeps: melodies that fit a contour, dots and ties, a tablature chosen by dynamic programming, round trips, bits, and a page read back."""

import math
from fractions import Fraction

import numpy as np

from videos.coursekit import labs
from explainer.music.monochord import Clip, concat
from explainer.music.monochord import score as S
from explainer.music.monochord.partkit import organ_tone
from explainer.music.monochord.score import codes, perform, raster, read, tab, write

TITLE = "Notation, measured: what each way of writing keeps"
GOAL = ("Count the melodies that fit a row of neumes, write any length with dots and ties, let dynamic programming choose a "
        "guitar fingering, send the Tune through MusicXML and MIDI and see what comes back, count its bits against its "
        "sound, and watch a simple reader fail on a tilted page.")
TASKS = [
    "Set CONTOUR to (0, 1, 0, 1, 0, -1), the Tune's first phrase, and NOTES to 6, 8 and 12. How fast does the count grow? What does that say about neumes for a singer with a wide range?",
    "Set OPEN to 3.0, so that an open string costs as much as three frets of travel. Where on the neck does the Tune go now, and how many frets does the hand span?",
    "Set TILTS to end at 0.6 and SPACE to 8 and then 16. Does a finer scan (a bigger SPACE) break at a smaller or a larger tilt? Why?",
]
CONTOUR = (1, 1, -1, -1, 1)     # Problem 1: up, up, down, down, up
NOTES = 7                       # how many notes of a scale the singer may use
LENGTH = Fraction(11, 16)       # a length to write with dots and ties, in whole notes
OPEN = 0.0                      # the cost of playing an open string (Problem 4)
TILTS = np.arange(0.0, 1.21, 0.1)
SPACE = 12                      # pixels between two staff lines in the scan
SR = 48_000


def run(seed=0):
    rng = np.random.default_rng(seed)
    lab = labs.Lab()
    tune = S.tune_score(words=True)
    keys = [n.pitch.midi for n in tune.voices[0].notes]

    # 1. neumes (Problem 1): how many melodies have this contour?
    ways = codes._ways(list(CONTOUR), NOTES)
    lab.row(f"melodies on {NOTES} notes with the contour {CONTOUR}", f"{codes.count_contour(list(CONTOUR), NOTES)}  (ways to finish from each first note: {', '.join(str(int(w)) for w in ways[0])})")
    lab.row("one of them, drawn at random", " ".join("CDEFGABcdefgab"[s] for s in codes.with_contour(list(CONTOUR), NOTES, seed)))
    if (CONTOUR, NOTES) == ((1, 1, -1, -1, 1), 7):
        assert codes.count_contour(list(CONTOUR), NOTES) == 1799

    # 2. dots and ties (Problem 2)
    parts = codes.binary_values(LENGTH)
    lab.row(f"{LENGTH} of a whole note, written", " tied to ".join(("a " + codes.value_name(v, d) + " note") for v, d in parts))
    lab.row("a note with 1, 2, 3 dots lasts", ", ".join(str(codes.dotted(k)) for k in (1, 2, 3)) + " times its plain length")
    assert sum(v * codes.dotted(d) for v, d in parts) == LENGTH

    # 3. a tablature by dynamic programming (Problem 4)
    def cost(a, b):
        return tab._cost(a, b) + (OPEN if b[1] == 0 else 0.0)

    f = tab.fingering(keys, cost=cost, first=lambda a: 0.15 * a[1] + (OPEN if a[1] == 0 else 0.0))
    frets = [fr for _, fr in f["positions"]]
    lab.row("tablatures of the whole Tune", f"{tab.count_fingerings(keys):.3g}")
    lab.row("the cheapest, as string/fret (first phrase)", " ".join(f"{'EADGBe'[s]}{fr}" for s, fr in f["positions"][:7]))
    lab.row("frets used", f"{min(frets)} to {max(frets)}; open strings: {frets.count(0)}")
    assert tab.sounded(f["positions"]) == keys

    # 4. round trips: what comes back
    via_xml = read.musicxml(write.musicxml(tune))
    via_midi = read.midi(write.midi(S.Score([S.Voice([S.Note(S.Pitch.parse(n), S.Q) for n in ("Eb4", "G4", "Bb4")])], key=-3)))
    same = all((a.pitch, a.dur, a.lyric) == (b.pitch, b.dur, b.lyric) for a, b in zip(tune.voices[0].events, via_xml.voices[0].events))
    lab.row("the Tune through MusicXML and back", "identical" if same else "changed")
    lab.row("E flat, G, B flat through MIDI and back", ", ".join(n.pitch.name for n in via_midi.voices[0].notes))
    assert same

    # 5. bits
    sizes = codes.sizes(tune)
    d = codes.description_bits(tune)
    seconds = tune.seconds(tune.length)
    audio_bits = seconds * SR * 16
    lab.row("bytes: jianpu, ABC, MIDI, MEI, MusicXML", ", ".join(str(sizes[k]) for k in ("jianpu", "ABC", "MIDI", "MEI", "MusicXML")))
    lab.row("bits the notes need", f"{d['plain_bits']} spelled out; {d['entropy_bits']:.0f} coded by frequency")
    lab.row("the sound of the page, as on a CD", f"{audio_bits / 1e6:.1f} million bits: {audio_bits / d['plain_bits']:,.0f} times the page")
    dv = perform.deviations(perform.expressive(tune))
    lab.row("a performance by four rules strays from the page by", f"up to {dv['largest_ms']:.0f} ms and {dv['db_range']:.1f} dB")

    # 6. a page read back
    notes = [(n.pitch.staff_position(), bool(n.dur < S.H)) for n in tune.voices[0].notes]
    img = raster.page(notes, space=SPACE)
    naive, fixed = [], []
    for a in TILTS:
        t = raster.distort(img, float(a))
        naive.append(raster.accuracy(raster.read_page(t), notes))
        fixed.append(raster.accuracy(raster.read_page(raster.deskew(t)[0]), notes))
    broke = next((float(a) for a, v in zip(TILTS, naive) if v < 0.5), None)
    lab.row("a clean page: notes read", f"{round(42 * naive[0])} of 42")
    lab.row("the reader fails at a tilt of", f"{broke:.1f} degrees" if broke is not None else "not in this range")
    assert naive[0] == 1.0

    # 7. the ear problem (Problem 3): a sharp and its flat neighbour, or the same note twice?
    c4 = 261.6255653005986
    g_sharp, a_flat = c4 * 25 / 16, c4 * 8 / 5
    kinds = rng.integers(0, 2, 6)
    if kinds.min() == kinds.max():
        kinds[0] = 1 - kinds[0]
    tone = lambda hz: Clip(organ_tone(hz, 1.0, partials=6), SR).fade(0.03, 0.1).at_level(-20.0)       # noqa: E731
    pairs = []
    for k in kinds:
        first = float(rng.choice([g_sharp, a_flat]))
        second = (a_flat if first == g_sharp else g_sharp) if k else first
        pairs.append(concat([tone(first), tone(second)], gap=0.15))
    lab.audio = concat(pairs, gap=0.9)
    lab.row("ear problem, the six pairs (listen first)", "; ".join("different" if k else "the same" for k in kinds))
    lab.row("G sharp and A flat in quarter-comma meantone", f"{g_sharp:.1f} and {a_flat:.1f} Hz: {1200 * math.log2(a_flat / g_sharp):.0f} cents apart")

    fig, (p, q) = labs.figure(2)
    p.plot(TILTS, naive, color=labs.RED, lw=1.6, marker="o", ms=3, label="read as scanned")
    p.plot(TILTS, fixed, color=labs.GOLD, lw=1.6, marker="o", ms=3, label="straightened first")
    p.set_title("A toy reader and a tilted page")
    p.set_xlabel("tilt of the page (degrees)")
    p.set_ylabel("fraction of the notes read")
    p.legend()
    names = ["page, spelled out", "jianpu", "ABC", "MIDI", "MEI", "MusicXML", "sound, as on a CD"]
    vals = [d["plain_bits"] / 8, sizes["jianpu"], sizes["ABC"], sizes["MIDI"], sizes["MEI"], sizes["MusicXML"], audio_bits / 8]
    q.barh(range(len(vals)), vals, color=[labs.GOLD] * 6 + [labs.RED])
    q.set_xscale("log")
    q.set_yticks(range(len(vals)))
    q.set_yticklabels(names)
    q.invert_yaxis()
    q.set_title("The Tune, in bytes")
    q.set_xlabel("bytes (each grid line is ten times the last)")
    lab.fig = fig
    lab.note = ("Every notation is a code that keeps some of the music and leaves the rest to a reader who knows the tradition. "
                "Counting makes the bargain visible: neumes fit hundreds of melodies, a staff fits billions of fingerings, a "
                "key number fits two spellings, and a whole page is a hundred-thousandth of its sound.")
    return lab

Now change it

  1. Set CONTOUR to (0, 1, 0, 1, 0, -1), the Tune's first phrase, and NOTES to 6, 8 and 12. How fast does the count grow? What does that say about neumes for a singer with a wide range?
  2. Set OPEN to 3.0, so that an open string costs as much as three frets of travel. Where on the neck does the Tune go now, and how many frets does the hand span?
  3. Set TILTS to end at 0.6 and SPACE to 8 and then 16. Does a finer scan (a bigger SPACE) break at a smaller or a larger tilt? Why?

Problems, with solutions

Try each problem before opening its solution.

  1. Neumes. How many melodies on the seven notes C to B have the contour up, up, down, down, up? Count them with a table: for each note, the number of ways to finish the melody from there.

    Solution

    Work backwards. From the last note there is one way to finish, wherever it is: 1, 1, 1, 1, 1, 1, 1 (for C … B). The step before it must rise, so from each note the ways are the number of notes above it: 6, 5, 4, 3, 2, 1, 0. The step before that falls, so add up the entries below each note: 0, 6, 11, 15, 18, 20, 21. Another fall: 0, 0, 6, 17, 32, 50, 70. Then a rise (add the entries above): 175, 175, 169, 152, 120, 70, 0. And a rise again: 686, 511, 342, 190, 70, 0, 0. The total is 686 + 511 + 342 + 190 + 70 = 1799 melodies, of 7⁶ = 117,649: the five signs carry log₂(117649/1799) ≈ 6.0 of the 16.8 bits. (The lab prints the table.)

  2. Dots and ties. Show that a note with n dots lasts 2 − 2⁻ⁿ times its plain length, and that any length k/2ᵐ of a whole note can be written with no more tied notes than there are ones in the binary expansion of k.

    Solution

    Each dot adds half of what the one before added, so the length is 1 + ½ + ¼ + … + 2⁻ⁿ, a geometric series with sum (1 − 2⁻ⁿ⁻¹)/(1 − ½) = 2 − 2⁻ⁿ. For the second part, write k in binary: k/2ᵐ is then a sum of distinct note values 2ʲ/2ᵐ, one for each 1 in k, and tying those notes gives the length. That is the bound. Dots do better: a run of adjacent ones in k is one dotted note (7/8 = ½ + ¼ + ⅛ is a half note with two dots), so the least number of notes is the number of runs of ones, if any number of dots is allowed.

  3. Ear. The lab plays six pairs of notes in quarter-comma meantone. For each pair, say whether you heard a sharp and the flat next to it, 41 cents apart, or the same note twice.

    Solution

    The lab prints the order. 41 cents is about eight times the smallest difference a practised listener can hear near 400 Hz, so with attention every pair can be got right; it is easiest to sing the first note and feel whether the second asks the voice to move.

  4. Build. With score.tab, change the cost of a move so that open strings are avoided, and find the best fingering of the Tune. How many frets does the hand now span, and how many tablatures did you rule out?

    Solution

    In the lab set OPEN = 10.0. The only note of the Tune with an open string is E (the top string), which now moves to the fifth fret of the B string, and the F beside it to the sixth: the Tune sits on the B and top strings from fret 1 to fret 6, with no open strings. Each of the Tune's eight Es had three places and now has two, so the tablatures left are (2/3)⁸ ≈ 3.9% of the 2.16 × 10¹⁹: about 96% are ruled out, and 8.4 × 10¹⁷ remain. (With OPEN = 3.0 the open E survives where the hand would otherwise have to shift.)

  5. ★ A notation for the performance. Design a notation for the Tune that also keeps the four rules of performance from chapter 9, in fewer than 300 bits in all. What must its reader already know? Is your notation descriptive or prescriptive?

    Where the frontier is. Writing the performance note by note costs about 800 bits, but the performance was generated by four rules with half a dozen constants, so 168 bits of notes plus a few dozen bits of constants reproduce it exactly, provided the reader holds the rules. That is the bargain of every notation in the part: the shorter the page, the more the reader must know. It is also a research programme. Rule systems for performance (Sundberg and Friberg's at KTH; Todd's models) explain part of what players do; models fitted to recorded performances predict timing and dynamics measurably better than rules, and none yet accounts for why two great players differ. Whether "expression" can be written down in few bits is the question of how much of it is rule and how much is choice.

Notes and sources

Sources

Books: T. F. Kelly, Capturing Music: The Story of Notation (2015); E. Gould, Behind Bars: The Definitive Guide to Music Notation (2011); E. Selfridge-Field (ed.), Beyond MIDI: The Handbook of Musical Codes (1997); W. Apel, The Notation of Polyphonic Music, 900–1600 (5th ed., 1953), for mensural notation and the rules of imperfection and alteration; O. Strunk (ed.), Source Readings in Music History (1950), for Isidore, Guido's Prologus and Epistola de ignoto cantu, and Franco's Ars cantus mensurabilis; D. Pesce, Guido d'Arezzo's Regule rithmice, Prologus in antiphonarium, and Epistola ad Michahelem (1999); A. Barbera (ed.), Music Theory and Its Sources: Antiquity and the Middle Ages (1990); B. Yung, Celestial Airs of Antiquity: Music of the Seven-String Zither of China (1997); the MIDI 1.0 Detailed Specification (1983; 1996) and the Standard MIDI Files 1.0 specification.

Papers: A. D. Kilmer, "The discovery of an ancient Mesopotamian theory of music", Proceedings of the American Philosophical Society 115 (1971), and "The cult song with music from ancient Ugarit: another interpretation", Revue d'Assyriologie 68 (1974); M. L. West, "The Babylonian musical notation and the Hurrian melodic texts", Music & Letters 75 (1994) (whose remark on rival decipherments "each yielding entirely different results" the film paraphrases); C. Seeger, "Prescriptive and descriptive music-writing", The Musical Quarterly 44 (1958); N. P. McA. Todd, "A model of expressive timing in tonal music", Music Perception 3 (1985), and "The dynamics of dynamics: a model of musical expression", JASA 91 (1992); A. Friberg and J. Sundberg, "Does music performance allude to locomotion? A model of final ritardandi derived from measurements of stopping runners", JASA 105 (1999); M. Good, "MusicXML for notation and analysis", in The Virtual Score (2001); P. Roland, "The Music Encoding Initiative (MEI)", Proceedings of the First International Conference on Musical Applications Using XML (2002); D. Pruslin, "Automatic recognition of sheet music", ScD thesis, MIT (1966); J. Calvo-Zaragoza and D. Rizo, "End-to-end neural optical music recognition of monophonic scores", Applied Sciences 8 (2018); J. Calvo-Zaragoza, J. Hajič jr. and A. Pacha, "Understanding optical music recognition", ACM Computing Surveys 53 (2020).

About this partfrom its README

Part 10 of a sixty-eight-part course in music (see the series plan and the syllabus), and the first part of Act II. For nine parts the series made sounds; now it has to say which ones, and when, to someone who is not in the room. Every way of doing that keeps some things and throws the rest away, and the part asks of each notation what it kept: neumes, Guido's staff, mensural notes, bar lines and scores, tablature, figured bass, gongche, jianpu, guqin tablature, graphic scores, piano rolls, MIDI, MusicXML and MEI. It ends by counting: the bits on the page of the Tune against the bits in its sound. The score model, its readers and writers, and the counting are Monochord's (explainer/music/monochord/score/); the staff is drawn by the series' own engraver (explainer/music/staff.py) and the other notations by explainer/music/notations.py; every sound is computed in compute.py. Dates and attributions are the published ones, listed under Sources.

  • A song nobody can read. The tablet h.6 from Ugarit (about 1400 BCE): names of pairs of lyre strings, each with a number; its first line read two ways (neither a reconstruction); at least five published reconstructions, no two alike; Isidore of Seville (about 630): sounds "cannot be written down"; a tune as a picture with two axes; the plan.
  • 1. A reminder. Neumes, simplified to three signs; an ear question (three melodies, and all three fit the signs); counting the melodies that fit a contour (85 on six notes, 322 on eight; 309,538,560 for the whole Tune on eight); 9.5 bits against 18.1; heighted neumes and the first ruled line.
  • 2. Guido's lines. Four lines and a letter (about 1025); clefs as letters; Guido's claim (a year or two in place of ten); the staff as a graph, three centuries before Oresme; Ut queant laxis sung line by line (each line starts a step higher); ut, re, mi, fa, sol, la; the half step the staff does not show.
  • 3. How long? Two voices and no lengths; Franco of Cologne (about 1280); long, breve, semibreve, minim and their descendants; perfect and imperfect time, the circle and the broken circle (the C of common time); one row of marks read in twos and in threes; imperfection and alteration (breve, semibreve, semibreve, breve = 3, 1, 2, 3); the modern system: halvings, dots and ties; a predict-pause (5/8 and 7/8); n dots give 2 − 2⁻ⁿ; why a third needs a triplet.
  • 4. Bars and scores. Part books; the score and the bar line (printed scores from the 1570s); two voices with one cursor; a note cut and tied at a bar line (Monochord's exact fractions); what was added later: tempo words, dynamics, hairpins, the metronome mark (1815).
  • 5. What to do. Tablature (printed for the lute in 1507); Seeger's descriptive and prescriptive writing (1958); middle C in three places on a guitar; 2,125,764 tablatures of fourteen notes and about 2 × 10¹⁹ of the Tune; the one with the least movement, by dynamic programming; figured bass (about 1600); one bass realized twice, among 6,291,456 ways.
  • 6. Numbers and characters. Gongche; Rousseau's numbers (1742) and jianpu; changing key by changing one sign; the Tune in numbers and characters, on Part 8's flute; a guqin character assembled from its parts, and no rhythm; graphic scores (after Feldman, 1950, and in the manner of Cardew's Treatise).
  • 7. Holes and bytes. The piano roll (the 1890s; Welte's reproducing piano, 1904); MIDI (1983): the first bytes of the Tune's file, decoded (nine bytes for this example note, 425 for the Tune); what a key number forgets (E♭ G B♭ E♭ comes back as D♯ G A♯ D♯); an ear question (G♯ and A♭ in quarter-comma meantone, 41 cents apart).
  • 8. The page as data. MIDI, MusicXML 1.0 (2004) and MEI; the first note of the Tune three ways; round trips (MusicXML returns all 42 notes with spelling, lengths and words; our MIDI reader returns keys and lengths only); the table of what each notation keeps.
  • 9. How many bits? The Tune in bytes, from 126 (gongche as text) to 2.7 million (48 kHz mono PCM16 sound); 42 notes × 4 bits = 168 bits; 96 with its repeats; 21.3 million bits of sound: 127,000 to 1, against 6 to 1 for an MP3; an ear question (the page played exactly, and by four rules of performance); how far the performance strays (69 ms, 8 dB, a last note 1.5 times its length), and what it costs to write that down (798 bits).
  • 10. Frontier: reading the page back. Optical music recognition as a toy: row sums, line removal, blobs; 42 of 42 on a clean page; nothing at all on a page tilted by 0.4 degrees; straightening; specks; an ear question (a speckled scan read back, with four mistakes); where the field and the encoding standards stand. ★ research problem.
  • Variation 10, recap and problems. The Tune read from ten notations, two to a phrase, and its sixth phrase played with expressive deviations omitted from these particular score examples; the ledger; what we found; five problems; where it comes back; in practice; references; Part 11.
What is computed and built

python -m videos.music.music10.compute (under a minute) fills .cache/music10/.

Item What it computes Checked against
hook the first line of h.6's notation, read two ways on a Pythagorean scale the line as published; the pairs of strings of CBS 10996
neumes the melodies on 6, 7, 8 notes with the contour of the Tune's first phrase; two others drawn at random brute force over all 6⁷ melodies
guido Ut queant laxis sung by Part 8's voice the first notes of its six lines: C D E F G A
mensural one row of marks read under imperfect and perfect time; imperfection and alteration; dots and ties Franco's rules as Apel states them; every length k/64
score the Tune's first two phrases with a bass, on Part 7's piano —
tab every place each note can be played on a guitar; the fingering with the least movement it sounds the Tune; it beats the one-string fingering
figured every realization of each figure within a hand's reach; two smooth ones each chord holds the notes its figure asks for; no parallel fifths or octaves
east the Tune in jianpu and gongche —
midi the bytes of the Tune's MIDI file; a round trip that loses spelling; G♯ and A♭ in meantone the Standard MIDI File format; 128/125 = 41.06 cents
xml MusicXML and MEI of the Tune; what each round trip returns the score itself
bits the bytes of seven encodings and four audio codecs (ffmpeg); bits spelled out, by entropy and by structure; a performance by rule —
omr a page as a bitmap, read back; accuracy against tilt and specks; deskewing the page's own notes
tune Variation 10 the first 35 notes are on the page's beat exactly

Monochord's score model and the engraver are held against these in tests/music/test_score.py, tests/music/test_staff.py and tests/music/test_notations.py; this part's claims and clips in tests/music/test_music10.py.

Sounds. Twelve clips, labelled on screen. physical model: Part 1's plucked string, Part 7's piano and guitar, Part 8's flute and voice, playing notes that this part's code read from a notation. synthesized: the two organ tones of chapter 7. There are no recordings.

What the models are, and are not. The tablet. The two readings of h.6's first line are not reconstructions: they are two of the ways the same signs can be read (strings together or in turn; the lyre counted from either end; the numbers as strokes), on a seven-note scale tuned by fifths. The pairs of strings are those of the Babylonian tablet CBS 10996 as Kilmer and West give them. Neumes are reduced to three signs (higher, the same, lower); real neumes also show groups of notes on a syllable and, in some scripts, lengthening. The hymn is sung in equal notes, each line on the vowel of its first syllable, by Part 8's source-filter voice; its melody is the one in modern chant books. Mensural notation is shown for breves and semibreves only, with Franco's rules of imperfection and alteration; the film uses the three simplest cases. The engraver draws one voice to a staff, with no chords or slurs. Tablature's cost of a move is a plain rule (travel along the neck is dear, crossing strings is cheap), not a model of a hand. Figured bass is realized within a fixed range with three upper notes, choosing by total movement and forbidding parallel fifths and octaves; real continuo playing has many more rules and freedoms. The performance follows four rules from the literature (Todd; Friberg and Sundberg) with constants chosen to be audible; it is one plausible reading, and the film says a machine made it. The bit counts are for this tune and these files: 168 bits is a fixed-length code for this tune's six pitches and two lengths, not a universal figure. The page reader reads only what raster.page draws; it is there to show why the first step of the classical pipeline is fragile, and it is not a music reader.

The historical notation drawings are teaching schematics. The three-sign contour toy omits real neumes’ articulatory and rhythmic detail. Guido helped consolidate staff practice; the historical development was not a single invention. Horizontal staff spacing orders events rather than uniformly measuring time. Seeger’s descriptive/prescriptive distinction does not make all staff writing descriptive: ordinary scores and tablatures both prescribe aspects of performance.

The MIDI example distinguishes the 1983 messaging protocol from later Standard MIDI Files. Nine bytes is one example event encoding, not a fixed cost per note. MIDI can carry controllers, bends, lyrics and key metadata; the round-trip omissions belong to this implementation. The 41-cent enharmonic distinction is scoped to quarter-comma meantone, not a universal consequence of spelling.

The 168- and 96-bit codes assume a shared vocabulary, duration unit, tempo and decoder. They are illustrative code lengths, not minimum entropy or lossless waveform compression. The waveform here is 48 kHz mono PCM16, not CD-format audio. Codec ratios depend on the selected 128 kb/s MP3 and 32 kb/s Opus settings. The extra 798 bits are a toy quantized budget: per note, seven bits each for onset and duration correction, and five for level. The resolutions are 2 ms, 10 ms and 32 level bins, with agreed ranges; these are not exact performance records. Both listening examples are synthesized.

Companion material in this repository

The syllabus's plan for this partfrom SYLLABUS.md, the plan of record
  1. Hook: the tablet's first line, read two ways; Isidore: sounds cannot be written down; the plan.
  2. A reminder: neumes; three melodies that fit the same signs (an ear question); counting them; the first line.
  3. Guido's lines: the staff and its clefs; the staff as a graph; Ut queant laxis; the hidden half step.
  4. How long? Franco's shapes; perfect and imperfect time; a note read by its neighbours; dots and ties (a predict-pause); the rule for dots.
  5. Bars and scores: part books; the score and the bar line; a note cut at a bar line; what was added later.
  6. What to do: tablature and its count of fingerings, by dynamic programming; figured bass, realized twice.
  7. Numbers and characters: gongche; Rousseau and jianpu; guqin tablature; graphic scores.
  8. Holes and bytes: the piano roll; MIDI's bytes; what a key number forgets (an ear question: G♯ and A♭).
  9. The page as data: MusicXML and MEI; round trips; the table of what each notation keeps.
  10. How many bits? Files; 168 bits against 21 million; the page played exactly and played well (an ear question).
  11. Frontier: reading a page back, as a toy that a tilt breaks (an ear question); where the field stands.
  12. Variation 10: the Tune in ten notations, and a last phrase as none of them says. Outro: problems, payoffs.

Covers: neumes; the staff and the hexachord; mensural notation and the invention of written duration; barlines and scores; tablature; figured bass; jianpu, gongche and guqin tablature; graphic scores; piano rolls; MIDI, MusicXML and MEI; the bits in a score against the bits in its recording. Built and computed: Monochord's score module (spelled pitches, exact durations; MusicXML, MEI, MIDI, ABC, LilyPond and jianpu writers; MusicXML and MIDI readers; contours, tablature, figured bass, mensural lengths, performance rules, a toy page reader), and the series' engraver (explainer/music/staff.py). Variation 10: the Tune in ten notations, then what none of them recorded. Frontier: optical music recognition; encoding standards; digital critical editions. Reading: Kelly, Capturing Music; Gould, Behind Bars; Selfridge-Field (ed.), Beyond MIDI.

Build the film

python -m videos.music.music10.compute        # the part's numbers, into .cache/music10
python tools/build.py music10                  # render and assemble the film
EXPLAINER_TTS=silent python tools/qa_scene.py music10 Hook   # one chapter, silent, with a contact sheet

Scenes: videos/music/music10. Setup: see the course page. Source of these notes: the README and the scenes' narration.

Build it
python -m videos.music.music10.compute                          # numbers and sounds (under a minute)
EXPLAINER_TTS=silent python tools/build.py music10 -q l --fps 15   # a silent-narration preview, with the sounds
python tools/qa_sound.py music10 --sync                         # the sound gates
python tools/dead_air.py renders/music10_480p.mp4 --sound music10  # no empty screen; no sound over a still one
python tools/lecture_length.py music10                          # 30 to 60 minutes, listening included
python tools/build.py music10                                   # 1080p30, narrated
python -m pytest -q tests/music                                 # Monochord against its references; this part's claims and clips
python -m videos.music.labs 10                                  # the lab (writes a figure and a short WAV)

The staff needs a font with the Unicode musical symbols (GNU FreeFont's FreeSerif is used here) and the gongche and guqin characters a CJK font (AR PL UMing); explainer/music/staff.py says which fonts it looks for.