Added FFTSize setting

This commit is contained in:
Ryzerth 2021-04-13 18:31:38 +02:00
parent b74043e2ee
commit 48bba00cb3
5 changed files with 81 additions and 50 deletions

View File

@ -108,6 +108,7 @@ int sdrpp_main(int argc, char *argv[]) {
defConfig["colorMap"] = "Classic";
defConfig["fastFFT"] = false;
defConfig["fftHeight"] = 300;
defConfig["fftSize"] = 65536;
defConfig["frequency"] = 100000000.0;
defConfig["fullWaterfallUpdate"] = false;
defConfig["max"] = 0.0;

View File

@ -33,25 +33,6 @@
#include <options.h>
#include <gui/colormaps.h>
const int FFTSizes[] = {
65536,
32768,
16384,
8192,
4096,
2048,
1024
};
const char* FFTSizesStr = "65536\0"
"32768\0"
"16384\0"
"8192\0"
"4096\0"
"2048\0"
"1024\0";
int fftSizeId = 0;
int fftSize = 8192 * 8;
std::mutex fft_mtx;
@ -64,6 +45,7 @@ bool experimentalZoom = false;
void fftHandler(dsp::complex_t* samples, int count, void* ctx) {
std::lock_guard<std::mutex> lck(fft_mtx);
if (count != fftSize) { return; }
memcpy(fft_in, samples, count * sizeof(dsp::complex_t));
fftwf_execute(p);
@ -568,22 +550,6 @@ void drawWindow() {
spdlog::error("Will this make the software crash?");
}
if (ImGui::Combo("##test_fft_size", &fftSizeId, FFTSizesStr)) {
std::lock_guard<std::mutex> lck(fft_mtx);
fftSize = FFTSizes[fftSizeId];
gui::waterfall.setRawFFTSize(fftSize);
sigpath::signalPath.setFFTSize(fftSize);
fftwf_free(fft_in);
fftwf_free(fft_out);
fftwf_destroy_plan(p);
fft_in = (fftwf_complex*)fftwf_malloc(sizeof(fftwf_complex) * fftSize);
fft_out = (fftwf_complex*)fftwf_malloc(sizeof(fftwf_complex) * fftSize);
p = fftwf_plan_dft_1d(fftSize, fft_in, fft_out, FFTW_FORWARD, FFTW_ESTIMATE);
}
ImGui::Spacing();
}
@ -670,4 +636,20 @@ void setViewBandwidthSlider(float bandwidth) {
bool sdrIsRunning() {
return playing;
}
void setFFTSize(int size) {
std::lock_guard<std::mutex> lck(fft_mtx);
fftSize = size;
gui::waterfall.setRawFFTSize(fftSize);
sigpath::signalPath.setFFTSize(fftSize);
fftwf_free(fft_in);
fftwf_free(fft_out);
fftwf_destroy_plan(p);
fft_in = (fftwf_complex*)fftwf_malloc(sizeof(fftwf_complex) * fftSize);
fft_out = (fftwf_complex*)fftwf_malloc(sizeof(fftwf_complex) * fftSize);
p = fftwf_plan_dft_1d(fftSize, fft_in, fft_out, FFTW_FORWARD, FFTW_ESTIMATE);
}

View File

@ -6,4 +6,5 @@
void windowInit();
void drawWindow();
void setViewBandwidthSlider(float bandwidth);
bool sdrIsRunning();
bool sdrIsRunning();
void setFFTSize(int size);

View File

@ -4,6 +4,7 @@
#include <core.h>
#include <gui/colormaps.h>
#include <gui/gui.h>
#include <gui/main_window.h>
namespace displaymenu {
bool showWaterfall;
@ -14,6 +15,26 @@ namespace displaymenu {
std::string colorMapNamesTxt = "";
std::string colorMapAuthor = "";
const int FFTSizes[] = {
65536,
32768,
16384,
8192,
4096,
2048,
1024
};
const char* FFTSizesStr = "65536\0"
"32768\0"
"16384\0"
"8192\0"
"4096\0"
"2048\0"
"1024\0";
int fftSizeId = 0;
void init() {
showWaterfall = core::configManager.conf["showWaterfall"];
showWaterfall ? gui::waterfall.showWaterfall() : gui::waterfall.hideWaterfall();
@ -38,17 +59,52 @@ namespace displaymenu {
fullWaterfallUpdate = core::configManager.conf["fullWaterfallUpdate"];
gui::waterfall.setFullWaterfallUpdate(fullWaterfallUpdate);
fftSizeId = 0;
int fftSize = core::configManager.conf["fftSize"];
for (int i = 0; i < 7; i++) {
if (fftSize == FFTSizes[i]) {
fftSizeId = i;
break;
}
}
setFFTSize(FFTSizes[fftSizeId]);
}
void draw(void* ctx) {
float menuWidth = ImGui::GetContentRegionAvailWidth();
if (ImGui::Checkbox("Show Waterfall", &showWaterfall)) {
if (ImGui::Checkbox("Show Waterfall##_sdrpp", &showWaterfall)) {
showWaterfall ? gui::waterfall.showWaterfall() : gui::waterfall.hideWaterfall();
core::configManager.aquire();
core::configManager.conf["showWaterfall"] = showWaterfall;
core::configManager.release(true);
}
if (ImGui::Checkbox("Fast FFT##_sdrpp", &fastFFT)) {
gui::waterfall.setFastFFT(fastFFT);
core::configManager.aquire();
core::configManager.conf["fastFFT"] = fastFFT;
core::configManager.release(true);
}
if (ImGui::Checkbox("Full Waterfall Update##_sdrpp", &fullWaterfallUpdate)) {
gui::waterfall.setFullWaterfallUpdate(fullWaterfallUpdate);
core::configManager.aquire();
core::configManager.conf["fullWaterfallUpdate"] = fullWaterfallUpdate;
core::configManager.release(true);
}
ImGui::Text("FFT Size");
ImGui::SameLine();
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
if (ImGui::Combo("##test_fft_size", &fftSizeId, FFTSizesStr)) {
setFFTSize(FFTSizes[fftSizeId]);
core::configManager.aquire();
core::configManager.conf["fftSize"] = FFTSizes[fftSizeId];
core::configManager.release(true);
}
if (colorMapNames.size() > 0) {
ImGui::Text("Color Map");
ImGui::SameLine();
@ -64,18 +120,6 @@ namespace displaymenu {
ImGui::Text("Color map Author: %s", colorMapAuthor.c_str());
}
if (ImGui::Checkbox("Fast FFT", &fastFFT)) {
gui::waterfall.setFastFFT(fastFFT);
core::configManager.aquire();
core::configManager.conf["fastFFT"] = fastFFT;
core::configManager.release(true);
}
if (ImGui::Checkbox("Full Waterfall Update", &fullWaterfallUpdate)) {
gui::waterfall.setFullWaterfallUpdate(fullWaterfallUpdate);
core::configManager.aquire();
core::configManager.conf["fullWaterfallUpdate"] = fullWaterfallUpdate;
core::configManager.release(true);
}
}
}

View File

@ -97,7 +97,10 @@ void SignalPath::unbindIQStream(dsp::stream<dsp::complex_t>* stream) {
void SignalPath::setFFTSize(int size) {
fftSize = size;
int skip = (sampleRate / fftRate) - fftSize;
reshape.stop();
reshape.setSkip(skip);
reshape.setKeep(fftSize);
reshape.start();
}
void SignalPath::startFFT() {