diff --git a/src/demod/DemodulatorPreThread.cpp b/src/demod/DemodulatorPreThread.cpp index ac92c65..0283b86 100644 --- a/src/demod/DemodulatorPreThread.cpp +++ b/src/demod/DemodulatorPreThread.cpp @@ -57,9 +57,13 @@ void DemodulatorPreThread::initialize() { firStereoRight = firfilt_rrrf_create(h, h_len); // stereo pilot filter + float bw = params.bandwidth; + if (bw < 100000.0) { + bw = 100000.0; + } unsigned int order = 5; // filter order - float f0 = ((double) 19000 / (double) params.bandwidth); - float fc = ((double) 19500 / (double) params.bandwidth); + float f0 = ((double) 19000 / bw); + float fc = ((double) 19500 / bw); float Ap = 1.0f; As = 60.0f; iirStereoPilot = iirfilt_crcf_create_prototype(LIQUID_IIRDES_CHEBY2, LIQUID_IIRDES_BANDPASS, LIQUID_IIRDES_SOS, order, fc, f0, Ap, As); diff --git a/src/demod/DemodulatorThread.cpp b/src/demod/DemodulatorThread.cpp index 3541b61..146603e 100644 --- a/src/demod/DemodulatorThread.cpp +++ b/src/demod/DemodulatorThread.cpp @@ -117,6 +117,7 @@ void DemodulatorThread::threadMain() { ampmodem_reset(demodAM); } freqdem_reset(demodFM); + nco_crcf_reset(stereoPilot); } if (firStereoLeft != inp->firStereoLeft) { @@ -223,7 +224,7 @@ void DemodulatorThread::threadMain() { unsigned int numAudioWritten; msresamp_rrrf_execute(audioResampler, &demodOutputData[0], bufSize, &resampledOutputData[0], &numAudioWritten); - if (stereo) { + if (stereo && inp->sampleRate >= 100000) { if (demodStereoData.size() != bufSize) { if (demodStereoData.capacity() < bufSize) { demodStereoData.reserve(bufSize); @@ -302,7 +303,7 @@ void DemodulatorThread::threadMain() { ati->sampleRate = audioSampleRate; ati->setRefCount(1); - if (stereo) { + if (stereo && inp->sampleRate >= 100000) { ati->channels = 2; if (ati->data.capacity() < (numAudioWritten * 2)) { ati->data.reserve(numAudioWritten * 2); @@ -343,7 +344,7 @@ void DemodulatorThread::threadMain() { ati_vis->busy_update.lock(); int num_vis = DEMOD_VIS_SIZE; - if (stereo) { + if (stereo && inp->sampleRate >= 100000) { ati_vis->channels = 2; int stereoSize = ati->data.size(); if (stereoSize > DEMOD_VIS_SIZE) { diff --git a/src/demod/DemodulatorWorkerThread.cpp b/src/demod/DemodulatorWorkerThread.cpp index 6e421df..8725a94 100644 --- a/src/demod/DemodulatorWorkerThread.cpp +++ b/src/demod/DemodulatorWorkerThread.cpp @@ -70,10 +70,14 @@ void DemodulatorWorkerThread::threadMain() { result.firStereoLeft = firfilt_rrrf_create(h, h_len); result.firStereoRight = firfilt_rrrf_create(h, h_len); + float bw = filterCommand.bandwidth; + if (bw < 100000.0) { + bw = 100000.0; + } // stereo pilot filter unsigned int order = 5; // filter order - float f0 = ((double) 19000 / (double) filterCommand.bandwidth); - float fc = ((double) 19500 / (double) filterCommand.bandwidth); + float f0 = ((double) 19000 / bw); + float fc = ((double) 19500 / bw); float Ap = 1.0f; As = 60.0f;