| Crates.io | xlaw |
| lib.rs | xlaw |
| version | 0.0.3 |
| created_at | 2025-05-14 19:11:33.13252+00 |
| updated_at | 2025-05-16 12:26:39.718311+00 |
| description | PCM-aLaw and PCM-MuLaw codecs. |
| homepage | |
| repository | https://github.com/0xAA55-rs/xlaw |
| max_upload_size | |
| id | 1673854 |
| size | 32,981 |
PCM-aLaw and PCM-MuLaw codecs.
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.