mirror of https://github.com/LX3JL/xlxd.git
commit
c8e28e77d6
@ -0,0 +1,94 @@
|
|||||||
|
//
|
||||||
|
// cagc.cpp
|
||||||
|
// ambed
|
||||||
|
//
|
||||||
|
// Created by Jean-Luc Deltombe (LX3JL) on 28/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/>.
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Geoffrey Merck F4FXL / KC3FRA AGC code borrowed from Liquid DSP
|
||||||
|
// Only took the parts we need qnd recoeded it to be close the XLX coding style
|
||||||
|
// https://github.com/jgaeddert/liquid-dsp/blob/master/src/agc/src/agc.c
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include "cagc.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// constructor
|
||||||
|
|
||||||
|
CAGC::CAGC(float initialLeveldB)
|
||||||
|
{
|
||||||
|
// set internal gain appropriately
|
||||||
|
m_Gain = pow(10.0f, initialLeveldB/20.0f);
|
||||||
|
//+- 10dB Margin, TODO Move margin to constant
|
||||||
|
m_GainMax = pow(10.0f, (initialLeveldB + AGC_CLAMPING)/20.0f);
|
||||||
|
m_GainMin = pow(10.0f, (initialLeveldB - AGC_CLAMPING)/20.0f);
|
||||||
|
|
||||||
|
m_EnergyPrime = 1.0f;
|
||||||
|
|
||||||
|
// We do not target full scale to avoid stauration
|
||||||
|
m_targetEnergy = 32767.0f * pow(10.0f, (initialLeveldB - 25.0)/20.0f);//25 dB below saturation as stated in docs
|
||||||
|
//we also substract our target gain
|
||||||
|
|
||||||
|
//this is the time constant of our AGC...
|
||||||
|
m_Bandwidth = 1e-2f;//TODO : Move to parameter ?
|
||||||
|
m_Alpha = m_Bandwidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// get
|
||||||
|
|
||||||
|
float CAGC::GetGain()
|
||||||
|
{
|
||||||
|
return 20.0f*log10(m_Gain);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// process
|
||||||
|
|
||||||
|
inline void CAGC::ProcessSampleBlock(uint8* voice, int length)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < length; i += 2)
|
||||||
|
{
|
||||||
|
float input = (float)(short)MAKEWORD(voice[i+1], voice[i]);
|
||||||
|
//apply AGC
|
||||||
|
// apply gain to input sample
|
||||||
|
float output = input * m_Gain;
|
||||||
|
|
||||||
|
// compute output signal energy, scaled to 0 to 1
|
||||||
|
float instantEnergy = abs(output) / m_targetEnergy;
|
||||||
|
|
||||||
|
// smooth energy estimate using single-pole low-pass filter
|
||||||
|
m_EnergyPrime = (1.0f - m_Alpha) * m_EnergyPrime + m_Alpha * instantEnergy;
|
||||||
|
|
||||||
|
// update gain according to output energy
|
||||||
|
if (m_EnergyPrime > 1e-6f)
|
||||||
|
m_Gain *= exp( -0.5f * m_Alpha * log(m_EnergyPrime) );
|
||||||
|
|
||||||
|
// clamp gain
|
||||||
|
if (m_Gain > m_GainMax)
|
||||||
|
m_Gain = m_GainMax;
|
||||||
|
else if(m_Gain < m_GainMin)
|
||||||
|
m_Gain = m_GainMin;
|
||||||
|
|
||||||
|
//write processed sample back
|
||||||
|
voice[i] = HIBYTE((short)output);
|
||||||
|
voice[i+1] = LOBYTE((short)output);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
//
|
||||||
|
// 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/>.
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Geoffrey Merck F4FXL / KC3FRA AGC code largely inspired by Liquid DSP
|
||||||
|
// Only took the parts we need qnd recoeded it to be close the XLX coding style
|
||||||
|
// https://github.com/jgaeddert/liquid-dsp/blob/master/src/agc/src/agc.c
|
||||||
|
|
||||||
|
#ifndef cagc_h
|
||||||
|
#define cagc_h
|
||||||
|
|
||||||
|
#include "csampleblockprocessor.h"
|
||||||
|
|
||||||
|
class CAGC : CSampleBlockProcessor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//Constructor
|
||||||
|
CAGC(float initialLeveldB);
|
||||||
|
|
||||||
|
//methods
|
||||||
|
void ProcessSampleBlock(uint8* voice, int length) ;
|
||||||
|
float GetGain();//gets current gain
|
||||||
|
|
||||||
|
private:
|
||||||
|
float m_Gain; // current gain value
|
||||||
|
float m_GainMax, m_GainMin; //gain clamping
|
||||||
|
float m_targetEnergy; // scale value for target energy
|
||||||
|
|
||||||
|
// gain control loop filter parameters
|
||||||
|
float m_Bandwidth; // bandwidth-time constant
|
||||||
|
float m_Alpha; // feed-back gain
|
||||||
|
|
||||||
|
// signal level estimate
|
||||||
|
float m_EnergyPrime; // filtered output signal energy estimate
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* cgc_h */
|
||||||
@ -0,0 +1,75 @@
|
|||||||
|
//
|
||||||
|
// cfirfilter.cpp
|
||||||
|
// 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/>.
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// FIRFilter by Geoffrey Merck F4FXL / KC3FRA
|
||||||
|
|
||||||
|
#include "cfirfilter.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
CFIRFilter::CFIRFilter(const float* taps, int tapsLength)
|
||||||
|
{
|
||||||
|
m_taps = new float[tapsLength];
|
||||||
|
m_buffer = new float[tapsLength];
|
||||||
|
m_tapsLength = tapsLength;
|
||||||
|
|
||||||
|
::memcpy(m_taps, taps, tapsLength * sizeof(float));
|
||||||
|
::memset(m_buffer, 0, tapsLength * sizeof(float));
|
||||||
|
m_currentBufferPosition = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
CFIRFilter::~CFIRFilter()
|
||||||
|
{
|
||||||
|
delete[] m_taps;
|
||||||
|
delete[] m_buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CFIRFilter::ProcessSampleBlock(uint8* voice, int length)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < length; i += 2)
|
||||||
|
{
|
||||||
|
float input = (float)(short)MAKEWORD(voice[i+1], voice[i]);
|
||||||
|
float output = 0.0f;
|
||||||
|
int iTaps = 0;
|
||||||
|
|
||||||
|
// Buffer latest sample into delay line
|
||||||
|
m_buffer[m_currentBufferPosition] = input;
|
||||||
|
|
||||||
|
for(int i = m_currentBufferPosition; i >= 0; i--)
|
||||||
|
{
|
||||||
|
output += m_taps[iTaps++] * m_buffer[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = m_tapsLength - 1; i > m_currentBufferPosition; i--)
|
||||||
|
{
|
||||||
|
output += m_taps[iTaps++] * m_buffer[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
m_currentBufferPosition = (m_currentBufferPosition + 1) % m_tapsLength;
|
||||||
|
|
||||||
|
//write processed sample back
|
||||||
|
voice[i] = HIBYTE((short)output);
|
||||||
|
voice[i+1] = LOBYTE((short)output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
//
|
||||||
|
// cfirfilter.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/>.
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// FIRFilter by Geoffrey Merck F4FXL / KC3FRA
|
||||||
|
|
||||||
|
#ifndef cfirfilter_h
|
||||||
|
#define cfirfilter_h
|
||||||
|
|
||||||
|
#include "csampleblockprocessor.h"
|
||||||
|
|
||||||
|
class CFIRFilter : CSampleBlockProcessor
|
||||||
|
{
|
||||||
|
public :
|
||||||
|
//Constructor
|
||||||
|
CFIRFilter(const float* taps, int tapsLength);
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
~CFIRFilter();
|
||||||
|
|
||||||
|
// Processing
|
||||||
|
void ProcessSampleBlock(uint8* voice, int length);
|
||||||
|
|
||||||
|
private:
|
||||||
|
float* m_taps;
|
||||||
|
int m_tapsLength;
|
||||||
|
float* m_buffer;
|
||||||
|
int m_currentBufferPosition;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //cfirfilter_h
|
||||||
|
|
||||||
@ -0,0 +1,53 @@
|
|||||||
|
//
|
||||||
|
// cfixedgain.cpp
|
||||||
|
// ambed
|
||||||
|
//
|
||||||
|
// Created by Jean-Luc Deltombe (LX3JL) on 28/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/>.
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Geoffrey Merck F4FXL / KC3FRA AGC
|
||||||
|
|
||||||
|
#include "cfixedgain.h"
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// constructor
|
||||||
|
|
||||||
|
CFixedGain::CFixedGain(float gaindB)
|
||||||
|
{
|
||||||
|
m_gaindB = gaindB;
|
||||||
|
m_gainLinear = pow(10.0f, m_gaindB/20.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// processing
|
||||||
|
|
||||||
|
inline void CFixedGain::ProcessSampleBlock(uint8* voice, int length)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < length; i += 2)
|
||||||
|
{
|
||||||
|
float input = (float)(short)MAKEWORD(voice[i+1], voice[i]);
|
||||||
|
//apply gain
|
||||||
|
float output = input * m_gainLinear;
|
||||||
|
|
||||||
|
//write processed sample back
|
||||||
|
voice[i] = HIBYTE((short)output);
|
||||||
|
voice[i+1] = LOBYTE((short)output);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
//
|
||||||
|
// cfixedgain.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/>.
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Geoffrey Merck F4FXL / KC3FRA
|
||||||
|
|
||||||
|
#ifndef cfixedgain_h
|
||||||
|
#define cfixedgain_h
|
||||||
|
|
||||||
|
#include "csampleblockprocessor.h"
|
||||||
|
|
||||||
|
class CFixedGain : CSampleBlockProcessor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//Constructor
|
||||||
|
CFixedGain(float gaindB);
|
||||||
|
|
||||||
|
//processing
|
||||||
|
void ProcessSampleBlock(uint8* voice, int length);
|
||||||
|
|
||||||
|
private:
|
||||||
|
float m_gaindB; //gain in dB
|
||||||
|
float m_gainLinear; //linearized gain
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* cfixedgain_h */
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
//
|
||||||
|
// csampleprocessor.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/>.
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Geoffrey Merck F4FXL / KC3FRA
|
||||||
|
|
||||||
|
#ifndef csamplebloclprocessor_h
|
||||||
|
#define csamplebloclprocessor_h
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
class CSampleBlockProcessor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//processing
|
||||||
|
virtual void ProcessSampleBlock(uint8* voice, int length) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* csampleprocessor_h */
|
||||||
@ -0,0 +1,94 @@
|
|||||||
|
//
|
||||||
|
// cagc.cpp
|
||||||
|
// ambed
|
||||||
|
//
|
||||||
|
// Created by Jean-Luc Deltombe (LX3JL) on 28/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/>.
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Geoffrey Merck F4FXL / KC3FRA AGC
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
#include "csignalprocessor.h"
|
||||||
|
|
||||||
|
#if USE_AGC == 1
|
||||||
|
#include "cagc.h"
|
||||||
|
#else
|
||||||
|
#include "cfixedgain.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if USE_BANDPASSFILTER == 1
|
||||||
|
#include "cfirfilter.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// constructor
|
||||||
|
|
||||||
|
CSignalProcessor::CSignalProcessor(float gaindB)
|
||||||
|
{
|
||||||
|
#if USE_BANDPASSFILTER
|
||||||
|
m_sampleProcessors.push_back((CSampleBlockProcessor*)new CFIRFilter(FILTER_TAPS, FILTER_TAPS_LENGTH));
|
||||||
|
#endif
|
||||||
|
#if USE_AGC == 1
|
||||||
|
m_sampleProcessors.push_back((CSampleBlockProcessor*)new CAGC(gaindB));
|
||||||
|
#else
|
||||||
|
m_sampleProcessors.push_back((CSampleBlockProcessor*)new CFixedGain(gaindB));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// destructor
|
||||||
|
|
||||||
|
CSignalProcessor::~CSignalProcessor()
|
||||||
|
{
|
||||||
|
for(int i = 0; i < m_sampleProcessors.size(); i++)
|
||||||
|
{
|
||||||
|
delete m_sampleProcessors[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// processing
|
||||||
|
|
||||||
|
void CSignalProcessor::Process(uint8* voice, int length)
|
||||||
|
{
|
||||||
|
/*float sample;
|
||||||
|
int j;*/
|
||||||
|
auto processorsSize = m_sampleProcessors.size();
|
||||||
|
|
||||||
|
for(int j = 0; j < processorsSize; j++)
|
||||||
|
{
|
||||||
|
m_sampleProcessors[j]->ProcessSampleBlock(voice, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*for(int i = 0; i < length; i += 2)
|
||||||
|
{
|
||||||
|
//Get the sample
|
||||||
|
sample = (float)(short)MAKEWORD(voice[i+1], voice[i]);
|
||||||
|
|
||||||
|
for(j = 0; j < processorsSize; j++)
|
||||||
|
{
|
||||||
|
sample = m_sampleProcessors[j]->ProcessSample(sample);
|
||||||
|
}
|
||||||
|
|
||||||
|
//write processed sample back
|
||||||
|
voice[i] = HIBYTE((short)sample);
|
||||||
|
voice[i+1] = LOBYTE((short)sample);
|
||||||
|
}*/
|
||||||
|
}
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
//
|
||||||
|
// csignalprocessor.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/>.
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Geoffrey Merck F4FXL / KC3FRA
|
||||||
|
|
||||||
|
#ifndef csignalprocessor_h
|
||||||
|
#define csignalprocessor_h
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include "csampleblockprocessor.h"
|
||||||
|
|
||||||
|
class CSignalProcessor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//Constructor
|
||||||
|
CSignalProcessor(float gaindB);
|
||||||
|
|
||||||
|
//Destructor
|
||||||
|
~CSignalProcessor();
|
||||||
|
|
||||||
|
//Processing
|
||||||
|
void Process(uint8* voice, int length);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<CSampleBlockProcessor *> m_sampleProcessors;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* csignalprocessor_h */
|
||||||
Loading…
Reference in new issue