Audioadapter Buffers
Wrappers and buffers for audio data implementing the audioadapter traits
Repository Health
Technical Analysis
Audioadapter Buffers (audioadapter-buffers) is a Rust crate in the audioadapter family that provides a selection of wrappers and buffers for audio sample data. It implements the core audioadapter traits over common data structures such as slices and vectors, so audio and DSP code can read and write samples through a uniform interface regardless of how the underlying data is laid out.
The crate offers direct wrappers that pass sample values through unchanged when data is already in a usable format and only the memory layout (interleaved versus sequential) needs handling, as well as converting adapters that translate between integer PCM and floating-point representations. It supports both owned buffers and borrowed slices, and works in no_std environments.
What You Get
- Direct wrappers (InterleavedSlice, sequential variants) over slices and vectors
- Owned buffer types plus borrowed-slice adapters
- Converting adapters between integer PCM and floating-point samples
- Uniform sample read/write access via the audioadapter Adapter trait
- no_std support and benchmarks via Criterion
Common Use Cases
- Wrapping an existing interleaved audio buffer to process channels and frames uniformly
- Converting between i16/i32 PCM and f32/f64 samples in a DSP pipeline
- Abstracting over interleaved vs sequential layouts in audio processing code
Under The Hood
Architecture - The crate is organized into layout-focused modules: direct and owned provide pass-through wrappers over borrowed slices and owned buffers respectively, while adapter_to_float and number_to_float implement converting adapters between integer PCM and floating-point sample types. slicetools supplies helper operations over sample slices, and lib.rs re-exports the public surface. All types implement the Adapter traits from the core audioadapter crate so consumers program against a single interface.
Tech Stack - Pure Rust (edition 2021, minimum Rust 1.74), depending on num-traits for numeric abstraction and on the sibling audioadapter and audioadapter-sample crates for the trait definitions and sample-format conversions. It is no_std-capable, gating the standard library behind a default std feature, and uses Criterion for benchmarking.
Code Quality - Test code lives inline within the source modules (owned, direct, number_to_float, adapter_to_float, slicetools all contain tests), giving per-module coverage of the wrapper and conversion behavior. An iteration benchmark harness measures sample-access performance. The crate is small, focused, and maintained by the author of the broader audioadapter and CamillaDSP projects.
API Design - The API is minimal and ergonomic: constructing InterleavedSlice::new(&data, channels, frames) yields an adapter whose channels(), frames(), and read_sample(channel, frame) methods read naturally in nested loops. The README documents each module with runnable examples, and because everything routes through the shared audioadapter traits, swapping buffer types requires no change to processing code.