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:

CategoryNode Types
GeneratorsOscillator, Noise, GrainCloud
ProcessorsFilter, Delay, Reverb, Compressor, Waveshaper
ModulatorsLFO, ADSR, Envelope, RandomWalk
Physics ModelsKarplusStrong, CombFilter, FMOperator, Waveguide, ModalBank
AtomsCrackleAtom, HissAtom, RumbleAtom, ImpactAtom
OutputOutput, 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:

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

FilePurpose
audio/synth/WebAudioNodeFactory.jsMain-thread node creation (30+ types)
audio/synth/NodeRegistry.jsNode type registry and categories
audio/synth/nodes/WaveguideNode.jsPhysical modeling waveguide
audio/synth/nodes/ModalBankNode.jsResonant modal bank
audio/bridge/SubstanceAudioResolver.jsMaterial→audio parameter mapping
sim/particles/ParticleAudioBridge.jsParticle→audio bridge (87K)
audio/SpatialAudioEnvironment.js3D spatial audio (33K)