Close

µ-law audio compression

A project log for GPS Talking Clock

Accurate time without a display

nick-sayerNick Sayer 08/05/2019 at 18:170 Comments

There was never any reason to compress the audio back when it was on µSD cards. But flash rom SOIC chips aren't anywhere near as large. That's ok, though. You can get 16 MB flash chips, and the audio for the talking clock didn't need half that much space. But in the interest of reducing the BOM cost even further, I've investigated whether going from raw 12 bit audio to 8 bit µ-law encoded audio would work. It turns out it works just fine - the audio is half the size but the fidelity to my ear is exactly the same.

µ-law audio uses an exponential system for the quantization step. The closer to zero (µ-law is inherently signed. Our audio system requires unsigned values, so we also convert to unsigned as part of the decoding) a value is, the less difference there is between adjacent values. Values far from zero have a much wider separation.

The conversion used by the firmware is compatible with the mu-law codec in sox, which makes it particularly convenient to prepare audio samples. You just turn whatever your source audio is into raw 8 bit single channel 8kHz µ-law audio streams.

Discussions