Skip to content

WebAudio Engine

MixiEngine

Singleton audio engine at 44,100 Hz. See Architecture for the complete signal chain.

Memory Management

  • Buffer limit: 200 MB max per session
  • Node pooling: AudioBufferSourceNode instances are stopped, disconnected, and dereferenced after use
  • Waveform cache: Analyzed waveform data cached after first analysis to avoid re-computation

Audio Analysis Queue

Track analysis (waveform, BPM, key) is serialized via a queue to avoid hitting the browser's limit of ~6 concurrent OfflineAudioContext instances.

Wasm DSP Bridge

Optional Rust/WebAssembly signal chain running entirely on the audio thread.

Initialization

  1. Check SharedArrayBuffer + Atomics support (requires COOP/COEP headers)
  2. Register AudioWorklet processor (mixi-dsp-worklet.js)
  3. Create 2-input worklet node (Deck A = input 0, Deck B = input 1)
  4. Create shared buffers (audio ring + param bus + metering bus)
  5. Fetch and compile Wasm module
  6. Send compiled module to worklet via postMessage
  7. Wait for ready confirmation (5 second timeout, fallback to native WebAudio)

Shared Memory Layout

BufferSizeDirectionPurpose
audioRing32,776 bytesMain → WorkletSPSC ring buffer (~93 ms at 44.1 kHz)
paramBus512 bytesBidirectionalAll DSP parameters (see below)
meteringBus28 bytesWorklet → Main7 floats: peakL, rmsL, peakR, rmsR, masterPeak, masterRms, limiterGR

Parameter Bus Layout (512 bytes)

Per-Deck (bytes 0–127 for A, 128–255 for B):

OffsetParameterDefault
+0Trim1.0
+4EQ Low0 dB
+8EQ Mid0 dB
+12EQ High0 dB
+16Fader1.0
+20Crossfader Gain(computed)
+24Color FX FrequencyHz
+28Color FX ResonanceQ
+32CUE Active0/1
+36Playback Rate1.0
+40–96FX params (filter, delay, reverb, phaser, flanger, gate)per-FX

Master (bytes 256–383):

OffsetParameterDefault
256Gain1.0
260Filter0 (bypass)
264Distortion0
272Punch0
280Limiter Active1
284Limiter Threshold-1 dB

Global (bytes 384–511):

OffsetParameter
384Crossfader position
388Crossfader curve (0=smooth, 1=sharp, 2=constant)
392Headphone mix
396Headphone level
400Sample rate
508Layout version (must match Rust)

DSP Modules in Wasm

The Rust engine implements the full signal chain:

  • 3-band EQ (per deck)
  • Color FX filter (per deck)
  • Per-deck FX: Filter, Delay, Reverb, Phaser, Flanger, Gate
  • Master: Gain, Filter, Distortion, Punch compressor, Limiter
  • Crossfader with 3 curve types
  • Headphone/CUE monitoring
  • Auto-gain per deck
  • Metering: per-channel peak/RMS, master peak/RMS, limiter gain reduction

Opt-in

The Wasm DSP path defaults to off. Enable it in Settings. When active, it bypasses the native WebAudio EQ/FX/MasterBus nodes entirely.

AudioWorklets

WorkletFilePurpose
mixi-dsp-processormixi-dsp-worklet.jsFull Rust/Wasm signal chain
diode-ladder-processordiode-ladder-processor.jsTurboBass 4-pole diode ladder filter
recording-taprecording-tap.jsDisk recording bridge (WAV, crash-proof)

Recording

Format

WAV, 32-bit float PCM, stereo, 44,100 Hz. Tapped post-limiter from master bus output.

Architecture

Crash-proof ring buffer design:

  • 131,072 frames capacity (~3 seconds)
  • Fixed ~1 MB RAM regardless of recording length
  • Flush interval: 500 ms
  • Temp file survives crashes; orphan recovery available

Features

  • Start/stop/cancel
  • Save As via native dialog
  • Cue marks during recording
  • Orphan recovery for crashed sessions

Electron Only

Recording requires the Electron desktop app with SharedArrayBuffer support.