Repository navigation
Spec: per-event params, so a bell can sit on a note - #1
Conversation
- 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
Listen to itI rendered 24 short clips from this branch, each one a single Spec through https://parker-brown-family.github.io/orb-audio/ Church bell: pitch
Church bell: timbre
Church bell: length
Church bell: strike
Synth roles
What plain words cannot reachParams are Spec-only, so the planner cannot be asked for a note. I gave these three sentences to the shipped planner on this branch:
Limitations
The clips, the script that made them (make_demo.py) and the measurements (results.json) live on a |
|
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. |
|
Love it - great work! |
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
bellrings at 880 Hz whatever the seed. Eachchurch_bellis 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
paramson 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.paramsexists on the Score,render_eventalready merges it overROLE_PARAMS, andbell,ui_pop,click,impactandsub_dropalready readf0,t60andf_endfrom that dict. What was missing was the door at the Spec layer, which is the layer agents andorb-mcpactually 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
bell,ui_pop,click,impactf0(Hz),t60(ring time, s)sub_dropf0,f_end(Hz: where the drop starts and lands)church_bellf0(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_PARAMSis the registry: role, then name, then range and meaning. A role that is not listed takes no params. Defaults stay where they already live, inROLE_PARAMS, so nothing is stated twice.SpecEvent.paramsis an optional dict. It goes throughspec_to_dictanddict_to_spec, andscore_from_spechands it toEvent.params.orb_validate_specrejects an unknown or out-of-range param with the event's path (events[0].params.f0: 5 is outside [110, 2400]).SpecEventraises the same messages for direct API use.orb_describe_grammarlistsroles.<role>.paramswith each range, description and default. The church bell'sf0has a default ofnull, because unset there is no default: the seed picks the bell.church_bellreads 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_dbbed_dbis the precedent I copied. Params are render-only in the same way:SpecTokenizer.encode_specrefuses a Spec that carries any, with the same kind of message it gives forbed_db.spec_to_dictwritesparamsonly when set, so a planner Spec serialises exactly as before.Nothing existing moves
mainand 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.pypasses unchanged.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_specon a Spec dict, at 48 kHz:church_bellnominal against2 * f0, doublets closed (beat: 0), 4 notes x 4 seedsbeat)bellon C4, D4, F♯4, A4ring0.35 / 1 / 2.5 on one bell, seconds to fall 40 dBhardness0.05 / 0.5 / 1, spectral centroid of the first 150 msAs 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
f0on 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 withf0set also had a true prime, that is a one-line change.bell'sf0stops at 2400 Hz so its 8.93 partial stays under the 0.45 x sample-rate cutoff inmodal. They are easy to widen.hardnessis 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.site/py/orb.zipis the bundled copy of the renderer, so the in-browser demo ignoresparamsuntil the site is rebuilt withscripts/build_site.py. I left that to you because it rewrites published assets.web/engine.py's_check_specpasses unknown event keys through today, so nothing breaks in the meantime.scripts/make_demo.pydumpse.__dict__, so its report rows gain"params": null. I did not change the script.phone_ring,clock_alarm,car_horn,siren. I kept this PR to the roles that already read their pitch fromp, 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.pyChecklist
pytest -qpasses: 584 passed, 3 skipped with CPU torch 2.15 (Linux x86_64, Python 3.12); 541 passed, 16 skipped in a NumPy-only environmentpython examples/04_no_torch.pyruns (the DSP path must never import torch)python examples/01_generate.pystill passes the audit[Unreleased]