Disable stereo @ <100khz to prevent invalid filters

This commit is contained in:
Charles J. Cliffe 2015-06-06 20:47:14 -04:00
parent 25dc28d350
commit 95ff1e9c36
3 changed files with 16 additions and 7 deletions

View File

@ -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);

View File

@ -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) {

View File

@ -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;