From 65a5dbb24de67141ed1097cca5145941dc8fbbb6 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Wed, 26 Nov 2014 22:29:23 -0500 Subject: [PATCH] Proper demodulator resamp and filter reinit --- src/demod/DemodulatorThread.cpp | 25 ++++++++++++++++++------- src/demod/DemodulatorThread.h | 2 ++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/demod/DemodulatorThread.cpp b/src/demod/DemodulatorThread.cpp index db4dbaa..fe4c6fb 100644 --- a/src/demod/DemodulatorThread.cpp +++ b/src/demod/DemodulatorThread.cpp @@ -3,7 +3,11 @@ #include DemodulatorThread::DemodulatorThread(DemodulatorThreadInputQueue* pQueue) : - inputQueue(pQueue), visOutQueue(NULL), terminated(false), initialized(false), audio_resampler(NULL), audio_resample_ratio(1) { + inputQueue(pQueue), visOutQueue(NULL), terminated(false), initialized(false), audio_resampler(NULL), resample_ratio(1), audio_resample_ratio(1), resampler(NULL), commandQueue(NULL), fir_filter(NULL) { + + float kf = 0.75; // modulation factor + fdem = freqdem_create(kf); +// freqdem_print(fdem); } @@ -32,23 +36,30 @@ void DemodulatorThread::initialize() { float h[h_len]; liquid_firdes_kaiser(h_len, fc, As, mu, h); - fir_filter = firfilt_crcf_create(h, h_len); + if (fir_filter) { + firfilt_crcf_recreate(fir_filter, h, h_len); + } else { + fir_filter = firfilt_crcf_create(h, h_len); + } // create multi-stage arbitrary resampler object + if (resampler) { + msresamp_crcf_destroy(resampler); + } resampler = msresamp_crcf_create(resample_ratio, As); // msresamp_crcf_print(resampler); + if (audio_resampler) { + msresamp_crcf_destroy(audio_resampler); + } audio_resampler = msresamp_crcf_create(audio_resample_ratio, As); // msresamp_crcf_print(audio_resampler); - float kf = 0.75; // modulation factor - - fdem = freqdem_create(kf); -// freqdem_print(fdem); initialized = true; - std::cout << "inputResampleRate " << params.bandwidth << std::endl; +// std::cout << "inputResampleRate " << params.bandwidth << std::endl; + last_params = params; } DemodulatorThread::~DemodulatorThread() { diff --git a/src/demod/DemodulatorThread.h b/src/demod/DemodulatorThread.h index 125ec7c..ef2f158 100644 --- a/src/demod/DemodulatorThread.h +++ b/src/demod/DemodulatorThread.h @@ -146,6 +146,8 @@ protected: float audio_resample_ratio; DemodulatorThreadParameters params; + DemodulatorThreadParameters last_params; + freqdem fdem; std::atomic terminated;