Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Audio board automatic volume

  1. #1
    Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    41

    Audio board automatic volume

    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);}
    }

  2. #2
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    1,895
    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.

  3. #3
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    304
    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-Conv...-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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •