Here’s DFPWM, a 1-bit-per-sample compressed audio codec. Reference implementation is aucmp.py, C version is aucmp.c and audecmp.c, all public domain. Look at aucmp.py for a (totally not peer-reviewed) mathematical definition of the base encoder, as well as some suggestions to get rid of the whining and make it not look so high-pass filtered.
Is this the right codec for me?
Well, let’s look at what it’s not for:
- If you can’t stream your own audio to the sound card, this is not for you.
- If you’re an audiophile, run away now. It’s a fairly comprehensible codec, but it definitely sounds compressed (it tends to add noise).
- There are definitely better-quality codecs. This is supposed to be simple to implement.
Now, some stuff itcould be good for:
- Low-power CPUs. Note, a hardware multiply would help.
- Low-latency encoding. This encodes sample-per-sample.
- Really, really small audio data. Encoding at 16kHz gives you 2KB/s.
- Avoiding having dependencies for libogg/libvorbis – though these DO have better audio quality than this codec.
…Well, I’m not all too sure what the hell this’d be useful for, considering that most people in Ludum Dare can’t code at any level other than “as far away from the hardware as possible”, but it’s a suprisingly decent codec.
So, if you’re implementing voice chat for whatever reason, or you are limited by memory (storage and/or RAM), this might be the codec for you.