mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-04 08:21:16 -05:00
Remap mis-matched averaging buffers on resampler change
This commit is contained in:
parent
e22e696a7d
commit
0b03ed47d4
@ -1050,15 +1050,9 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
|
||||
GetStatusBar()->SetStatusText(wxString::Format(wxT("Spectrum averaging speed changed to %0.2f%%."),val*100.0));
|
||||
}
|
||||
|
||||
proc->setView(waterfallCanvas->getViewState());
|
||||
proc->setBandwidth(waterfallCanvas->getBandwidth());
|
||||
proc->setCenterFrequency(waterfallCanvas->getCenterFrequency());
|
||||
|
||||
SpectrumVisualProcessor *dproc = wxGetApp().getDemodSpectrumProcessor();
|
||||
|
||||
dproc->setView(demodWaterfallCanvas->getViewState());
|
||||
dproc->setBandwidth(demodWaterfallCanvas->getBandwidth());
|
||||
dproc->setCenterFrequency(demodWaterfallCanvas->getCenterFrequency());
|
||||
dproc->setView(demodWaterfallCanvas->getViewState(), demodWaterfallCanvas->getCenterFrequency(),demodWaterfallCanvas->getBandwidth());
|
||||
|
||||
SpectrumVisualProcessor *wproc = waterfallDataThread->getProcessor();
|
||||
|
||||
@ -1070,11 +1064,11 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
|
||||
GetStatusBar()->SetStatusText(wxString::Format(wxT("Waterfall max speed changed to %d lines per second."),(int)ceil(val*val)));
|
||||
}
|
||||
|
||||
wproc->setView(waterfallCanvas->getViewState());
|
||||
wproc->setBandwidth(waterfallCanvas->getBandwidth());
|
||||
wproc->setCenterFrequency(waterfallCanvas->getCenterFrequency());
|
||||
wproc->setView(waterfallCanvas->getViewState(), waterfallCanvas->getCenterFrequency(), waterfallCanvas->getBandwidth());
|
||||
wxGetApp().getSDRPostThread()->setIQVisualRange(waterfallCanvas->getCenterFrequency(), waterfallCanvas->getBandwidth());
|
||||
|
||||
proc->setView(wproc->isView(), wproc->getCenterFrequency(), wproc->getBandwidth());
|
||||
|
||||
demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
||||
|
||||
if (modemPropertiesUpdated.load() && demod && demod->isModemInitialized()) {
|
||||
|
@ -34,6 +34,15 @@ void SpectrumVisualProcessor::setView(bool bView) {
|
||||
busy_run.unlock();
|
||||
}
|
||||
|
||||
void SpectrumVisualProcessor::setView(bool bView, long long centerFreq_in, long bandwidth_in) {
|
||||
busy_run.lock();
|
||||
is_view.store(bView);
|
||||
bandwidth.store(bandwidth_in);
|
||||
centerFreq.store(centerFreq_in);
|
||||
busy_run.unlock();
|
||||
}
|
||||
|
||||
|
||||
void SpectrumVisualProcessor::setFFTAverageRate(float fftAverageRate) {
|
||||
busy_run.lock();
|
||||
this->fft_average_rate.store(fftAverageRate);
|
||||
@ -133,7 +142,9 @@ void SpectrumVisualProcessor::process() {
|
||||
|
||||
unsigned int num_written;
|
||||
long resampleBw = iqData->sampleRate;
|
||||
|
||||
bool newResampler = false;
|
||||
int bwDiff;
|
||||
|
||||
if (bandwidth > resampleBw) {
|
||||
iqData->decRefCount();
|
||||
iqData->busy_rw.unlock();
|
||||
@ -199,8 +210,10 @@ void SpectrumVisualProcessor::process() {
|
||||
|
||||
resampler = msresamp_crcf_create(resamplerRatio, As);
|
||||
|
||||
bwDiff = resampleBw-lastBandwidth;
|
||||
lastBandwidth = resampleBw;
|
||||
lastInputBandwidth = iqData->sampleRate;
|
||||
newResampler = true;
|
||||
}
|
||||
|
||||
|
||||
@ -285,6 +298,7 @@ void SpectrumVisualProcessor::process() {
|
||||
fft_result.resize(fftSizeInternal);
|
||||
fft_result_ma.resize(fftSizeInternal);
|
||||
fft_result_maa.resize(fftSizeInternal);
|
||||
fft_result_temp.resize(fftSizeInternal);
|
||||
}
|
||||
|
||||
for (int i = 0, iMax = fftSizeInternal / 2; i < iMax; i++) {
|
||||
@ -300,14 +314,49 @@ void SpectrumVisualProcessor::process() {
|
||||
fft_result[fftSizeInternal / 2 + i] = (c);
|
||||
}
|
||||
|
||||
for (int i = 0, iMax = fftSizeInternal; i < iMax; i++) {
|
||||
if (is_view.load()) {
|
||||
fft_result_maa[i] += (fft_result_ma[i] - fft_result_maa[i]) * fft_average_rate;
|
||||
fft_result_ma[i] += (fft_result[i] - fft_result_ma[i]) * fft_average_rate;
|
||||
if (newResampler) {
|
||||
if (bwDiff < 0) {
|
||||
for (int i = 0, iMax = fftSizeInternal; i < iMax; i++) {
|
||||
fft_result_temp[i] = fft_result_ma[(fftSizeInternal/4) + (i/2)];
|
||||
}
|
||||
for (int i = 0, iMax = fftSizeInternal; i < iMax; i++) {
|
||||
fft_result_ma[i] = fft_result_temp[i];
|
||||
|
||||
fft_result_temp[i] = fft_result_maa[(fftSizeInternal/4) + (i/2)];
|
||||
}
|
||||
for (int i = 0, iMax = fftSizeInternal; i < iMax; i++) {
|
||||
fft_result_maa[i] = fft_result_temp[i];
|
||||
}
|
||||
} else {
|
||||
fft_result_maa[i] += (fft_result_ma[i] - fft_result_maa[i]) * fft_average_rate;
|
||||
fft_result_ma[i] += (fft_result[i] - fft_result_ma[i]) * fft_average_rate;
|
||||
for (int i = 0, iMax = fftSizeInternal; i < iMax; i++) {
|
||||
if (i < fftSizeInternal/4) {
|
||||
fft_result_temp[i] = 0;
|
||||
} else if (i > fftSizeInternal - fftSizeInternal/4) {
|
||||
fft_result_temp[i] = 0;
|
||||
} else {
|
||||
fft_result_temp[i] = fft_result_ma[(i-fftSizeInternal/4)*2];
|
||||
}
|
||||
}
|
||||
for (int i = 0, iMax = fftSizeInternal; i < iMax; i++) {
|
||||
fft_result_ma[i] = fft_result_temp[i];
|
||||
|
||||
if (i < fftSizeInternal/4) {
|
||||
fft_result_temp[i] = 0;
|
||||
} else if (i > fftSizeInternal - fftSizeInternal/4) {
|
||||
fft_result_temp[i] = 0;
|
||||
} else {
|
||||
fft_result_temp[i] = fft_result_maa[(i-fftSizeInternal/4)*2];
|
||||
}
|
||||
}
|
||||
for (int i = 0, iMax = fftSizeInternal; i < iMax; i++) {
|
||||
fft_result_maa[i] = fft_result_temp[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0, iMax = fftSizeInternal; i < iMax; i++) {
|
||||
fft_result_maa[i] += (fft_result_ma[i] - fft_result_maa[i]) * fft_average_rate;
|
||||
fft_result_ma[i] += (fft_result[i] - fft_result_ma[i]) * fft_average_rate;
|
||||
|
||||
if (fft_result_maa[i] > fft_ceil) {
|
||||
fft_ceil = fft_result_maa[i];
|
||||
|
@ -24,6 +24,7 @@ public:
|
||||
|
||||
bool isView();
|
||||
void setView(bool bView);
|
||||
void setView(bool bView, long long centerFreq_in, long bandwidth_in);
|
||||
|
||||
void setFFTAverageRate(float fftAverageRate);
|
||||
float getFFTAverageRate();
|
||||
@ -67,6 +68,7 @@ private:
|
||||
std::vector<double> fft_result;
|
||||
std::vector<double> fft_result_ma;
|
||||
std::vector<double> fft_result_maa;
|
||||
std::vector<double> fft_result_temp;
|
||||
|
||||
msresamp_crcf resampler;
|
||||
double resamplerRatio;
|
||||
|
Loading…
Reference in New Issue
Block a user