Close

Added u-law encoding support

A project log for Drum Master

Electric drum set based on Teensy 3.1 and Audio Board

the-big-oneThe Big One 01/27/2016 at 18:030 Comments

In an effort to give myself even more room, I implemented u-law encoding support in the play_serialflash_raw audio objects. For those who had not heard of this encoding method before, u-law (or µ-law or mu-law, a.k.a. a version of G.711 standard) is an 8 bit telephony encoding scheme which relies on the fact that human hearing is logarithmic to reproduce better sounding audio with less space needed. The implementation is just a lookup table, so very little processor requirements. Theoretically it gives you about 14 bits of data in 8 bit space, which sounds wonderful. Wikipedia knows all if you are interested in more details.

I found that in practice, this works very well for some sounds, and not well at all for others. In general, higher pitched sounds with low resonance tend to work well; I found that all of my cymbal samples could be encoded in u-law and I would be unable to differentiate between that and 16-bit PCM. However, drums (especially the lower drums, like the toms and bass) sound very bad.

Given that my cymbals constitute the majority of the samples by size, though, this works out very well for me. After picking and choosing samples that work with the new encoding scheme, I was able to reduce my sample set from 120MB to 77MB. This will give me lots more room for other samples and more kits to choose from at run time!

Discussions