First Light: Betocsin
README.md
audio.synth
Pure-CPU audio synthesis. Every noise First Light: Vagant makes is computed
here as interleaved f32 PCM in a buffer, then handed to audio.encodePcm /
asset.create("soundClip", …). No network, no credits, no failure mode.
Author time only — audio.recipes and audio.bake are its consumers, and the
game ships the baked clips, so a browser session synthesises nothing on the
player's machine.
Two conventions run through it:
- every generator adds into a destination buffer, so layers compose;
- a loop-coherent generator takes its frequency in cycles across the WHOLE buffer rather than in hertz, which is what makes a bed seamless end to end.
What is in it
- Oscillators —
sine(table-driven),addTone(a gliding harmonic stack with vibrato),addLoopPartial(the loop-coherent form),addPluck(Karplus-Strong),addNoise. - Envelopes —
env(breakpoints in seconds),decayEnv(attack plus an exponential tail),mulEnv. - Filters —
lowpass,highpass,lowpassSweep,bandpass(a swept state-variable band), and the circular formslowpassCircular/bandpassCircular, which converge the filter's state on the wrap point so its output is continuous ACROSS the loop join. - Space and finishing —
reverb(four combs into two allpasses),resample,gain,normalize,softClip,removeDc,fadeEdges,mix,addWrapped(a tail that wraps round to the head of a loop). - Measurement —
peak,rms, andseamError, which reports the step across a loop's join in the units the signal itself steps in: around 1 is seamless, a click reads in the tens.