diff --git a/src/modules/modem/analog/ModemLSB.cpp b/src/modules/modem/analog/ModemLSB.cpp index 31d86a3..d418426 100644 --- a/src/modules/modem/analog/ModemLSB.cpp +++ b/src/modules/modem/analog/ModemLSB.cpp @@ -2,8 +2,20 @@ ModemLSB::ModemLSB() : ModemAnalog() { // half band filter used for side-band elimination - ssbFilt = resamp2_crcf_create(12,-0.25f,60.0f); demodAM_LSB = ampmodem_create(0.5, 0.0, LIQUID_AMPMODEM_LSB, 1); + // options + float fc = 0.25f; // filter cutoff frequency + float ft = 0.05f; // filter transition + float As = 90.0f; // stop-band attenuation [dB] + float mu = 0.0f; // fractional timing offset + + // estimate required filter length and generate filter + unsigned int h_len = estimate_req_filter_len(ft,As); + float h[h_len]; + liquid_firdes_kaiser(h_len,fc,As,mu,h); + ssbFilt = firfilt_crcf_create(h,h_len); + ssbShift = nco_crcf_create(LIQUID_NCO); + nco_crcf_set_frequency(ssbShift, (2.0 * M_PI) * 0.25); } Modem *ModemLSB::factory() { @@ -15,7 +27,8 @@ std::string ModemLSB::getName() { } ModemLSB::~ModemLSB() { - resamp2_crcf_destroy(ssbFilt); + firfilt_crcf_destroy(ssbFilt); + nco_crcf_destroy(ssbShift); ampmodem_destroy(demodAM_LSB); } @@ -45,8 +58,12 @@ void ModemLSB::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *a liquid_float_complex x, y; for (int i = 0; i < bufSize; i++) { // Reject upper band - resamp2_crcf_filter_execute(ssbFilt,input->data[i],&x,&y); - ampmodem_demodulate(demodAM_LSB, x, &demodOutputData[i]); + nco_crcf_step(ssbShift); + nco_crcf_mix_up(ssbShift, input->data[i], &x); + firfilt_crcf_push(ssbFilt, x); + firfilt_crcf_execute(ssbFilt, &x); + nco_crcf_mix_down(ssbShift, x, &y); + ampmodem_demodulate(demodAM_LSB, y, &demodOutputData[i]); } buildAudioOutput(akit, audioOut, true); diff --git a/src/modules/modem/analog/ModemLSB.h b/src/modules/modem/analog/ModemLSB.h index 04a462c..875921d 100644 --- a/src/modules/modem/analog/ModemLSB.h +++ b/src/modules/modem/analog/ModemLSB.h @@ -16,6 +16,7 @@ public: void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut); private: - resamp2_crcf ssbFilt; + firfilt_crcf ssbFilt; + nco_crcf ssbShift; ampmodem demodAM_LSB; }; \ No newline at end of file diff --git a/src/modules/modem/analog/ModemUSB.cpp b/src/modules/modem/analog/ModemUSB.cpp index 8f3202b..dac0073 100644 --- a/src/modules/modem/analog/ModemUSB.cpp +++ b/src/modules/modem/analog/ModemUSB.cpp @@ -2,8 +2,20 @@ ModemUSB::ModemUSB() : ModemAnalog() { // half band filter used for side-band elimination - ssbFilt = resamp2_crcf_create(12,-0.25f,60.0f); demodAM_USB = ampmodem_create(0.5, 0.0, LIQUID_AMPMODEM_USB, 1); + // options + float fc = 0.25f; // filter cutoff frequency + float ft = 0.05f; // filter transition + float As = 90.0f; // stop-band attenuation [dB] + float mu = 0.0f; // fractional timing offset + + // estimate required filter length and generate filter + unsigned int h_len = estimate_req_filter_len(ft,As); + float h[h_len]; + liquid_firdes_kaiser(h_len,fc,As,mu,h); + ssbFilt = firfilt_crcf_create(h,h_len); + ssbShift = nco_crcf_create(LIQUID_NCO); + nco_crcf_set_frequency(ssbShift, (2.0 * M_PI) * 0.25); } Modem *ModemUSB::factory() { @@ -15,7 +27,8 @@ std::string ModemUSB::getName() { } ModemUSB::~ModemUSB() { - resamp2_crcf_destroy(ssbFilt); + firfilt_crcf_destroy(ssbFilt); + nco_crcf_destroy(ssbShift); ampmodem_destroy(demodAM_USB); } @@ -45,7 +58,11 @@ void ModemUSB::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *a liquid_float_complex x, y; for (int i = 0; i < bufSize; i++) { // Reject lower band - resamp2_crcf_filter_execute(ssbFilt,input->data[i],&x,&y); + nco_crcf_step(ssbShift); + nco_crcf_mix_down(ssbShift, input->data[i], &x); + firfilt_crcf_push(ssbFilt, x); + firfilt_crcf_execute(ssbFilt, &x); + nco_crcf_mix_up(ssbShift, x, &y); ampmodem_demodulate(demodAM_USB, y, &demodOutputData[i]); } diff --git a/src/modules/modem/analog/ModemUSB.h b/src/modules/modem/analog/ModemUSB.h index 44dd0f3..259af62 100644 --- a/src/modules/modem/analog/ModemUSB.h +++ b/src/modules/modem/analog/ModemUSB.h @@ -16,6 +16,7 @@ public: void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut); private: - resamp2_crcf ssbFilt; + firfilt_crcf ssbFilt; + nco_crcf ssbShift; ampmodem demodAM_USB; }; \ No newline at end of file