Audamir

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.

· updated 6 November 2026 · 19 min read

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 OctIn the game todayState
A rhythmic grid, a key and a scale from the seedEvery 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 cadenceYour 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 barA fixed ceiling of 16; the densest piece of each style had 10 to 16.done
A prototype without an interface, listen firstA gallery with files to listen to; the decision "go on" was made after listening.done
One round is one barA 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 roundThe 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.

From an event of the game to a note: the rules of the composerA diagram of the rules by which the game turns the events of a game into music. Your attack is one note of the lead voice, longer and louder with more dice. The chance of an attack: from 65% it is a chord tone, quietly, up to 35% a tenser note of the scale and up to 50% an outside note now and then (at most 2.5% of the notes of the lead voice). A win rises towards a chord tone, a loss falls by a step or by a third. An opponent's attack is a short note in its own voice, a conquest of 6 dice or more is longer and louder. With more than 8 of your attacks in a round, three notes sound, a run up the scale and a last note. The elimination of a player is a cadence and its voice no longer sounds. The end of the game is a coda: a win rises, a loss falls. The turning point from the analysis is a change of chord and the climax of the piece a bar of silence, a hit and a key a tone higher.Event in the gameWhat soundsYour attackone note of the lead voicemore dice: longer and louderAttack chanceby the dicefrom 65%: a chord tone, quietlyto 35%: a tenser scale noteto 50%: sometimes an outside note0%100%355065Win, lossa win rises to a chord tonea loss falls a step or a thirdOpponent’sattacka short note in their own voice6 dice and more: longer, louderBurstover 8 per roundthree notes, a run up the scaleand a last note; the rest is silentEliminationcadence: the bass goes from the fifthto the tonic, the voice then stopsEnd of gamewin: the coda rises, to majorloss: falls, to minor; a draw hangsTurning pointa chord change; the climax:a silent bar, a hit, key up a tone
The rules of the composer according to docs/DESIGN.md §38.5 and §38.6 of the game; the thresholds of the chance 35, 50 and 65% and the numbers 8 and 6 are from the data of the game (MusicData.GEN), not from one game.

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.

One game, two styles: a piece of music as a piano rollThe same game (four players, twelve rounds, a win) composed by the game into two styles. At the top ambient in the key C# Lydian, 78 beats per minute, 36 bars, 1 minute 51 seconds; at the bottom techno in the key C# Aeolian, 131 beats per minute, 64 bars, 1 minute 57 seconds. The bars of the piece lie horizontally with the mark of each round, the pitch vertically. Each note is a small rectangle in the colour of the player: red is your lead voice, blue, green and yellow are the voices of the opponents. The intro, the climax and the coda are marked by the background, an eliminated player by a cross and a key change by a dashed line. The bass, the pad, the rhythm accompaniment and the drums are not drawn, only the lead voice and the voices of the opponents.AmbientC# Lydian · 78 BPM · 36 bars · 1:51introclimaxcodaC5C6round14812TechnoC# Aeolian (minor) · 131 BPM · 64 bars · 1:57introclimaxcodaC5C6round14812You (lead voice)BlueGreenYellowplayer eliminated: voice stopskey change
The game principalities4 from the music gallery of the game: seed CLS4, Principalities, four players, 12 rounds, 140 attacks, a win; composed by Composer.compose with the story from the analysis, game 0.119.0, 6 Nov 2026. The bass, the pad, the rhythm accompaniment and the drums are not drawn.
  • 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).

At most 16 notes in a bar are left of the 443 attacks of the gameA game of six players in teams, 19 rounds and 443 attacks, composed by the game into two styles. The light columns show how many attacks fall on one bar, the dark columns how many notes of the lead voice and of the opponents' voices really sound in a bar. In ambient one round is one bar: at most 52 attacks in a bar turn into at most 7 notes. In techno a round has two bars: at most 26 attacks per bar turn into at most 14 notes. The dashed line is the ceiling of 16 notes in a bar.Ambient: a round is one barat most 52 attacks in a bar, at most 7 sound016324852round15101519Techno: a round is two barsat most 26 attacks per bar, at most 14 sound016324826round15101519attacks of the round per barnotes of the lead voice and the opponents in a barceiling 16
The game teams6 from the music gallery of the game: six players in teams, seed TEAM6, 19 rounds, 443 attacks, a win; ambient and techno from Composer.compose, game 0.119.0, 6 Nov 2026. The light column is the attacks of the round divided by the number of its bars, the dark one the notes of the lead voice and of the opponents' voices in a bar.

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:

StyleTempo (beats/min)ScalesWhat makes it differentThe piece from the game
Ambient64 – 80Lydian, Dorian, Aeolian (minor)bells over a broad pad, no hard drums, a long reverbC# Lydian, 1:51
Techno124 – 132Aeolian, Phrygian, Dorianfour beats to the bar, an acid bass, everything "pumps" into the kickC# Aeolian, 1:57
Rock96 – 122Aeolian, Mixolydianpower chords through distortion, a double guitarC# Mixolydian, 2:13
Hip-hop beat82 – 94Aeolian, Dorian, Mixolydiana beat with no voice (no rap), swing, an 808 bass, an electric pianoC# Aeolian, 1:42
Chiptune136 – 156Ionian (major), Mixolydian, Aeolian, Dorianpulse waves of an 8-bit chip, a triangle bass, noise drumsC# Mixolydian, 1:34
Synthwave98 – 116Aeolian, Dorianfour beats to the bar, a gated snare, saw arpeggios, a broad padC# Dorian, 1:31
Classical (an attempt)78 – 104Ionian (major), harmonic minorstrings, a piano and a cello made of oscillators, no drumsC# harmonic minor, 1:33
Space opera132 – 148Mixolydian, Lydian, Aeoliana pulsing bass, big toms, an "aah" choir of filtered saws, a gong at the climaxC# Mixolydian, 1:40
Spaghetti western88 – 108Phrygian, Aeolian, Dorian, Mixolydiana guitar with tremolo, a whistle, a wordless soprano, a gallop of hooves, the crack of a whipC# Aeolian, 1:25
Punk rock156 – 178Ionian (major), Mixolydian, Aeolianeighth notes on power chords, a pounding bass, shoutingC# Ionian, 1:33
Folk metal136 – 164harmonic minor, Aeolian, Doriana double kick, a galloping guitar, a fiddle, a whistle and bagpipesC# 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.

The window Game music after a finished game: the style, the density and the volume, the graph of the course of the song with its time line, the buttons Play and Stop and the picture that grows with the music.
The song is composed from the record; while it plays the picture of the game grows beside the graph, and it can be saved as MIDI or sound (WAV).

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.

A game with the Live music and the Live picture on: beside the map the picture of the game grows a round at a time, and the Music panel says that the live music is on and in which style it plays.
The live picture grows with every round and the Music panel shows the style and the volume of the live music; both are off by default.

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.

Where the music of the game is against the sounds of the gameLoudness in LUFS, quieter on the left. The sounds of the game: the loudest dice roll has minus 32.4 LUFS for 400 milliseconds and ordinary sounds as a stream (roll, capture, placing) have minus 37.3. The music before the change of 22 October played louder than all the sounds, minus 21 to minus 24.3. Today the music at slider 50 is at minus 45.3 LUFS, that is 8 units below the stream of sounds; slider 25 has minus 50.3 and slider 75 minus 40.4. Slider 100 would by calculation be at minus 35.3, 2 units above the stream of sounds; that was not measured.Loudness in the game (LUFS)−55−50−45−40−35−30−25−20LUFS, quieter on the leftgame sounds as a stream −37.3Music before the change of 22 Oct, “normal”−24.3 to −21.013 to 16 LU aboveThe loudest sound: a dice roll (400 ms)−32.4Music today: slider 100 (+10 dB, calculated)−35.32 LU aboveMusic today: slider 75 (“loud”)−40.43 LU belowMusic today: slider 50 (“normal”)−45.38 LU belowMusic today: slider 25 (“quiet”)−50.313 LU below
Measurement of 6 Nov 2026: tools/…/loudness.js --check, game 0.119.0, the sounds through the master volume 0.35, eleven styles from the first golden game. “Before the adjustment” is from docs/TUNING.md §35.2 (22 Oct). The slider at 100 is calculated (−45.3 + 10 dB), not measured.

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 recap showed 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 --check in 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 play recap was 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 .ogg files of 58 s and 11 .mid files from the game CLS4, 8.0 MB in all.

Notes

  1. Until version 0.65.6 of 31 October 2026 it was called Classic. ↩︎