mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-03-12 12:00:08 +01:00
Added FFTSize setting
This commit is contained in:
parent
b74043e2ee
commit
48bba00cb3
@ -108,6 +108,7 @@ int sdrpp_main(int argc, char *argv[]) {
|
|||||||
defConfig["colorMap"] = "Classic";
|
defConfig["colorMap"] = "Classic";
|
||||||
defConfig["fastFFT"] = false;
|
defConfig["fastFFT"] = false;
|
||||||
defConfig["fftHeight"] = 300;
|
defConfig["fftHeight"] = 300;
|
||||||
|
defConfig["fftSize"] = 65536;
|
||||||
defConfig["frequency"] = 100000000.0;
|
defConfig["frequency"] = 100000000.0;
|
||||||
defConfig["fullWaterfallUpdate"] = false;
|
defConfig["fullWaterfallUpdate"] = false;
|
||||||
defConfig["max"] = 0.0;
|
defConfig["max"] = 0.0;
|
||||||
|
@ -33,25 +33,6 @@
|
|||||||
#include <options.h>
|
#include <options.h>
|
||||||
#include <gui/colormaps.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;
|
int fftSize = 8192 * 8;
|
||||||
|
|
||||||
std::mutex fft_mtx;
|
std::mutex fft_mtx;
|
||||||
@ -64,6 +45,7 @@ bool experimentalZoom = false;
|
|||||||
|
|
||||||
void fftHandler(dsp::complex_t* samples, int count, void* ctx) {
|
void fftHandler(dsp::complex_t* samples, int count, void* ctx) {
|
||||||
std::lock_guard<std::mutex> lck(fft_mtx);
|
std::lock_guard<std::mutex> lck(fft_mtx);
|
||||||
|
if (count != fftSize) { return; }
|
||||||
|
|
||||||
memcpy(fft_in, samples, count * sizeof(dsp::complex_t));
|
memcpy(fft_in, samples, count * sizeof(dsp::complex_t));
|
||||||
fftwf_execute(p);
|
fftwf_execute(p);
|
||||||
@ -568,22 +550,6 @@ void drawWindow() {
|
|||||||
spdlog::error("Will this make the software crash?");
|
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();
|
ImGui::Spacing();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -671,3 +637,19 @@ void setViewBandwidthSlider(float bandwidth) {
|
|||||||
bool sdrIsRunning() {
|
bool sdrIsRunning() {
|
||||||
return playing;
|
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);
|
||||||
|
}
|
@ -7,3 +7,4 @@ void windowInit();
|
|||||||
void drawWindow();
|
void drawWindow();
|
||||||
void setViewBandwidthSlider(float bandwidth);
|
void setViewBandwidthSlider(float bandwidth);
|
||||||
bool sdrIsRunning();
|
bool sdrIsRunning();
|
||||||
|
void setFFTSize(int size);
|
@ -4,6 +4,7 @@
|
|||||||
#include <core.h>
|
#include <core.h>
|
||||||
#include <gui/colormaps.h>
|
#include <gui/colormaps.h>
|
||||||
#include <gui/gui.h>
|
#include <gui/gui.h>
|
||||||
|
#include <gui/main_window.h>
|
||||||
|
|
||||||
namespace displaymenu {
|
namespace displaymenu {
|
||||||
bool showWaterfall;
|
bool showWaterfall;
|
||||||
@ -14,6 +15,26 @@ namespace displaymenu {
|
|||||||
std::string colorMapNamesTxt = "";
|
std::string colorMapNamesTxt = "";
|
||||||
std::string colorMapAuthor = "";
|
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() {
|
void init() {
|
||||||
showWaterfall = core::configManager.conf["showWaterfall"];
|
showWaterfall = core::configManager.conf["showWaterfall"];
|
||||||
showWaterfall ? gui::waterfall.showWaterfall() : gui::waterfall.hideWaterfall();
|
showWaterfall ? gui::waterfall.showWaterfall() : gui::waterfall.hideWaterfall();
|
||||||
@ -38,17 +59,52 @@ namespace displaymenu {
|
|||||||
|
|
||||||
fullWaterfallUpdate = core::configManager.conf["fullWaterfallUpdate"];
|
fullWaterfallUpdate = core::configManager.conf["fullWaterfallUpdate"];
|
||||||
gui::waterfall.setFullWaterfallUpdate(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) {
|
void draw(void* ctx) {
|
||||||
float menuWidth = ImGui::GetContentRegionAvailWidth();
|
float menuWidth = ImGui::GetContentRegionAvailWidth();
|
||||||
if (ImGui::Checkbox("Show Waterfall", &showWaterfall)) {
|
if (ImGui::Checkbox("Show Waterfall##_sdrpp", &showWaterfall)) {
|
||||||
showWaterfall ? gui::waterfall.showWaterfall() : gui::waterfall.hideWaterfall();
|
showWaterfall ? gui::waterfall.showWaterfall() : gui::waterfall.hideWaterfall();
|
||||||
core::configManager.aquire();
|
core::configManager.aquire();
|
||||||
core::configManager.conf["showWaterfall"] = showWaterfall;
|
core::configManager.conf["showWaterfall"] = showWaterfall;
|
||||||
core::configManager.release(true);
|
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) {
|
if (colorMapNames.size() > 0) {
|
||||||
ImGui::Text("Color Map");
|
ImGui::Text("Color Map");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -64,18 +120,6 @@ namespace displaymenu {
|
|||||||
ImGui::Text("Color map Author: %s", colorMapAuthor.c_str());
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -97,7 +97,10 @@ void SignalPath::unbindIQStream(dsp::stream<dsp::complex_t>* stream) {
|
|||||||
void SignalPath::setFFTSize(int size) {
|
void SignalPath::setFFTSize(int size) {
|
||||||
fftSize = size;
|
fftSize = size;
|
||||||
int skip = (sampleRate / fftRate) - fftSize;
|
int skip = (sampleRate / fftRate) - fftSize;
|
||||||
|
reshape.stop();
|
||||||
reshape.setSkip(skip);
|
reshape.setSkip(skip);
|
||||||
|
reshape.setKeep(fftSize);
|
||||||
|
reshape.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SignalPath::startFFT() {
|
void SignalPath::startFFT() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user