High-performance WAV (PCM) parser and packet decoder in Rust, with runtime SIMD dispatch and a streaming API.
wave_rush is a systems-focused Rust project built to demonstrate:
- Binary format parsing with strict boundary and overflow checks.
- Performance-oriented audio decoding with AVX2/SSE4.1/scalar backends.
- Streamed processing of large files without loading everything into memory.
- Test coverage for parser behavior, decoder equivalence, and fuzz-style random inputs.
- Parses RIFF/WAVE headers and chunks (
fmt,data,LIST/INFO,fact). - Decodes PCM samples to
i32packets viaFallibleStreamingIterator. - Supports PCM bit depths:
8,16,24, and32. - Extracts
LIST/INFOmetadata intoHashMap<String, String>. - Uses aligned buffers (
aligned-vec) for SIMD-friendly packet decoding. - Performs runtime decoder selection on x86_64:
AVX2when availableSSE4.1otherwise- Scalar fallback
- Container: RIFF/WAVE
- Audio format: PCM (
audio_format = 1) - Bit depths: 8/16/24/32-bit
- Endianness: little-endian PCM
- Non-PCM formats are rejected.
WAVE_FORMAT_EXTENSIBLEis not implemented yet.- Current demo executable reads from a fixed
input.wavpath insrc/main.rs.
- Rust stable toolchain (see
rust-toolchain.toml).
- Place a WAV file named
input.wavin the project root. - Run:
cargo run --releaseuse std::fs::File;
use wave_rush::{FallibleStreamingIterator, Result, WavDecoder, WavReader};
fn decode_file(path: &str) -> Result<()> {
let file = File::open(path)?;
let reader = WavReader::try_new(file)?;
let mut decoder = WavDecoder::try_new(reader)?;
let mut packets = decoder.packets()?;
while let Some(packet) = packets.next()? {
// packet: &[i32] with interleaved samples
let _ = packet;
}
Ok(())
}cargo fmt
cargo clippy --all-targets --all-features -- -D warnings
cargo testsrc/lib.rs: WAV parser, metadata handling, decoders, and tests.src/main.rs: minimal executable example.docs/wave_specification.html: local WAV format reference.
- Chunk parsing validates boundaries and alignment bytes.
- Metadata parsing includes limits (
MAX_TAGS, max tag size) to mitigate malformed input risks. - Integer arithmetic uses checked operations where overflow could occur.
Active prototype suitable for portfolio/CV presentation and further extension (CLI args, extensible WAV support, benchmarking, CI).
No license file is currently included in this repository.