Audio System
Fully procedural audio engine with node-graph synthesis, material-to-sound mapping, spatial audio, and real-time particle-driven sound generation. No pre-recorded samples required.
Architecture
The audio system has three execution paths that converge on the same patch format:
┌─────────────────────────────────────┐
│ Audio Editor (AudioEditorPanel.js) │ ← Main-thread preview
│ WebAudioNodeFactory → Web Audio │
├─────────────────────────────────────┤
│ Worklet Runtime (PatchRunner) │ ← Production playback
│ NODE_PROCESSORS → AudioWorklet │
├─────────────────────────────────────┤
│ Particle Bridge │ ← Real-time mapping
│ ParticleAudioBridge.js → patches │
└─────────────────────────────────────┘
Patch System
A patch is a JSON descriptor defining a node graph of audio generators and processors. Patches are the universal currency of the audio system.
// Example patch: simple sine with envelope
{
nodes: [
{ id: 'osc', type: 'Oscillator', params: { waveform: 'sine', frequency: 440 } },
{ id: 'env', type: 'ADSR', params: { attack: 0.01, decay: 0.1, sustain: 0.5, release: 0.3 } },
{ id: 'out', type: 'Output' }
],
connections: [
{ from: 'osc', to: 'env' },
{ from: 'env', to: 'out' }
]
}
Node Types
30+ node types organized by category:
| Category | Node Types |
|---|---|
| Generators | Oscillator, Noise, GrainCloud |
| Processors | Filter, Delay, Reverb, Compressor, Waveshaper |
| Modulators | LFO, ADSR, Envelope, RandomWalk |
| Physics Models | KarplusStrong, CombFilter, FMOperator, Waveguide, ModalBank |
| Atoms | CrackleAtom, HissAtom, RumbleAtom, ImpactAtom |
| Output | Output, SoundBlender |
Material-to-Sound Mapping
The ParticleAudioBridge maps particle substance properties to audio parameters in real time. When particles burn, flow, or collide, sounds are generated procedurally:
- Temperature → pitch, brightness, crackle intensity
- Density → body/weight of the sound
- Velocity → whoosh intensity, impact force
- Phase → which procedural patch to use (fire, water, wind)
Spatial Audio
SpatialAudioEnvironment.js provides 3D positional audio with distance attenuation, reverb zones, and environmental effects. Sound sources are positioned in world space and attenuated based on listener distance.
Synthesis Modules
Waveguide
Bidirectional delay-line physical model for string and tube sounds. Supports damping, reflection, and excitation.
Modal Bank
Resonant filter bank with material presets (metal, glass, wood) using Bessel zeros for accurate modal frequencies.
Noise Generator
8 noise colors via Voss-McCartney algorithm: white, pink, brown, blue, violet, velvet, grey, and crackle.
Key Files
| File | Purpose |
|---|---|
audio/synth/WebAudioNodeFactory.js | Main-thread node creation (30+ types) |
audio/synth/NodeRegistry.js | Node type registry and categories |
audio/synth/nodes/WaveguideNode.js | Physical modeling waveguide |
audio/synth/nodes/ModalBankNode.js | Resonant modal bank |
audio/bridge/SubstanceAudioResolver.js | Material→audio parameter mapping |
sim/particles/ParticleAudioBridge.js | Particle→audio bridge (87K) |
audio/SpatialAudioEnvironment.js | 3D spatial audio (33K) |