Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified ModemAM #865

Merged
merged 1 commit into from
Jan 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
};