mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-29 05:47:50 +02:00
Fixed waterfall at very low samplerates
This commit is contained in:
@ -38,9 +38,6 @@ void MainWindow::init() {
|
||||
gui::waterfall.init();
|
||||
gui::waterfall.setRawFFTSize(fftSize);
|
||||
|
||||
appliedWindow = new float[fftSize];
|
||||
generateFFTWindow(selectedWindow, fftSize);
|
||||
|
||||
credits::init();
|
||||
|
||||
core::configManager.acquire();
|
||||
@ -215,10 +212,14 @@ void MainWindow::init() {
|
||||
void MainWindow::fftHandler(dsp::complex_t* samples, int count, void* ctx) {
|
||||
MainWindow* _this = (MainWindow*)ctx;
|
||||
std::lock_guard<std::mutex> lck(_this->fft_mtx);
|
||||
if (count != _this->fftSize) { return; }
|
||||
|
||||
// Apply window
|
||||
volk_32fc_32f_multiply_32fc((lv_32fc_t*)_this->fft_in, (lv_32fc_t*)samples, _this->appliedWindow, count);
|
||||
volk_32fc_32f_multiply_32fc((lv_32fc_t*)_this->fft_in, (lv_32fc_t*)samples, sigpath::signalPath.fftTaps, count);
|
||||
|
||||
// Zero out the rest of the samples
|
||||
if (count < _this->fftSize) {
|
||||
memset(&_this->fft_in[count], 0, (_this->fftSize-count) * sizeof(dsp::complex_t));
|
||||
}
|
||||
|
||||
// Execute FFT
|
||||
fftwf_execute(_this->fftwPlan);
|
||||
@ -231,7 +232,7 @@ void MainWindow::fftHandler(dsp::complex_t* samples, int count, void* ctx) {
|
||||
}
|
||||
|
||||
// Take power of spectrum
|
||||
volk_32fc_s32f_power_spectrum_32f(fftBuf, (lv_32fc_t*)_this->fft_out, count, count);
|
||||
volk_32fc_s32f_power_spectrum_32f(fftBuf, (lv_32fc_t*)_this->fft_out, _this->fftSize, _this->fftSize);
|
||||
|
||||
// Push back data
|
||||
gui::waterfall.pushFFT();
|
||||
@ -663,30 +664,11 @@ void MainWindow::setFFTSize(int size) {
|
||||
fft_in = (fftwf_complex*)fftwf_malloc(sizeof(fftwf_complex) * fftSize);
|
||||
fft_out = (fftwf_complex*)fftwf_malloc(sizeof(fftwf_complex) * fftSize);
|
||||
fftwPlan = fftwf_plan_dft_1d(fftSize, fft_in, fft_out, FFTW_FORWARD, FFTW_ESTIMATE);
|
||||
|
||||
delete appliedWindow;
|
||||
|
||||
appliedWindow = new float[fftSize];
|
||||
generateFFTWindow(selectedWindow, fftSize);
|
||||
}
|
||||
|
||||
void MainWindow::setFFTWindow(int win) {
|
||||
std::lock_guard<std::mutex> lck(fft_mtx);
|
||||
selectedWindow = win;
|
||||
generateFFTWindow(selectedWindow, fftSize);
|
||||
}
|
||||
|
||||
void MainWindow::generateFFTWindow(int win, int size) {
|
||||
if (win == FFT_WINDOW_RECTANGULAR) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
appliedWindow[i] = (i%2) ? 1 : -1;
|
||||
}
|
||||
}
|
||||
else if (win == FFT_WINDOW_BLACKMAN) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
appliedWindow[i] = ((i%2) ? dsp::window_function::blackman(i, size) : -dsp::window_function::blackman(i, size))*2;
|
||||
}
|
||||
}
|
||||
sigpath::signalPath.setFFTWindow(win);
|
||||
}
|
||||
|
||||
bool MainWindow::isPlaying() {
|
||||
|
@ -11,12 +11,6 @@
|
||||
|
||||
#define WINDOW_FLAGS ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoBackground
|
||||
|
||||
enum {
|
||||
FFT_WINDOW_RECTANGULAR,
|
||||
FFT_WINDOW_BLACKMAN,
|
||||
_FFT_WINDOW_COUNT
|
||||
};
|
||||
|
||||
class MainWindow {
|
||||
public:
|
||||
void init();
|
||||
@ -37,7 +31,6 @@ public:
|
||||
Event<bool> onPlayStateChange;
|
||||
|
||||
private:
|
||||
void generateFFTWindow(int win, int size);
|
||||
static void fftHandler(dsp::complex_t* samples, int count, void* ctx);
|
||||
static void vfoAddedHandler(VFOManager::VFO* vfo, void* ctx);
|
||||
|
||||
@ -46,7 +39,6 @@ private:
|
||||
std::mutex fft_mtx;
|
||||
fftwf_complex *fft_in, *fft_out;
|
||||
fftwf_plan fftwPlan;
|
||||
float* appliedWindow;
|
||||
|
||||
// GUI Variables
|
||||
bool firstMenuRender = true;
|
||||
|
Reference in New Issue
Block a user