hound icon indicating copy to clipboard operation
hound copied to clipboard

support mulaw format

Open xd009642 opened this issue 1 year ago • 1 comments

So mulaw is still commonly used in domains like telephony and I found recently when integrating with some voip platforms that hound doesn't support the sample format. mulaw is basically a sigmoidal instead of linear curve on the samples so data towards the middle ranges is more accurately encoded than at the edges meaning you can approach 16 bit quality while just using 8 bit via a lossy compression. There's no state tracking so I guess just a wrapper type could suffice.

I think only 8 bit and 16 bit mulaw are common so there's no need to go further than that and cover a mulaw version of every integer sample format but I can look deeper into it. I've only personally seen 8 bit mu law.

Other relevant issue would be the adpcm one given this is another different sample format: https://github.com/ruuda/hound/issues/45

Example wav file which is just a short amount of silence silence.zip

xd009642 avatar Jul 18 '24 08:07 xd009642

I've written audio-codec-algorithms, which includes a decoder and encoder for μ-Law and A-Law. It also includes a decoder and encoder for 4-bit IMA ADPCM. I've been using them in my aifc and ausnd audio readers and writers.

If you want, you can use audio-codec-algorithms in hound to compress/decompress audio samples. The crate uses a very liberal 0BSD license, so you can use the crate as a dependency or just copy the code to hound. For instance, decoding μ-Law or A-Law is just a 256 item lookup table.

karip avatar Jan 23 '25 08:01 karip