|
Cutting Corners Is Not Enough argued that spacing should follow the ink itself, not boxes around it. Taken to its conclusion, that applies to the ledger lines as well. So I recomputed them from Bravura's outlines, read straight from the font file, with everything else as in the animations since Ut Tensio, Sic Vis. This is what happens. Here's a bar of chromatic sixteenths, dragged from its tightest to loose and back. Watch the panel on the right. At the tight end, ledger lines come in from both sides of the sharp, between its crossbars, and each one stops just short of the ink. The sharp stays tight to its notehead, and its lines lose only what the ink itself takes from them. Even at the tightest, nothing collides. Incidentally, that's exactly what Magnus asked for under Dials: stave 4's sharp, tight to its notehead, without C♯6's ledger lines cut short. With the real shapes, a line simply runs on until it meets ink. The second animation mixes sharps, flats and naturals. Each has a shape of its own, and all three are handled the same way, without a rule for any of them. Ledger line shortening occurs naturally regardless of the accidental, and on both sides of it. As before, these are reference models, not Ooloi's output. The outlines and Bravura's engraving metrics are real; the clearances and the opening width are placeholders.
And for anyone joining this thread late: every one of these values is a setting you can change. This closes an arc that began with Ut Tensio, Sic Vis less than a fortnight ago, and it settles how Hegazy and Gourlay belong in Ooloi. Their springs decide where the notes go, and they never had to learn what a ledger line is. Everything about ledger lines happens at either end of the pipeline: Stage 1 works out how short each line may become against the accidentals' real shapes, and Stage 5 lengthens it again into whatever room the springs have given. The 1987 model stays exactly as it was. The six stages around it do the rest.
5 Comments
For almost two weeks now, the number of blog posts has reached an all-time high. The discussions here have all been about music. The turn came almost the moment horizontal spacing and casting off were settled, which is roughly what I predicted in The Machinery of Taste: once the work reached the page, the conversation would follow it into a musician's habitat. My mind has followed it there too – hence all the posts – even though I really should be finishing the file picker's last bells and whistles. It keeps returning to a single ledger line, running between the crossbars of a sharp. Between the CrossbarsIn Dials, stave 4 keeps every sharp tight to its notehead and shortens the ledger lines around it. Under that post, Magnus Johansson asked whether stave 1 could have stave 4's accidental position without shortening C♯6's ledger lines. I said yes: the accidental would then stand on top of the line. But would it? A sharp's bounding box, the rectangle around its ink, is mostly white space, so a ledger line that reaches into the box isn't necessarily under anything. The upper of C6's two ledger lines is the sharpest case. It runs between the sharp's crossbars, where the only ink is the two stems. Whether a full-length line there lies under the sharp, or merely passes through its white space, depends on exactly where the ink is. The ledger line is in the accidentals territory, but there's no actual overlap of ink. The animation in Dials couldn't say. It worked from Bravura's bounding box for the sharp, refined by SMuFL's cut-outs: rectangles in a font's metadata that mark a corner of the box as empty. The panel beside stave 4 shows the lower ledger line reaching into one of them. But the space between the crossbars isn't a corner. No corner cut-out describes it, and no corner cut-out could, so the question behind Magnus's request can't be answered from the metadata at all. For engraving at this level, corner cut-outs are far too coarse. Cutting corners, in other words, isn't enough. What the Font KnowsA font can describe a glyph's shape three ways. The bounding box is the coarsest. The cut-outs refine it, where the designer has supplied them. The outline is the ink itself, and every font has one for every glyph. From the outline, Ooloi keeps each glyph's profiles: how far the ink reaches sideways at every height, and up and down along its width. It isn't only the sharp. Rectangles fare worst against curves, and a flat's bowl is nothing but curve. Text fonts, for lyrics and expressions, have no SMuFL metadata at all, but they do have outlines. So when Ooloi reaches the lyric hyphens Malte asked about on NOTATIO, the syllables will be spaced by their real shapes. Read, Never RenderedThe obvious way to find the ink would be to draw the glyph and look. I considered it and rejected it: a bitmap depends on the software that draws it, so upgrading a graphics library could move a note. A page has to depend on the piece, not on the machine. Outlines need no drawing. They're already exact numbers, and Ooloi reads them as the font stores them. For the curious: each curve is halved until the polygon around every piece hugs it closely, and the profile is taken from the polygons, which always lie outside the curve. So a profile never cuts into the ink. This happens once, when a font is registered. The profiles are stored with it, and layout only ever reads them. (None of the pictures here was drawn by hand, by the way. They were computed from Bravura's actual outlines.) Down the MountainThis matters more than any single sharp. In High Hrothgar I described two kinds of notation program: on the mountain, the ones handed a whole piece, which take their time and produce the best pages; in the valley, the ones that answer as you work. Hegazy and Gourlay's casting off was the first piece of the mountain's knowledge to come down. This is the second. Spacing against the ink has been the mountain's way. LilyPond, which shares Ooloi's lineage from Hegazy and Gourlay, builds the same kind of profiles from glyph outlines (the usual word is skylines), which a program that compiles the whole piece at once can afford. A year ago, in The Lineage: When Ledger Lines Shorten, I wrote that a ledger line shortened beside an accidental, in LilyPond's essay on engraving, sent a tingle down my spine. Fitting, then, that a ledger line beside an accidental should lead back into the same family. What Ooloi adds is the way down. Read once and kept as data, the profiles give a program that answers as you work the mountain's geometry at no cost per keystroke. The springs, the ink itself and an answer while you type: as far as I know, no interactive program has had all three. That's why a ledger line between a sharp's crossbars is worth a post. TuckingEngravers have always let accidentals slip under things. When a note is followed by a lower one, its accidental can slide in under the first notehead; in a chord, stacked accidentals interlock. That's tucking (though not in the RuPaul sense), and profiles do it without being told: glyphs come as close as their ink allows, and no rule has to mention a flat or a sharp. Here is F5 followed by C♯5, three ways. With the outlines, the sharp's whole upper half slips in beneath the F. (A caveat about these pictures: they show how close the shapes can come with nothing added for clearance, so with outlines the sharp actually touches the F. Real spacing keeps a gap. What matters is the order: boxes allow the least, cut-outs a little more, outlines the most.) Some engravers call all of this kerning, whatever slides into whatever. It's a good analogy: in metal type, a kern was the part of a letter that hung over onto the next. But letters share a baseline and notes don't, so it isn't quite accurate. Which brings me back to the line between the crossbars. Here is C6 followed by C♯6's sharp, as close as the outlines allow; the dashed sharp is where the boxes would put it. In this gap the cut-outs don't help at all; only the outline lets the two come closer. And it answers the question behind Magnus's request: up to the sharp's left stem, the line runs through white space. Only beyond it is it under the ink. Too Much of a Good ThingLook how far those ledger lines go, though: right up to the stem, further than an engraver would let them. Going back to boxes would be the wrong cure: they'd hold the lines back for the wrong reasons, and in the wrong places too. ADR-0055 has a dial instead, the opening width. Openings narrower than it are filled in before spacing, and only the wider ones are left for tucking. Here is that gap again, with the opening open, partly filled and filled. Because a sharp's crossbars slope, the dial works gradually rather than like a switch. The Other DirectionSo far, everything has been horizontal. Read from above, the same profiles tell a slur how close it may come, and two staves how close they may stand. Measured from the outlines, the slur (solid) sits noticeably lower than when measured from boxes (dashed). Good engravers overlap things on purpose, and to do that you need to know exactly where the ink is. The same knowledge decides other things too: in this bar, whether the accent might go outside the slur instead, house style permitting.
So, back to where this started. A sharp can stand over a full-length ledger line, and Ooloi knows whether that line is under its ink or only in its white space. The mechanism is in ADR-0056, Glyph Geometry from Outlines. Seven other ADRs have been brought into line with it, ADR-0055 and its dials among them. And now, back to finally getting that file picker out of the way, even though this is so much more interesting. After all, it's the very thing I've been building the architecture for. It's a lovely feeling. In the comments to Ut Tensio, Sic Vis I told Magnus Johansson that Hegazy and Gourlay provide the physics, I provide the dials, and the user provides the artistic judgement. I meant it as a summary, but it also is a work plan. The physics has had several posts of its own. This one is about a few of the dials: what they are, what each is called, what kind of control it is, and what it does to the page. Two animations show them at work. The first is about what takes the room when a system is looser than its notes need. The second answers the question Magnus asked in those comments, which NOTATIO took up almost at once: who gives way when an accidental meets a ledger line? Who Takes the RoomWhen a system has more room than its notes need, something has to take it. Which notes take it is decided by a single setting, the stretch dial: a slider from 0 to 100%, shown in the animation at three positions, labelled λ = 0, 0.5 and 1. At 0, the whole distance from one note to the next stretches. Every gap grows in proportion to its ideal width, so a loose system is simply the ideal one, scaled. At 100%, only the air stretches: the white space left over once the noteheads have taken theirs. The half note then takes most of the room, and the sixteenths stay together. That end of the slider is LilyPond’s behaviour. At 50% the two share it, and the slider can stop anywhere along the way. Where its default belongs is for the plates to say, not me. Watch three moments. While the bar is compressed, all three rows are identical, because the dial only acts when there’s room to spare. At r = 0, the ideal spacing, they’re still identical, with the gaps before the sharps held open at exactly the width the sharps need. Then the barline moves out, and the rows go their separate ways. The gauges show the adjustment ratio, r, the number the line breaker judges each system by. At −1 the music is as tight as it can go; at 0 it's ideal; the green band is the looseness the breaker accepts. All three gauges agree at every width, and that's deliberate: the breaker judges a system by how much room it has to spare, not by which notes take it. So the dial never changes its verdict. It decides where the room goes and nothing else, which means it can't move a line break, and turning it never obliges you to adjust anything else to keep the casting off sound. Note that in practice, r is as close to 0.0 as possible: that's the entire purpose of casting off. Values for r near -1 are very extreme and rarely or never appear, unless you force it explicitly. So keep in mind that an r of -1 results in the music having lost all rhythmic proportionality. But – with Hegazy-Gourlay's algorithm, you still get no horizontal collisions. Who Gives WayMagnus asked whether the C♯4 and A♯5 in the ‘Ut Tensio’ examples could keep ledger lines of normal length when there’s room to the left of the accidental. They can. Three settings decide who gives way, the ledger line or the accidental:
One difference between them matters more than any other. The minimum protrusion decides how much room the notes reserve, so it’s the only one of the three that moves notes. The other two only spend room the spacing has already given. They never move a note, and they never move a line break. (The image below is very large and is reduced in size to fit. Click on it to open it in a new window where it can be zoomed.) Each stave changes one setting from the stave above, and the changed value is highlighted. Stave 1 never shortens its ledger lines. Magnus, you once said that shortened ledger lines weren’t always necessary as far as you were concerned. This is that setting, and it has a price. At the tight end the bar doesn’t fit, and the sharps end up nearer the previous note than their own. They turn rust when that happens. Stave 2 lets the lines shorten to 0.16 stave spaces, so the bar fits. But as room appears, the sharps move out past the lengthening lines and drift towards the previous note. Stave 3 switches on setting 3. The lines give way instead, and the sharps stay where they belong. They turn blue while the setting holds them. Stave 4 keeps every sharp tight to its notehead and cuts the ledger lines around it. Given room to spare, the first three staves agree. The fourth keeps its own look. Beside each stave, a panel magnifies one gap, C6 to C♯6. The note’s own notehead stays put, so you can watch the sharp travel, and the distances to both noteheads change as it does. In stave 4 the panel shows something else as well. Bravura’s sharp has open corners, and the lower ledger line reaches into one of them, further under the sharp than the line beside the notehead. Nobody had to write a rule for that: the sharp’s outline, band by band, is all the springs need. The ledger lines don’t only give way to accidentals. Look at C6 in the panels when the bar is at its tightest: its lower ledger line is shorter on the left than the one above it. B5 has a ledger line at the same height, and the two share the space between them, keeping a sliver of air in the middle; the line above has no neighbour at its height and only has to clear B5’s notehead. There’s no special rule here. The lines reserve only their shortest acceptable form, so they never push the notes apart, and the notes stay where their durations put them. If you’d rather the lines kept their full length and the notes moved apart instead, that’s the minimum protrusion on the other side, set to the full extension. So these three aren’t the whole story. Whether a note’s ledger lines should be evened out, so that the lower one is never shorter than the one above, is a matter of taste, and so is shortening both ends of a line symmetrically, which someone on NOTATIO suggested. Both are candidates for dials of their own, and both will get their turn. Division of LabourA word on what you’re looking at. Both animations are conceptual. Positions are computed from the published specifications and drawn from a real music font, but nothing in either was rendered by Ooloi. Bravura’s metrics are real; every other value is a placeholder until the plates have spoken. What they do show is the division of labour. The springs guarantee that notes stay where their durations put them and that nothing collides. Within that guarantee, the dials decide how the page looks, each doing a single job, none needing to know about the others. Which positions are right is the engraver’s call, as it always was. Both animations are free to use. Download them, put them in a lecture, a forum post, a book or a presentation, cut them up or build on them; no permission is needed. Formally, they’re released under CC0.
“As the extension, so the force” Hooke’s law, first published in 1676 as the anagram ceiiinosssttuv (Gourlay’s springs are Hooke’s law with a stop) The last few posts described Hegazy and Gourlay’s springs in prose and formulae. That’s the right way to specify something, and a poor way to feel it. The engraver in me wanted to see the music move, so I had the mathematics turned into animation, one computed frame at a time. What came back stopped me. I’ve lived with music notation for most of my life, as a musician and as the author of Igor Engraver, and I’d never seen spacing behave like this: calm, legible at every width, and never once wrong. Below is a bar of chromatic sixteenths, C4 to D♯5, with its end barline dragged from as tight as it will go to loose, and back. Nothing in it is drawn by hand. For every frame the program finds one number, the force that makes the bar fit where the barline is, and every note then goes where the model sends it. The formula is the one ADR-0037 specifies, and the shrinkability is ADR-0037’s baseline. Until now the spacing could only be described. Now it can be run. Watch the gaps before the sharps. In a tight bar they’re wider than the others, because a sharp needs room. As the bar opens they stay where they are while the rest catch up. Once they’ve been caught, every sixteenth sits the same distance from the next, and stays there however far the barline goes. Notehead to NoteheadHere is the idea on four notes. The springs join notehead to notehead and run straight through the accidentals, because what the eye measures is the distance from one note to the next. The shapes themselves are solid and can’t pass through each other. When they touch, the spring between them can shrink no further, and that point is its blocking width. The short note is followed by one with a double flat, and the gap between them needs about twice the room its duration would give it. Under compression the long notes give way while that gap holds. When the bar opens it waits until the force has caught up with it, and only then stretches with the others. By the end it’s longer than its blocking width, which is exactly what a prestretched spring should do. The Springs Made VisibleThis is the same scale as the first animation, with the springs drawn in. A rust-coloured spring is held at its blocking width, where the shapes touch; a grey one is free. On the way out the springs before the sharps turn grey one after another. The one into the low C♯ goes last, because the C’s ledger line has to clear that sharp as well. On the way back every free spring turns rust at the same instant. That’s deliberate: each gap’s shrinkability is its own room above collision, so they all run out of room together, and the tightest legible setting means the same thing across the whole system. Three Ways to Fit a BarThis is why the simpler options lost. All three rows are given the same width, and each finds its own fit. Row A raises a gap’s ideal width to its minimum and scales everything by one factor. Accidentals then add space, and the bar can’t compress below its natural width, so its barline overruns the margin. Row B lets each gap shrink only by its own spare room. Compression comes out right, but the inflated gaps keep stretching in proportion as the bar opens, and B ends up indistinguishable from A. Row C is the springs: under pressure the gaps differ, and as the bar loosens the grid evens out and stays even. To a trained musician there’s no contest. Row A is impossible when the bar is tight and lopsided when it’s loose. Row B is right only while the bar is tight, and as soon as it opens, the notes with accidentals drift apart from the rest. Only C, Hegazy and Gourlay’s springs, cuts the mustard at every width. Ledger LinesThe last animation is about craft. Chromatic sixteenths run from A5 to C7, with one to five ledger lines each, six of them sharped. Blocking widths are computed from ledger lines in their shortest acceptable form, so a ledger line never pushes notes apart. It only takes the room the springs have already given. In a tight bar the lines are short; as the bar opens they lengthen, side by side and height by height, up to Bravura’s full extension. The side facing a note’s own sharp stays short. A line facing the next note’s sharp stops clear of it. Two lines at the same height share the gap between them and keep a sliver of air in the middle. Engravers have always shortened ledger lines when room ran out. Here they do it because the space tells them to. This is the one I keep coming back to. Nothing CollidesLook again at any of the five animations, at any width you like: nothing ever collides horizontally. Nothing checks for it either. A single maximum guarantees it. A gap’s width is the larger of its blocking width and its spring’s length, so it can never become narrower than the point where the shapes touch. Once everything that can give has given, the bar simply won’t get narrower, and the line breaker never asks it to. For me as a programmer, this is the best part. There’s no special case for a sharp drifting into the previous note, none for a ledger line touching its neighbour, and none for an accidental meeting a dot. No clean-up pass looks for collisions afterwards, because there’s nothing for it to find. In previous blog posts I've written about how correction passes are where layout code grows old. Each is written for a case someone noticed, each can disturb what the others arranged, and none is ever safe to remove. Ooloi won’t have a single one for horizontal collisions. Not fewer: none. ADR-0055 states this as an invariant, tested over random music: no collision at any feasible width. Don’t read too much into the exact amounts. The notehead and sharp widths, the line thicknesses and the full ledger extension are Bravura’s, but everything else is a placeholder I picked, and the glyphs are plain geometric shapes. How far a ledger line may shorten, how close a sharp may come to the note before it, and where the full form begins are house-style matters, and in Ooloi they’ll be the user’s. The motion is the model’s. The measurements aren’t Ooloi’s yet. WarmthThat brings me to Roland Gurt’s point about warmth. To me it’s essential, and it’s one of the things Ooloi is designed for. But the springs don’t supply it. What they supply is a guarantee: notes stay where their durations put them, and nothing collides. Warmth is in the tuning. That’s how much more room a quarter gets than an eighth, how far a short note gives way to a long one under pressure, and how much air an accidental keeps from its note. A tracker action doesn’t make an organ beautiful. It makes it obedient, and the beauty is the voicer’s work, pipe by pipe. The numbers that make a page warm will come from engraved plates, and the user will be able to change them. Under the Pointer What you’ve been watching is also how it’s meant to feel in Ooloi. ADR-0055 specifies the barline drag as live: each movement of the pointer refits the system being dragged, and the music follows the barline as you move it. Nothing reflows anywhere else while you drag, because the dragged system is held where it is and no line break moves. However long you drag, the whole gesture is a single undo. As far as I know, no other program spaces music live under the pointer like this. Until now I’ve had to imagine how this would move. Now I’ve seen it, and as a musician I was simply wowed. The notes keep their rhythm under any pressure, the accidentals hold their ground and then let go, and the ledger lines know exactly how much room they have. I hope you’ll feel the same. And now I’m raring to build the machinery that will let me drag that barline myself. The five animations are free to use. Download them, put them in a lecture, a forum post, a book or a presentation, cut them up or build on them; no permission is needed.
Formally, they’re released under CC0. An accidental, a grace note, a clef change and a repeat barline walk into a bar. It’s the first bar of a system, so it’s already crowded. The clef change says, ‘Don’t worry, I sent word ahead’, and points to the courtesy clef waiting at the end of the previous system. The repeat barline says, ‘I’ve been here before’. The grace note says, ‘I can’t stay long’. The accidental just nods at the notehead and says, ‘I’m with him’. Most bartenders sigh and reach for the special-case drawer. Ooloi’s hands each of them a spring (‘boinggg’) and goes back to polishing glasses. A postscript, since the joke is less of one than it looks.
I’ve dreaded this part for two years. Casting off and spacing are where the Minotaur lives: the centre of the labyrinth, where the model finally has to become a page. I assumed I’d have to go in and wrestle it, and I spent the pipeline years arming myself. I knew what the fight would look like. In a conventional architecture, each kind of object that needs room at a system start has a formatter of its own: one for accidentals, one for grace notes, one for clefs, one for barlines. Each is reasonable in isolation. The trouble is that they’re independent, so they needs must negotiate. The accidental takes its room, the grace note needs some of it back, the courtesy clef changes what’s left over, and every pair that meets needs an agreement. Too many of those agreements end up as correction passes, and correction passes are the bane of notation programs, and their elephant graveyard: it’s where Finale finally went, after more than three decades. The agreements grow with the combinations, not with the objects. It isn’t one hard problem; it’s herding cats, each one patched where it was caught, until adding one more kind of object costs more than the program can bear. Instead the Minotaur stretched out a hand: ‘Pleased to meet you, Peter. Let’s get to work, shall we?’ There were no cats to herd. There was only one Master Ring, if I may mix my metaphors further. Information in Ooloi’s pipeline flows one way, and every horizontal rule has to take one of four forms before breaking begins. By the time the accidental, the grace note, the clef and the barline reach the breaker, they’re all springs, combined the same way every time. The problem I met wasn’t the one I’d prepared for. I’d expected a fight with chaos. What I got was a choice between two pieces of mathematics, and the only question was which one was right. The chaos had been dealt with upstream, years earlier, without my quite realising that this was what I was doing. I’m increasingly convinced this is also why Hegazy and Gourlay’s method hasn't been used in interactive programs. The usual explanation is that optimal breaking is too slow to recompute after every edit. It isn’t. It hasn’t been for decades. What it needs is width data that’s settled before breaking begins and stays put while the breaker works. An army of negotiating formatters can’t supply that, because in such an architecture widths are what layout produces, not what it starts from. Speed was never the obstacle; the cats were. The single model also makes the rest of the formatting much, much more straightforward to implement. Every rule that remains has one thing to become and one place to go, and none of them has to know about the others. Foundation work succeeds by disappearing, and this is what it looks like when it does: you walk into the room where the monster is supposed to be, and find a bartender polishing glasses. Oh, and by the way: the stability term is gone.
In 'The Seven Thousand Steps' I described Clear Skies, a cost charged for every system that differs from the layout the user has just been looking at, and concluded that it belonged on by default. I've changed my mind. The reasons say something about why Ooloi adopted Hegazy and Gourlay in the first place, so they're worth a few paragraphs. The term worked. In the model it cut the share of rhythm edits that moved breaks from 33 in 60 to 8, for under one per cent of the total cost. Cost was never the problem. The problem is what it does to the meaning of a page. With the term in place, the layout of a piece is no longer a function of the piece. It depends on the layout before it, which depended on the one before that, all the way back through every edit since the file was created. Two routes to the same music arrive at different pages. The piece carries, invisibly, a memory of how it was edited, and the part a player eventually reads can be worse than it should be because of the order in which its engraver happened to work. The springs were adopted to abolish exactly that kind of thing. LilyPond makes a useful contrast. It is deterministic, as a compiler that starts from scratch every time must be: there is only one route to any page, because there is no history. What LilyPond gave up, in October 1999, was exactness. It added a term comparing each system with its predecessor, judged against a single stored predecessor, so its breaker finds an approximation of its own cost rather than the minimum. Ooloi has neither that term nor any substitute for it. The cost of a system depends on that system alone, as it does in the 1987 paper, and the optimum is exact. Ooloi doesn't start from scratch, though. It re-optimises after every edit from two stored tables, and that is precisely where history could creep in. So the rule is this: after any edit, Ooloi must arrive at the page a full casting off from scratch would produce. Any route gives the same page, whether after undo, after a reload, on another machine, or with edits made in a different order. That is now an invariant to be tested, not a hope. Breaks will therefore move, sometimes before the bar you edited. That is the optimum doing its job, and I want it to. Keeping you oriented is a matter of presentation, not of layout: the bar you're working on stays where your eye was, and whatever moves around it moves legibly. Where you want breaks to stay put, you say so, by freezing systems or forcing breaks, and that decision is stored in the piece like any other, where it can be seen, changed and undone. A layout decision you made is part of the music. One the program made for you because of the order you worked in is not. The anchoring duration won't get the hysteresis I floated either, for the same reason: it gets a value you can pin, and nothing else. ADR-0037 and ADR-0055 have been revised accordingly. On 12/9, at the end of 'The Machinery of Taste', I wrote that things would be slower here for a month or so. A new client placement was taking a great deal of attention, one of my AWS Professional certifications was due for renewal, and Ooloi would have to wait its turn.
It was, for about a fortnight. Then came the heaviest run of posts this blog has had: three long ones in less than a week. So much for the quiet month. What was left to do on the engine was mechanical: refining the file chooser, and building the permission and invitation machinery for collaboration. Neither needs much thought once it's specified, and both were specified. That left the part of my mind that doesn't type with nothing to do, and it went where it always goes, to the next hard problem. Given the six-stage pipeline, how should a score be cast off, and how should the notes in each system share out its width? I read and mulled, argued with myself and with language models, left it alone and came back to it. I didn't recognise what I was doing until it was over. Rich Hickey gave a talk in 2010, 'Hammock Driven Development', about exactly this. You load a problem into your waking mind as thoroughly as you can, then step away and let the background get on with it. That background is where most real design happens, he argues, and it only works on what you've given it. Mine had been given two years of pipeline and had nothing urgent to do with its hands. Then the paper arrived, and the timing is what I keep turning over. Hegazy and Gourlay's 'Optimal Line Breaking in Music' reached me after I'd converted completely to Knuth–Plass. ADR-0037 had been aligned with the original down to TeX's constants, and 'Boxes & Glue' had ended on an unfinished thought about notes that want to stretch and give by different amounts. A month earlier it would have been an interesting old paper. When it came, I already had the question it answered. It's the second time this has happened. In April I wrote that I needed Ross's The Art of Music Engraving and Processing and couldn't buy it. Kim Bastin in Melbourne read it and put his own copy in the post. In September I asked in a comment whether anyone had the Hegazy and Gourlay report, and within a week Ulrik Bodén had found one. I hadn't asked either of them personally. The paper changed the project's direction, which is a different thing from being grateful, though I'm that too. Until Ulrik's copy arrived, Ooloi's design used one scale factor per system, both to choose the breaks and to place the notes. It was one model, but a crude one. It had no way of letting an accidental hold a gap open while its neighbours carried on, so every way of fitting chromatic music into it was wrong somewhere. Letting an accidental hold its gap while the others carry on is exactly what Gourlay's springs were made for. The force that decides where a system ends now decides, gap by gap, where each note in it sits, and it treats an accidental the way an engraver would. 'Vestigia' has the details. The short version is that casting off and note positioning are now governed by one single piece of mathematics that's right where it matters. That's huge, actually. Huge because of what it protects. Information in Ooloi's pipeline flows one way: no stage asks an earlier one to think again. A model that's wrong in some cases will sooner or later tempt somebody to fix those cases afterwards, just this once, and that's the frost troll from yesterday's post. A model that's right about the hard cases gives the troll nothing to work with. Every rule about horizontal space reaches the springs as data, and once it does, it combines with all the others without anybody writing special cases. Engraving becomes far easier to reason about, for me and for the AI, which is at its best with mathematics somebody has written down. It's encouraging, too, how little resistance the change met. The dynamic program didn't move at all. Stages 1 and 2 were already producing the widths the springs need, and each bar now keeps a couple of extra sums and a short list of the gaps its accidentals hold open. ADR-0037 was revised and ADR-0055 written within days of the paper arriving, and nothing around them had to change. None of it is built yet, so what passed the test was the specification, not the code. But building something that a better idea could walk into without a fight was the point of the last two years, and this was a big idea. In 'High Hrothgar' I wrote that 'Nun denn, allein!' could have been carved over the monastery door. That was the honest picture of the first two years, and I won't revise it now. In April, when Kim offered me his copy of Ross, I wrote that something like an informal fellowship seemed to be forming around the work. That was a feeling. This is a fact about the engine: the model at the centre of its layout came from a paper I couldn't find and Ulrik could. 'Alone' describes how Ooloi was started. It no longer describes how it's being built. That changes how the work feels. The conversation here will change too. When the permission and invitation machinery is finished, I'll show it in a video, and that will be the last of the plumbing. In August I raked the ring and left it empty. What comes next is what it was raked for: spacing, beams, slurs, page turns, the page itself. Those are questions musicians can argue about without reading a line of Clojure, and the people already gathered in the comments are the ones who'll know when I've got an answer wrong. I should take more quiet months. 'High Hrothgar' was about where the deepest knowledge of engraving lives, and my decision to take the mountain's method and try to carry it down into the valley. This post is about the climb itself: whether that can really be done in a program that answers as you work, what it costs in time and in code, and what turns up on the way. In the game, the Seven Thousand Steps begin at a bridge in Ivarstead, and along the path stand stone tablets, each engraved with a fragment of the mountain's story. You read them as you climb, one at a time, out of breath. Ooloi's path has its tablets too, the ADRs, each recording a decision taken on the way up, and this post reads two of them again. Last time I said two things: that everything I could see suggested the architecture would allow it, and that none of it was built yet. Both remain true. What has changed is that some of the claims can now be checked, and some of them have been. Counting the StepsIn 'Vestigia Nulla Retrorsum' I wrote that the real cost of the springs would be known only when there was a benchmark, and that until then I was offering reasoning rather than measurement. There is now a first measurement, of a modest kind. Since then I've had Claude Opus 5.5, at its extra-high reasoning level, write an independent model of Stage 3 in Python from the published ADRs: a language model with no history of this project, no special knowledge of Ooloi and no access to its code. It implements the baseline as specified (springs, calibration, demerits and tie-break), and it runs the slow way, in pure Python with exact fractions: about the least flattering setting the algorithm could be given. Clojure is much, much faster. On a synthetic single-stave part of 800 bars, with accidentals scattered through it, a complete casting off into 143 systems took about 0.3 seconds. A part of 150 bars took 30 milliseconds. The exact re-optimisation after an edit, using the two stored tables of best layouts before and after the edited bar, gave the same answer as a full pass in every trial, down to the tie-break. Two different routes to the same answer, agreeing exactly in rational arithmetic, are a strong sign that the specification is consistent. The worked numbers in the ADRs held up too, from the point at which a thirty-second's spring starts to stretch before an accidental to the error of interpolating the duration table. Nor does anyone have to take my word for it. The mathematics can be checked, and a similar model built, by anyone who cares to: give ADR-0037 and ADR-0055 to a language model set to a high level of reasoning, add the last few posts here for context, and go. That is exactly how the model above came about. The specifications were written to be precise enough to execute, and anyone can run that test. Real scores are also kinder than that 800 suggests. A long work isn't one paragraph: movements, scenes and sections end at hard breaks, and each stretch between them is a problem of its own. The total work still grows only with the number of bars, so partitioning saves less time than you might think. What it buys is better: a fence around how far an edit can reach. The JVM should do considerably better than Python; the real benchmark will say by how much. But the order of magnitude is settled. Speed was never the obstacle, I wrote. Now there's a number to go with it. The Wind Above the Monastery "Clear Skies" Above High Hrothgar the path to the summit is closed by a wind that no traveller survives. The Greybeards teach a shout, Clear Skies, that parts it long enough to pass. The breaker has a wind of its own, and it's movement, not speed: breaks that shift in places the user never touched. A global optimum is not local. The ADR says so plainly: an edit to one bar can move breaks anywhere between the hard breaks around it, before the edit as well as after it. The model makes that concrete. On a synthetic part of 150 bars and about 28 systems, toggling a single accidental moved breaks in 2 edits out of 40. Replacing the rhythm of a whole bar, a large edit such as turning quarters into sixteenths, moved them in 33 out of 60, and in 21 of those 60 a system before the edited one changed. When such an edit moved anything, a median of 7 systems were rearranged. That is the wind, and I suspect it's part of what Dorico's stated principle guards against: doing only the minimal recalculation an edit requires, as Daniel Spreadbury put it in 2015. That spares the user's sense of where things are as well as the processor. The ADR's Clear Skies is a stability term: a cost for every system that differs from the layout the user has just been looking at. Set equal to the charge each system already carries, it brought the rhythm edits down to 8 moved out of 60, and an earlier system changed in only 3. The price, in the breaker's own currency, was under one per cent of the total cost in the median case. Ten times stronger, and only 1 edit in 60 moved anything at all. The music in the model is random, so these numbers are indicative, not final. But they say something clear about defaults. The stability term is what makes an exact optimum liveable in a program that answers as you work, so it belongs on by default, switched off only when the user asks for a fresh casting off. The HourglassThe model of Stage 3 contains no knowledge of engraving at all, and that says more about the architecture than about the model. Look at where the musical knowledge sits in the six stages and the pipeline takes the shape of an hourglass. At the top, before rendering begins, sits the semantic model: which accidentals a note needs, how beams are grouped. Stages 1 and 2 hold the horizontal knowledge of engraving: how a chord with seconds is assembled, the outlines of glyphs, clearances, the table that turns durations into space, what changes at a break. Stages 5 and 6 hold the vertical and the page-level knowledge: slurs, ties, beams, articulations, ledger lines lengthened into the room they've been given, and eventually page turns. In the waist, Stages 3 and 4 hold none at all. They are mathematics over springs. Compilers are built the same way, with the knowledge of the language in the front end, the knowledge of the machine in the back end, and a clean intermediate form between them. In Ooloi that form is the stack summary: a handful of numbers per bar that never change underneath the breaker. Taste reaches the waist only as numbers, and musical structure only as cost, never as procedure. What the waist forbids matters most: there are no correction passes. Every horizontal rule reaches the breaker in one of four forms (an ideal width, a blocking width, a constraint spanning several gaps or a difference at a break), and the springs combine them the same way every time. Nobody has to write the formatter for an accidental, a grace note, a clef change and a repeat barline that happen to meet at a system start. A greedy breaker commits to each system before it has seen the rest of the piece, so whatever depends on the whole, such as a full last system, can only be put right afterwards, by a correction step or by hand. Spacing has its own version: a system that comes out too wide, or with a collision, has to be re-spaced and tried again. Dorico distributes a remainder at the end of each flow; MuseScore re-spaces an overfull system with its paddings reduced in steps. Each is a sensible answer to the problem greedy filling poses. In Ooloi both kinds of correction disappear, for two reasons. The exact breaker sees the whole piece before it decides anything, so nothing is left over to redistribute. The springs carry every collision inside the model, so no system ever needs re-spacing. Much follows from that one prohibition. The same music always gives the same page, on every machine and after any history of edits. A dragged note is stored as a change to its springs, not as an offset, so it survives every recomputation. 'No collision at any feasible ratio' becomes an invariant that can be tested. Settings stop being choices between rival heuristics; they become parameters of one model, and compose instead of colliding. And every task that remains, from tuning a value to supporting a new kind of notation, comes down to giving the one model better input, never to teaching one more formatter about all the others. Correction passes are where layout code grows old. Each is written for a case someone noticed, each can disturb what earlier ones arranged, and none can safely be removed, so they accumulate for as long as a program lives. Not needing them at all is the quiet difference underneath everything else in this post. The knowledge of engraving has moved upstream and turned into data: tables and outlines rather than procedures. That's what makes it inspectable, and what lets a stranger rebuild the waist in another language in an afternoon. The Tablets Along the Path ADR-0055 lists twenty-two open questions about horizontal spacing, and none of them is a research problem. Each has a known shape, and the architecture already says where its answer goes: a value in a table, a cost in a dynamic program, or a parameter of the springs. Most are values to be measured from printed plates; some are matters of taste that should simply become settings. A few questions, some from that list and some beyond it, deserve a tablet of their own. Page turns. This is the delightful one. Once page breaking is written down it's almost a pleasure: hard breaks partition the work, repeats and rests become costs at the boundaries, odd and even pages join the state, and the program over a part is tiny. The catch is architectural. Stage 6 can only choose among the system breaks Stage 3 has already made, and a turn in a rest needs a system break at that rest. The two are kept apart because heights aren't known until Stage 5, a reason that is strong in a full score and weak in a single-stave part, whose heights are nearly predictable. Parts are exactly where page turns matter, so for parts I'm inclined to let systems and pages meet, using conservative heights derived from Stage 1's outlines, which keeps the result exact for those heights and never overflows a page. Full scores can keep the separation. Lyrics. A long syllable over a melisma spans several gaps, and the baseline turns it into minimums on the individual gaps before breaking. Under compression that can hold back up to a quarter of their spare room beyond what the syllable needs, which in a choral score could cost a system now and then. The exact form of the reduction uses machinery the springs already have, and for vocal music I lean towards making it the default. Drags. Dragging a note in a tightly compressed system moves it very little on screen while storing a large change to its springs, because there's so little room left to give. If the music later reflows into a loose system, a nudge of a fifth of a stave space can turn into three stave spaces. The stored change is right in principle, but the amplification near the collision limit needs a rule of its own. The anchoring duration. ADR-0055 starts from LilyPond's way of choosing the value around which spacing is built: the most common shortest note per bar across the piece. That statistic can flip when a single bar changes, and then a whole section is re-spaced. It's a second source of wind, upstream of the breaker, and it wants hysteresis or a value the user can pin. Open metre. Systems currently break only at barlines, and music without them needs breaks inside long bars. The mathematics extends without strain, but it isn't specified yet. None of these is a cliff. Straightforward isn't the same as small, though. Measuring the plates is slow, careful work, and it's where the quality will actually be seen. The breaker decides where lines end; the tables decide whether the page is beautiful. The Frost Troll Somewhere on the upper slopes a frost troll waits for anyone who has underestimated the climb. I've found that simply running past it avoids the entire fight. That is the deepest habit of this architecture. Immutable data and a one-way flow don't win the battles other programs fight every day, with state that changes underneath them, caches that must be invalidated in the right order, and layouts that negotiate with themselves until they settle. It runs past them. Those fights never start. The troll will still try to make me stop. One day a page of Ligeti's Requiem will come out wrong, and the quickest fix will be a small nudge after the springs have done their work, just this once. That is exactly the moment to keep running: back upstream, to better input for the one solver. ADR-0037 already says so: a rule that fits none of the four forms is a design problem to be solved, not a pass to be added. Keep to that, and the engine stays as clean in its fiftieth year as in its first. The steps have been counted now. The results are encouraging. But that isn't the same as climbing them. In Skyrim, there's a monastery just below the summit of the Throat of the World, the tallest mountain in the land, and the only way there is on foot. The path is called the Seven Thousand Steps. It starts in a small village called Ivarstead and climbs through pine forest into snow, past stone tablets that tell the story of the place, into a wind that gets worse the higher you go. Somewhere on the upper slopes a frost troll waits for anyone who's underestimated the climb. The name of the monastery is High Hrothgar. At the top live the Greybeards. They are masters of the Voice, the Thu'um, the ancient art of speaking words so charged with power that they move the world. The Voice is spoken in the tongue of dragons, a language almost no one outside the monastery understands. Their own voices are so strong that they almost never use them: one of them, Arngeir, speaks to visitors on behalf of the rest, and the others keep silent. They take no part in the affairs of the land below. Wars come and go, dragons return to the skies, and the Greybeards go on meditating, keeping what they know for the few who make the climb and prove equal to it. It's a game, but the image has stayed with me all week. It describes, more exactly than anything I could have invented, where the deepest knowledge of music engraving has lived for the last thirty years. The MonasteryMasters of the Voice, guarding its secrets on a mountain: you could hardly ask for a better image of the people who know how music should be laid out on a page. Never mind what the notes are, which is the composer's business; the question is how they share out the width of a line, where each line should end, and why a well-engraved page can be read at a glance while a poor one makes the player work for every bar. Those are the real secrets of engraving, and they're mostly invisible. When they're kept, nobody notices anything at all. In the world of notation software, the monastery is LilyPond. Over three decades its makers have assembled the most serious body of engraving knowledge any program possesses, much of it traceable to a handful of academic papers from the 1980s, and built it into a program whose output a great many musicians regard as the nearest thing the field has to a grail. The Seven Thousand Steps are real too. To engrave a piece in LilyPond you don't place notes on a page. You write the music out as text, in a syntax of its own that has to be learned, and hand the whole thing to the program, which works through it in one go and returns finished pages. If you want it to do something differently, you have to speak the monastery's own dragon language, Scheme: a dialect of Lisp, one of the oldest families of programming languages, famous for its thickets of parentheses and impenetrable to most outsiders. Nothing answers you while you work. You write, you wait, you look. I want to be fair to the mountain, because the analogy invites a sneer it doesn't deserve. The steps are no affectation. A program that is given the whole piece at once, and allowed to take its time, can afford to consider every way of laying it out and choose the best. That is exactly what makes its results what they are. The climb is the price of the view. The ValleyMost musicians stay below, and so do most notation programs. Down in the valley a program has to answer as you work: you enter a note and the page changes in front of you. That leaves no time to reconsider the whole piece after every keystroke, so the programs of the valley fill each line as they go, bar by bar, move on when the next bar won't fit, and make the best of whatever they've been left with. Dorico, which takes engraving more seriously than most, works this way, and its developers have said openly why: the careful method was evaluated and found too slow for a program that must respond in real time. Most of the time the results are very good. The rest of the time the engraver finishes the job by hand. So the field has divided along the mountain's flank. Up there, the beautiful results, for those who make the climb. Down here, the convenience, at the cost of a little beauty and a good many afternoons spent correcting. Hardly anyone has said outright that it must be so, but everything has been built as though it were. The knowledge of High Hrothgar, the assumption goes, can only be practised on High Hrothgar. The Path UpUntil a few days ago Ooloi would have been counted among the valley programs, if it was counted at all. It's an interactive program, after all, and that seemed to settle which side of the mountain it belonged to. It doesn't any longer. I've decided that Ooloi will lay out its music by the method Wael Hegazy and John Gourlay described in 1987, in the paper Ulrik Bodén tracked down for me and which I wrote about in the last post. It's the same text LilyPond's teaching grew from, and I'm taking it in its original form: the whole piece considered at once, and the best layout found exactly. ADR-0037, which specifies Ooloi's line breaking, has been revised accordingly, and a new decision record, ADR-0055, now describes how the music is prepared for it. The details are there for anyone who wants them; this post isn't the place. That puts Ooloi in the mountain's lineage. It doesn't put it anywhere near the top. LilyPond has thirty years of practice behind its answers; Ooloi has a decision and a specification. The monastery's knowledge was earned slowly, and I'm a newcomer at its gate with a borrowed book. I do at least speak a dialect of the language. Ooloi is written in Clojure, which is also a Lisp: I speak Dragon. This is perhaps not a coincidence. Down the MountainKnowledge that stays on the mountain is only half useful, though. The real question, the one this whole project keeps returning to, is whether it can be brought down: whether a program that answers as you work can produce what has so far only been produced at the summit. Ooloi takes its name from Octavia Butler's Xenogenesis trilogy. Butler's alien Oankali have three sexes, and the third, the ooloi, can perceive and rearrange the living matter of other creatures. They take genetic material from different lineages and combine it, by instinct, into children that neither parent could ever have produced alone. Nikanj, the ooloi at the heart of the first novel, does exactly this with humans. That's the most honest way I can describe what I'm attempting without a single formula. Ooloi takes the mountain's DNA, its knowledge of how music should be spaced and where lines should break, and combines it with the valley's: a program that answers as you work. If it works, the child will be neither LilyPond made faster nor Dorico made more careful, but something neither lineage could have become by itself. Speed has very little to do with it. Computers have been fast enough for this for decades. What makes the crossing possible is the way Ooloi has been built over the last two years, for reasons that had nothing to do with engraving: by the time layout begins, every bar has been reduced to a handful of numbers that will never change underneath it. The monks' long contemplation of the whole piece becomes a short piece of arithmetic, quick enough to repeat after every note you enter. The last post was about that, under Horace's motto: all the footprints lead one way, and none lead back. (There's also a Dragonborn in the story, a mortal who learns in days what the Greybeards needed lifetimes for. I'll resist that one.) On the MountainThere's another way to read the picture, and it would be dishonest to leave it to the comments. A man working alone for two years on foundations nobody can see yet, refusing to show anything until it's right, measuring himself against a fifty-year horizon: that isn't a portrait of the valley. 'Nun denn, allein!' could have been carved over the door of High Hrothgar. If anyone in this story is living on the mountain at the moment, it's me. The difference, I hope, is the direction of travel. I'm up here so that what gets built can be used down there, by someone who has never heard of Gourlay and never will, and who simply wants a part whose page turns fall in rests. Whether that works isn't something a blog post can settle. None of it is built yet. Everything I can see suggests the architecture will allow it, and the judges will be the printed pages of the great engraving houses, not my hopes for them. 'Come Back in a Year'Almost exactly a year ago, people on various forums were asking when they'd see Ooloi render any notation, and I answered in a short post called 'Where's the Music?'. Not yet, I wrote: foundations first. Come back in a year, and the conversation will be about music by then. The day after, in 'The Lineage: When Ledger Lines Shorten', I wrote that reading LilyPond's essay on engraving had made me realise we came from exactly the same place. I had no idea then how literally that would turn out to be true. Here we are, two weeks early. 'Boxes & Glue', 'Vestigia Nulla Retrorsum' and this post deal with the very heart of engraving: how a line of music shares out its space, and where it should end. Together with ADR-0037 and ADR-0055, they say everything you need to know to understand what Ooloi is aiming for and how it means to get there. The TradeButler's ooloi aren't comfortable creatures. Their trade is seldom asked for, and the humans they trade with don't come through it unchanged. The engraving version is gentler. LilyPond will go on compiling on its mountain and Dorico will go on answering in the valley, exactly as before; nothing is taken from either that doesn't remain where it was. Only the child is new.
Dawn, the first volume of Butler's trilogy, was published in 1987, the same year as Hegazy and Gourlay's paper. That's a coincidence, and I won't pretend otherwise. But Nikanj would have approved. The paper is here. 'Optimal Line Breaking in Music', by Wael A. Hegazy and John S. Gourlay of the Ohio State University, 1987: fifteen typed pages, scanned from somebody's reading copy, complete with underlinings and a few pencilled notes in the margins. It's out of print and it isn't online, and I'd been looking for it far and wide. In the end Ulrik Bodén, owner of Musikboden and one of Ooloi's sponsors, tracked down a copy and sent it to me. Once again the small circle of friends around this project has done what searching couldn't, and I'm very grateful. Under the last post, Magnus Johansson asked whether I'd had the chance to study it yet. I have, and this is what I found. First, a word about how I look at other programs, since several of them appear below. I don't run Dorico, MuseScore or LilyPond, and I don't intend to. That isn't disdain. I read what can be read: source code where it's open, development diaries where their authors have published them, forum posts where a decision has been explained. I read them as I read the source of gRPC or the JVM, to understand how something was built and, above all, why. What I don't do is examine the latest release to see what I'm up against, because I'm not up against anything. Ooloi isn't a feature race. I'm trying to build an engine for music notation in which the difficult parts are dealt with underneath, once and properly, so that whoever builds on it doesn't have to. If it works, it'll be because of what Ooloi is rather than what it does. Casting off and horizontal spacing are where reading other programs is most illuminating. Casting off is the engraver's term for deciding where each system ends; horizontal spacing is how the notes within a system share out its width. Between them they decide whether a page reads evenly or lurches, and whether the last system of a movement is full or holds two forlorn bars. A player takes all of that in before reading a single note. Every notation program has to answer the question, the answers differ, and the reasons for the differences say a great deal about the architectures behind them. The Other Ninety Per CentIn September 1985 Jon Bentley's Programming Pearls column in Communications of the ACM collected a page of programmers' aphorisms. One of them, credited to Tom Cargill of Bell Labs, has outlived most of the others: 'The first 90 percent of the code accounts for the first 90 percent of the development time. The remaining 10 percent of the code accounts for the other 90 percent of the development time.' Engravers have their own version. Notation software handles about 95% of engraving well, and engravers spend about 95% of their time on the remaining 5%. Those figures are practitioners' experience rather than measurements, but anyone who has prepared parts for a performance will recognise the shape. The afternoon goes on forcing system breaks, prising collisions apart, and recasting a part so that the page turns fall in rests. The two rules describe the same remainder from opposite ends. The cases a developer leaves unfinished, because they belong to the last 10% that would take the other 90% of the time, are precisely the cases the engraver then finishes by hand. Shipping at the 90% mark doesn't make the remaining work go away. It passes it on to the users, multiplied by every user and every score. That's a tax, and like most taxes it's paid continuously by people who never voted for it. Ooloi is in large part an attempt to abolish taxes of this kind wherever the architecture allows, from undo to collaboration. The engraver's 5% is the largest of them. I should be fair here, because it matters. Doing 95% well might genuinely be good enough for most people's music. In December 2016 Daniel Spreadbury wrote that Dorico's casting off, tested against the Gourlay method, 'produced very similar results a lot of the time'. That's the 95% working exactly as designed. The 5% is where it doesn't, and that's where the engraver's afternoons go. Knuth & Plass, BrieflyI wrote about the algorithm in 'Boxes & Glue', so a reminder will do. In 1981 Donald Knuth and Michael Plass published the line breaker that TeX still uses. A paragraph is a row of boxes (the words, which are rigid) with glue between them (the spaces, each with a natural width and a given capacity to stretch and shrink). Any choice of breaks gives each line an adjustment ratio r: the stretch or shrink the line needs, divided by the stretch or shrink its glue can supply. So r = 0 is a line at its natural width, r = 1 is a line stretched as far as its glue is meant to go, and r = −1 is the tightest line TeX will set. Knuth turns r into badness, roughly 100 × |r|³, and badness into demerits, (l + b)² + p², where l is a small charge for every line and p the penalty attached to the break. Then he finds the set of breaks with the smallest total for the whole paragraph. The cubes and squares mean that one very bad line is punished far more than several slightly imperfect ones, which is exactly the judgement a good compositor makes. What makes it fast is dynamic programming. The program walks through the paragraph once and, at each possible break, remembers only the best way of getting there. If the cost of a line depends on that line alone, nothing more is needed: when the walk reaches the end, the best layout of the whole paragraph is recovered by following the remembered steps backwards. The result is exact, meaning provably the minimum of its cost rather than a good guess, and the work grows with the number of possible breaks times the number of words that can share a line. The alternative, and still the usual one, is greedy filling: put bars on a system until the next one won't fit, move on, and never look back. It's quick and it's local, and the bill arrives at the end of the piece. What Hegazy and Gourlay Actually WroteAs far as I can tell, nobody has described this paper in public. LilyPond's source names it as the origin of its first line breaker, and Daniel Spreadbury has said it informed Dorico's casting off, but I've found no account of what it actually contains. ADR-0037, which specifies Ooloi's breaker, cited it while admitting that it described none of its contents. That ADR has now been updated with a description along these lines. The paper opens by explaining why music isn't text. The last system of a piece is always full, so a copyist has to be prepared to revise early breaks that don't lead to a full last line, and a program must be able to do the same or it'll stretch the last system grotesquely. Long works should also fill their last page, which sometimes means forcing a particular number of systems. Clefs and key signatures repeat at the start of every system, and they change, in content and in width. Most important of all, notes don't move linearly when a system is stretched or squeezed. The state of the art, they note, offered little help. Byrd's 1984 thesis program did first-fit breaking, which is greedy filling by another name, and expected users to choose their own breaks. Ross's engraving manual advised avoiding bad breaks and keeping the spacing uniform. 'There appears to be no published algorithm', they write, that attempts to deal with these problems at all. Their claim is that Knuth's model already handles the first three. A paragraph with no fill glue at its end gets a full last line automatically. Penalties encourage or discourage particular breaks, which is how a performer's awkward page turn can be avoided. TeX can be told to use a set number of lines. And TeX's discretionary breaks, the mechanism behind hyphenation, can change what's printed at the end of one line and the start of the next. Only the fourth problem needs new theory. That theory is the paper's real contribution, and it's lovely. Think of the space between two notes as a spring. In text the springs join the outsides of rigid boxes. Hegazy and Gourlay pass the springs through the boxes and attach them to the left edges of the noteheads, because what the eye measures is the distance from one note to the next, not the white space between their shapes. The boxes still can't pass through each other, though. A note and the accidentals of the note after it take up room, and when those shapes touch, the spring between them can shrink no further. So each gap carries four numbers: an ideal width w, a stretchability y, a shrinkability z, and a blocking width b, the width at which the shapes on either side collide. Under a force f, which is Knuth's adjustment ratio under another name, positive to stretch and negative to compress, the gap's width is the larger of two quantities: width = max(b, w + f·k), where k is y when stretching and z when compressing. Read as a musician: the spring tries to be its ideal width plus whatever the force asks of it, but never narrower than the collision allows. Read as a mathematician: each gap is a piecewise-linear function of the force, and therefore so is the whole system. The interesting case is the one where b exceeds w, which they call 'prestretched'. Their Figure 1 shows it: a note preceded by two flats so wide that the gap before it is already larger than its duration warrants. That gap doesn't move at any line length until the force on the rest of the system has caught up with it; only then does it begin to grow with the others. The accidental takes the room it needs and not a hair more, and once the system is loose enough it costs nothing at all. That's exactly how an engraver treats an accidental. The consequence for breaking is that the force needed to fit a system is no longer a single division, as it is in TeX. It's the solution of a piecewise-linear equation whose kinks lie wherever an individual gap collides or begins to stretch. The search around it is Knuth's, which they say 'does not differ in any significant way' from TeX's: remember the best predecessor for each barline, discard lines whose force falls outside a permitted window, and trace the optimum backwards from the end. Their efficiency section is the most telling part of the paper, because they never treat the dynamic programming as the expensive part. The expense lies in working out the force for each candidate system, and they attack it twice. First comes a cheap lower bound on the force, built from running totals: 'the sums are computed from the beginning of the piece to the current place, and two such sums are subtracted to obtain the sum for what lies between them'. Programmers call these prefix sums. The bound is designed so that it can never wrongly reject a system that would fit. Second comes a fast path for the common case, in which the force stays on the first straight segment of the curve, before any gap has collided. They test for that with minima precomputed for each bar. Their evidence is modest and well chosen. They broke a 48-bar piece on a single stave, Dean K. Roush's 'Lacrimosa', into systems. The breaks matched those chosen by a professional musician, who had spent a few hours on it. The program took a few seconds on a personal computer of 1987. So is it Knuth–Plass? Not purely. The search is Knuth's without his fitness classes, which TeX uses to stop a tight line from sitting next to a loose one, at the price of extra bookkeeping. The cost is shaped like TeX's but never written down as a formula. And the model of a line is a strict generalisation of boxes and glue: TeX's glue is the special case in which nothing ever collides. But it isn't approximate either. The cost of each system depends only on that system, the pruning is sound, and the cheap bound never discards a line that would fit, so the result is the exact optimum of its own cost. Nor do the modifications reduce the efficiency of the algorithm. The dynamic programming is untouched; what grows is the arithmetic inside the evaluation of a single system. What Hegazy and Gourlay did to Knuth and Plass was extend them. The DescendantsThree documented lines of descent made three different choices, and in each case the authors have said why. LilyPond's first line breaker, gourlay-breaking.cc, says in its source that it was 'adapted from the OSU Tech report on breaking lines'. It was a straightforward dynamic program until October 1999 (release 1.2.14), when a term comparing each system with its predecessor was added for the sake of evenness. With only one predecessor stored per breakpoint, that made the result an approximation of its own cost, and the term survives in LilyPond's current breaker. LilyPond's spacing, which I'll come back to, is solved afresh for every candidate line. Han-Wen Nienhuys, who wrote the original breaker, commented in 2015 that he'd first run it on a 386 at about 40 MHz, where 'it was somewhat expensive'; that computers had since become a hundred times faster; and that you have to solve 'O(#bars * #bars-per-system) spacing problems'. He thought it could be used for interactive scores too. Dorico's team evaluated the Gourlay method early on. In 2015 Spreadbury set out the reasoning in his development diary. A program that compiles its output from text input needn't respond in real time, but for an interactive one 'a compromise is needed in order to balance the quality of the result against the time taken to compute it', and Dorico's principle was to 'always do only the minimal amount of recalculation to respond to an edit'. In December 2016 he wrote that the method's performance characteristics weren't suitable for Dorico's real-time use, and that Dorico's own algorithm 'basically runs only one way, from the start of the layout to the end'. In April this year he confirmed that the paper had informed Dorico's casting off, which is greedy, with a separate remainder-distribution step at the end of each flow. That remainder step deals with the full last system, the first of the four problems Hegazy and Gourlay listed in 1987. Others claim the full prize. Christof Schardt, the author of PriMus, wrote in 2015 that PriMus had used TeX's total-fit algorithm, 'modified for scores instead of text', interactively for over ten years, taking collisions into account 'by an equivalent linear operation'. Basil Crow's open-source Neanes editor does optimal line breaking for Byzantine neume notation. I haven't checked either at source. None of this is a league table. Each choice was rational under the constraints its makers had, and Spreadbury's 2013 statement of Dorico's ethos, that the application should do 'automatically what an experienced engraver or copyist would do anyway', is one I'd sign without changing a word. The goal is shared. The constraints aren't. Speed was Never the ObstaclePut the dates side by side. In 1987 an exact optimum over a nonlinear spring model ran in seconds on a personal computer. In 2015 the author of LilyPond's first breaker, who had run it on a 386, reckoned that machines a hundred times faster could manage it interactively. Processor speed hasn't been the obstacle for a very long time. What costs something is evaluating each candidate system, and everyone who has looked closely puts the cost there: Hegazy and Gourlay in 1987, Han-Wen in 2015. Hegazy and Gourlay's remedies, the running totals and the per-bar minima, rest on an assumption so basic they never needed to state it, which is that each bar's numbers are fixed before breaking begins. They could assume it because their input was a single stave, handed to the program as a ready-made sequence of springs. A notation program has to manufacture that input from a full score, and this is where architecture comes in. Suppose a candidate system's width depends on which bars share it, or on something settled only after the breaks are chosen: the courtesy accidentals at a system start, an accidental decision that changes when a tie crosses a break, spacing that's adjusted and then fed back. Then every candidate needs its own spacing calculation. In a mutable, incremental program, every moved break also invalidates whatever was computed downstream of it. A global optimum, where one edit can move breaks anywhere in the score, then becomes the most expensive thing you could possibly ask for, and greedy filling is the sensible choice. I can't see inside anyone else's program, so take this as my reading of the problem rather than a finding about any product. But it's consistent with everything their authors have said, and it puts the obstacle where the 1987 paper already implied it was: in the data, not in the processor. Vestigia Nulla RetrorsumOoloi lays out a score in six stages, and information moves through them in one direction only. Stage 1 works on every bar in parallel. It forms the atoms (a note or chord with its accidentals, dots and articulations, handled as one unit) and traces their outlines from the font, the shape each presents to its neighbours. Stage 2 lines the staves up vertically and works out, for every gap, both its ideal width, which comes from the durations, and its minimum, where neighbouring outlines would touch, so that each measure stack (one bar across all the staves) leaves it as a handful of numbers. Stage 3 breaks the systems. Stage 4 positions the atoms. Stage 5 draws what connects them, the ties, slurs, hairpins and beams, and works out how tall each system is. Stage 6 breaks the pages. Nothing flows back. Stage 5 can't ask Stage 3 for more room, and Stage 3 can't reopen a decision made in Stage 1. The musical questions, such as which accidentals a note needs, are closed before layout begins, so layout can't change them. Everything Stage 3 needs is known before it starts, including what each bar would require at the start of a system and at the end of one. The pipeline has a motto, borrowed from Horace. In the first of his Epistles (I.1.73–75) a fox declines the sick lion's invitation into its den and explains why: 'quia me vestigia terrent, omnia te adversum spectantia, nulla retrorsum'. The footprints frighten me: they all lead towards you, and none lead back. In the fable that's a warning; in a layout pipeline it's the design. Every footprint points forward, and that single property is what turns casting off from a negotiation into arithmetic. Arriving at the Same PlaceOoloi’s breaker, specified in ADR-0037, was written from Knuth and Plass directly, before I’d read a line of Hegazy and Gourlay. Reading them now is a curious experience, because the search is the same. Both remember one best predecessor per barline, with no fitness classes. Both subtract running totals between barlines, and both stop extending a candidate system as soon as more bars can’t possibly fit. Their per-bar minima, used to test whether a line has reached its first collision, correspond to a number every Ooloi measure stack carried until now: its tightest gap’s ratio of minimum to ideal width, tracked as a running maximum while the candidate system grew. The correspondence goes deeper than I expected. Until now, Ooloi’s baseline let every gap stretch and shrink in proportion to its ideal width, so each system had a single scale factor. It also calibrated the adjustment ratio so that r = −1 fell exactly where the tightest gap in the system reached its minimum, and allowed nothing beyond that point. In Hegazy and Gourlay’s terms, that was their model restricted to the first straight segment, before any gap has collided, with the force rescaled so that the first collision sits at −1. I got there independently, but I don't think the convergence is remarkable. Both designs start from TeX, and both discover that the cost lies in evaluating a line; from there the problem pushes you towards the same answers. I find that reassuring rather than surprising. Where Ooloi goes further, most of the reasons lead back to the direction of flow. The first concerns system starts and ends. Hegazy and Gourlay pointed at TeX's discretionary breaks for the clefs and keys at each system start, and left it there. A discretionary has three parts: what's printed before the break, what's printed after it, and what's printed if no break happens. Ooloi's breaker has all three. A postamble holds what a system's end needs, which is the cautionary key and time signatures; a preamble and a gutter hold what the next system's start needs: clef and key, courtesy accidentals for tied notes, a start repeat. Everything else at a barline belongs to a bar, wherever that bar falls: the barline itself, as it looks at the end of a system, and a clef change drawn in front of it belong to the bar they close, and a new key or time signature to the bar it begins. The third part holds what exists only mid-system: the start half of a repeat barline, which at a break moves to the start of the next system, and the cancellation naturals of a key change, if the house style drops them at a system start because the previous system's cautionary has already shown them. Each is a fixed width at its barline, and the breaker subtracts those inside a candidate system with a single subtraction of running totals, so the result stays exact. All of it is known before breaking, because nothing downstream can change it. This also matters for exactness. Hegazy and Gourlay's pruning is only safe because their systems carry no such material. Give each system start a width that varies from bar to bar and their pruning can wrongly discard systems that would have fitted. ADR-0037 prunes against the full system width instead, which stays exact. The second concerns editing. A global optimum means that one edit can move breaks anywhere, which is why interactive programs avoid it. In Ooloi every stack's numbers are immutable and cached, so after an edit nothing upstream is recomputed except what the edit actually touched, which is usually the bar that changed. The new optimum is then found exactly from two stored tables, holding the best layouts of everything before the edit and of everything after it, in roughly K² evaluations, where K is the number of bars that fit on a system. That's a couple of hundred cheap evaluations, not a re-layout. Keeping breaks where they were while you work is a separate problem, and the ADR specifies mechanisms for it that are anchored to the identity of bars rather than to luck. The third is determinism. Layout is computed once, by the authoritative backend, not separately by each client; but it still matters that the same music always produces the same layout. Everything is computed in exact rational arithmetic, and when two layouts cost exactly the same, which under exact arithmetic happens whenever bars are identical, the tie is broken by a rule that depends only on the layout itself, never on the order in which the program happened to meet the candidates. Re-optimising after an edit therefore gives the same answer as starting from scratch, undo brings back the identical layout, and a score opened on another machine looks the same there. Nothing on the page moves unless the music has given it a reason to, which removes a whole class of jitter at its source. One further difference has nothing to do with immutability: Ooloi's cost is written down. It uses Knuth's badness and demerits with TeX's own constants as the starting point. That only works because the adjustment ratio is calibrated so that −1 means collision and +1 means a stated amount of stretch; without the calibration, TeX's numbers would mean something quite different for music. That one is simply care. What Gourlay has that Ooloi Doesn'tThe other direction is the more interesting one. Until now, ADR-0037 allowed four fitting rules, which are ways of deciding how each gap gives way when a system is looser or tighter than ideal. All four were linear glue: each gap stretches and shrinks in fixed proportion, and a system’s force is a single division. None of them could represent a gap that blocks while its neighbours carry on, and none could represent a prestretched gap at all. The ADR’s contract with Stages 1 and 2 actually forbade it, since every gap’s minimum had to be at or below its ideal. And the case isn’t rare. The engraver’s principle is that everything belonging to a note, accidentals included, should fit within its proportional allocation: accidentals don’t add space. But a sixteenth’s allocation is around one and a half stave spaces, and a notehead plus a sharp plus clearance needs more than two. In any chromatic passage in sixteenths, a good share of the gaps have a minimum larger than their ideal. That’s Gourlay’s prestretched spring, and it’s what the decision below turns on. All of this is easiest to picture on a single stave, but Ooloi doesn't space just single staves. Stage 2 aligns every stave in a measure stack on a shared vertical raster: one column for each rhythmic position that occurs in any stave, so that notes sounding together line up from the top of the system to the bottom. A gap in Gourlay's sense is the distance between two columns, and its blocking width is set by whichever stave needs the most room there. A sharp in the violas widens that column for the flutes as well. What I Have to DecideThere are three ways to go, and each of them shows on the page. Take a bar of chromatic sixteenths, half of them carrying accidentals, as the running example.
I have decided that Ooloi will adopt Gourlay’s springs, and ADR-0037 has been revised to specify them. Will it make Ooloi slower? As with Hegazy and Gourlay, the dynamic programming itself doesn’t change at all: the same states, the same number of candidate systems, the same tables for re-optimising after an edit. What changes is the arithmetic inside the evaluation of a single candidate system, and only for the systems that need it. Compression is always a single division, exactly as before. So is stretching, until a gap held open by an accidental starts to stretch. Only then does the candidate take the slower path, in which those gaps’ kinks are kept in sorted order as the candidate grows and the force is found by walking them. That costs a handful of extra operations per kink passed, not a spacing calculation. Those are precisely the systems the linear baseline spaced wrongly. The ones it rejected outright, frozen by a single gap that couldn’t shrink, now cost nothing extra at all. Stages 1 and 2 already compute every gap’s ideal and minimum, so nothing new is asked of them; each stack simply keeps a few sums and a short list of its accidental-held gaps. The result stays exact and identical on every machine, and nothing flows backwards. I’ll know the real cost when there’s a benchmark on chromatic material. Until then, that’s reasoning rather than measurement. As I've decided to go with the springs, more questions follow. The first is what r = −1 should mean. If each gap’s shrinkability is set to its room above collision, every gap reaches collision at the same moment, at −1, and TeX’s constants keep their meaning. But wherever long notes have more room than short ones, they give up more of it, and the rhythmic hierarchy flattens under pressure. If shrinkability is weighted by duration instead, short values compress and collide first while longer ones keep giving. That’s nearer to the way engravers describe their own practice, but −1 then needs another definition. The choice decides whether a tight system still reads as rhythm. I’m starting with the first, which is also LilyPond’s default and keeps compression a single division; duration weighting stays a candidate for the plates to decide. The second is minimum distances that span more than one gap: a long syllable sung across a melisma, or material that crosses between staves. Gourlay’s blocking works between neighbours, so such constraints have to be reduced to minimums on adjacent gaps before breaking. LilyPond’s spacer shows how: a minimum distance spanning several notes becomes a blocking force on every spring beneath it, at a small cost in density that a comment in its source considers acceptable. Since that force depends only on the springs inside the span, it can be worked out before any break is chosen, and that’s the reduction ADR-0037 now specifies, in Stage 2. So Ooloi doesn’t need the per-candidate spacing calculation that LilyPond chose to pay for. The third is what the raster should do with the room. Take two staves of sixteenths in the same stack, some notes carrying accidentals and some not, in different places in each stave. One answer is that every sixteenth in the bar sits at the same distance from the next, so the rhythm reads as a regular grid and every column gets as much room as the most demanding one. Another is that each column takes only what it needs, so a column with an accidental in any stave is a little wider and the rest a little narrower: more economical, less regular. Gourlay's springs give a third answer that moves between the two. Under pressure the columns differ; as the system loosens, the columns held open by accidentals stop growing while the others catch up, until at some point the grid is even again. Which of these an engraver would choose, and at what degree of tightness, is a question for the plate. A related case shows what's at stake. Take a bar that opens with a half note, continues with eight thirty-second notes and ends on a quarter. Logarithmic spacing already gives the thirty-seconds far more room than strict proportion would, and with their beams, stems and perhaps an accidental or two they may need more still. The half note and the quarter, on the other hand, are mostly air. An engraver lets them pay: the run of thirty-seconds gets the room it needs, and the long notes give some of theirs back. Proportional scaling can’t do that. Every gap shrinks by the same factor, so the thirty-seconds reach their minimum first and the whole system stops compressing while the half note still has room to spare. Shrinkability bounded by each gap’s own room, the second option above, does let the long notes give way, and Gourlay’s springs do it as a matter of course: the thirty-seconds, with little or no room above their minimum, give up little or nothing, and the half note and the quarter absorb the rest. This is also where the weighting question gets interesting. ‘Shorter values compress first’ sounds right until the shorter values have nowhere left to go; beyond that point the blocking decides, not the weighting. What none of this decides is who pays. Gourlay's force is one number for the whole system, so the cost of the thirty-seconds is spread over every gap in it, including a half note three bars away. An engraver might prefer the half note in the same bar to pay, and leave the rest of the system alone. That's a choice between consistency, where the same duration gets the same space across the system, and locality, where each bar settles its own debts. It belongs to the setting of ideal widths within a bar, before any fitting begins. In a full score it's subtler still: if the half note sounds against thirty-seconds in another stave, the raster has no half-note gap to shrink at all. All of this sits beside two questions ADR-0037 already left open. One was whether to add a term for evenness between neighbouring systems, as TeX does with its fitness classes. I’ve decided against it. The cubic badness already punishes an extreme system out of all proportion, so under an exact optimum a cramped system survives next to a loose one only when every alternative costs more. And a comment in LilyPond’s source warns that such a term can make cramped lines more cramped where the music grows gradually denser. Music changes density for reasons of its own, and the layout shouldn’t pretend otherwise. The other question, how page breaking and with it the page turns in parts should be costed, remains open. How the Others AnswerEach of the programs I've read has answered these questions definitely, and since I read rather than run them, what follows comes from their source and their documentation. It describes how they work, not how their pages look. LilyPond's answer is the closest to Gourlay's, more literally than I'd realised. A spring in its spring.cc has an ideal length, a stretch, a compression and a minimum, and its length under a force is the larger of the minimum and the ideal plus the force times the flexibility: Hegazy and Gourlay's formula, prestretched springs included. By default a spring compresses by exactly its room above its minimum, which is the second option above, and a note's stretch is proportional to the space between bare noteheads, so the air stretches and the ink doesn't. In the bar with the half note and the thirty-seconds, the half note therefore takes most of any stretching and most of any compression, because it has most of the air. Durations are spaced from the most common shortest duration, each doubling adding a fixed increment of about a notehead's width, and each column takes the shortest duration sounding in it. MuseScore, in its current source, derives each note's natural width from its duration on a logarithmic curve: every doubling multiplies the space by a factor, 1.5 by default, starting from 3.5 stave spaces for a quarter. Where a collision demands more room, the extra is spread over the preceding notes rather than piled into one gap. When a system is justified, its notes act as springs whose stiffness comes from their durations, and a note already widened by a collision doesn't stretch until the force reaches it, which is the stretching half of Gourlay's model. Compression works differently: a system that is too wide is re-spaced with paddings and duration spacing reduced in steps, and as a last resort collisions are accepted. Bars are added to a system until the next one no longer fits at its natural width, and the system is then stretched to the margin, as its handbook also describes. Dorico's documentation says less about mechanism, but two things are on record. In 2015 Spreadbury described forming a column for every onset across all staves and giving it the value of the shortest note sounding there, the same raster as Ooloi's, and spreading surplus space as 'a tiny fraction of a space to each column', in contrast to the hand engraver's habit of giving it to the longest notes first. Its current layout options include a minimum space for short notes, which is the thirty-seconds' case, and a choice, when justifying, between 'actual widths', which count accidentals and dots, and 'ideal widths only', which count the notes. That last option is, in effect, the question of whether accidentals add space, offered to the user as a setting. None of it will be settled by argument. Ooloi's Vorbilder, the models it measures itself against, are printed pages from the great engraving houses, made by people who did this by hand for a living, and that's where the questions will be settled: on material chosen for where the 5% lives, such as chromatic passages, vocal scores heavy with lyrics, tight orchestral pages and parts with page turns. The measure is how many interventions it takes to reach the layout an engraver produced by hand. That number is the tax. And when I start showing pages from Ooloi, I'll set them beside printed music, never beside another program's output, however anonymised. Coda'Boxes & Glue' ended on a thought I hadn't finished: that the space after a whole note and the space after a sixteenth want different things, that each might have its own idea of how far it will stretch and how far it will give, and that this seemed very close to how a human engraver reasons about whitespace.
The thought is thirty-nine years old. Hegazy and Gourlay had it in 1987. They passed the springs through the boxes, gave each one a point beyond which it won't give, and solved the result exactly on a machine any modern thermostat would outrun. What they didn't have was a full score reduced to numbers that couldn't change underneath them. But that's exactly what I've spent the last two years building, mostly without realising that this was one of the things it was for. Something's been nagging at the edge of my mind. Knuth–Plass, the algorithm that breaks TeX's paragraphs into lines, has been adapted for music at least once, by Hegazy and Gourlay, and I ought to look at what they did. If there's prior art, so much the better: that's a strength, and something to build on.
For musicians, the underlying question is an old one: where should each system end? A score has to be cut into lines, and where the cuts fall decides whether the spacing is even, whether a crammed system sits next to a loose one, and where a page can be turned. The simplest method, and a common one, fills a system bar by bar, moves on when the next bar won't fit, and stretches whatever is there to the width of the page. It's quick, it never looks ahead, and it leaves the engraver forcing breaks by hand. Programmers call this greedy filling, and it doesn't produce optimal breaks. Knuth's algorithm, written for paragraphs of text, does the opposite: it weighs every possible set of breaks and picks the best. This matters because a player judges a page at a glance, before reading a note of it. And it's technical because that glance is decided here, in the model, long before anything is drawn. The questions were harder to settle than I'd expected. Was Hegazy and Gourlay's algorithm, and whatever descended from it, really Knuth–Plass, or something merely inspired by it or adapted from it? If adapted, was it still provably optimal, as the original is? And had the real algorithm ever been used to engrave music at all? The last question has the clearest answer: yes, in 1987. MuTeX, a master's thesis at Bonn by Andrea Steinbach and Angelika Schofer, set music with TeX's own glue and line breaking. The MusiXTeX manual later explained why that struggles: a line of text holds dozens of words and a system only a handful of bars, so the stretch piles up as gaps before the barlines. Hegazy and Gourlay's paper, from the same year, isn't online, so exactly what they did I can't say. What can be read is its descendant, described in ADR-0037. LilyPond's first line breaker, written ten years later, names their report in its source as its origin, and it's a dynamic program in Knuth–Plass's family. Later versions added a term for the evenness of consecutive systems, judged against a single stored predecessor, which makes the result an approximation of their own cost rather than its exact minimum. The other half of Ooloi's model, fixed space for clefs and signatures with one scale factor for everything else, is what Daniel Taupin, Ross Mitchell and Andreas Egler built into MusiXTeX in the mid-nineties. ADR-0037 now sets all of this out. Ooloi's own algorithm had been specified as Knuth–Plass from the start. What I hadn't expected was that it could be aligned with the original exactly. The atoms are the boxes, the spacing between them is the glue, and Ooloi's baseline is simply the case in which every piece of glue stretches in proportion to its natural width. So I aligned it fully, down to TeX's badness and demerits, with TeX's constants as starting points, and it's optimal in precisely Knuth's sense: the dynamic program finds the exact minimum of its own cost. That turned out to have real advantages. One of them I hadn't foreseen at all. Claude reasons far better about a forty-five-year-old algorithm, documented down to its last constant, than about anything bespoke. Once the cost had Knuth's shape, whole classes of question could be settled by reference instead of argument. None of this makes the algorithm Ooloi's; it's textbook, and the ADR says so. What Ooloi supplies is the conditions it needs. Knuth's algorithm wants stable inputs, and by the time Ooloi's pipeline reaches the breaking stage it has them, because information only flows forward. It's fast for a related reason: the earlier stages have already reduced the music to a very small set of numbers, a handful per bar, which are trivial to process even when the score runs to 800 pages and is set in Valhalla. The best layout can be recomputed while you type. For the person reading the part, the result should simply look right: systems evenly spaced from first to last, no cramped system beside a loose one, fewer breaks to force by hand. Stopping that layout from jumping about while you edit is a different problem, and the ADR deals with it in its own right. The glue has a further implication, one I haven't finished thinking through. The space after a whole note and the space after a sixteenth want different things. One is mostly air and can give a good deal in either direction. The other sits close to its neighbour: squeeze it and rhythm becomes collision, stretch it and a beamed group falls apart. Under the glue model the space after each note can have its own idea of how far it will stretch and how far it will give, and the two needn't match. The system then stops giving way in simple proportion, and if Knuth–Plass does what it should, the breaks are still optimal. That seems to me very close to how a human engraver reasons about whitespace. In June I published a road map and claimed the list was plumbing, every line of it. It was. Networking, certificates, session persistence, collaboration state, window geometry: nothing on that list would ever appear on a page, and the whole argument for doing it then was that none of it would be sharing the desk when the page finally arrived. That list is nearly spent, and what replaces it is a different kind of work: Where things stand Everything about a piece except the music itself can now be manipulated from the interface. That reads like a summary. It's actually a precise statement, and it names a boundary the architecture drew long before this summer. Changes to the things that contain the music – musicians, instruments, staves, layouts, and a piece's own settings – announce themselves structurally the instant they happen, on every connected client. Changes to the music itself defer to the formatting pipeline, which is asynchronous and which doesn't yet exist. One side of that line is now complete, all the way up to the interface. The other is a routing-table entry with no producer and no consumer. The summer went into the first side. Pieces open and save and close and reopen where you left them. Musicians and instruments are created, numbered, renamed, cloned, reordered and deleted by gesture, with the numbering falling out of the gesture rather than out of a dialog. Layouts assemble into scores and parts. A piece's settings live in a window of its own. A field refuses a value it cannot take, in the field you typed it into, in your own language. Every one of those acts is a single transaction, a single event, a single refetch, a single named step in the Edit menu, and the path is identical whether you are working alone or someone on another continent is working beside you. The semantic model, in other words, finally has a surface. For two years it existed and could only be reached through tests. It can now be reached with a mouse. Except for the music. Which is what the rest of the tickets are for: Finishing what collaboration started
The distributed machinery is proven. Two Oolois on two laptops, one hosting, one connected, editing shared state with undo reaching across the wire and respecting each other's work. What's missing is everything that governs who may do what: invitations, single-use tokens, deep links, JWT identity, role-based access, a host-side collaborator registry, and a piece picker that shows a guest their own slice of a catalogue rather than someone else's filesystem. There's an obvious objection to doing this now. Collaboration is the exception. I fully expect the overwhelming majority of Ooloi users to run it standalone on one machine and never invite anybody to anything. Why finish the exception before the rule? Precisely because it is the exception. Work that sits half-done at the edge of a system does not stay quiet. It surfaces as a special case in every subsequent decision, and it surfaces at the worst moment, which is when you're concentrating on something else. Finishing it now means never thinking about it again. When the engraving work begins, the access model will be behind me rather than beside me, and single-user operation will be what it already is architecturally: a collaboration group whose size happens to be 1. A word about #229, because its title invites exactly the wrong inference. The standalone server isn't a second product. Not a separate edition, not a server variant, not a codebase carrying features the desktop application lacks. It's the backend half of ordinary Ooloi – the same backend, the same components, the same behaviour – packaged to run on its own: in the cloud, on a conservatory's machine, on a collaborator's laptop in another city. There's no new functionality involved. The administrator connects to it as a client, through the same authentication path as anyone else, which is the whole reason it comes after #136 rather than before. The substrate
Ooloi 'eats its own soup'. The formatters that draw a page are plugins, on exactly the same terms as anything a third party might write: the same API, the same performance, the same access. There's no privileged internal path that the public one imitates. This is not a gesture towards openness; it's the mechanism by which engraving conventions stay arguable. If you disagree with how Ooloi slopes a beam or hangs a secondary, and the settings provided aren't enough or your formatting philosophy is different, you can replace the formatter, in whichever JVM language you prefer, and Ooloi doesn't notice the difference. Which is why the plugin layer precedes the drawing. It also precedes MusicXML, because the importer is itself a plugin, and it'll be the first serious test of whether the plugin surface is genuinely sufficient rather than merely declared to be. Skija brings Skia into Ooloi: the graphics engine behind Chrome, Android and Flutter, and the third incarnation of a lineage that runs back through AlphaMask to QuickDraw GX, which is where Igor Engraver began. I have written about that circle before. What matters here is narrower. Until Skija is in, Ooloi cannot draw anything at all. Not a stave, not a notehead, not the small music example that ought to sit inside a preferences dialog showing you what a setting actually does to the page. The layout windows currently open onto a considered and entirely empty surface. Skija is what fills them. The page, assembled
The full specification is in ADR-0028 and I will not rehearse it here. What's worth stating is the order of implementation, because it reads rather like a page assembling itself: First blank pages. Then the text on them: titles, headers, footers, page numbers. Then systems, with their instrument names, brackets and braces. Then staves and their staff lines. Then the measures on those staves, which is where noteheads, stems, flags, dots and accidentals first appear. And spanners last. Ties, slurs, hairpins, lyrics, ottavas, and above all beams, which are the hardest of them and the most revealing of a system's quality. That sequence isn't an implementation convenience. It's the pipeline's own structure: everything that can be computed independently, computed first and in parallel, and everything that depends on final positions deferred until those positions are fixed. The page is built the way the architecture says a page is built. The TurnHere is what actually changes, and it's not the subject matter. For two years an argument could be settled by running something. Does the traversal allocate? Measure it. Does the accidental algorithm handle a grace note at a barline under a hierarchical key override? There is a test, and it either passes or it doesn't. Determinism is a property you can demonstrate. When I wrote that two supposedly intractable problems had collapsed into ordinary algorithms, the claim was checkable, and anyone who doubted it could check it. Nothing in the next phase works that way. No test will tell me a beam slope is beautiful. No suite will fail because a slur's curvature is slightly graceless, or because the white space on a page reads as mean rather than generous. The machinery that has caught every error for two years is about to fall silent on precisely the questions that matter most, and the only instrument left is a musician's eye. Mine first. Then, with any luck, other people's. And the ground underfoot isn't solid in the way the engine's was. Staff notation is roughly a thousand years old. Printed engraving as a craft is five hundred. The copperplate house styles I'm actually implementing are perhaps two hundred and fifty. Each layer left conventions behind. They don't agree with one another, and they don't always agree with themselves: Ross devotes some fifty pages to beaming and contradicts himself more than once within them, and where Ross and Gould differ, they differ because the profession differs. Bärenreiter is not Durand. Neither is wrong. So the design consequence was settled in advance. Engraving rules live as editable data rather than as conditionals buried in source. House styles are configuration. Formatters are replaceable. Where taste genuinely differs, Ooloi takes a position and makes the position adjustable, because the alternative is to pretend a live craft is a solved one. That's the work now: the objective machinery in service of something irreducibly subjective. It's the part I have been waiting two years for, and it's also the part where merely being right is no longer sufficient. TempoA practical note. I've just begun a new client placement, with a complex system to get into production, and it's absorbing a great deal of attention. On top of that my AWS DevOps Professional certification is due for renewal, and I take the AWS exams seriously enough to actually study for them rather than turn up and hope. The next month or so will therefore be slower here than the last three have been. This does not worry me in the slightest. The summer's pace was fast and, if anything, accelerating: subsystem after subsystem closed and stopped asking to be thought about again. The project's in a good place. A quiet month against that background is a quiet month, not a stall. CodaThe anxiety inverts here, which I hadn't quite anticipated.
Invisible work fails by remaining invisible. You solve something genuinely difficult and it vanishes into infrastructure, and the better you have done it the less anyone can see. I have written about that loneliness before. Visible work fails by being looked at. Every judgement I make about a beam, a slur, a page, will be in front of musicians who have spent their lives reading engraved music and who will know immediately, and without being able to say why, whether it's right. I'd rather have that problem. It is, after all, the one I set out to have. There is a Swedish expression, kratta manegen: literally, to rake the circus ring before the performance begins. Prepare the ground, clear away what shouldn't be there, make the arena ready.
For rather more than two years, that's what Ooloi has been doing. This week I finally reached the place where I can open The Maids, double-click its score layout in the Piece Window, and watch a Layout Window appear. It contains almost nothing: a subtle background colour and a large, empty, scrollable surface. Excellent. This is where the music will be engraved. The rendering pipeline, spacing algorithms, geometric constraint solving, paintlists and Skija drawing will all end up here. The fact that the window is empty is precisely the point. Everything underneath it already exists. I've also spent the past few weeks raking the arena in the other sense: finishing the Piece Window, completing undo and redo around its operations, tightening failure handling, localisation and editing behaviour, and removing the small architectural exceptions that would otherwise have followed us into the graphical work. So here we are. The ring is empty. The stage is set. Spring has finally arrived in Stockholm. I mention it only because there's a quality of north European light returning after winter that genuinely affects how work feels. The past two weeks have been quiet on the Ooloi front, code-wise. I'm being onboarded into a large AWS project at work, where my decisions will eventually affect roughly five thousand developers, and onboarding at that scale absorbs a great deal of attention. What Ooloi work I've done has been architectural cleanup: the sort of small consolidations you make when the ground is about to be built on. Data field validation refactored to be entirely general, for instance. Not glamorous, but the kind of work that matters once it has disappeared from notice. Ross also arrived this week. The 1987 third edition, posted from Melbourne in a padded envelope, in pristine condition, and now on the desk where it belongs. Two weeks ago I wrote that I needed the book and couldn't buy it. The void was listening, as the coda noted. It is one thing to write that, and another to hold the consequences. The book is dense and beautifully exact where it counts. It's also, in places, at odds with itself, which is the honest record of any craft this old. The beaming section alone runs to fifty pages and doesn't entirely agree across them; the accidental positioning sections give horizontal spacings down to fractions of a stave space. Exactly what I'd hoped for. Translating it into data and code will be a pleasure. What strikes me paging through is how much of the material I already know in some sense. Musicians absorb this kind of thing through a lifetime of reading and writing scores. The interest is not the content as content; it's the formalisation. Ross surfaces principles that intuition alone never quite articulates. He's rigorous about things most musicians never have to put into words, and that's where the real value sits. It's also what makes the book usable as a specification rather than as commentary.
The road ahead, briefly. The Piece Window comes first, multi-user collaboration aware from the start, built on the patterns the Instrument Library established. After that: frontend session persistence so windows reappear where you left them; the Piece Preferences window (also collaboration aware); clock skew compensation for reliable distributed undo and redo; and the full multi-mode client work, with Google-Docs-style permission management for connecting peers. That last item closes a chapter. Once it's done, I won't have to think about multi-user logic again. It'll simply be there. Then plugins for all JVM languages, a first version of MusicXML import and export, and Skia/Skija with GPU acceleration. The last of those is when SMuFL fonts can finally be drawn on the page. After which the rendering pipeline proper begins. The first stage draws everything except the music: page numbers, titles, headers, footers, staves, system barlines, braces, brackets, instrument names. Crucially, it's done through the plugin system itself, in Clojure plugins. If you don't like the choices, you can replace them, in whatever JVM language suits. I'm not sure it'll ever be necessary, but it can be done if so desired. Then the interesting material: noteheads, horizontal spacing, flags, augmentation dots, multi-voice collision resolution, accidental clustering, unisons. Everything that isn't a spanner. The solver gets the supposedly easy work first. Spanners last: beams, ties, slurs, hairpins, glissandi, lyrics, pedalling, 8vas. Where Magnus's question about hovering secondary beams will finally have somewhere proper to live. But first: piece windows. Expect GIFs/videos soon! Elaine Gould's Behind Bars is here. Ted Ross's The Art of Music Engraving and Processing isn't, because there's nowhere to order it from. The print edition has been dead for decades. Hansen Books no longer functions in any meaningful commercial sense. Ted Ross himself is dead. Second-hand copies surface occasionally on AbeBooks or eBay, usually in poor condition, usually at absurd prices, usually spoken for within hours. The Internet Archive lends a scanned copy in twenty-four-hour slots. A Californian outfit called npc Imaging has sold a searchable CD-ROM edition since 2001, though whether it still runs on a modern operating system is an open question.
Which provokes the obvious one: do I still need Ross in 2026? The temptation to answer no was real. The book was published fifty-six years ago. It describes a workflow of punches and gravers, of metal plates and photographic reproduction, none of which has survived the move to digital notation. Gould arrived forty-one years later, covers what publishers currently expect, and is in print. But no. I need it. Gould and Ross overlap, but their centres of gravity differ. Gould's focus is editorial: contemporary conventions, edge cases in modern repertoire, the negotiated practices that settle disputes between composer and copyist. Her domain is current, and her vocabulary includes extended techniques and the Ferneyhough generation's demands. Ross's focus is geometric. Stem lengths with actual measurements. Beam angles. Optical spacing tables. Ledger line dimensions. The precise relationships between noteheads, stems, beams, and staff lines, specified with the exactitude of someone producing real plates. His specifications are tabular and implementable rather than descriptive. Ross becomes data in Ooloi; Gould has to be read and decided. The invariance argument settles the age question. The five-line staff hasn't changed since 1970. A half note still looks the same. The geometric relationships Ross specifies have the same validity now as when he wrote them, because notation itself hasn't shifted underneath them. What dates in Ross is the production workflow, which I can skip entirely without losing anything I need. LilyPond's spacing algorithms reference Ross directly. Gourlay's seminal paper on music spacing builds on him. The rendering pipeline I'm about to close – spanner geometry, optical adjustments, beam slope selection – sits more in Ross's territory than Gould's. Not consulting him would be working blind on problems he addressed head-on half a century ago. So I need the book, and I can't buy it. There's something grimly appropriate about this. Ross's book is the kind of reference work whose commercial half-life expires decades before its technical half-life even begins to decay. The market that would sustain a reprint is smaller than the importance of the content. LilyPond's continued citation of Ross is, in a sense, more preservation than any library has managed. The notation community keeps him alive by quoting him, not by reading him. It's also, not incidentally, one of the reasons Ooloi's documentation looks the way it does. The normal fate of a specialist reference work is exactly what happened to Ross: the author dies, the publisher dissolves, the copies scatter, and fifty years later someone trying to do the work has to borrow the book in twenty-four-hour slots from a scanner in San Francisco. None of which amounts to preservation. And even if it did, neither book would be the final word. They don't fully agree with each other, because the engraving community and major publishers don't fully agree with each other. Ross, despite devoting some fifty pages to beaming, contradicts himself more than once within that span. This isn't a failing. Engraving is a living craft with regional traditions, house conventions, and genuine disagreements about what looks right; two books documenting it honestly will reflect those disagreements rather than paper them over. Which means the rendering pipeline isn't a matter of looking up The Answer. It's a matter of taking positions in ongoing debates, and making the positions configurable wherever taste genuinely differs. Ooloi's formatting is data-driven wherever it can be. Engraving rules live as editable values, not as switch statements buried in source code. Hard-coding them treats them as invariant when they aren't, and turns house styles into an act of patching rather than configuration. Which is how the real disputes get handled: Boosey & Hawkes flat beams against sloped ones, whether grace note beams separate from or share the main beam, whether a slanted beam group shears or rotates. Ooloi will rotate. I'm looking forward to that.
I've published a guide to Ooloi's frontend architecture – long, precise, and detailed, written for architects and developers who want to understand the system from the inside.
It covers window lifecycle, event architecture, the rendering pipeline, fetch coordination, localisation, collaboration, and the testing model. Together with the Timewalking Guide and the Polymorphic API Guide, it forms the main conceptual gateway into Ooloi's internals. Worth flagging for experienced frontend developers: this architecture inverts several instincts. The frontend holds no semantic authority. It is computationally strong and structurally subordinate; that subordination is precisely what makes distributed collaboration, transport independence, and first-class plugin composition possible without architectural compromise. The guide explains why. I think the argument is sound, though I'm aware it might feel distinctly odd, or even regressive, to a developer whose instincts were formed in React or a similar ecosystem. If you work in notation – as a musician, engraver, or editor – and find this kind of writing opaque, current large language models are genuinely useful here. Feed the guide to one and ask what it means for your daily work. It's a reasonable use of the technology, and the answers tend to be surprisingly good – when they're not inventing things I'd never claim ;) Worth stating plainly: the subject here is art, and the technical rigour exists in service of that, not despite it. This blog documents the reasoning behind Ooloi as it develops – for future contributors, researchers, maintainers, and critics. Systems like this have a lineage and a psychological architecture as much as a technical one. I want that visible. This blog has a voice because it was written by someone who considers authorial invisibility a failure mode rather than a virtue. Well, that was quick! The multi-tiered frontend event infrastructure is complete and implemented. One evening's work added the Event Router, the Rendering Data Manager, and the Fetch Coordinator. This implements ADR-0031 and shows that having the implementation architected in detail before writing the code saves a lot of time. I'd expected to be busy with frontend events for some time.
Now that that's out of the way comes what it enables: windows, dialogs, menus, notifications. I'll be working with JavaFX, cljfx, AtlantaFX: what's called 'UI chrome'. It's concrete work without semantic subtleties for a change: does the window open? Does the NordDark theme apply correctly? Does the dialog render? Aesthetic decisions instead of semantic ones. I expect these blog posts will turn quite practical in tone for a while, as this is standard engineering, plumbing, connecting things, turning detailed ADRs into working code. Quite relaxing, as a matter of fact. And I can now, after 18 months, finally give in to that desire to actually open a window. Fresh air! A few weeks ago I wrote a post explaining computer science terminology to musicians. This is the inverse: an explanation of music notation for programmers who assume the domain is simpler than it is. That assumption is common. It's also expensive. Most notation software has been written by very competent engineers who underestimated the problem. The result is systems that work impressively until they don't – at which point they fail in ways that seem arbitrary to users but are, in fact, architectural. This post explains why. Notation Is Not MIDI with Graphics The most damaging assumption programmers bring to this domain is that music notation is a visual layer over time-stamped events. Work with audio software, game engines, or digital music for long enough, and this seems obvious: notes have start times, durations, and pitches. Notation just draws them nicely. This is wrong in a way that corrupts everything downstream. Consider two representations of identical duration:
These produce the same acoustic event. They do not mean the same thing. The first is a single rhythmic impulse sustained. The second implies a specific re-articulation point encoded in the notation itself. Performers read these differently. Conductors might even beat them differently. The semantic distinction is not ornamental. MIDI cannot represent this distinction. It knows only NOTE_ON, NOTE_OFF, and duration. Notation systems built on MIDI-like assumptions inherit this blindness and spend their entire existence fighting it. Music notation encodes musical meaning, not acoustic events. The implications of this single fact occupy the rest of this post. Time Is Not Integers Programmers reach instinctively for integer representation. MIDI uses ticks – typically 480 or 960 per quarter note. DAWs use samples. The assumption is that any temporal precision can be achieved by choosing a sufficiently small quantum. This is false for music notation. Consider a simple case: a quarter-note triplet against regular eighth notes. The triplet divides the beat into thirds; the eighths divide it into halves. To represent both exactly in a tick-based system, you need a tick count divisible by both 2 and 3. Fine: use 6 subdivisions. Now add a quintuplet in another voice. You need divisibility by 2, 3, and 5: LCM = 30. Now consider what real music does. Chopin writes nested tuplets. Ferneyhough writes 7:6 against 5:4 against 3:2. Elliott Carter writes simultaneous streams at different tempi. The required tick resolution grows combinatorially: where di are tuplet denominators and k is your base resolution. For complex contemporary music, this can exceed 10^6 ticks per beat, at which point integer overflow becomes a real concern and accumulated floating-point error in tempo calculations produces audible drift. The solution is obvious once stated: rational arithmetic. A quarter-note triplet is exactly 1/3 of a half note. No approximation. No accumulated error. The arithmetic is exact because the representation matches the domain.
These don't share a finite decimal expansion. They don't need to. Rationals are closed under the operations music requires. Clojure provides this natively. Most notation software doesn't use it. The consequences appear everywhere timing matters – which in notation is everywhere The Structure Is Not a Tree Programmers expect hierarchical data. XML, JSON, ASTs, DOM trees – the mental model is that complex structures decompose into nested containers. Parent nodes own child nodes. Traversal is well-defined. Music notation has multiple simultaneous hierarchies that do not nest cleanly. A single note participates in:
These hierarchies intersect. They do not nest. Consider cross-staff notation: a chord where some notes appear on the treble staff and others on the bass. Which staff 'owns' the chord? Neither. Both. The question assumes a tree structure that doesn't exist. Or consider voice exchange: soprano and alto swap pitches mid-phrase. The melodic line (a horizontal relationship) contradicts the voice assignment (a vertical relationship). Both are musically meaningful. Neither subsumes the other. Grace notes exist precisely at the intersection of conflicting hierarchies. They have pitch (placing them in a voice) but steal time from adjacent notes (making their metric position contextual). They may or may not take accidentals from the main-note context. The rules vary by historical period. Systems that force music into a single hierarchy spend enormous effort on edge cases that are only 'edge' cases because the data model is wrong. Context Is Non-Local: The Accidental ProblemHere is a concrete example of why music notation is harder than it looks. Question: Does this F need a sharp sign? Answer: It depends on:
A naive algorithm checks each note against previous notes in the measure. This is O(n) per note, O(n^2) per measure. Fine for simple music. Now add multiple voices. The F in the soprano might be affected by an F♯ in the alto, depending on conventions. You need to track alterations across voices. If voices cross staves (as in keyboard music), the interactions multiply. Now add simultaneity. What happens when two voices sound the same pitch at the same instant but with different accidentals? Yet another edge case difficult to catch when imprisoned in the Jail of Recursive Descent. Now add grace notes. A grace note at the beginning of a measure might be notated at the barline but sound at the end of the previous measure. Does its accidental affect the next measure? Does the next measure's key signature affect it? The dependency graph for accidentals is not a simple sequence. It's a directed acyclic graph with edges determined by temporal position, voice membership, staff assignment, and notational category. Correct handling requires topological sorting with domain-specific edge semantics. Most notation software handles this with heuristics: rules-of-thumb that cover common cases and fail on uncommon ones. The failures aren't bugs in the usual sense. They're consequences of architectural decisions made decades ago when the problem was less well understood. Ooloi handles this through what I call the 'timewalker' – a transducer that processes musical events in semantic order (not storage order) allowing full temporal context accumulation. The accidental algorithm becomes stateless over its input stream: given the same sequence of musical facts, it produces the same decisions. Deterministically. Every time. The complexity is still O(n · v) for n events and v voices, but the constant factor drops dramatically because traversal and processing are separated. The transducer handles navigation; the algorithm handles meaning. Concurrency Is Not Optional Here is where most notation software fails silently. A modern computer has multiple cores. Users expect responsiveness: type a note, see it appear immediately. But notation isn't like a word processor where inserting a character affects only nearby layout. Changing one note can alter accidentals throughout a measure, reflow an entire system, or invalidate cached engraving calculations across pages. The traditional approach is to serialise everything. One thread handles all mutations. The UI blocks or queues. This is why notation software freezes when you paste a large passage, or why collaborative editing remains essentially unsolved in this domain. The problem deepens when you consider what 'correct' means during an edit. If a user changes an F♮ to an F♯ in measure 4, the accidental state of measure 5 depends on this change. But if the rendering thread is currently drawing measure 5, what does it see? The old state? The new state? Some inconsistent mixture? Mutable state with locks doesn't solve this; it creates a new category of bugs. Deadlocks. Race conditions. Heisenbugs that appear only under specific timing. A very difficult work environment indeed, and one where diminishing returns becomes a real impeding factor. The functional approach is different. If musical data is immutable, the question dissolves. The rendering thread has a consistent snapshot – always. The editing thread produces a new snapshot. There's no moment of inconsistency because there's no mutation. This is what Software Transactional Memory provides in Clojure. Transactions compose. Reads are always consistent. Writes are atomic. The system guarantees that no thread ever sees a half-updated score. The performance implications are substantial. Ooloi's STM handles heavy contention without the coordination overhead that serialised systems pay constantly. The bottleneck shifts from synchronisation to actual work. Real-time collaboration becomes architecturally possible. Two users editing the same passage don't corrupt each other's state; they produce alternative futures that the system can merge or present as conflicts. This isn't a feature bolted on afterwards. It's a consequence of representing music correctly from the start. Engraving Is Constraint SatisfactionProgrammers sometimes assume that once you have the musical data, displaying it is straightforward. Calculate positions, draw glyphs, done. This underestimates the problem by roughly an order of magnitude. Consider accidental placement in a dense chord. Multiple accidentals must avoid colliding with each other, with noteheads, with stems, with ledger lines, and with accidentals in adjacent chords. The placement rules aren't arbitrary – they encode centuries of engraving practice optimised for readability. This is a constraint satisfaction problem. In the general case, it's NP-hard. Real systems use heuristics, but the heuristics are subtle. Gould's Behind Bars – the standard reference on notation practice – devotes many pages to accidental stacking alone. Now multiply by every other engraving decision: beam angles, stem lengths, tie curves, slur routing, dynamic placement, tuplet brackets, ottava lines, system breaks, page breaks. Each interacts with the others. Change a stem length and the beam angle needs adjustment; beam ends need to follow sit-straddle-hang rules and might both move. Change a beam angle and adjacent voices may collide. LilyPond's engraving quality comes precisely from treating this as a serious optimisation problem. Its page-breaking algorithm runs a variant of the Knuth-Plass line-breaking algorithm (developed for TeX). Its spacing uses spring-based constraint systems. The 'simple' rendering layer contains some of the most sophisticated code in the system. Interactive notation software faces an additional challenge: these calculations must be fast enough for real-time editing. You can't spend ten seconds optimising layout every time the user adds a note. The tension between quality and responsiveness has driven much of the architectural evolution in this field. Historical Conventions Are Not Bugs A programmer encountering music notation for the first time will find countless apparent inconsistencies. Surely these could be rationalised? No. Or rather: not without destroying information. A fermata on a note means 'sustain this note'. A fermata on a barline means 'pause here'. A fermata on a rest means something slightly different again. These distinctions emerged from practice. Composers use them. Performers understand them. A system that normalises them into a single 'fermata event' loses musical meaning. Grace notes in Bach are performed differently than grace notes in Chopin. The notation looks similar. The performance practice differs. A system that treats all grace notes identically will produce correct output that performers find misleading. Clefs change meaning by context. A C-clef on the third line is an alto clef; on the fourth line, a tenor clef. Same symbol, different staff position, different meaning. This isn't legacy cruft – orchestral scores routinely use multiple C-clef positions because different instruments read different clefs. Mensural notation (pre-1600) has entirely different rules. The same notehead shapes mean different things. Accidentals follow different conventions. Barlines serve different purposes. A truly comprehensive notation system must handle this or explicitly disclaim it. The temptation to clean this up, to impose regularity, to treat historical conventions as technical debt – this temptation must be resisted. These conventions encode musical knowledge. Destroying them in the name of consistency destroys the knowledge. The Performer Is the Point All of this serves a purpose that has nothing to do with computers. Notation exists to communicate with humans. Specifically: performers who bring interpretation, physical constraints, and centuries of inherited practice to their reading. This isn't sentimental. It has engineering consequences. A page turn in the wrong place forces a pianist to stop playing or memorise a passage. This is a functional failure, not an aesthetic preference. The page-breaking algorithm must allow this to be modelled. Awkward beam groupings obscure metric structure. The performer reads beats through beam patterns. Wrong beaming means wrong emphasis. The beaming algorithm must model this based on the currnent time signature. Unclear voice leading forces performers to decode the texture before they can interpret it. The system must make voices visually distinct in ways that match musical distinctness. Engraving choices that are mathematically equivalent may not be performatively equivalent. Two layouts might use the same space and avoid all collisions, but one reads naturally and the other requires active deciphering. The difference matters. This is why notation is not a solved problem. The specification is 'communicate musical meaning to human performers'. That's not a format spec. It's a design constraint that touches every decision in the system. Conclusion Music notation looks like a data format problem. It is actually a meaning representation problem with a millennium of accumulated context. The systems that fail – and most fail in some way – do so because they treat notation as something to be processed rather than something to be understood. They model the symbols without modelling what the symbols mean. The systems that succeed take the domain seriously. They represent time exactly. They handle multiple hierarchies without forcing false containment. They process context correctly even when context is non-local. They treat engraving as a real problem, not a rendering detail. They preserve historical conventions because those conventions carry meaning. This is why Ooloi's architecture looks the way it does. Rational arithmetic isn't ideology; it's the only way to represent tuplets exactly. Immutability isn't fashion; it's the only way to guarantee that accidental decisions are deterministic. Transducers aren't showing off; they're the cleanest and most efficient way to process a semantic stream with accumulated context. STM isn't over-engineering; it's the only way to achieve both correctness and responsiveness without sacrificing either. The domain dictates the tools. Not the reverse. We have a new year, and it's time to make plans. Ooloi's architecture is now closed, and the work enters a new phase. What follows is a road map, not a schedule – no dates, no promises – but a logical progression. These stages are different in nature from what has gone before. Conceptually simpler than the deep semantic work (what the music is, how it's represented and manipulated) or the infrastructure (server/client transports and roundtrips, monitoring, certificates). Everything below is comprehensively architectured and implementation-ready. The thinking is done; what remains is execution. The PreparationsEvent-Driven Client Architecture: The nervous system that lets the interface respond without freezing. (ADR-0022, ADR-0031)
Windowing System: Windows, menus, palettes, dialogs, notifications, connection status. The application becomes something you can see and touch. (ADR-0005, ADR-0038) Multi-Mode Clients: Standalone operation, peer-to-peer connection, shared server connections. (ADR-0036) Skija / GPU Rendering: The drawing substrate. GPU-accelerated graphics, paintlist caching, lazy fetching. The machinery for putting marks on screen. (ADR-0005, ADR-0038) Hierarchical Rendering Pipeline: The transformation from musical structure to visual layout. (ADR-0028, ADR-0037) Plugin System: First-class access from any JVM language. (ADR-0003, ADR-0028) MusicXML: The first, limited version, implemented as a canonical plugin. Real scores entering the system. (ADR-0030) And then – and only then – will the first staff line appear. To implement what was described in the last blog post deterministically, ADR 0028, on the hierarchical rendering pipeline, and ADR 0037, about measure distribution, both have been updated. The rendering pipeline now has six stages rather than five. The additional stage enables the behaviour discussed in the previous post, but also allows slurs, lyrics, dynamics, and other elements that require vertical space to adapt dynamically without introducing layout jitter. What follows is a brief tour of the six pipeline stages. Each has a clearly defined role, a fixed direction of information flow, and no hidden feedback paths. Together, they transform musical structure into pages without iteration. If you are a musician, you should be able to follow how the music moves from essential meaning to visual expression. If you are a developer, the architectural choices should be readable between the lines. In both cases, the ADRs contain the full technical detail. Stage 1: AtomsEach measure is processed independently and turned into engraving atoms: indivisible musical units that already contain noteheads, augmentation dots, accidentals, stems, articulations: everything that belongs together. A note or a chord is an atom, including everything at a fixed distance from that note or chord. Once an atom is computed, its constituent parts never move relative to each other, though they can be adjusted manually or converted by the user to pure graphics for Illustrator-like manipulation. From these atoms, the system derives three facts about the measure stack: a minimum width, where atoms are simply lined up after one another (guaranteeing that nothing ever collides); an ideal width, based on proportional spacing from rhythmic density; and a gutter width – extra space required only if the measure begins a system. Courtesy accidentals caused by system breaks are accounted for here as space requirements, not as symbols. Ordinary courtesy accidentals are already part of the atom. Stage 2: Rhythmical AlignmentAll measures in a stack contribute a rhythmic raster: the sequence of atom positions implied by their rhythmic content at ideal spacing. Stage 2 takes these per-staff rasters and aligns them into a single, stack-wide rhythmic grid, so that 'the beat structure' is shared across staves rather than each staff carrying its own local spacing. Because the system has both the rasters and the atom extents from Stage 1, it can adjust the aligned positions so that collisions are avoided while still preserving the intended proportional structure. Stage 3: System FormationWith rhythmical alignment complete, the score collapses to a one-dimensional sequence of measure stacks, each described only by stack minimum width, stack ideal width, and possible stack system-start gutter. System breaks are chosen using dynamic programming, and a scale factor is computed for each system so that ideal proportions are preserved as well as possible within the available width. At the same time, system preambles (clefs, key signatures) are fully determined. Apart from these, the stage produces only break decisions and scale factors; no measure content is positioned yet. Stage 4: Atom PositioningThe abstract decisions from system formation are applied. Each atom is positioned horizontally by scaling its ideal spacing according to the scale factor of its system. Because atoms were defined with purely relative internal geometry, they can be moved without recomputation. This stage is a pure projection from musical proportions to absolute coordinates. Stage 5: SpannersAll connecting elements are resolved against the fixed atom positions: ties, slurs, hairpins, ottavas, lyric extenders. They adapt to the horizontal geometry they are given and never influence spacing upstream. System-start decorations live here as well: courtesy accidentals now appear in the gutter space that was explicitly reserved earlier. Actual system heights emerge at this stage as a consequence of what must be drawn – slurs, ties, lyrics, pedalling indications, hairpins – each claiming vertical space as required to avoid collisions. In this stage, braces, brackets, and instrument name indications are also computed for the left margin, as all information required to determine system grouping and extent is now available. Stage 6: Page FormationSystems are distributed across pages using dynamic programming, this time over the actual system heights produced by the previous stage. As in Stage 3, the distribution is optimal with respect to the available space. Once page breaks are chosen, layout is locked and no earlier stage is revisited. At this point, all rendering decisions have been made. The score can now be drawn directly from the cached paintlists.
|
AuthorPeter Bengtson – SearchArchives
November 2026
Categories
All
|
|
|
Ooloi is an open-source desktop music notation system for musicians who need stable, precise engraving and the freedom to notate complex music without workarounds. Scores and parts are handled consistently, remain responsive at scale, and support collaborative work without semantic compromise. They are not tied to proprietary formats or licensing.
Ooloi is currently under development. No release date has been announced.
|










RSS Feed