Bandwidth change patch

This commit is contained in:
Charles J. Cliffe 2015-01-23 02:09:37 -05:00
parent dd9bc9aa2c
commit c55b94eee1
2 changed files with 36 additions and 21 deletions

View File

@ -106,7 +106,7 @@ void DemodulatorPreThread::threadMain() {
}
}
if (inp->sampleRate != tempParams.sampleRate) {
if (inp->sampleRate != tempParams.sampleRate && inp->sampleRate) {
tempParams.sampleRate = inp->sampleRate;
rateChanged = true;
}
@ -218,17 +218,25 @@ void DemodulatorPreThread::threadMain() {
case DemodulatorWorkerThreadResult::DEMOD_WORKER_THREAD_RESULT_FILTERS:
msresamp_crcf_destroy(iqResampler);
iqResampler = result.iqResampler;
audioResampler = result.audioResampler;
stereoResampler = result.stereoResampler;
iqResampleRatio = result.iqResampleRatio;
audioResampleRatio = result.audioResamplerRatio;
if (result.iqResampler) {
iqResampler = result.iqResampler;
iqResampleRatio = result.iqResampleRatio;
}
params.audioSampleRate = result.audioSampleRate;
params.bandwidth = result.bandwidth;
params.sampleRate = result.sampleRate;
if (result.audioResampler) {
audioResampler = result.audioResampler;
audioResampleRatio = result.audioResamplerRatio;
stereoResampler = result.stereoResampler;
params.audioSampleRate = result.audioSampleRate;
}
if (params.bandwidth) {
params.bandwidth = result.bandwidth;
}
if (params.sampleRate) {
params.sampleRate = result.sampleRate;
}
break;
default:
break;

View File

@ -24,9 +24,6 @@ void DemodulatorWorkerThread::threadMain() {
commandQueue->pop(command);
switch (command.cmd) {
case DemodulatorWorkerThreadCommand::DEMOD_WORKER_THREAD_CMD_BUILD_FILTERS:
if (!filterCommand.bandwidth || !filterCommand.audioSampleRate) {
break;
}
filterChanged = true;
filterCommand = command;
break;
@ -40,18 +37,28 @@ void DemodulatorWorkerThread::threadMain() {
if (filterChanged && !terminated) {
DemodulatorWorkerThreadResult result(DemodulatorWorkerThreadResult::DEMOD_WORKER_THREAD_RESULT_FILTERS);
result.iqResampleRatio = (double) (filterCommand.bandwidth) / (double) filterCommand.sampleRate;
result.audioResamplerRatio = (double) (filterCommand.audioSampleRate) / (double) filterCommand.bandwidth;
float As = 60.0f; // stop-band attenuation [dB]
result.iqResampler = msresamp_crcf_create(result.iqResampleRatio, As);
result.audioResampler = msresamp_rrrf_create(result.audioResamplerRatio, As);
result.stereoResampler = msresamp_rrrf_create(result.audioResamplerRatio, As);
if (filterCommand.sampleRate && filterCommand.bandwidth) {
result.iqResampleRatio = (double) (filterCommand.bandwidth) / (double) filterCommand.sampleRate;
result.iqResampler = msresamp_crcf_create(result.iqResampleRatio, As);
}
if (filterCommand.bandwidth && filterCommand.audioSampleRate) {
result.audioResamplerRatio = (double) (filterCommand.audioSampleRate) / (double) filterCommand.bandwidth;
result.audioResampler = msresamp_rrrf_create(result.audioResamplerRatio, As);
result.stereoResampler = msresamp_rrrf_create(result.audioResamplerRatio, As);
result.audioSampleRate = filterCommand.audioSampleRate;
}
if (filterCommand.bandwidth) {
result.bandwidth = filterCommand.bandwidth;
}
if (filterCommand.sampleRate) {
result.sampleRate = filterCommand.sampleRate;
}
result.audioSampleRate = filterCommand.audioSampleRate;
result.bandwidth = filterCommand.bandwidth;
result.sampleRate = filterCommand.sampleRate;
resultQueue->push(result);
}