Game sound effects (WAV)
Available in npm 0.2.0. Check release status for the
current package version and validation scope.
Use Format.Wav and components from @delino/react-forge/sfx to compose procedural
game effects. Export a WAV buffer or file for your game engine. Generation is
offline and does not need recordings, audio devices, fonts or a conversion tool.
A zombie-game gunshot
Save this as gunshot.tsx:
The layers provide a sharp crack, low body, falling tone, mechanical click and short room tail. Changing the noise seeds gives variations. This is original procedural game audio, not a recording or a claim of realistic weapon acoustics. Exported audio is 16-bit PCM WAV. Listen in your target game's mix to choose the appropriate gain. Files are only generated on explicit export; nothing plays automatically.
Components and parameters
Layer parameters are required duration, optional start, gain, pan,
attack, release and decay. Times are seconds and gain is linear. Each
layer must fit entirely inside its Sound. Noise and Tone are leaves; use ordinary
React components and fragments to reuse or repeat layers.
Defaults are SampleRate.Game (48000 Hz), Channels.Mono, unity gain and start
zero. SampleRate.Cd selects 44100 Hz. Channels.Stereo enables equal-power pan
from -1 (left) to 1 (right); mono requires pan zero. Gains range from zero to four.
Tone defaults to Waveform.Sine; Waveform.Triangle is also available. Tone
frequency sweeps linearly to endFrequency when supplied.
Attack and release provide linear fades. They default to 1 ms and 10 ms, each
capped at one quarter of the layer and floored at one sample. Each must be at
least one sample and together must fit the layer. Optional decay is an
exponential amplitude time constant from one sample to 30 seconds. The first
and last sample of each layer are zero. Peaks above 0.95 are attenuated together
without boosting quiet sounds or changing stereo balance.
Seeds are integers from 1 through 4294967295. Noise filters and tone frequencies
range from 20 Hz to one Hz below half the sample rate. When both filters are used,
highPass must be below lowPass. Repeatable seeds reproduce the same sound on
the same runtime and host; byte identity across platforms is not guaranteed.
Sessions, MCP and limits
Use the common session APIs, CLI or
MCP tools. MCP execution accepts the same TSX task; inspect
its session and call react_forge_export with an output ending in .wav.
measure returns timeline geometry: x is the sample-rounded start and width
is duration in seconds, with y zero and height one. A changed revision invalidates
an earlier measurement.
Sounds last from two samples to 30 seconds, with one to 256 layers. The sum of
layer durations in samples cannot exceed 16 million. capabilities exposes
these limits. Invalid latest renders fail export; cancellation and failed
exports preserve existing destinations. Existing files require explicit
overwrite. Library callers should dispose sessions in finally.
SFX supports generation only. Audio import, recorded samples, MP3/OGG, MIDI,
microphone capture and live playback are not supported. WAV sessions reject
image and font registration. The 0.2.0 release workflow exercised installed
consumers on all six supported native hosts. No game-engine listening evaluation
is claimed; see validation scope.
For animated pixel artwork instead of audio, see Sprite.