Audio board automatic volume

Status
Not open for further replies.

pd0lew

Well-known member
Dear all,

I like to adjust the gain from the my CW decoder I use this code,

// GUItool: begin automatically generated code
AudioInputI2S i2sIn; //xy=231.25,88
AudioAmplifier amp1; //xy=435.25,80.25
AudioFilterBiquad iirIn; //xy=575.25,80
AudioRecordQueue inQueue; //xy=740.25,236
AudioAnalyzePeak peakIn; //xy=765.25,66
AudioConnection patchCord1(i2sIn, 0, amp1, 0);
AudioConnection patchCord2(amp1, iirIn);
AudioConnection patchCord3(iirIn, inQueue);
AudioConnection patchCord4(iirIn, peakIn);
AudioOutputI2S audioOutput;
AudioControlSGTL5000 sgtl5000; //xy=1253.25,103
// GUItool: end automatically generated code

Is this possible in the loop to adjust the gain?

Thanks in advance,
Johan

void loop {


if (input_level > 2 ) { amp1.gain(0.005);}

if (input_level < 1 ) { amp1.gain(0.01);}
}
 
As for each AGC, some delay and/or low pass filtering is recommended. I'd take the peak value of the input signal for that. Usually, an increasing peak value would lead to a relatively quick attenuation while a decreasing peak value would make the output signal go up somewhat slower. I remember that there were recommendations by the EBU for suitable time constants, but I can't find these just now.
 
Hi Johan,

there is some more general information on AGC in the Teensy Convolution SDR Wiki with figures for some time constants:

https://github.com/DD4WH/Teensy-ConvolutionSDR/wiki/AGC-(automatic-gain-control)

You can also find the source code there which implements the excellent AGC by Warren Pratt from the wdsp lib. However, that does not match with the audio library, but manipulates the samples directly.

For your CW decoder you should best follow the path Thierry pointed you to: use peak values and low pass filter them [value = old_value * 0.9 + new_value * 0.1 or something similar] and then decide if you attenuate quick or increase volume slowly.

All the best 73s,

Frank DD4WH
 
Status
Not open for further replies.
Back
Top