synth
<!-- zero:scaffolded-readme --> <!-- Replace the line below with what this module provides and who consumes it, then delete both comment lines. -->
synth
<!-- zero:scaffolded-readme --> <!-- Replace the line below with what this module provides and who consumes it, then delete both comment lines. -->TODO: describe this module.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2audio.synth — the DSP kit the whole Nine Bells sound bank is made from. Pure CPU. Nothing here touches the engine except `buffer`, so it runs headless, deterministically, and cannot fail for credit or network reasons. Everything writes f32 samples into a `track`, and a track becomes a `.soundClip` through `audio.encodePcm` (see `audio.bake`). A track: { buf = <buffer of n f32>, n = <frames>, sr = <hz>, wrap = <bool> } `wrap = true` makes every writer index modulo n, so a decay that runs off the end folds back into the start. That is what makes a bed loop with no seam: render one period with wrap on, set loopStart = 0 / loopEnd = n. Frequencies in a looping bed must complete a whole number of cycles inside the loop, or the seam clicks. `Synth.qfreq(f, seconds)` snaps a frequency to the nearest one that does.
track(seconds: number, sr: number?, wrap: boolean?) → Track
| arg | type | description |
|---|---|---|
| seconds | number | |
| sr | number? | |
| wrap | boolean? |
rd(b: buffer, i: number) → number
| arg | type | description |
|---|---|---|
| b | buffer | |
| i | number |
wr(b: buffer, i: number, v: number) → void
| arg | type | description |
|---|---|---|
| b | buffer | |
| i | number | |
| v | number |
qfreq(f: number, seconds: number) → number
Snap a frequency so it completes a whole number of cycles in `seconds`.
| arg | type | description |
|---|---|---|
| f | number | |
| seconds | number |
rng(seed: number) → void
A deterministic LCG, so every bake of the bank is byte-identical.
| arg | type | description |
|---|---|---|
| seed | number |
envAt(u: number, dur: number, attack: number, release: number) → number
Envelopes Every generator takes the same envelope vocabulary: start seconds into the track dur seconds the voice lasts attack seconds of fade-in (default a 3 ms click-guard) t60 seconds for the body to fall 60 dB (nil = flat, then a release) release seconds of fade-out at the tail (default 20 ms)
| arg | type | description |
|---|---|---|
| u | number | |
| dur | number | |
| attack | number | |
| release | number |
partial(t: Track, opts: { [string]: any }) → void
Voices A decaying sine partial. Uses a two-pole resonator (one multiply and one subtract per sample) rather than math.sin, because a bell is sixteen of these over seven seconds and the bank has nine bells in it. opts: freq, amp, start, dur, t60, attack, release, phase
| arg | type | description |
|---|---|---|
| t | Track | |
| opts | { [string]: any } |
sweep(t: Track, opts: { [string]: any }) → void
A swept tone — a phase accumulator, because the resonator cannot glide. opts: f0, f1, amp, start, dur, t60, curve (1 = linear, 2 = fast then slow), shape ("sine" | "saw" | "square" | "tri")
| arg | type | description |
|---|---|---|
| t | Track | |
| opts | { [string]: any } |
noise(t: Track, opts: { [string]: any }) → void
White noise through the same envelope vocabulary. opts: amp, start, dur, t60, attack, release, seed
| arg | type | description |
|---|---|---|
| t | Track | |
| opts | { [string]: any } |
lowpass(t: Track, cut: number) → void
Filters — applied to a whole track, in place One-pole low pass. `cut` in Hz.
| arg | type | description |
|---|---|---|
| t | Track | |
| cut | number |
highpass(t: Track, cut: number) → void
One-pole high pass.
| arg | type | description |
|---|---|---|
| t | Track | |
| cut | number |
svf(t: Track, cut: number, q: number, mode: string?) → void
A state-variable filter — the one that gives a resonant "voice" to noise. mode: "lp" | "bp" | "hp". q from 0.5 (soft) to 12 (a whistle).
| arg | type | description |
|---|---|---|
| t | Track | |
| cut | number | |
| q | number | |
| mode | string? |
svfSweep(t: Track, cutAt: (number) → void
A bandpass whose cutoff moves — wind, a whoosh, a passing gust. `cutAt(u)` returns the cutoff in Hz for a normalised position u in [0,1).
| arg | type | description |
|---|---|---|
| t | Track | |
| cutAt | (number |
reverb(t: Track, size: number, decay: number, wet: number) → void
Space A Schroeder reverb: four combs into two allpasses. `size` scales the delay network (1.0 is a stone room, 2.6 is a cathedral); `mix` is the wet amount; `decay` is comb feedback, 0..0.95.
| arg | type | description |
|---|---|---|
| t | Track | |
| size | number | |
| decay | number | |
| wet | number |
gain(t: Track, g: number) → void
Shaping
| arg | type | description |
|---|---|---|
| t | Track | |
| g | number |
peak(t: Track) → number
| arg | type | description |
|---|---|---|
| t | Track |
normalize(t: Track, target: number) → void
| arg | type | description |
|---|---|---|
| t | Track | |
| target | number |
softclip(t: Track, drive: number) → void
tanh-ish saturation: keeps a loud transient from clipping into a buzz.
| arg | type | description |
|---|---|---|
| t | Track | |
| drive | number |
trimEdges(t: Track, seconds: number) → void
Fade the very ends to silence. A one-shot with a hard edge clicks.
| arg | type | description |
|---|---|---|
| t | Track | |
| seconds | number |
blend(dst: Track, src: Track, gain: number, offset: number?) → void
Mix one track into another at a gain and an offset (in seconds).
| arg | type | description |
|---|---|---|
| dst | Track | |
| src | Track | |
| gain | number | |
| offset | number? |
fromPcm(pcm: string, sr: number, channels: number) → Track
Build a track from decoded PCM. Interleaved input is downmixed to mono, because everything spatial in this game is a point in the street.
| arg | type | description |
|---|---|---|
| pcm | string | |
| sr | number | |
| channels | number |
resample(t: Track, ratio: number) → Track
Resample by linear interpolation, keeping the sample rate. `ratio` below 1 makes the track longer and lower; above 1, shorter and higher. This is the only pitch control there is here, and it moves the tempo with the pitch — which is why it reads as a different delivery rather than a chipmunk.
| arg | type | description |
|---|---|---|
| t | Track | |
| ratio | number |
pad(t: Track, seconds: number) → Track
Grow a track by `seconds` of silence at the end, so a reverb tail has somewhere to go.
| arg | type | description |
|---|---|---|
| t | Track | |
| seconds | number |
pcm(t: Track) → string
Output A mono track as the interleaved f32 string `audio.encodePcm` wants.
| arg | type | description |
|---|---|---|
| t | Track |
pcmStereo(l: Track, r: Track) → string
Two mono tracks interleaved into one stereo PCM string.
| arg | type | description |
|---|---|---|
| l | Track | |
| r | Track |
bell(t: Track, opts: { [string]: any }) → void
Instruments — the recurring shapes of this game's sound A struck bell. `partials` are ratios against `prime`, each with its own amplitude and decay; every one is laid down twice a fraction of a hertz apart, and that beating is what stops it sounding like an organ. opts: prime, amp, start, spread (beat detune in Hz), warmth (0..1 tilts the balance toward the hum), tail (t60 of the hum)
| arg | type | description |
|---|---|---|
| t | Track | |
| opts | { [string]: any } |
clink(t: Track, opts: { [string]: any }) → void
Bronze without the bell: a chain link, a lantern hoop, a stopper on glass.
| arg | type | description |
|---|---|---|
| t | Track | |
| opts | { [string]: any } |
knock(t: Track, opts: { [string]: any }) → void
Wood: a cane on stone, a board, a shutter. A short resonant knock.
| arg | type | description |
|---|---|---|
| t | Track | |
| opts | { [string]: any } |
whoosh(t: Track, opts: { [string]: any }) → void
A breath, a gust, a swing of the censer: filtered noise that opens and shuts. opts: amp, start, dur, low, high, q, seed
| arg | type | description |
|---|---|---|
| t | Track | |
| opts | { [string]: any } |
step(t: Track, surface: string, opts: { [string]: any }) → void
A footstep on a named surface.
| arg | type | description |
|---|---|---|
| t | Track | |
| surface | string | |
| opts | { [string]: any } |
vox(t: Track, opts: { [string]: any }) → void
A voice-shaped tone without words: an infected's moan, a patient's sigh. Two formants over a sawtooth. `f0` is the pitch.
| arg | type | description |
|---|---|---|
| t | Track | |
| opts | { [string]: any } |
Track = { buf: buffer, n: number, sr: number, wrap: boolean }Sub-parts
Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.
Problems
Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.
agent_score is exposed.+ quality × 0.35
+ performance × 0.25
± compat factor
Usability ratings
Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".
Scoped to this part · feeds back into the world's score.