Skip to content

Commit

Permalink
Disable stereo @ <100khz to prevent invalid filters
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcliffe committed Jun 7, 2015
1 parent 25dc28d commit 95ff1e9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
8 changes: 6 additions & 2 deletions src/demod/DemodulatorPreThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions src/demod/DemodulatorThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ void DemodulatorThread::threadMain() {
ampmodem_reset(demodAM);
}
freqdem_reset(demodFM);
nco_crcf_reset(stereoPilot);
}

if (firStereoLeft != inp->firStereoLeft) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 6 additions & 2 deletions src/demod/DemodulatorWorkerThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 95ff1e9

Please sign in to comment.