Author Topic: DSP based envelope interpolation  (Read 3806 times)

Eb7+9

DSP based envelope interpolation
« on: June 08, 2014, 02:38:30 PM »
after exhaustively building/designing the plethora of comp/limiter designs available to us many have arrived at the conclusion that altering the VCA part of the design, while maintaining a ubiquitous approach to envelope detection (ie., peak-hold/exp-decay), does nothing  to eliminate the main set of problems associated with AGC audio designs, especially when they are operating at higher ratio levels ...

consequently, researchers have turned their attention to developing DSP based techniques to approximating (RMS) the envelope curve that accompanies audio signals // which in turn can be used to control an analogue based VCA, or remain in the digital realm (bleh ...)

the following paper does a good job at singling out the parameters and includes pertinent references ... as far as instrument AGC applications go I would think that trying to eliminate the "drop-out" artifact is the chief goal here // ... in which case a non-linear (lobe-step or slope-step) approach might be fruitful ... lots to discuss here, and a solution that could well be within practical grasp

http://www.eecs.qmul.ac.uk/~dimitrios/A%20Tutorial%20on%20dynamic%20range%20compression%20design.pdf
« Last Edit: June 08, 2014, 03:53:31 PM by Eb7+9 »

PRR

Re: DSP based envelope interpolation
« Reply #1 on: June 10, 2014, 02:01:42 AM »
Giannoulis et al make a lot of bald assertions, and cite a few excellent references.

You may also enjoy his MSc project:
http://c4dm.eecs.qmul.ac.uk/audioengineering/compressors/documents/Giannoulis.pdf
I have not read it; bedtime.

Barry Blesser wrote it up, and more, 45 years back:

Analysis Of A Feedback-Controlled Limiter Using A Logarithmic Measuring Scale
IEEE vol AU-16, No 4, Dec 1968

Audio Dynamic Range Compression For Minimum Perceived Distortion
IEEE vol AU-17, No 1, Mar 1969

Odd that these papers do not cite Barry. His project became a commercial product with very excellent audio control (well above the simplistic models in the slide-show).

earthtonesaudio

Re: DSP based envelope interpolation
« Reply #2 on: June 25, 2014, 09:01:01 PM »
In this type of Delta Sigma ADC the amount of compression is embedded in the bitstream, and can be un-done later if desired. A bit off-topic but when I saw Giannoulis say "generally not invertable" it reminded me of that.

Transmogrifox

Re: DSP based envelope interpolation
« Reply #3 on: September 09, 2014, 01:26:38 AM »
... while maintaining a ubiquitous approach to envelope detection (ie., peak-hold/exp-decay), does nothing  to eliminate the main set of problems associated with AGC audio designs, especially when they are operating at higher ratio levels ...

As a general statement I agree.  However, a DSP compressor opens the doors to many possibilities not easily realizable by analog circuits.  Combining peak-hold with low-pass filtering along with variable ratio seems to soften the abrupt changes when driving the unit into the higher compression regions.

Consider this:
Code: [Select]
for (i = 0; i<PERIOD; i++) { //apply compression to auxresampled
auxtempl = input * smpsl[i];
auxtempr = input * smpsr[i];
auxcombi = 0.5f * (auxtempl + auxtempr);
if(fabs(auxcombi) > compeak) {
compeak = fabs(auxcombi); //First do peak detection on the signal
timer = 0;
}
if(timer>hold) {
compeak *= prls;
timer--;
}
timer++;
compenv = cbeta * oldcompenv + calpha * compeak; //Next average into envelope follower
oldcompenv = compenv;
if(compenv > cpthresh) { //if envelope of signal exceeds thresh, then compress
compg = cpthresh + cpthresh*(compenv - cpthresh)/compenv;
cpthresh = cthresh + cratio*(compg - cpthresh); //cpthresh changes dynamically
tmpgain = compg/compenv;
} else {
tmpgain = 1.0f;
}
if(compenv < cpthresh) cpthresh = compenv;
if(cpthresh < cthresh) cpthresh = cthresh;
smpsl[i] = auxtempl * tmpgain * level;
smpsr[i] = auxtempr * tmpgain * level;
};
//End compression

The main point is it's a combination of several principles:
Envelope detector:  Holdoff preceding each decay prevents premature change in envelope due to pulsating rectified audio frequency tones (not far different from the round-robin peak hold detector).
Compression Curve:  Not log-linear, but rather continuously increasing compression ratio, so the let-off is even less abrupt.
Attack/release:  I found atk/rls symmetrically of about 75ms best, and just hard-coded it.  Because of the adaptive compression curve, the atk/rls characteristic is sympathetic to the gain change characteristic.  More could be done here to dynamically modify the atk/rls according to dynamics as well as program material spectral composition -- if the envelope harmonically correlates to the program material, then the results will be less muddy at high compression ratios.

Basically this compressor works like a distortion pedal.  You have a pre-drive (gain) control on the input, and an output volume to attenuate the output.  The threshold is fixed since this is arbitrary and meaningless in a variable-ratio system.  You want lots of compression:  drive the input with lots of gain.  Mild compression?  Input mild signal levels (lower gain).

It is a stereo compressor, but mono is as simple as eliminating the left channel.  This algorithm is intentionally very interactive and the resulting curve was developed in a very non-scientific manner:  I graphed the output until I liked the way the curve made me feel == very "artistic" :/

Well, despite the non-scientific means of developing this, it is really well suited as a guitar compressor.  I originally developed it as a microphone input compressor to a DSP Vocoder I created for Rakarrack:
http://sourceforge.net/p/rakarrack/git/ci/master/tree/src/Vocoder.C
Then made it into a guitar compressor effect .

Probably not too hard to re-factor it into a fixed-point architecture.  The divisions are the most painful operations to work around.  Food for thought anyway.  

If anybody shows interest I can record some audio samples. If you have Linux, just use Rakarrack "Sustainer" effect and you have this algorithm as written.  I'm hoping to succeed at implementing this in an MSP430.  Won't be the highest quality implementation due to sample clock jitter, 12-bit sampling and dubious A/D conversion, but it wouldn't be as much fun if there wasn't any challenge to it.  If it sounds too bad then maybe only sidechain processing will be done in the MSP430 and then it will be analog slew-rate limited 12-bit gain control.
« Last Edit: September 09, 2014, 01:33:00 AM by Transmogrifox »
trans·mog·ri·fy
tr.v. trans·mog·ri·fied, trans·mog·ri·fy·ing, trans·mog·ri·fies To change into a different shape or form, especially one that is fantastic or bizarre.

Digital Larry

Re: DSP based envelope interpolation
« Reply #4 on: September 10, 2014, 12:11:20 AM »
Thanks for this... I'm currently geeking out on digital phase shifter design... filters next... why not add dynamics to the mix?  Keeps me out of jail.
Digital Larry
DSP tinkerer and former transistor twister

Transmogrifox

Re: DSP based envelope interpolation
« Reply #5 on: September 10, 2014, 10:16:29 AM »
Keeps me out of jail.
Yeah, this stuff probably keeps most of us out of trouble at the very least :)
trans·mog·ri·fy
tr.v. trans·mog·ri·fied, trans·mog·ri·fy·ing, trans·mog·ri·fies To change into a different shape or form, especially one that is fantastic or bizarre.