2020-01-28 15:06:43 -05:00
|
|
|
//
|
|
|
|
// cagc.h
|
|
|
|
// ambed
|
|
|
|
//
|
|
|
|
// Created by Jean-Luc Deltombe (LX3JL) on 26/04/2017.
|
|
|
|
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
|
|
|
|
//
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// This file is part of ambed.
|
|
|
|
//
|
|
|
|
// xlxd is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// xlxd is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
// ----------------------------------------------------------------------------
|
2020-01-29 11:30:22 -05:00
|
|
|
// Geoffrey Merck F4FXL / KC3FRA AGC code largely inspired by Liquid DSP
|
2020-01-28 15:06:43 -05:00
|
|
|
// Only took the parts we need qnd recoeded it to be close the XLX coding style
|
2020-01-29 14:02:03 -05:00
|
|
|
// https://github.com/jgaeddert/liquid-dsp/blob/master/src/agc/src/agc.c
|
2020-01-28 15:06:43 -05:00
|
|
|
|
|
|
|
#ifndef cagc_h
|
|
|
|
#define cagc_h
|
|
|
|
|
|
|
|
#include "main.h"
|
|
|
|
|
|
|
|
class CAGC
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//Constructor
|
|
|
|
CAGC(float initialLeveldB);
|
|
|
|
|
|
|
|
//methods
|
|
|
|
void Apply(uint8 * voice, int size);
|
2020-01-29 11:30:22 -05:00
|
|
|
float GetGain();//gets current gain
|
2020-01-28 15:44:51 -05:00
|
|
|
|
2020-01-28 15:06:43 -05:00
|
|
|
private:
|
2020-01-29 13:57:12 -05:00
|
|
|
float m_Gain; // current gain value
|
|
|
|
float m_GainMax, m_GainMin; //gain clamping
|
|
|
|
float m_targetEnergy; // scale value for target energy
|
2020-01-28 15:06:43 -05:00
|
|
|
|
|
|
|
// gain control loop filter parameters
|
2020-01-29 13:57:12 -05:00
|
|
|
float m_Bandwidth; // bandwidth-time constant
|
|
|
|
float m_Alpha; // feed-back gain
|
2020-01-28 15:06:43 -05:00
|
|
|
|
|
|
|
// signal level estimate
|
2020-01-29 13:57:12 -05:00
|
|
|
float m_EnergyPrime; // filtered output signal energy estimate
|
2020-01-28 15:06:43 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* cgc_h */
|