Skip to content

Commit

Permalink
Modified ModemAM (#865)
Browse files Browse the repository at this point in the history
Works perfectly :)
  • Loading branch information
colbyAtCRI authored Jan 2, 2021
1 parent 7b1956f commit 6a709fe
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
24 changes: 16 additions & 8 deletions src/modules/modem/analog/ModemAM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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);
}
12 changes: 6 additions & 6 deletions src/modules/modem/analog/ModemAM.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

0 comments on commit 6a709fe

Please sign in to comment.