xlaw

Crates.ioxlaw
lib.rsxlaw
version0.0.3
created_at2025-05-14 19:11:33.13252+00
updated_at2025-05-16 12:26:39.718311+00
descriptionPCM-aLaw and PCM-MuLaw codecs.
homepage
repositoryhttps://github.com/0xAA55-rs/xlaw
max_upload_size
id1673854
size32,981
0xaa55 (0xAA55)

documentation

README

XLaw - aLaw and μLaw PCM codecs

PCM-aLaw and PCM-MuLaw codecs.

Overview

The usage is very simple.

let alaw_encoder = PcmXLawEncoder::new_alaw();

let samples = vec![1i16, 30000i16, 500i16, -30000i16];
let mut encoded = Vec::<u8>::new();

for sample in samples {
	encoded.push(alaw_encoder.encode(*sample));
}

There are also PcmXLawDecoder, new_alaw(), and new_ulaw() to create them, and the encode() and decode() functions are just as easy as you want.

Simply, they do encode i16 samples into u8 codes, and decode u8 codes into i16 samples.

Personally, I'd prefer not to use these encoders. Just convert the WAV s16le PCM to the u8 PCM. My supreme sound card can handle u8 playback, its DSP functions can restore the u8 sound just like you are hearing the i16 format sample audio.

Commit count: 8

cargo fmt