▣
module · drop-in viewer
synth
No recordings. A drone, a wind, a bell, a bird and a hiss are all built here out of sines, noise and envelopes, and `../bake.module` writes the result out as `.soundClip` assets.
by·posted 1mo ago
What it does
synth — the arithmetic every sound in this game is made of
No recordings. A drone, a wind, a bell, a bird and a hiss are all built here
out of sines, noise and envelopes, and ../bake.module writes the result out
as .soundClip assets.
The one idea worth knowing is the difference between the two shapes:
- A LOOP has to join its own end to its own start with no seam. Every
partial in a loop is locked to a whole number of cycles across the loop
(
Syn.k(hz, seconds)), so the waveform at sample N IS the waveform at sample 0 — not approximately, by construction. The phase of partial k at sample i is(i * k) % n / n, integer arithmetic that cannot drift. Noise has no partials to lock, sonoiseLooprenders the source longer than the loop and equal-power crossfades its own overhang back onto its own head. - A ONE-SHOT is struck once and left to decay. It never wraps, so
strike,sweepandnoiseShotare free to start and end where they like;edgestakes the click off both ends.
The calls
| call | what it makes |
|---|---|
zeros(n) | a silent f32 sample buffer |
k(hz, seconds) | the whole-cycle harmonic index of a frequency over a loop |
partials(buf, n, parts) | sums loop-locked sines, each with its own loop-locked tremolo |
noiseLoop(n, rate, opts) | coloured noise that loops without a seam |
noiseShot(n, rate, opts) | a one-shot burst of the same colour |
strike(buf, n, rate, hz, a, atk, decay) | one decaying sine — a bell partial, a thud |
sweep(buf, n, rate, hz0, hz1, …) | a sliding tone — a whistle, a whoosh, a bird |
mix / shape | add or multiply through a per-sample envelope |
normalize(buf, n, target) | scale to a peak and clamp |
edges(buf, n, rate, seconds) | fade a one-shot's own ends to silence |
rng(seed) | a seeded LCG, so a re-bake is byte-identical |
sinp(ph) | one table-interpolated sine, exposed for callers that render their own |
NoiseOpts colours noise with two one-pole lowpasses (lp), a one-pole
highpass (hp) and an optional resonant peak (bandHz / bandQ /
bandMix); fadeSec is how long noiseLoop's wrap crossfade runs.
Nothing here touches the engine except buffer.
Discussion
Scoped to this part · feeds back into the world's score.
Sign in to post.sign in
No comments yet. Be the first.