Rust audio types and conversions.
An audio buffer can be cheaply converted to and from raw samples (i16, u8, f32, and f64) buffers, enabling interoperability with other crates.
Many audio formats are supported:
- Any integer sample rate (32 bits needed to support at least 96_000 Hz)
- Common bit depths (you can use 16-bit to fake 12-/10-/8-bit, as well as fake unsigned by XOR'ing the top bit)
- 16-bit Signed Integer PCM (Listening/publishing standard)
- 24-bit Signed Integer PCM (Older recording/processing standard)
- 32-bit Float PCM (Newer recording/processing standard)
- 64-bit Float PCM (Ultra high-quality audio standard)
- Up to 8 channels (following FLAC/SMPTE/ITU-R recommendations):
- 1 Channel: Mono (Mono)
- 2 Channels: Stereo (Left, Right)
- 3 Channels: Surround 3.0 (Left, Right, Center)
- 4 Channels: Surround 4.0 (FrontL, FrontR, SurroundL, SurroundR)
- 5 Channels: Surround 5.0 (FrontL, FrontR, Front, SurroundL, SurroundR)
- 6 Channels: Surround 5.1 (FrontL, FrontR, Front, Lfe, SurroundL, SurroundR)
- 7 Channels: Surround 6.1 (FrontL, FrontR, Front, Lfe, Back, Left, Right)
- 8 Channels: Surround 7.1 (FrontL, FrontR, Front, Lfe, BackL, BackR, Left, Right)
Getting Started
To understand some of the concepts used in this library, this MDN article is a good read (although the stuff about compression isn't relevant to this crate's functionality). This crate uses the MDN definitions for what an audio frame and audio channel are.
8-Bit Sawtooth Wave Example
use ;
use Mono;
use Audio;
let mut a = with_silence;
let mut counter = 0.0;
for f in a.iter_mut
let mut audio = with_audio;