Half-band transition and frequency change peak hold tweaks

This commit is contained in:
Charles J. Cliffe 2015-12-31 21:28:56 -05:00
parent fe264b9da1
commit 01c10efeff
3 changed files with 19 additions and 16 deletions

View File

@ -420,6 +420,7 @@ void CubicSDR::setFrequency(long long freq) {
} }
frequency = freq; frequency = freq;
sdrThread->setFrequency(freq); sdrThread->setFrequency(freq);
getSpectrumProcessor()->setPeakHold(getSpectrumProcessor()->getPeakHold());
} }
long long CubicSDR::getOffset() { long long CubicSDR::getOffset() {

View File

@ -81,7 +81,7 @@ void SpectrumVisualProcessor::setPeakHold(bool peakHold_in) {
fft_ceil_peak = fft_floor_maa; fft_ceil_peak = fft_floor_maa;
fft_floor_peak = fft_ceil_maa; fft_floor_peak = fft_ceil_maa;
for (int i = 0, iMax = fftSizeInternal; i < iMax; i++) { for (int i = 0, iMax = fft_result_peak.size(); i < iMax; i++) {
fft_result_peak[i] = fft_floor_maa; fft_result_peak[i] = fft_floor_maa;
} }
peakHold.store(peakHold_in); peakHold.store(peakHold_in);
@ -405,9 +405,9 @@ void SpectrumVisualProcessor::process() {
} else { } else {
for (int i = 0, iMax = fftSizeInternal; i < iMax; i++) { for (int i = 0, iMax = fftSizeInternal; i < iMax; i++) {
if (i < fftSizeInternal/4) { if (i < fftSizeInternal/4) {
fft_result_temp[i] = fft_result_ma[fftSizeInternal/4]; fft_result_temp[i] = 0; // fft_result_ma[fftSizeInternal/4];
} else if (i >= fftSizeInternal - fftSizeInternal/4) { } else if (i >= fftSizeInternal - fftSizeInternal/4) {
fft_result_temp[i] = fft_result_ma[fftSizeInternal - fftSizeInternal/4-1]; fft_result_temp[i] = 0; // fft_result_ma[fftSizeInternal - fftSizeInternal/4-1];
} else { } else {
fft_result_temp[i] = fft_result_ma[(i-fftSizeInternal/4)*2]; fft_result_temp[i] = fft_result_ma[(i-fftSizeInternal/4)*2];
} }
@ -416,9 +416,9 @@ void SpectrumVisualProcessor::process() {
fft_result_ma[i] = fft_result_temp[i]; fft_result_ma[i] = fft_result_temp[i];
if (i < fftSizeInternal/4) { if (i < fftSizeInternal/4) {
fft_result_temp[i] = fft_result_maa[fftSizeInternal/4]; fft_result_temp[i] = 0; //fft_result_maa[fftSizeInternal/4];
} else if (i >= fftSizeInternal - fftSizeInternal/4) { } else if (i >= fftSizeInternal - fftSizeInternal/4) {
fft_result_temp[i] = fft_result_maa[fftSizeInternal - fftSizeInternal/4-1]; fft_result_temp[i] = 0; // fft_result_maa[fftSizeInternal - fftSizeInternal/4-1];
} else { } else {
fft_result_temp[i] = fft_result_maa[(i-fftSizeInternal/4)*2]; fft_result_temp[i] = fft_result_maa[(i-fftSizeInternal/4)*2];
} }
@ -427,8 +427,10 @@ void SpectrumVisualProcessor::process() {
fft_result_maa[i] = fft_result_temp[i]; fft_result_maa[i] = fft_result_temp[i];
} }
} }
}
if (newResampler) {
for (int i = 0, iMax = fftSizeInternal; i < iMax; i++) { for (int i = 0, iMax = fftSizeInternal; i < iMax; i++) {
fft_result_peak[i] = fft_result_maa[i]; fft_result_peak[i] = fft_floor_maa;
} }
} }
@ -485,15 +487,16 @@ void SpectrumVisualProcessor::process() {
while (visualAccum >= 1.0) { while (visualAccum >= 1.0) {
int idx = round(visualStart+i); int idx = round(visualStart+i);
if (idx < 0) { if (idx > 0 && idx < fftSizeInternal) {
idx = 0; acc += fft_result_maa[idx];
} if (doPeak) {
if (idx > fftSizeInternal-1) { peak_acc += fft_result_peak[idx];
idx = fftSizeInternal-1; }
} } else {
acc += fft_result_maa[idx]; acc += fft_floor_maa;
if (doPeak) { if (doPeak) {
peak_acc += fft_result_peak[idx]; peak_acc += fft_floor_maa;
}
} }
accCount += 1.0; accCount += 1.0;
visualAccum -= 1.0; visualAccum -= 1.0;

View File

@ -141,7 +141,6 @@ void SpectrumCanvas::moveCenterFrequency(long long freqChange) {
freq -= freqChange; freq -= freqChange;
} }
wxGetApp().setFrequency(freq); wxGetApp().setFrequency(freq);
wxGetApp().getSpectrumProcessor()->setPeakHold(wxGetApp().getSpectrumProcessor()->getPeakHold());
} }
} }