Added some basic FIR filter code (2.8 khz SSB filter).

Biggest thing, discovered that I needed to increase AudioMemory to 16 to
fix some "motorboating" that seemed to startup anytime I transmitted
through USB.
This commit is contained in:
Rob French 2020-05-19 21:39:35 -05:00
parent 9c1a490963
commit 7aa2cbc1c4
3 changed files with 37 additions and 26 deletions

View File

@ -2,6 +2,7 @@
// audio.ino
//======================================================================
#include <dynamicFilters.h>
#include "audio.h"
extern IOPConfig iopConfig;
@ -27,37 +28,41 @@ AudioAnalyzeRMS rmsRX; //xy=383,47
AudioAnalyzePeak peakRX; //xy=387,98
AudioMixer4 mixRX; //xy=444,163
AudioMixer4 mixTX; //xy=444,279
AudioAmplifier calRxUSB; //xy=634,165
AudioAmplifier calRxSpkr; //xy=638,55
AudioAmplifier calRxLine; //xy=641,112
AudioAmplifier calTxLine; //xy=653,248
AudioAmplifier calTxUSB; //xy=654,305
AudioAnalyzePeak peakTX; //xy=669,378
AudioAnalyzeRMS rmsTX; //xy=683,433
AudioOutputAnalog outSpkr; //xy=814,55
AudioOutputUSB outUSB; //xy=823,255
AudioOutputI2S outLine; //xy=826,204
AudioFilterFIR filterRX; //xy=577,161
AudioAmplifier filterAmp; //xy=700,160
AudioAmplifier calRxUSB; //xy=873,172
AudioAmplifier calRxSpkr; //xy=877,62
AudioAmplifier calRxLine; //xy=880,119
AudioAmplifier calTxLine; //xy=892,255
AudioAmplifier calTxUSB; //xy=893,312
AudioAnalyzePeak peakTX; //xy=908,385
AudioAnalyzeRMS rmsTX; //xy=922,440
AudioOutputAnalog outSpkr; //xy=1053,62
AudioOutputUSB outUSB; //xy=1062,262
AudioOutputI2S outLine; //xy=1065,211
AudioConnection patchCord1(sideTone, 0, mixRX, 2);
AudioConnection patchCord2(inLine, 0, rmsRX, 0);
AudioConnection patchCord3(inLine, 0, peakRX, 0);
AudioConnection patchCord4(inLine, 0, mixRX, 0);
AudioConnection patchCord5(inLine, 1, mixTX, 0);
AudioConnection patchCord6(sine2, 0, mixTX, 3);
AudioConnection patchCord7(inUSB, 0, mixRX, 1);
//AudioConnection patchCord7(inUSB, 0, mixRX, 1);
AudioConnection patchCord8(inUSB, 1, mixTX, 1);
AudioConnection patchCord9(sine1, 0, mixTX, 2);
AudioConnection patchCord10(mixRX, calRxSpkr);
AudioConnection patchCord11(mixRX, calRxLine);
AudioConnection patchCord12(mixRX, calRxUSB);
AudioConnection patchCord13(mixTX, calTxLine);
AudioConnection patchCord14(mixTX, calTxUSB);
AudioConnection patchCord15(mixTX, peakTX);
AudioConnection patchCord16(mixTX, rmsTX);
AudioConnection patchCord17(calRxUSB, 0, outUSB, 0);
AudioConnection patchCord18(calRxSpkr, outSpkr);
AudioConnection patchCord19(calRxLine, 0, outLine, 0);
AudioConnection patchCord20(calTxLine, 0, outLine, 1);
AudioConnection patchCord21(calTxUSB, 0, outUSB, 1);
AudioConnection patchCord10(mixRX, filterRX);
AudioConnection patchCord11(mixTX, calTxLine);
AudioConnection patchCord12(mixTX, calTxUSB);
AudioConnection patchCord13(mixTX, peakTX);
AudioConnection patchCord14(mixTX, rmsTX);
AudioConnection patchCord15(filterRX, filterAmp);
AudioConnection patchCord16(filterAmp, calRxSpkr);
AudioConnection patchCord17(filterAmp, calRxLine);
AudioConnection patchCord18(filterAmp, calRxUSB);
AudioConnection patchCord19(calRxUSB, 0, outUSB, 0);
AudioConnection patchCord20(calRxSpkr, outSpkr);
AudioConnection patchCord21(calRxLine, 0, outLine, 0);
AudioConnection patchCord22(calTxLine, 0, outLine, 1);
//AudioConnection patchCord23(calTxUSB, 0, outUSB, 1);
AudioControlSGTL5000 audioCtrl; //xy=391,443
// GUItool: end automatically generated code
@ -66,6 +71,8 @@ RxOutput audioRxOutput;
TxInput audioTxInput;
TxOutput audioTxOutput;
short firActive[NUM_COEFFICIENTS];
// audioInit()
// Setup the audio subsystem.
void audioInit()
@ -98,13 +105,17 @@ void audioInit()
audioSelectTxInput(TX_MIC_IN); // superfluous I think
//audioCtrl.adcHighPassFilterDisable();
audioCtrl.audioPreProcessorEnable();
//audioCtrl.audioPreProcessorEnable();
// setup the two-tone generator
sine1.frequency(700);
sine2.frequency(1900);
sine1.amplitude(0);
sine2.amplitude(0);
audioFilter(firActive, NUM_COEFFICIENTS, ID_BANDPASS, W_HAMMING, 300.0, 3100.0); // 2.8 kHz filter
filterRX.begin(firActive, NUM_COEFFICIENTS);
filterAmp.gain(1.0);
}
inline void updateRxRigIn()

View File

@ -12,7 +12,7 @@
#include "keyer.h"
// comment this out to disable debugging code
#define DEBUG
//#define DEBUG
#if defined(DEBUG)
#define USBDEBUG(x) USBSERIAL.print("IOP: "); USBSERIAL.println(x);

View File

@ -248,7 +248,7 @@ void setup() {
// put your setup code here, to run once:
initCAT(38400, SERIAL_8N1);
AudioMemory(12);
AudioMemory(16);
micPTT.attach(MIC_PTT_PIN, INPUT_PULLUP);
micPTT.interval(25);