Before: the straight sketch
A steady pulse, even accents and a melody that repeats.
Audio as Code presents
Open-source Audio as Code: 70 instruments synthesized from code, WAV and MIDI rendered locally, and a score your agent can keep revising.
An open-source music framework for creative agents. Compose with 70 instruments synthesized from code, take the WAV into your project, and keep every note editable. No recorded samples.
Writing it yourself? Developer quickstart · Get the source. Version 0.5.0 · Python 3.10+.
Give your project a soundtrack. A tiny dragon's boss fight. A quarterly report with a villain arc. A launch video with a pulse. Describe the scene; your agent composes the music and delivers a WAV you can use. You can change the score whenever the scene changes.
Your agent needs a shell and Python 3.10+. You supply the brief; it handles the setup.
Use Audio as Code to create the music in the brief below.
1. Read the skill at skills/audio-as-code/SKILL.md and the guide index at llms.txt on the Audio as Code website.
2. If you don't already have an Audio as Code checkout, download download/audio-as-code-0.5.0-source.zip from the same website and extract it into a new project folder. Then follow its bundled skills/audio-as-code/SKILL.md.
3. Install its Python dependencies, compose an original score (Audio as Code makes instrumental music and cues, not speech or sound effects), then validate and render it locally.
4. Deliver the WAV, the MIDI file, the editable score JSON, the Python source you wrote and the render report. If I'm working in a video, game or presentation project, put the WAV where that project expects audio and keep the score and source beside it for revisions. Then tell me what you would try next.
Music brief:
A tiny dragon thinks this is the final boss fight. A 16-second battle cue for my game: timpani and drums, low brass stabs and a frantic string ostinato at about 150 BPM, then a separate 2-second victory sting. Deliver each cue as its own WAV for the game's audio folder, and keep the editable scores.
This local preview has no public link. Download the source ZIP below and give your agent the extracted folder; the skill is inside.
Your agent writes and renders the music, then places the WAV in your creative project. Keep the whole composition for the next revision:
Then ask for changes the way you'd talk to a musician:
Keep the melody. Give it to the marimba, calm the drums down, and land the final note on the reveal.
Working in Hyperframes, Codex or Claude Code? The integrations guide has recipes for a video timeline, a game's audio folder and a slide deck. Building an agent soundtrack? Read AI agent soundtrack with Python.
First, the classic. Then, a plot twist. Compare familiar music with an agent's new arrangement: different instruments, rhythms and moods. Both versions are synthesized from code, with editable scores.
The runnable bundle and the full source ZIP include this script and its supporting files: .
The classic versions follow the credited public-domain scores. The reimagined versions are new arrangements by an AI agent. Audio as Code synthesizes every sound; both versions include editable scores and source.
Full notes: score credits and scope · what each reimagining changed
Play streams a compressed preview. Download WAV for the full render, or MIDI to continue in a DAW with its own instrument sounds.
A few lines become a score you can hear and change. Run this example yourself, or let your agent do the typing.
from audio_as_code import Pattern, Song, Track, export_midi, render
melody = Pattern.sequence(["C4", "E4", "G4", None], step=0.5).repeat(4)
kick = Pattern.sequence([36, None], step=1, gate=0.3).repeat(4)
song = Song(
title="My first loop",
bpm=110,
beats=8,
seed=42,
tracks=[
Track(name="Melody", instrument="pluck", notes=melody.notes, gain=0.5),
Track(name="Kick", instrument="kick", notes=kick.notes, gain=0.7),
],
)
song.save("output/loop.json")
report = render(song, "output/loop.wav")
export_midi(song, "output/loop.mid")
print(report["wav"])Run it from a terminal:
uv run aac validate output/loop.json
uv run aac render output/loop.json -o output/loop.wav --report output/report.json
uv run aac analyze output/loop.wavLevel checks catch silence and clipping. Your ears decide whether the music works.
One original piece, two arrangements. Keep the harmony and instruments. Give the rhythm a little more room to move.
A steady pulse, even accents and a melody that repeats.
Swing, softer offbeats, answering phrases and a fill every fourth bar.
Switch versions at the same playback position. Each is 19.44 seconds, matched to -20 LUFS. Same tempo, harmony, instruments and mix settings; only the written arrangement changes.
Download the full comparison Get the Python composer Make your own variation
The pattern tools are included in Audio as Code 0.5.0 on PyPI and the source download. Audio here is rendered locally from code.
The melody, timing and instrumentation stay in an editable score. Your agent can make a precise change and render another take.
Take one
Pluck a string, strike a bell, call in the brass. Every voice is generated from equations. These are playful, simplified instrument models; audition them to find the character your piece needs.
Shape the timing, move parts across the stereo field, and give the ending room to ring. Explore tempo, movement and space.
210 preview clips: a famous-music arrangement, a phrase, and a single note or hit for every voice.
Take the classical theme to the dance floor: disco, techno, trance and drum & bass.