Skip to content

Spec: per-event params, so a bell can sit on a note - #1

Merged
stdevMac merged 1 commit into
stdevMac:mainfrom
parker-brown-family:spec-event-params
Nov 20, 2026
Merged

stdevMac merged 1 commit into
stdevMac:mainfrom
parker-brown-family:spec-event-params

Conversation

@parker-brown-family

@parker-brown-family parker-brown-family commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What and why

A sound that sits over music has to follow its key, and today a Spec cannot ask for a pitch. The synth bell rings at 880 Hz whatever the seed. Each church_bell is cast by its seed somewhere between C4 and B4: I measured the strongest partial of sixteen as-shipped church bells (seeds 0 to 15) and got sixteen different answers, from 167 Hz to 970 Hz, with no field that moves any of them. This came out of trying ORB for scoring short films, where a cue has to land on the chord under it, and the bell was the first sound I wanted to put on a note.

This PR lets a hand-written Spec carry params on an event:

{"role": "church_bell", "t": 1.0, "dur": 6.0, "seed": 0, "params": {"f0": 293.66, "ring": 1.5}}

Most of the path was already there. Event.params exists on the Score, render_event already merges it over ROLE_PARAMS, and bell, ui_pop, click, impact and sub_drop already read f0, t60 and f_end from that dict. What was missing was the door at the Spec layer, which is the layer agents and orb-mcp actually write. So this is mostly plumbing and validation, plus one renderer, church_bell, that learns to listen.

Listen: 24 clips of these params against the sounds as shipped, with what plain words cannot reach and the limitations: https://parker-brown-family.github.io/orb-audio/

What it adds

Role Params
bell, ui_pop, click, impact f0 (Hz), t60 (ring time, s)
sub_drop f0, f_end (Hz: where the drop starts and lands)
church_bell f0 (strike note, Hz), ring (scales every partial's decay), hardness (clapper: 0 felt, 0.5 as shipped, 1 hard), tierce (the third: 0.6 minor, 0.63 major), beat (doublet width)
  • orb.grammar.EVENT_PARAMS is the registry: role, then name, then range and meaning. A role that is not listed takes no params. Defaults stay where they already live, in ROLE_PARAMS, so nothing is stated twice.
  • SpecEvent.params is an optional dict. It goes through spec_to_dict and dict_to_spec, and score_from_spec hands it to Event.params.
  • orb_validate_spec rejects an unknown or out-of-range param with the event's path (events[0].params.f0: 5 is outside [110, 2400]). SpecEvent raises the same messages for direct API use.
  • orb_describe_grammar lists roles.<role>.params with each range, description and default. The church bell's f0 has a default of null, because unset there is no default: the seed picks the bell.
  • church_bell reads the five dials. Every random draw is made whether or not a param is set, so a param changes only the thing it names: asking for D4 on seed 2 gives seed 2's bell on D4, not a different bell.

It follows bed_db

bed_db is the precedent I copied. Params are render-only in the same way:

  • The caption grammar and the planner do not express them. The planner never emits them and no training data changes.
  • SpecTokenizer.encode_spec refuses a Spec that carries any, with the same kind of message it gives for bed_db.
  • Validation adds a warning that they will not round-trip through the planner.
  • spec_to_dict writes params only when set, so a planner Spec serialises exactly as before.

Nothing existing moves

  • I rendered every one of the 47 roles at four seeds, plus a scene-bed cue, on main and on this branch and compared SHA-256 of the float32 samples: 189 renders, 0 differences (Linux x86_64, NumPy 2.5.5).
  • tests/test_render_baseline.py passes unchanged.
  • New tests assert that params: {} is the same audio as no params, and that a param set to its default is the same audio as leaving it out, for every role in the registry.

Measured on this branch

Through render_spec on a Spec dict, at 48 kHz:

What Result
church_bell nominal against 2 * f0, doublets closed (beat: 0), 4 notes x 4 seeds within 0.19 cents
The same as cast (default beat) within 0.74 cents
bell on C4, D4, F♯4, A4 within 0.12 cents
ring 0.35 / 1 / 2.5 on one bell, seconds to fall 40 dB 2.1 / 5.85 / 11.25
hardness 0.05 / 0.5 / 1, spectral centroid of the first 150 ms 850 / 1450 / 1944 Hz

As cast, each partial is a pair that straddles its frequency by at most 0.06 %, and a tuner reads the louder half, which is where the last fraction of a cent goes.

Choices you may want to change

  1. f0 on a church bell is the strike note, defined as half the nominal. The nominal, superquint and octave nominal are the 2nd, 3rd and 4th harmonics of that pitch, so it is what a listener hears. The seed still detunes the hum and the prime, as your model intends for an old bell, so the prime itself can sit a little off the note asked for. If you would rather a bell with f0 set also had a true prime, that is a one-line change.
  2. The ranges are my judgement. For example bell's f0 stops at 2400 Hz so its 8.93 partial stays under the 0.45 x sample-rate cutoff in modal. They are easy to widen.
  3. hardness is a first model, checked by measurement and not tuned by ear against recordings the way your realism pass was. Above the nominal each partial's weight is scaled by (0.15 + 1.7 h) ** log2(ratio), the clank scales with (2 h) ** 2, and below 0.5 the blow gets an attack ramp of up to 12 ms. At 0.5 all three are exactly the shipped values.
  4. The web demo is not touched. site/py/orb.zip is the bundled copy of the renderer, so the in-browser demo ignores params until the site is rebuilt with scripts/build_site.py. I left that to you because it rewrites published assets. web/engine.py's _check_spec passes unknown event keys through today, so nothing breaks in the meantime.
  5. scripts/make_demo.py dumps e.__dict__, so its report rows gain "params": null. I did not change the script.
  6. Other roles can join the registry in the same shape when someone wants them: the marimba phone_ring, clock_alarm, car_horn, siren. I kept this PR to the roles that already read their pitch from p, plus the one bell.

Try it

python examples/06_tuned_bell.py     # three church bells toll a D minor triad, then together
pytest -q tests/test_params.py

Checklist

  • pytest -q passes: 584 passed, 3 skipped with CPU torch 2.15 (Linux x86_64, Python 3.12); 541 passed, 16 skipped in a NumPy-only environment
  • python examples/04_no_torch.py runs (the DSP path must never import torch)
  • If the renderer changed: python examples/01_generate.py still passes the audit
  • If a role or texture was added: planner data regenerated and retrained (see CONTRIBUTING.md). Not applicable: no role or texture is added, and the planner's vocabulary and data are untouched.
  • CHANGELOG.md updated under [Unreleased]

- A Spec event may carry `params`, renderer parameters for that one event:
  {"role": "church_bell", "t": 1.0, "dur": 6.0, "params": {"f0": 293.66}} puts the strike note on D4
- `orb.grammar.EVENT_PARAMS` is the registry (role -> name -> range and meaning): `f0` and `t60` for
  bell, ui_pop, click and impact; `f0` and `f_end` for sub_drop; `f0`, `ring`, `hardness`, `tierce`
  and `beat` for church_bell
- The synth roles already read these from `ROLE_PARAMS` and `Event.params`; this opens that path at the
  Spec layer. The church bell gains the five dials, with every random draw made either way, so a param
  changes only what it names
- Render-only, like `bed_db`: the caption and the planner cannot express params, the tokenizer refuses
  them, validation warns, and a planner Spec serialises exactly as before
- No existing sound moves: all 47 roles x 4 seeds hash the same before and after, and a param at its
  default is the same audio as leaving it out
- orb_validate_spec rejects unknown or out-of-range params by path; orb_describe_grammar lists each
  role's params with ranges and defaults (null where the seed picks the value)
- examples/06_tuned_bell.py, tests/test_params.py, README, docs/agents.md, CHANGELOG
@parker-brown-family

Copy link
Copy Markdown
Contributor Author

Listen to it

I rendered 24 short clips from this branch, each one a single Spec through render_spec, next to the sound as it ships today. The page has a player on every row:

https://parker-brown-family.github.io/orb-audio/

Church bell: pitch

Clip Setting Measured Listen
Three bells, as cast (no params) seeds 0, 2, 4 the seed picks each bell: nominals 672 Hz, 804 Hz, 875 Hz play · mp3
The same three bells on D4, F4, A4 "params": {"f0": 293.66} and so on nominal against 2 x f0: +0.65, +0.10, -0.17 cents play · mp3
D minor, all three together f0 = D4, F4, A4 a minor chord suits the church bell's minor third play · mp3

Church bell: timbre

Clip Setting Measured Listen
D major on church bells (tierce 0.6) f0 = D4, F#4, A4 each bell's own minor third sits against the major chord play · mp3
D major on major-third bells "tierce": 0.63 the third partial moves from 0.60 to 0.63 of the nominal play · mp3
Beating: none "beat": 0.0 doublets closed: one line per partial play · mp3
Beating: as cast "beat": 0.0012 each partial's pair up to 0.12% apart play · mp3
Beating: heavy "beat": 0.006 each partial's pair up to 0.60% apart play · mp3

Church bell: length

Clip Setting Measured Listen
Ring x 0.35 "ring": 0.35 2.1 s to fall 40 dB play · mp3
Ring x 1 "ring": 1 5.8 s to fall 40 dB play · mp3
Ring x 2.5 "ring": 2.5 11.2 s to fall 40 dB play · mp3

Church bell: strike

Clip Setting Measured Listen
Clapper: felt "hardness": 0.05 spectral centre of the first 150 ms: 850 Hz play · mp3
Clapper: as cast "hardness": 0.5 spectral centre of the first 150 ms: 1450 Hz play · mp3
Clapper: hard "hardness": 1 spectral centre of the first 150 ms: 1944 Hz play · mp3
A toll that grows, as five events gain_db -24 to 0, hardness 0.1 to 0.9 one event per strike: a single tolling event cannot change strike by strike play · mp3

Synth roles

Clip Setting Measured Listen
bell, as shipped no params 880.0 Hz whatever the seed play · mp3
bell on C5, E5, G5, C6 "f0": 523.25 …, "t60": 2.0 within 0.07 cents of each note play · mp3
ui_pop three times, as shipped no params all near 880 Hz play · mp3
ui_pop on C6, E6, G6 "f0": 1046.5 … a three-note confirmation in key play · mp3
impact, low "f0": 45 body at 45 Hz play · mp3
impact, as shipped no params body at 70 Hz play · mp3
impact, high "f0": 120 body at 120 Hz play · mp3
sub_drop, as shipped no params 110 Hz down to 35 Hz play · mp3
sub_drop from 220 Hz to 40 Hz "f0": 220, "f_end": 40 an octave more travel play · mp3

What plain words cannot reach

Params are Spec-only, so the planner cannot be asked for a note. I gave these three sentences to the shipped planner on this branch:

Typed Planned Listen
“a church bell ringing on the note D” church_bell (seed 0, no params) play · mp3
“three church bells tolling a D minor chord” church_bell (seed 0, no params), church_bell (seed 0, no params), church_bell (seed 0, no params) play · mp3
“a soft low bell, then a hard high bell” church_bell (seed 0, no params), bell (seed 0, no params) play · mp3

Limitations

  • They change what you can ask for, not how real it sounds. A tuned church bell is the same sixteen partials as before. To my ear it still sounds synthesized; it is now synthesized on the right note.
  • f0 on a church bell is the strike note, half the nominal. The seed still detunes the hum and the prime, as the model intends for an old bell, so a tuner reading the prime can sit a little off the note asked for.
  • hardness is one dial, not a strike curve. It tilts the upper partials, scales the clank and, below 0.5, slows the attack. It was set by measurement and not tuned by ear against recordings.
  • A tolling bell strikes at one loudness. An odd seed tolls every 2.5 s with one set of params. A toll that grows strike by strike is written as one event per strike (the crescendo clip), which spends the eight-event limit quickly.
  • Spec only. A caption cannot carry params and the planner never emits them, so plain words cannot ask for a note: see the three typed prompts below.
  • Six roles so far. bell, ui_pop, click, impact, sub_drop and church_bell. The marimba phone_ring, clock_alarm, car_horn and siren have a pitch and no param yet.
  • The web demo does not know params yet. site/py/orb.zip is a bundled copy of the renderer; it ignores params until the site is rebuilt.

The clips, the script that made them (make_demo.py) and the measurements (results.json) live on a params-demo branch of my fork, so nothing is added to this pull request's diff.

@stdevMac
stdevMac merged commit 07f9713 into stdevMac:main Nov 20, 2026
1 check passed
@stdevMac

Copy link
Copy Markdown
Owner

Merged, thank you Parker!

This is a great first contribution. Putting a bell on a note is exactly what was missing for cues that have to sit over music, and you kept every random draw intact, so existing Specs still render bit-identical. The tests and the tuned-bell example made the review easy. I checked that a bell at 440 Hz peaks at 440 Hz, and the church bell's clapper and tierce controls sound great.

Your onset measurements on X (keys and footsteps landing 30 to 46 ms late) are now at the top of the v2 list: every sound should start within 1 ms of where it's placed. More soon.

@parker-brown-family

Copy link
Copy Markdown
Contributor Author

Love it - great work!
Happy sending!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants