part 17
A piece of music from one game: from an idea to a finished feature
In the article about the record a piece of music from a game was only an idea. Today the game has eleven styles, live music and a Listen button. How a record becomes a piece, what did not come out of the plan and what cannot be measured about the sound.
In the article about the record, the analysis and the piece of music a piece of music from a game was still only an idea: a plan in the documentation and a tool that "does not exist yet". The rule was no interface until I have listened to the prototype. Seventeen days have passed since 20 October and the piece of music is a feature of the game (version 0.119.0): after a finished game there is the Music button, during a game live music can be switched on, there are eleven styles and in the settings there is the Listen button.
The article tells how one record becomes a piece of music, what came out of the plan and what did not, and what can be measured about the quality of the sound. The pictures are drawn from data that the tools of the game made from real games.
From an idea to the game
What of the plan stayed, changed or fell out:
| The plan of 20 Oct | In the game today | State |
|---|---|---|
| A rhythmic grid, a key and a scale from the seed | Every note starts on a sixteenth of a bar (not one is off the grid); twelve keys by seed, in 20 games 14 to 17 different ones. | done |
| A voice for the player, the chance decides the pitch, wins go to chord tones, a knock-out is a cadence | Your attacks are the lead voice and each opponent has a voice of its own (at most three at a time); a likely hit is a chord tone, a long shot is more tense; a player who is knocked out no longer sounds. | done |
| At most about 16 events per bar | A fixed ceiling of 16; the densest piece of each style had 10 to 16. | done |
| A prototype without an interface, listen first | A gallery with files to listen to; the decision "go on" was made after listening. | done |
| One round is one bar | A round has 1 to 16 bars, a very long game puts several rounds into one bar; a piece always lasts 75 to 200 s. | changed |
| During a game a short recap of the previous round | The composer can compose it, the game does not play it. | did not work out |
From an event to a note
The composer is a pure function. It receives the facts of a game (who attacked whom, with how many dice, what the chance was, a win or a loss, who was eliminated), a style and a seed, and returns a piece written in whole numbers (pitch, time, volume; no frequency and no text). The facts are made by replaying the record, so a link to a record is at the same time the piece and nothing is stored. The rules are in the diagram.
A test guards two properties:
- No randomness from outside. Every "random" choice (which note of the motif, which bar rests) is a fingerprint of the identity of the thing: the seed, the bar and the number of the event. The same record, style and seed therefore give the same bytes of the MIDI file. Today's check (6 Nov) composed 660 pieces twice, read them back from MIDI and all came out the same.
- A piece is written bar by bar and only from the past. The music of a round depends on the rounds before it, so the same composer can also handle a game in progress. A test composes a piece from the whole game and from a game cut after round k and compares the bars of the closed rounds (today 220 cut games, all of them matched). Only after the game does it learn the plan from the analysis: where the climax is and how the piece turns.
One game, two styles
The picture is a piano roll of one real game: the bars of the piece horizontally, the pitch vertically, the colour is the player. It is a game from the music gallery: Principalities[1], four players, seed CLS4, twelve rounds, 140 attacks, of which 58 attacks were player 0's (55 won). The game was played by the AI; player 0, whose voice is red and who in the game would be you, won it. The same facts were composed into two styles.
- The same game, a different length of bar. Ambient has 36 bars and a round is two bars, techno has 64 bars and a round is four. The tempo (78 and 131 beats per minute) is chosen so that the piece lasts 75 to 200 seconds, and the pieces came out almost equally long, 1:51 and 1:57.
- The red voice tells the same game in both styles. In this game each of the 58 attacks of player 0 had a chance of at least 65%, so the voice plays only chord tones and nothing tense. Tension would be shown by a game in which risks are taken.
- The crosses are the eliminated players: yellow after round 4, green after 5 and blue after 12. At the end of their round there is a cadence and their voice then no longer sounds.
- The dotted lines are changes of key. The climax of the piece (in both it begins at about 56% of the length) brings a bar of near silence, a hit and a key a tone higher; in the coda the key returns. Techno has one more change, in round 4: the game was decided, and so the minor changes to the brighter Dorian. In ambient this cannot be seen, because Lydian is already bright. The two big turning points of the game were in rounds 1 and 2, far before the window of the piece in which the climax is looked for, so the climax was determined differently.
At most 16 notes in a bar out of 443 attacks
In a small game the ceiling of 16 notes in a bar does not matter, in a big one it does. That is why the second game is big: six players in teams, 19 rounds and 443 attacks (seed TEAM6).
In ambient a round is one bar and in the first rounds there are as many as 52 attacks per bar; of them at most 7 notes sound. In techno a round has two bars, there are at most 26 attacks per bar and at most 14 sound, that is below the ceiling. The music does not play everything, it chooses:
- First your attacks are kept. Each has a weight: a base of 100, plus up to 40 for a low chance, 10 for a win, up to 20 for a big stack of dice, 70 for eliminating an opponent and 60 in the turning round from the analysis. What does not fit drops out, starting with the lightest.
- A burst (more than 8 of your attacks in a round) turns into three notes, a run up the scale and a last note.
- At most three opponents can be heard at a time; the other attacks are folded into quiet hi-hat hits that carry no melody.
- At least a quarter of the beats of the lead voice is silent (in today's check even the worst of the 60 pieces of each style had at least 28% silence). The pauses are structure, not chance: the first version kept them only by luck and 6 of 200 new pieces in techno did not have enough of them.
In the quiet rounds at the end of the game there are, on the contrary, more notes than attacks in the chart (techno, rounds 13 to 19). It is not a bug: an arpeggio is added from the dice that the player placed after the round, and that is not an attack.
Eleven styles
A style is mostly data: a tempo, scales, drum patterns written as strings of 16 characters, voices and a mix. For a new style a synthesizer voice or one rule of the composer is sometimes added (an arpeggio for chiptune); punk rock and folk metal did not need anything, the voices that already existed were enough. The last column is the pieces from the game of the piano roll, composed by today's game:
| Style | Tempo (beats/min) | Scales | What makes it different | The piece from the game |
|---|---|---|---|---|
| Ambient | 64 – 80 | Lydian, Dorian, Aeolian (minor) | bells over a broad pad, no hard drums, a long reverb | C# Lydian, 1:51 |
| Techno | 124 – 132 | Aeolian, Phrygian, Dorian | four beats to the bar, an acid bass, everything "pumps" into the kick | C# Aeolian, 1:57 |
| Rock | 96 – 122 | Aeolian, Mixolydian | power chords through distortion, a double guitar | C# Mixolydian, 2:13 |
| Hip-hop beat | 82 – 94 | Aeolian, Dorian, Mixolydian | a beat with no voice (no rap), swing, an 808 bass, an electric piano | C# Aeolian, 1:42 |
| Chiptune | 136 – 156 | Ionian (major), Mixolydian, Aeolian, Dorian | pulse waves of an 8-bit chip, a triangle bass, noise drums | C# Mixolydian, 1:34 |
| Synthwave | 98 – 116 | Aeolian, Dorian | four beats to the bar, a gated snare, saw arpeggios, a broad pad | C# Dorian, 1:31 |
| Classical (an attempt) | 78 – 104 | Ionian (major), harmonic minor | strings, a piano and a cello made of oscillators, no drums | C# harmonic minor, 1:33 |
| Space opera | 132 – 148 | Mixolydian, Lydian, Aeolian | a pulsing bass, big toms, an "aah" choir of filtered saws, a gong at the climax | C# Mixolydian, 1:40 |
| Spaghetti western | 88 – 108 | Phrygian, Aeolian, Dorian, Mixolydian | a guitar with tremolo, a whistle, a wordless soprano, a gallop of hooves, the crack of a whip | C# Aeolian, 1:25 |
| Punk rock | 156 – 178 | Ionian (major), Mixolydian, Aeolian | eighth notes on power chords, a pounding bass, shouting | C# Ionian, 1:33 |
| Folk metal | 136 – 164 | harmonic minor, Aeolian, Dorian | a double kick, a galloping guitar, a fiddle, a whistle and bagpipes | C# harmonic minor, 1:35 |
Four styles (hip-hop, chiptune, synthwave, classical music) were added after the first listening, four at my wish: music as from a space adventure of 1980, a spaghetti western, punk rock and folk metal. One rule holds for them: the sound is taken, not a single note. The game uses no melody, riff or chord progression of any piece, the melody is determined by the game and the names of films or bands are not in any text of the game.
Music after a game, live music and the Listen button
After a finished game the Music button opens a window that composes the piece from the record right in the page: at once without the story from the analysis and then again with it, when the analysis finds it in the background (then it gets the climax and the arc). The window has the style, the density (Calm, Normal, Busy), the volume, Another version (a new seed of the same game), saving as MIDI or as sound (WAV) and a timeline that can be clicked.

Live music plays during a game and is off by default, because it is "for a strong computer". It is switched on in the settings or in the 🎵 window on the top bar of the game (one big switch, and under it the state and the reason if it does not play; see the article about the menu and the windows). The plan of 20 Oct counted on a short recap of the previous round, because a loop that keeps growing turns into noise after about ten rounds. In the game it is different: the composer has recap (one bar, with a test), the game does not play it. The live music is a bed that does not grow. Bar by bar it is composed from how the last closed round went (chords, bass, pad, drums), and each of your attacks gets a note on the nearest beat. The state of the bed after round r is the same as the state of the piece after the game for round r; a test compares it to the precision of a permille.

During a game the music runs under a guard: it switches itself off (and its setting is switched off too) if it slows the game down (a step of the scheduler above 6 ms on average over 40 steps, a single one above 60 ms, more than 8 notes scheduled into the past within 5 s, or more than 2,000 nodes). In a game with the fog of war it does not play at all: the collector of facts reads the whole map, so the tension and the mood would reveal what the player must not see. It does not play in a puzzle, a lesson or a minigame either.
The Listen button in the settings was made on 3 Nov and solves the last thing: hearing a style and a density without playing a game. It plays four bars of the live bed of the chosen style (6 to 12 seconds) from one fixed state, "the live middle of a game". It never starts by itself and does not play over the music of a game in progress. Next to it is the number of notes ("121 notes · 4 bars · 127 BPM"), so the density can be seen even by someone who cannot hear. In each of the eleven styles Calm has fewer notes than Normal and Normal fewer than Busy (ambient 12, 32 and 48; measured by today's code). It is also described by the page "Record, analysis, picture and music" in the wiki.
Volume and quality
It is measured in two places.
One piece. Every piece of the gallery is rendered by the same synthesizer as in the browser and a tool measures it (ffmpeg and an FFT of its own): a loudness of −20 to −12 LUFS before normalisation, a peak below −1 dBTP, no clipping, a spectrum without a dead band and without a constant hiss and the share of notes in the scale of at least 90% (measured 97.7 to 100%). At the climax it is checked that the silence and the hit are really there in the sound: the bar before the climax is 11.9 to 29.1 LU quieter than the rest. This is exactly how it was found that in ambient and in techno the climax did not sound in the audio although it was in the notes: the pad and the build-up played even through the bar of silence and the hit passed through a filter that cut off the low notes. (LUFS is loudness according to the EBU R128 standard, LU is the difference of two such loudnesses.)
The music against the sounds of the game. When it was measured on 22 Oct, the live music at "normal" played 10 LU louder than the loudest sound of the game (the roll of the dice) and 15 LU louder than sounds such as the stream; it drowned out every effect. So the bed was set so that at "normal" it is 8 LU below the stream of sounds, the three settings were 5 LU apart and the eleven styles within 2 LU of each other. The measurement was repeated on 6 Nov and came out the same: all eleven styles at "normal" have a median of −45.1 to −45.3 LUFS, 7.8 to 8.0 LU below the stream of sounds (−37.3 LUFS), the steps of the settings 5.0 and 4.9 LU.
The slider. The volume was for a long time a word (quiet, normal, loud), today it is a number from 0 to 100 and one step is 0.2 dB: the middle 50 is "normal", 25 and 75 are exactly −5 and +5 dB (that is where the old words were, so a player with a saved word hears the same), 0 is silence and 100 is +10 dB. The music window after a game has a scale of its own, louder: it has no sounds to share the room with. In addition, at effects the bed is dipped by 4 dB and comes back in 350 ms.
The upper end of the slider has never been measured as a stream of sound. A calculation from today's numbers (−45.3 + 10) gives −35.3 LUFS, that is 2 LU above the stream of sounds: at the very end of the slider the music is louder than the sounds. It is calculated, not measured, and the chart draws it with an empty circle.
Honest limitations
- The development assistant that built the prototype cannot hear. The quality was therefore guarded by measurements that say whether a piece is broken. An independent check said it clearly: "no problems found" means "not broken", not "sounds good". Whether a melody is pleasant cannot be found out by measurement, and the decision "go on" was mine, as the one who listens.
- Classical music is a music box. Oscillators can make a pad and a pizzicato, not an orchestra. In the game the style is called
Classical (an attempt)and the game says about it that it is the least convincing. An orchestra is not promised. - Neither melody, nor groove, nor fatigue after two minutes is measured. The rules make something pleasant of the melody, not something unforgettable.
- A style is not a copy. Hip-hop is a beat without a voice, chiptune has more channels than a real chip, synthwave has a lead voice similar to techno, and punk rock knows neither wit nor shouting.
- The plan was not fulfilled in full. The short recap of the previous round does not play in the game and a round is not one bar.
What I take from it
- A prototype without an interface paid off. The gallery was ready in 52 minutes, and looking, measuring and independent checks found thirty things on it, which were fixed before the first button appeared. The decision whether to go on was mine and it was made after listening.
- Measurement does not replace the ears, it only narrows the search: a piece is not broken, that does not yet mean it is good.
- A style is data. That is why three styles became eleven in two days, and the synthesizer was not changed for the last two.
- The plan has to be compared with the finished thing. A round that is not a bar is written down in the documentation as a deviation; that the game does not play
recapshowed itself only by comparing the code with the plan. - Measure what it sounds against. The music was 10 LU louder than the sounds of the game until anybody measured it.
Sources and notes
- State: the game Audamir 0.119.0, 6 Nov 2026. The table of styles is from the data and texts of the game; the thresholds, weights and ceilings of the composer are from the data of the game, not from the measurement of one game.
- Measured on 6 Nov 2026: the pieces from the games CLS4 and TEAM6 composed by today's composer; the ambient and the techno from CLS4 match the rows from 21 Oct in the documentation of the game, so it is the same piece. The check of the pieces (26 s): 60 games of the AI × 11 styles, with and without the story, all the gates passed. The loudness:
loudness.js --checkin a headless Chromium (24 min), the result "inside the bounds of the data". The numbers of notes and the lengths of the preview of the Listen button were given by today's code; that the game does not playrecapwas shown by searching its code. - Not measured again: the quality of one piece (the spectrum, the peak, the notes in the scale, the silence before the climax) and the loudness of 22 Oct (the music 10 LU louder than the sounds) are from 21 and 22 Oct 2026, from a gallery of 60 pieces. The guard of the live music and the fog of war are according to the documentation of the game. Calculated, not measured: the upper end of the slider (−45.3 + 10 dB = −35.3 LUFS).
- Series: the plan of 20 Oct is in article 15.
- What is not in the article: samples of the pieces (the site cannot embed sound yet); the game keeps them as 11
.oggfiles of 58 s and 11.midfiles from the game CLS4, 8.0 MB in all.
Notes
- Until version 0.65.6 of 31 October 2026 it was called Classic. ↩︎