Modified ModemAM (#865)

Works perfectly :)
This commit is contained in:
Paul Colby 2021-01-02 03:11:02 -08:00 committed by GitHub
parent 7b1956f7cd
commit 6a709fe24b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 14 deletions

View File

@ -4,12 +4,14 @@
#include "ModemAM.h"
ModemAM::ModemAM() : ModemAnalog() {
demodAM = ampmodem_create(0.5, LIQUID_AMPMODEM_DSB, 0);
// Create a DC blocker using 25 samples wide window
// and 30dB reduction of the DC level.
mDCBlock = firfilt_rrrf_create_dc_blocker (25,30.0f);
useSignalOutput(true);
}
ModemAM::~ModemAM() {
ampmodem_destroy(demodAM);
firfilt_rrrf_destroy(mDCBlock);
}
ModemBase *ModemAM::factory() {
@ -26,17 +28,23 @@ int ModemAM::getDefaultSampleRate() {
void ModemAM::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput* audioOut) {
ModemKitAnalog *amkit = (ModemKitAnalog *)kit;
initOutputBuffers(amkit,input);
if (!bufSize) {
return;
}
// Implement an AM demodulator. Compute signal
// amplitude followed by a DC blocker to remove
// the DC offset.
for (size_t i = 0; i < bufSize; i++) {
ampmodem_demodulate(demodAM, input->data[i], &demodOutputData[i]);
float I = input->data[i].real;
float Q = input->data[i].imag;
firfilt_rrrf_push (mDCBlock,sqrt(I*I+Q*Q));
firfilt_rrrf_execute (mDCBlock,&demodOutputData[i]);
}
buildAudioOutput(amkit,audioOut,true);
}

View File

@ -9,15 +9,15 @@ class ModemAM : public ModemAnalog {
public:
ModemAM();
~ModemAM();
std::string getName();
static ModemBase *factory();
int getDefaultSampleRate();
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut);
private:
ampmodem demodAM;
};
firfilt_rrrf mDCBlock;
};