Generating 9,240 Trichord Permutations

Generating 9,240 Trichord Permutations

How Python, SuperCollider, and AI assistance were used to build the computational backbone of the Sound Cells series — and what it means to automate music theory at scale.

The Sound Cells series is built on a complete enumeration of trichord pair combinations — every way that two trichords can be combined, across all 12 transpositions, in all 18 inversions and permutations. The total comes to 9,240 trichord permutations. No human working alone could generate, verify, and organize this material by hand in a reasonable timeframe. It required computational tools — and understanding how those tools work illuminates both the mathematics and the music.

12
Trichord types
The 12 prime forms for 3-note sets
78
Unique pairs
Combinations with repetition: C(12+1,2)
9,240
Total permutations
78 pairs × 12 transpositions × ~10 inversions avg.

The Generation Pipeline

The full pipeline from mathematical specification to practice-ready exercise files involves four distinct stages, each implemented with different tools:

The 9,240 Trichord Permutation Pipeline
1
Mathematical specification — Python
Enumerate all 12 trichord prime forms. Generate all 78 unique pairs (combinations with repetition from 12 types). For each pair, generate all 12 transpositions and all 18 inversions/permutations. Verify that each resulting hexatonic is a valid pitch class set. Filter out musically invalid combinations (e.g., those producing duplicate pitch classes).
itertools.combinations_with_replacement(trichords, 2)
2
Score generation — LilyPond via Python
For each of the 9,240 permutations, generate a LilyPond score file showing the two trichords, their combination as a hexatonic scale, and the exercise pattern (ascending, descending, combinations). LilyPond compiles each .ly file to a PDF. A Python script manages the batch compilation — thousands of PDF files generated automatically.
subprocess.run([‘lilypond’, f'{filename}.ly’])
3
Audio generation — SuperCollider
For each permutation, a SuperCollider (.scd) script synthesizes the exercise as audio — both the isolated trichords and their combination as a hexatonic line, played against a drone. SuperCollider’s pattern system allows parametric generation: one template script, fed different pitch class arrays, produces all 9,240 audio files.
Pbind(\note, Pseq(trichord_notes, 1), \dur, 0.5)
4
Organization and metadata — Python + AI
Generated files are organized by volume (78 volumes, one per trichord pair), by key (12 transpositions), and by permutation type (18 inversions). A metadata JSON file for each volume tracks Forte numbers, interval vectors, subset relationships, and chord compatibility. AI assistance (Claude) was used to verify mathematical correctness and generate book text for each volume.
json.dump(volume_metadata, f, indent=2)

Why LilyPond?

LilyPond is a music notation program that compiles plain-text score descriptions into publication-quality PDF scores. Unlike graphical notation programs (Finale, Sibelius, MuseScore), LilyPond is scriptable — you can generate .ly files programmatically and compile thousands of them in a batch without manual intervention.

For the 9,240 permutations project, this was essential. Each permutation needed its own score showing the exercise in standard notation. Generating these by hand in a graphical program would have taken years. LilyPond reduced the task to writing one template .ly file and a Python script to fill in the pitch class arrays — the compiler did the rest.

The tradeoff is a learning curve: LilyPond’s syntax is idiosyncratic, and generating complex scores (multiple staves, specific voicings, accidentals that follow pitch class set conventions rather than key signatures) requires detailed understanding of the language. Much of the development time in this project was spent debugging LilyPond output to match the exact notation standards required for the books.

Why SuperCollider?

SuperCollider is a programming language for audio synthesis and algorithmic composition. It is used in academic music technology programs worldwide and is the tool of choice for generating large quantities of audio from programmatic specifications.

For the Sound Cells series, SuperCollider generates the drone-plus-exercise audio files that accompany each volume — a constant reference pitch (the key center) plus the trichord pair exercises played at a specified tempo with a specified instrument sound. The same parametric approach applies: one template synthesis graph, fed different pitch arrays, produces all the audio needed.

SuperCollider’s pattern system is particularly suited to this task. A Pbind (pattern bind) object schedules note events based on arrays of pitch values, durations, and amplitudes. Changing the pitch array changes the exercise; the rest of the synthesis architecture stays fixed. This separation of content (the pitch class arrays) from form (the synthesis architecture) mirrors the mathematical separation of set content from interval structure that underlies the trichord pair system itself.

// SuperCollider: parametric trichord exercise generation
// trichord_1 and trichord_2 are pitch class arrays
var generateExercise = { |trichord_1, trichord_2, drone, tempo|
    var hexatonic = (trichord_1 ++ trichord_2).sort;
    Pbind(
        instrument, piano,
        
ote, Pseq(hexatonic ++ hexatonic.reverse, 1),
        dur, tempo,
        amp, 0.7
    )
};

The Role of AI in the Pipeline

Several stages of the 9,240 permutations project used AI assistance — specifically Claude — for tasks that are tractable for AI but time-consuming for humans:

Mathematical verification: Checking that each generated hexatonic is genuinely a valid pitch class set (no duplicate pitch classes, correct prime form classification, correct Forte number assignment). AI could process hundreds of these checks in a single session.

Text generation: Each of the 78 volumes in the Sound Cells series includes a book describing the trichord pair system, the specific characteristics of that volume’s trichord pair, and exercises. AI was used to generate drafts of this text, which were then reviewed and edited by Arnold.

Debugging: LilyPond error messages are often cryptic. AI assistance helped diagnose and fix notation bugs that would have taken hours to track down manually — identifying the source of an accidental placement error or a stem direction conflict in a multi-voice score.

The result is a production pipeline that would have been impossible for one person working alone in any reasonable timeframe. The 9,240 permutations, with their associated scores, audio files, and metadata, represent approximately five terabytes of generated material — a scale that only becomes tractable when computational tools and AI assistance are combined effectively.

Computationally Generated Compositions

These computer realizations were generated using the same SuperCollider pipeline described above — the trichord pair specified, the synthesis architecture handling everything else.

Sod Buster — Bruce Arnold, computer realization (013-025)
Nebraska Marble — Bruce Arnold, computer realization (013-025)

Technology enabling music at scale

Parametric generation

One template, many instances. The same LilyPond or SuperCollider template generates thousands of exercises by substituting different pitch class arrays. The separation of content from form is both a software engineering principle and a mathematical one.

Batch processing

Python orchestrates the full pipeline — calling LilyPond for scores, SuperCollider for audio, organizing output files, generating metadata. Thousands of files produced automatically from a specification that would take years to produce by hand.

AI-assisted verification

Mathematical verification of 9,240 pitch class sets — checking prime forms, Forte numbers, subset relationships — is tractable for AI in ways it is not for humans working manually. AI reduced weeks of checking to hours.

Scale of output

~5TB of generated material: 9,240 PDF scores, 9,240 audio files, 78 metadata manifests, 78 volume texts. A project that demonstrates what becomes possible when music theory, mathematics, and modern software tools are combined deliberately.

Technology as Musical Infrastructure

The 9,240 trichord permutations project is an example of technology serving music — not replacing musical judgment but extending what is tractable for a single composer-educator working over decades. The mathematics existed (Forte’s set theory, pitch class set analysis). The musical content existed (Arnold’s compositions and teaching). What technology added was the ability to make that content complete — to fill in every permutation, verify every relationship, generate every practice exercise, without requiring that each one be done by hand.

The next article looks at SuperCollider in more depth — how algorithmic composition tools shape the way composers think about pitch class sets, and what it means to use code as a compositional medium.

LilyPond music notation system: lilypond.org (GNU GPL). SuperCollider audio synthesis and algorithmic composition: supercollider.github.io (GPL). Python libraries for music theory computation include music21 (MIT License, MIT). The Sound Cells 9,240 Trichord Permutations series is available at muse-eek.com.

Leave a Reply

Your email address will not be published. Required fields are marked *