mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-09-12 11:47:47 -04: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));
|
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();
|
SpectrumVisualProcessor *dproc = wxGetApp().getDemodSpectrumProcessor();
|
||||||
|
|
||||||
dproc->setView(demodWaterfallCanvas->getViewState());
|
dproc->setView(demodWaterfallCanvas->getViewState(), demodWaterfallCanvas->getCenterFrequency(),demodWaterfallCanvas->getBandwidth());
|
||||||
dproc->setBandwidth(demodWaterfallCanvas->getBandwidth());
|
|
||||||
dproc->setCenterFrequency(demodWaterfallCanvas->getCenterFrequency());
|
|
||||||
|
|
||||||
SpectrumVisualProcessor *wproc = waterfallDataThread->getProcessor();
|
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)));
|
GetStatusBar()->SetStatusText(wxString::Format(wxT("Waterfall max speed changed to %d lines per second."),(int)ceil(val*val)));
|
||||||
}
|
}
|
||||||
|
|
||||||
wproc->setView(waterfallCanvas->getViewState());
|
wproc->setView(waterfallCanvas->getViewState(), waterfallCanvas->getCenterFrequency(), waterfallCanvas->getBandwidth());
|
||||||
wproc->setBandwidth(waterfallCanvas->getBandwidth());
|
|
||||||
wproc->setCenterFrequency(waterfallCanvas->getCenterFrequency());
|
|
||||||
wxGetApp().getSDRPostThread()->setIQVisualRange(waterfallCanvas->getCenterFrequency(), waterfallCanvas->getBandwidth());
|
wxGetApp().getSDRPostThread()->setIQVisualRange(waterfallCanvas->getCenterFrequency(), waterfallCanvas->getBandwidth());
|
||||||
|
|
||||||
|
proc->setView(wproc->isView(), wproc->getCenterFrequency(), wproc->getBandwidth());
|
||||||
|
|
||||||
demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
||||||
|
|
||||||
if (modemPropertiesUpdated.load() && demod && demod->isModemInitialized()) {
|
if (modemPropertiesUpdated.load() && demod && demod->isModemInitialized()) {
|
||||||
|
@ -34,6 +34,15 @@ void SpectrumVisualProcessor::setView(bool bView) {
|
|||||||
busy_run.unlock();
|
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) {
|
void SpectrumVisualProcessor::setFFTAverageRate(float fftAverageRate) {
|
||||||
busy_run.lock();
|
busy_run.lock();
|
||||||
this->fft_average_rate.store(fftAverageRate);
|
this->fft_average_rate.store(fftAverageRate);
|
||||||
@ -133,6 +142,8 @@ void SpectrumVisualProcessor::process() {
|
|||||||
|
|
||||||
unsigned int num_written;
|
unsigned int num_written;
|
||||||
long resampleBw = iqData->sampleRate;
|
long resampleBw = iqData->sampleRate;
|
||||||
|
bool newResampler = false;
|
||||||
|
int bwDiff;
|
||||||
|
|
||||||
if (bandwidth > resampleBw) {
|
if (bandwidth > resampleBw) {
|
||||||
iqData->decRefCount();
|
iqData->decRefCount();
|
||||||
@ -199,8 +210,10 @@ void SpectrumVisualProcessor::process() {
|
|||||||
|
|
||||||
resampler = msresamp_crcf_create(resamplerRatio, As);
|
resampler = msresamp_crcf_create(resamplerRatio, As);
|
||||||
|
|
||||||
|
bwDiff = resampleBw-lastBandwidth;
|
||||||
lastBandwidth = resampleBw;
|
lastBandwidth = resampleBw;
|
||||||
lastInputBandwidth = iqData->sampleRate;
|
lastInputBandwidth = iqData->sampleRate;
|
||||||
|
newResampler = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -285,6 +298,7 @@ void SpectrumVisualProcessor::process() {
|
|||||||
fft_result.resize(fftSizeInternal);
|
fft_result.resize(fftSizeInternal);
|
||||||
fft_result_ma.resize(fftSizeInternal);
|
fft_result_ma.resize(fftSizeInternal);
|
||||||
fft_result_maa.resize(fftSizeInternal);
|
fft_result_maa.resize(fftSizeInternal);
|
||||||
|
fft_result_temp.resize(fftSizeInternal);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0, iMax = fftSizeInternal / 2; i < iMax; i++) {
|
for (int i = 0, iMax = fftSizeInternal / 2; i < iMax; i++) {
|
||||||
@ -300,14 +314,49 @@ void SpectrumVisualProcessor::process() {
|
|||||||
fft_result[fftSizeInternal / 2 + i] = (c);
|
fft_result[fftSizeInternal / 2 + i] = (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0, iMax = fftSizeInternal; i < iMax; i++) {
|
if (newResampler) {
|
||||||
if (is_view.load()) {
|
if (bwDiff < 0) {
|
||||||
fft_result_maa[i] += (fft_result_ma[i] - fft_result_maa[i]) * fft_average_rate;
|
for (int i = 0, iMax = fftSizeInternal; i < iMax; i++) {
|
||||||
fft_result_ma[i] += (fft_result[i] - fft_result_ma[i]) * fft_average_rate;
|
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 {
|
} else {
|
||||||
fft_result_maa[i] += (fft_result_ma[i] - fft_result_maa[i]) * fft_average_rate;
|
for (int i = 0, iMax = fftSizeInternal; i < iMax; i++) {
|
||||||
fft_result_ma[i] += (fft_result[i] - fft_result_ma[i]) * fft_average_rate;
|
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) {
|
if (fft_result_maa[i] > fft_ceil) {
|
||||||
fft_ceil = fft_result_maa[i];
|
fft_ceil = fft_result_maa[i];
|
||||||
|
@ -24,6 +24,7 @@ public:
|
|||||||
|
|
||||||
bool isView();
|
bool isView();
|
||||||
void setView(bool bView);
|
void setView(bool bView);
|
||||||
|
void setView(bool bView, long long centerFreq_in, long bandwidth_in);
|
||||||
|
|
||||||
void setFFTAverageRate(float fftAverageRate);
|
void setFFTAverageRate(float fftAverageRate);
|
||||||
float getFFTAverageRate();
|
float getFFTAverageRate();
|
||||||
@ -67,6 +68,7 @@ private:
|
|||||||
std::vector<double> fft_result;
|
std::vector<double> fft_result;
|
||||||
std::vector<double> fft_result_ma;
|
std::vector<double> fft_result_ma;
|
||||||
std::vector<double> fft_result_maa;
|
std::vector<double> fft_result_maa;
|
||||||
|
std::vector<double> fft_result_temp;
|
||||||
|
|
||||||
msresamp_crcf resampler;
|
msresamp_crcf resampler;
|
||||||
double resamplerRatio;
|
double resamplerRatio;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user