The pieces / weirdnet-audio-engine

weirdnet-audio-enginenew

Audio output: the boundary between audio code and a device, a scene renderer and live engine, a fan-in router, a waveform player, and a cpal device sink.

v0.5.0 GitHub crates.io docs.rs weirdnet-audio-engine = "0.5.0"

What it is

Platform code lives behind one trait; everything above it is platform-free and testable without a sound card. The render function fills an interleaved f32 buffer on the audio thread and must not block, lock or allocate; a sink that cannot run the exact config returns SinkError::UnsupportedConfig instead of silently running at another rate.

Key types and modules

  • AudioSink, ManualSink (no device: the caller pulls blocks, so engine code is deterministic to test) and CpalSink (feature cpal: ALSA on Linux, AAudio on Android, and the other platforms cpal supports; feature pipewire adds its native PipeWire backend).
  • Scene and SceneRenderer: sounds plus events sorted by frame, mixed block by block from a fixed pool of 64 voices; a looping scene wraps on its exact frame. engine returns an Engine for the control thread and an EngineAudio for the device callback, with commands through a bounded lock-free queue and a dry bus tap.
  • render_offline and render_to_end: the same mixer without a device, so an export matches live playback sample for sample.
  • WaveformPlayer: plays one waveform from weirdnet-media with play, pause, seek, loop and gain from any thread.
  • router: a fan-in router of named endpoints (audio-thread sources, inputs fed from another thread, buses, taps and the device) with routes that carry gain, mute and solo, per-destination limiters and peak reports. With the feature route, RouterControl implements the weirdnet-audio-route Executor.

Usage

[dependencies]
weirdnet-audio-engine = "0.5.0"

Where it fits

Version 0.5.0 is on crates.io (docs.rs, repository). cargo test never opens an audio device; the device tests refuse to run unless the audio server is a private one.