Inspiration
AI agents can write code, text and pictures, but music is still hard for them to make reliably. Generative audio models turn a prompt into a finished recording: the same prompt gives a different result each time, and nothing in it can be edited. To change one bar, you generate the whole piece again. Musicians work differently: they write the notes, hear them, change one bar and hear it again. Orchestra gives agents that way of working, on real recorded instruments. The same instruments then play live in a browser for anyone, and let a learner practise a part along with the rest of the song.
Who it's for
It's for anyone who loves music:
- Agents and the developers who build them. Write a song as notes, check it, render it on real instruments, change one note and render again. The same song always renders the same.
- Players. Real pianos, guitars, drums, strings and synths in a browser tab, with no install and no account.
- Learners. Open a song, silence your part and play it with the band, slowly at first.
What it does
Orchestra is for consistent, reliable music generation. Agents write music as notes, and Orchestra renders it on real recorded instruments, the same every time. People do the same in a browser, end to end: open it, play the instruments, play a song, and practise their part.
- 41 sounds in five families. Pianos and harpsichords, guitars and bass, drum kits and drum machines, bowed strings and sections, and synthesizers. They play from a computer keyboard, a mouse, a touchscreen or a MIDI keyboard, with velocity, sustain, natural releases and five rooms, four of them measured in real spaces.
- The command line for agents.
instruments,check,render,midiandshow. A song is plain JSON. Every command answers with one JSON object, and every error names its field (parts[2].notes[14].note), so an agent can fix it and run again. The same song, seeds and settings give the sameperformanceSha256, and audio identical to within -90 dB. Renders come out as WAV, FLAC, MP3, Opus or AAC, with one stem per part. AGENTS.md is the full guide. - The song screen. Open a song, a MIDI file or a MusicXML score, and every part plays on its own instrument. The part in focus is written out:
- the piano reads from a music book on its desk
- a guitar from a sheet with tablature above its neck
- a violin from a sheet above its neck
- a drum kit from a chart on a music stand
- a synth from a piano roll on its own display
Its notes light as they sound, the guitar is picked on screen and the violin is bowed. Mute, solo, change the speed from 50% to 150%, or move a part to another instrument of the same family. A guitar part on the bass plays each chord's lowest note, an octave lower.
- Practice. Silence the part in focus while its notes stay lit, and play it yourself with the band.
- Two looks. Halloween and Original. Every instrument is restyled for Halloween, and its keys, strings and pads still line up exactly.
How I built it
- Engine (TypeScript, Web Audio, no runtime dependencies). Each sound is a sample pack (recordings plus a manifest) played by a playing model:
- struck: pianos and drums, with damping, pedals, half pedalling and sympathetic string resonance
- plucked: guitars, with every note on a string, strums spread across the strings, mutes, harmonics, hammer-ons, pull-offs, slides and a modelled valve amplifier
- sustained: bowed strings, with loops, slurs, styles and bow vibrato
- synth: oscillators, a resonant filter and envelopes, built live
Rooms are convolution with measured impulse responses.
- App (React, Vite, VexFlow). Every instrument is a picture with its playable parts measured on it. Songs play over several audio threads timed on one clock.
- Command line (Node, node-web-audio-api, ffmpeg). It renders offline through the same engine and checks, fits, mixes, normalises loudness and encodes.
- Recordings, all cleared and credited:
- Instruments: VCSL, VSCO 2, the University of Iowa, Meta Open Sound, Karoryfer and Accurate-Salamander
- Rooms: OpenAIR
- Guitar feel: strum timing and finger squeaks measured from the GuitarSet dataset
Every tuned number names the script that measures it.
- Pictures: made with Gemini (Nano Banana Pro). Each Halloween picture is exported onto the original's exact crop, so the measured geometry still fits.
How I used Kiro
Orchestra was built with Kiro, spec first. Most of it was built in the Kiro IDE and the later part in Kiro CLI. I found the CLI better overall: it's faster and simpler to use, and it suits a project driven by scripts, renders and tests.
- Specs: nine, one per area, with 523 tasks in all: the engine and piano family, guitar, drums, strings, synths, scores and songs, the song screen, the Halloween look, and Practice. Each has EARS requirements, a design with correctness properties, and an implementation plan. Every task names its requirements, and every property names the test that checks it.
- Sub-agents and an orchestrator: the orchestrator split each task into short briefs (files, signatures, behaviour, requirements, tests) and ran sub-agents in parallel batches. Two batches never edited the catalog, the pack configuration or the credits at once.
- Steering: twelve files. The key rules are
clean-room.md(code from scratch, only cleared audio and pictures, every source credited),working-rules.md(ask before deleting or rewriting history, report truthfully) andorchestration.md. - Custom agents:
pack-builderbuilds one sample pack from a cleared source, through to its calibration and creditreviewerchecks work against the specslicence-checkerchecks for copied code, incompatible licences and uncredited audio or pictures
- Hooks:
- a shell guard before every tool call
- the full suite and type check after each task
- engine and app tests on save
- a licence check whenever a manifest, licence or the credits change
- a song check whenever an example song is saved
- Skills: adding a sample pack, adding an instrument family, and rendering a song.
Testing
- 285 tests in 33 files (Vitest). None needs a browser, a sound card, the network or the recordings: the audio graph is replaced by fakes.
- Property-based tests (fast-check). One test per correctness property: zone selection, velocity layers and gain, voice stealing, the keymap, note names, and Practice's mute bookkeeping.
- Render checks. A song is rendered twice and must give the same
performanceSha256and audio within -90 dB. The loudness target is checked against ffmpeg's own measurement, with the peak under -1 dBFS.
Challenges I ran into
- Same input, same output. Every event sits on the exact sample a render puts it on, and all randomness comes from the part's seed.
- Large arrangements live in a browser. Parts are spread over several audio threads on one clock, so many instruments play without dropouts.
- Recordings that behave like instruments. Looped string notes pulsed until their loops were measured and moved. The Yamaha grand plays as its SFZ maps it, at 16 dynamics.
- Two looks on one geometry. Restyled pictures had painted strings and frets, and had to land exactly on the measured keys, strings and pads.
- Only cleared material. No openly licensed flute with enough dynamics was found, so the synth family covers sustained lead sounds.
Accomplishments that I'm proud of
- One engine plays 41 sounds, live in the browser and offline from the command line, with the same events both ways.
- An agent can write, check, render and hear a song in a loop, and change one note at a time.
- Every recording is cleared and credited, so what an agent renders can be used anywhere.
- All 523 spec tasks are complete.
What I learned
Exact, machine-readable feedback is what makes an agent effective: an error that names its field and a render that reports each part's loudness turn music into a loop an agent can close. Specs and steering keep a large build consistent, and hooks catch mistakes before they land.
What's next for Orchestra
More instrument families as cleared recordings appear, such as woodwinds and brass. Modelled instruments that are synthesised from physics instead of recordings. More example songs for agents.
Built With
- fast-check
- ffmpeg
- javascript
- kiro
- midi.js
- musicxml
- node-web-audio-api
- node.js
- numpy
- opus
- playwright
- python
- react
- scipy
- typescript
- vexflow
- vite
- vitest
- web-audio-api