DSPRelated.com
Forums

Applying Dynamic Range Compression to a PCM stream?

Started by Rich Fife June 1, 2006
Does anyone have a functioning example of how to apply DRC to a PCM
stream on the fly?  This is the stuff you might see on your stereo
labeled "Night Mode" that reduces peak volumes while leaving passages
that are at normal volume alone.

I can kind of wing it, but I'd like to do it right (When should I be in
log scale and when in linear?) and I can't find any good documentation
online.  C code is best, but an algorithm is plenty.

Thanks!

   -- Rich Fife --

Rich Fife wrote:
> > I can kind of wing it, but I'd like to do it right
> (When should I be in log scale and when in linear?)
if you like implementing power functions, you can do it in the linear amplitude world. but i think doing the gain calculation in the log world is conceptually easier. and there are fast approximations to log() and exp() that can make it work efficiently.
> and I can't find any good documentation > online. C code is best, but an algorithm is plenty.
Harmony Central can be your friend: http://en.wikipedia.org/wiki/Audio_level_compression http://www.harmony-central.com/Effects/effects-explained.html http://www.harmony-central.com/Effects/Articles/Compression/ http://www.harmony-central.com/Effects/Articles/Expansion/ for specific algorithms to measure the non-stationary amplitude, you have to be more specific about what you want to compress. peak level? rms? psycho-acoustically weighted rms? r b-j