mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-26 21:58:37 -05:00
Merge pull request #252 from cjcliffe/ssb_fix
SSB mode FIR filter side-band supression
This commit is contained in:
commit
12af109e84
@ -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);
|
||||
|
@ -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;
|
||||
};
|
@ -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]);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
};
|
Loading…
Reference in New Issue
Block a user