xbadpcm 0.1.1

Free 100% Rust Xbox ADPCM encoder and decoder
Documentation
  • Coverage
  • 81.82%
    9 out of 11 items documented1 out of 1 items with examples
  • Size
  • Source code size: 60.08 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 999.22 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • SnowyMouse/xbadpcm
    8 0 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • SnowyMouse

XbadPCM

Safe (and optionally no-std) Rust crate for encoding and decoding Xbox ADPCM blocks.

Decoding example

Here is example code for decoding stereo audio.

use xbadpcm::{XboxADPCMDecoder, XboxADPCMDecodeSink};

let adpcm_data = read_some_adpcm_blocks();
let mut output = [Vec::new(), Vec::new()];

// Two channels
let mut encoder = XboxADPCMDecoder::new(2, &mut output);

// Decode
encoder.decode(&adpcm_data).unwrap();

assert!(!output[0].is_empty() && output[0].len() == output[1].len());

Encoding example

Here is example code for encoding stereo audio.

use xbadpcm::{XboxADPCMEncoder, XboxADPCMEncodeSink};

let (left_channel, right_channel) = read_some_pcm_samples();
let mut output = Vec::new();

// Two channels with a lookahead of three samples
let mut encoder = XboxADPCMEncoder::new(2, 3, &mut output);

// Encode
encoder.encode(&[&left_channel, &right_channel]).unwrap();

// Finish encoding
encoder.finish().unwrap();

assert!(!output.is_empty());

No-std support

The crate is fully functional without the Rust Standard Library, but it is enabled automatically to provide traits for XboxADPCMEncodeSink and XboxADPCMDecodeSink on vectors.

To disable using the standard library, put default-features = false in the dependency declaration in your Cargo.toml. See Features - The Cargo Book for more information.

Acknowledgements

The encoder is based off of David Bryant's ADPCM-XQ encoder, an IMA-ADPCM encoder which can be found on GitHub at dbry/adpcm-xq.