The following is an example of an AI agent's ability to correct Bol Processor grammars following a change in the handling of serial tools. This highlights the agent's comprehensive understanding of grammar syntax and its application to musical composition.
On 24 November 2026, I asked Claude Opus 5.5 to redesign grammars -gr.Visser.Shapes, -gr.Visser.Waves and -gr.Visser5, for which we had implemented a special patch of serial tool management — namely ZoulebOld() — to work with an obsolete syntax of serial tools. We will demonstrate how Claude handled the -gr.Visser5 case.
👉 This explanation is also composed by Claude Opus for the major part.
The grammar
-gr.Visser5 was written by Harm Visser in April 1998. This very compact grammar produces a piano piece of about ten minutes. It has three subgrammars. The first builds the form S --> {Melos1 Melos2 Melos3}, the second builds phrases Mel1, Mel2 and Mel3, and the third builds motifs M1 to M5. The composer used the serial tool _rotate() twice:
Mel3 --> _transpose(6) _rotate(-1) {Mel1 - Mel2}M3 --> _transpose(-6) _rotate(-2) {{M1 M2}, {_keyxpand(C3,-1) M1}}
Both rules use variables that are themselves built from the other motifs, so the rotations reach deep into the structure. Since August 2026 the Bol Processor processes serial tools differently, and this grammar no longer produced the piece the composer had heard. The original version is shown below.
To get his piece, the “Ignore field separators” option had to be set in its settings file -se.Visser5, which made the console call the old procedure ZoulebOld() instead of Zouleb().
Two conventions for serial tools
Serial tools such as _retro, _rndseq and _rotate() are applied once an item has been produced, i.e. after all the variables have been replaced. They act on the work string, in which the rules no longer appear.
The old algorithm, used until BP3.5.1, and the current one in Zouleb.c differ on three points:
- What moves. The old algorithm cuts a sequence into “chunks”: notes and sound-objects, silences
-, numbers and complete{}expressions. Only these move. Parameters such as_transpose(),_keyxpand(),_vel()or_tempo(), and periods., keep their positions in the sequence, so after the rotation they apply to whatever objects arrive there. The current algorithm moves the parameters along with the objects that follow them. - How far a tool reaches. In the old algorithm, a tool acts on the rest of its field, up to the next
,or the closing}of the expression containing it. If the tool comes from a variable that was not enclosed in braces, its scope extends beyond the material of that variable. - Nested expressions. In the old algorithm, the rotation also applies inside every nested
{}expression, and adds up with the rotations found there.
For example, motif M1 --> {C3 - . D4 F#3 _keyxpand(B3,-1) C3 - D3 F#2} contains eight chunks: C3 - D4 F#3 C3 - D3 F#2. In the old convention, _rotate(-2) moves them two places to the right, while the period stays after the second chunk and _keyxpand(B3,-1) after the fourth:
{C3 - . D4 F#3 _keyxpand(B3,-1) C3 - D3 F#2} original
{D3 F#2 . C3 - _keyxpand(B3,-1) D4 F#3 C3 -} rotated by -2
The key expansion still applies from the fifth chunk on, but these are now D4 F#3 C3 - instead of C3 - D3 F#2.
Neither the current serial tools nor any combination of them can reproduce this, so translating the composer's instructions into the new syntax was not an option. His piece had to be preserved as he heard it, so the results of the old rotations had to be written down in the grammar.
What the old rotations actually did
Rule Mel1 --> {M1 - - - - - . M2 - - M3 M4 - - M5} includes M3, which brings _transpose(-6) _rotate(-2) into the field of Mel1. The rotation therefore applies to everything that follows in that field: M3 M4 - - M5, i.e. six chunks, since M5 produces two expressions. In turn, M5 --> {_keyxpand(B4,-1){M4, _vel(100) M1}} {M2, M3} contains M3 again, which adds its own -2. In Mel3, the rotation -1 is added to all of these.
The rotation applied to each motif therefore depends on where it occurs:
| Context | Rotation of the field | Rotation inside M5's copy of M3 |
|---|---|---|
Mel1 (also in Mel2) | 0 for M1 - - - - - . M2 - -, −2 for M3 M4 - - M5 | −4 |
Mel1 inside Mel3 | −1 for M1 - - - - - . M2 - -, −3 for M3 M4 - - M5 | −5 |
The fixed positions of parameters had a strange effect in Mel3. Its field {Mel1 - Mel2} becomes {Mel1 - _transpose(-11) {Mel1}}, three chunks with the transposition after the second. Rotated by −1, the chunks are {Mel1}, Mel1 and -, and _transpose(-11), which has stayed in place, now applies only to the final silence. This is not what the rule suggests, but it is what the composer heard, so it was kept.
A rotation can also leave the material unchanged. In the old version of -gr.Visser.Shapes, _rotate(20) applied to trills of 40 alternating notes and to intervals of six notes repeating a pattern of two, which an even rotation leaves as they are. Recognising such cases kept that grammar close to its original structure.
The method
Claude did not attempt to predict the old results by reasoning alone. It proceeded as follows:
- It ran the original grammar with the old algorithm and option
--trace-production, which prints the work string as it is after the serial tools have been applied (the lineResult = ...), with--seed 1so that the random velocities of_rndvel(20)are repeatable. It also saved the MIDI file and the Csound score (1152 notes) as references. - It ran the same grammar with the current algorithm to confirm that the result was different: the Csound score did not match.
- It cut the old work string into its
{}expressions and compared each one with the corresponding motif, which showed the rotation applied in each context (table above). - It rewrote the grammar, keeping the motifs
M1andM2and the phraseMel2unchanged, and adding rotated variants namedXrotateMinusNfor “{_rotate(-N) X}in the old convention”. OnlyM1andM4had to be written note by note, by a short script applying the old rule (objects move, parameters and periods stay). The variants ofM2,M3andM5are built from them like the original rules: for example,M3rotateMinus3 --> {{M2rotateMinus3 M1rotateMinus3}, {_keyxpand(C3,-1) M1rotateMinus3}}, in which the two motifs of the first field have changed places because the rotation is odd. - It ran the new grammar with the current algorithm and compared its outputs with the references. The MIDI file was identical byte for byte, and so was the Csound score, except for the line giving its date of creation.
The rewritten grammar contains no serial tools at all: Zouleb() is not even called. Its comments record the composer's original rules, so his intentions remain readable.
The same method was applied to -gr.Visser.Waves (two _retro and two _rotate()) and -gr.Visser.Shapes (five _rotate(), two of them nested). In -gr.Visser.Waves, the retrograde shows the other difference between the two conventions. The old _retro turns {3, _transpose(1) C3 F#3 F2 B3} into {3, _transpose(1) B3 F2 F#3 C3}. The current convention would move _transpose(1) to the end of the expression, where it no longer applies to any note.
Cleaning up
Once the three grammars produced the same works with the current algorithm, nothing in the examples needed the old one. ZoulebOld() and its four helper functions (about 500 lines of C), the variable IgnoreFields and the “Ignore field separators” option were removed from the console and the interface. Settings files that still contain this option are read without any message, and it disappears the next time they are saved. All grammar and data projects of the test suite were then run with the console before and after the removal (881 runs), and their outputs were identical.
The redesigned grammar is shown below.
Played by the Bol Processor on a Pianoteq physical-model synthesiser (Steinway D Classical)
🎶 Long silences are intentional. Listen up to the end!
