[music-dsp] Musical signal AGC (compressor..normalizer)

Rob Belcham robbelcham at blueyonder.co.uk
Sat Jan 17 04:27:00 EST 2004


Hi Alex,

I've recently developed a software AGC for a dj product I was working on. I
used a simple peak meter with a very slow release followed by a bit of PD
control logic (proportional + differential). The secret is getting the
attack and decay coeffs right - you want the gain to turn down quickly when
your input is over the threshold, but to increase very slowly when below the
threshold.

I run the meter at the audio sample rate but only do the gain calculations
every couple of ms.

The basic idea of the ACG calculations is shown below. You'll need to tweak
the coefficients to your application but it should get you started. I was
pretty happy with the results I got.

Regards
Rob


meter = peak meter reading
target = target level
gain = gain coefficient
prop_const_inc = Proportional control coefficient when increasing gain
prop_const_dec = Proportional control coefficient when decreasing gain
diff_const_dec = Differetial control coefficient when decreasing gain
quickly

if (peak > MIN_AGC_THRESHOLD) // Dont amplify the noise floor!
{
	err = meter - target;		// Error signal
	ddt_err = err - last_err;	// Differential error signal
	last_err = err;

	if (err < 0)	// If too quiet
	{
		gain -= err * prop_const_inc;	// Turn up
	}
	else
	{
		gain -= err * prop_const_dec;	// Turn down
		if (ddt_err > DIFF_THRESH)	// If signal is over threshold and still
increasing
		{
			gain -= ddt_err * diff_const_dec;	// Reduce gain much quicker
		}
	}
	// Then limit gain coefficient to some sensible range.
}


> -----Original Message-----
> From: music-dsp-admin at shoko.calarts.edu
> [mailto:music-dsp-admin at shoko.calarts.edu]On Behalf Of Alex Raider
> Sent: 14 January 2004 23:00
> To: Ross Bencina
> Subject: Re[2]: [music-dsp] Musical signal AGC (compressor..normalizer)
>
>
> Hi.
>
> >> I tried to program Automatic Gain Control
> >> Can anyone suggest me better technique than I used?
>
> RB> Hi Alex:
> RB> http://www.tml.hut.fi/~pjhamala/dafx2002/dafx_hamalainen.pdf
> RB> That's for a lookahead limiter.
>
> Thanx for a link.
>
>                             -n
> Really he does src signal  Z   delay line, not lookahead.
> The paper is very basic, I myself to hit upon an ideas described in
> this paper, because if one is patient enough to closely examine
> matlab`s plots, he come to a conclusion
> that envelope is slightly lags (phase shift)
> and attack/delays behaviour should be improved in adaptive manner.. ;-)
> I not a person who don`t realise such techniques, I am person who like
> a details :-)
>
> RB> But if you want to level whole tracks perhaps you should do a
> global RMS
> RB> scan on each file and normalize each track according to
> average level rather
> RB> than using a time-varying algorithm.
>
> CoolEdit does same thing.
>
> RB> Best wishes
> RB> Ross.
>
> Seems for me, that dumb RMS for 50 ms look-ahead buffer without
> filter does better work than any combination of power estimator +
> filter(smoother), because RMS is already does mean/averaging
> along look-ahead area.
> I would test it using running summ RMS.
>
>
> --
> State of the Art!
>  Flash inc. Alex Raider
>
> dupswapdrop -- the music-dsp mailing list and website:
> subscription info, FAQ, source code archive, list archive, book
> reviews, dsp links
> http://shoko.calarts.edu/musicdsp
> http://ceait.calarts.edu/mailman/listinfo/music-dsp
>




More information about the music-dsp mailing list