HardwareHeaven.com
Looking for the skin chooser?
 
 
  • Home

  • Reviews

  • Articles

  • News

  • Tools

  • GamingHeaven

  • Forums

  • Network

 

Go Back   HardwareHeaven.com > Forums > Hardware and Related Topics > kX Project Audio Driver Support Forum > Effects and the DSP


Reply
 
Thread Tools
Old Mar 27, 2003, 07:24 PM   #1
DriverHeaven Addict
 
Join Date: Dec 2002
Posts: 259
Rep Power: 0
eyagos is on a distinguished road

Automatic Gain Control (AGC)

Well, I have writed a pluging to avoid clipping produced in any effect. The method is very very simple: Just attenuates the signal a little each time a clip is detected. There are several things:

1.- It was designed to be intercalated between ecualizer and epilog, with the purpose of automatically reduce the gain until the maximum value wich don't produce clipping.

2.- It has a "memory" of one sample. This is, looks at the inmediately previous (stored in a variable) sample and if it is grater than 0.24 [0.25 = clip] reduce the gain in ~0.3 dB. There is no noticiable audio effect.

3.- It is not a compressor or a limiter: It reduces the gain for all the sound. This is, no distortion is produced.

4.- The pluging only reduces gain, and this gain remain untouched 'per seculam seculorum', although the ecualizer parameters are changed.

5.- There is a control in the tweak window to reset gain to 0dB. Could it be possible to "link" or "sincronize" this control with any change made in the ecualizer tweak window (via the dll).

Here you have the dll: agc.kxl (see next post)
(compiled for the 3531 version)

Last edited by eyagos; Mar 27, 2003 at 11:14 PM.
eyagos is offline   Reply With Quote


Old Mar 27, 2003, 11:13 PM Threadstarter Thread Starter   #2
DriverHeaven Addict
 
Join Date: Dec 2002
Posts: 259
Rep Power: 0
eyagos is on a distinguished road

Sorry, I have have put the incorrect version. Download this one and forget the other: agc_1.kxl
eyagos is offline   Reply With Quote
Old Mar 29, 2003, 04:32 PM Threadstarter Thread Starter   #3
DriverHeaven Addict
 
Join Date: Dec 2002
Posts: 259
Rep Power: 0
eyagos is on a distinguished road

If someone has proved the AGC, can you please post some coments??
eyagos is offline   Reply With Quote
Old Apr 6, 2003, 09:29 AM   #4
DriverHeaven Newbie
 
Join Date: Dec 2002
Location: Ottawa, Ontario, Canada
Posts: 19
Rep Power: 0
surealsurrender is on a distinguished road

AGC

Nice work on this plugin... it works well for me when tweaking the EQ on the final output to mains... just eq away and let the plugin take care of any clipping may occur, perfect!

Nice Work

Sur
surealsurrender is offline   Reply With Quote
Old Jun 11, 2003, 04:02 AM Threadstarter Thread Starter   #5
DriverHeaven Addict
 
Join Date: Dec 2002
Posts: 259
Rep Power: 0
eyagos is on a distinguished road

The abobe link doesn't work. You can download this plugin from my Web Site:

KXPlugins (sorry, only available in spanish)
eyagos is offline   Reply With Quote
Old Jul 22, 2003, 10:51 PM Threadstarter Thread Starter   #6
DriverHeaven Addict
 
Join Date: Dec 2002
Posts: 259
Rep Power: 0
eyagos is on a distinguished road

Hi LeMury.

Yes, that is "the other version". I mean, that is the first version I writed and, by mistake, it is the one included in the .da version you can download from the Web. And yes, it has two temporal registers unused/unneeded, so the one you posted is better.

But the .kxl version is different (as I said at the top this was my mistake):

* In the .kxl version you calculate the max value between the two stereo channels to detect clips.
* And in the other version (the one you use) you calculate the mean value between the two stereo channels to detect clips.

Both options are very close, but if the stereo is not balanced, the mean value does not assure you that there is no clip in the louder channel. So, the code used in the .kxl version is this (two code lines and two registers more):

Quote:
; Generated by kX DSP Editor - microcode dump
name "AGC";
copyright "by eYagos, copyright (c) 2003.";
engine "kx";
created "02/19/2003";
comment "Automatic Gain Control: Gain is reduced 0.3dB each time a clip is detected";
guid "f89b1669-e4e7-4e1c-a883-b9e7d997278c";

; Registers
input in1, in2;
output out1, out2, o_gain;
static gain=1;
static x1=0;
control clip=0.24, inc=0.96;
temp tmp, tmp1, tmp2;
temp tmp3, tmp4

; Code
macs tmp1, 0x0, in1, 1;
macs tmp2, 0x0, in2, 1;

tstneg tmp3, tmp1, tmp1, 0;
tstneg tmp4, tmp2, tmp2, 0;
limit tmp3, tmp3, tmp3, tmp4;

macsn tmp, x1, clip, 1;
skip ccr, ccr, 0x4, 0x1;
macs gain, 0, gain, inc;
macs x1, 0, tmp3, gain;

macs out1, 0, tmp1, gain;
macs out2, 0, tmp2, gain;
macs o_gain, 0, gain, 0.25;

end
Note: I have noticed that this code can be optimized too, saving one temporal register ('tmp' register is not needed, and 'tmp4' could be used instead).


And of course, I'll not get angry if you modify the code. In the other hand, I'll be very pleased.

Regards, and keep on the wave.
eyagos is offline   Reply With Quote
Old Jul 22, 2003, 11:52 PM   #7
DH Senior Member
 
Join Date: Jan 2003
Location: The Netherlands
Posts: 1,930
Rep Power: 62
Lex Nahumury is just really niceLex Nahumury is just really niceLex Nahumury is just really niceLex Nahumury is just really nice

Hi Eyagos,

Thank you for confirming.

Yes I noticed your .kxl version functioned different/better. Nice work!


>I have noticed that this code can be optimized too, saving one temporal register ('tmp' register is not
>needed, and 'tmp4' could be used instead).

Yes, and you can also re-use 'x1' , saving 1 more gpr like this:
macsn x1, x1, clip, 1
....etc.

>And of course, I'll not get angry if you modify the code. In the other hand, I'll be very pleased.
Ah,..ok.. I am very glad about that.

Next time I will send you a private message ok?

Regards,

/LeMury
Lex Nahumury is offline   Reply With Quote
Old Jul 29, 2003, 02:57 PM   #8
DriverHeaven Newbie
 
Join Date: Mar 2003
Location: 52°20'26" N , 9°22'40" E
Posts: 10
Rep Power: 0
MiskyWhixer is on a distinguished road

Hi...

First, this is a very nice plugin!
Thanks eyagos!
I'm not well versed in coding plugins, so I've a question.
What is the "o_gain" output for?
MiskyWhixer is offline   Reply With Quote
Reply

Bookmarks

Thread Tools