First Light: Lavic Odyssey
README.md
game.sound.synth — where the sound comes from
The clip bank of FIRST LIGHT, computed from nothing. Oscillators, noise,
one-pole and state-variable filters, a small Schroeder reverb for the caldera,
and a recipe per clip — all of it raw interleaved f32 PCM handed to
audio.encodePcm. No network, no credit, no service: the game cannot go
silent because a generation failed.
Baking
Run from an execute, never from a component — a create made inside a
component callback is filed in the ephemeral runtime store and never reaches
the commit.
local S = require("game.sound.synth")
S.bake() -- every recipe, into game/sound/clips/
S.bake({ "helm_off" }) -- one of them
S.render("helm_off") -- the samples, writing nothing
S.RECIPES is the table of recipes; S.ORDER is the bake order.
Two shapes of clip
- One-shots — Opus, small, played through
Audio:playOneShot. - Beds —
codec = "pcm", because an Opus payload loses the first few milliseconds on decode and a loop built on one clicks at the seam.
A bed is rendered longer than it ships and folded back on itself: the last
400 ms are crossfaded into the first, so the final sample runs into the first
one. Tonal layers additionally use frequencies that complete a whole number of
cycles in the loop length (cyc), which are continuous across the seam by
construction. The seam step of every bed is smaller than the largest ordinary
sample-to-sample step inside the same clip.
The noise source is a seeded xorshift, so two bakes of one recipe are the same bytes and a checksum that moved means the recipe moved.
Generated music, made loopable
S.bakeMusicFrom(path, name, foldSeconds) takes a clip audio_gen.music
produced, decodes it, trims the silence off both ends, folds the tail back
over the head, and re-encodes it under the game's own identity — so what ships
is one of this slice's own paths rather than a handle into /source/generated.
The source is addressed as a file path, not as an asset reference: a generated clip is named by the service, and a computed asset reference cannot be statically pinned for publishing.
Every clip is proved before it becomes an asset
bakeOne encodes the payload, reads it back with audio.info, and refuses to
create the asset if the frame count or the duration is zero — the failure that
otherwise ships silently.