mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-28 21:37:50 +02:00
lots o shit
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
#include <complex>
|
||||
#include <gui/widgets/waterfall.h>
|
||||
#include <gui/widgets/frequency_select.h>
|
||||
#include <signal_path/dsp.h>
|
||||
#include <signal_path/iq_frontend.h>
|
||||
#include <gui/icons.h>
|
||||
#include <gui/widgets/bandplan.h>
|
||||
#include <gui/style.h>
|
||||
@ -88,8 +88,8 @@ void MainWindow::init() {
|
||||
fft_out = (fftwf_complex*)fftwf_malloc(sizeof(fftwf_complex) * fftSize);
|
||||
fftwPlan = fftwf_plan_dft_1d(fftSize, fft_in, fft_out, FFTW_FORWARD, FFTW_ESTIMATE);
|
||||
|
||||
sigpath::signalPath.init(8000000, 20, fftSize, &dummyStream, (dsp::complex_t*)fft_in, fftHandler, this);
|
||||
sigpath::signalPath.start();
|
||||
sigpath::iqFrontEnd.init(&dummyStream, 8000000, true, 1, false, 1024, 20.0, IQFrontEnd::FFTWindow::NUTTALL, acquireFFTBuffer, releaseFFTBuffer, this);
|
||||
sigpath::iqFrontEnd.start();
|
||||
|
||||
vfoCreatedHandler.handler = vfoAddedHandler;
|
||||
vfoCreatedHandler.ctx = this;
|
||||
@ -227,37 +227,11 @@ void MainWindow::init() {
|
||||
core::moduleManager.doPostInitAll();
|
||||
}
|
||||
|
||||
void MainWindow::fftHandler(dsp::complex_t* samples, int count, void* ctx) {
|
||||
MainWindow* _this = (MainWindow*)ctx;
|
||||
std::lock_guard<std::mutex> lck(_this->fft_mtx);
|
||||
float* MainWindow::acquireFFTBuffer(void* ctx) {
|
||||
return gui::waterfall.getFFTBuffer();
|
||||
}
|
||||
|
||||
// Check if the count is valid
|
||||
if (count > _this->fftSize) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply window
|
||||
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);
|
||||
|
||||
// Get the FFT buffer
|
||||
float* fftBuf = gui::waterfall.getFFTBuffer();
|
||||
if (fftBuf == NULL) {
|
||||
gui::waterfall.pushFFT();
|
||||
return;
|
||||
}
|
||||
|
||||
// Take power of spectrum
|
||||
volk_32fc_s32f_power_spectrum_32f(fftBuf, (lv_32fc_t*)_this->fft_out, _this->fftSize, _this->fftSize);
|
||||
|
||||
// Push back data
|
||||
void MainWindow::releaseFFTBuffer(void* ctx) {
|
||||
gui::waterfall.pushFFT();
|
||||
}
|
||||
|
||||
@ -530,9 +504,9 @@ void MainWindow::draw() {
|
||||
ImGui::Checkbox("Show demo window", &demoWindow);
|
||||
ImGui::Text("ImGui version: %s", ImGui::GetVersion());
|
||||
|
||||
ImGui::Checkbox("Bypass buffering", &sigpath::signalPath.inputBuffer.bypass);
|
||||
// ImGui::Checkbox("Bypass buffering", &sigpath::iqFrontEnd.inputBuffer.bypass);
|
||||
|
||||
ImGui::Text("Buffering: %d", (sigpath::signalPath.inputBuffer.writeCur - sigpath::signalPath.inputBuffer.readCur + 32) % 32);
|
||||
// ImGui::Text("Buffering: %d", (sigpath::iqFrontEnd.inputBuffer.writeCur - sigpath::iqFrontEnd.inputBuffer.readCur + 32) % 32);
|
||||
|
||||
if (ImGui::Button("Test Bug")) {
|
||||
spdlog::error("Will this make the software crash?");
|
||||
@ -680,7 +654,7 @@ void MainWindow::draw() {
|
||||
void MainWindow::setPlayState(bool _playing) {
|
||||
if (_playing == playing) { return; }
|
||||
if (_playing) {
|
||||
sigpath::signalPath.inputBuffer.flush();
|
||||
sigpath::iqFrontEnd.flushInputBuffer();
|
||||
sigpath::sourceManager.start();
|
||||
sigpath::sourceManager.tune(gui::waterfall.getCenterFrequency());
|
||||
playing = true;
|
||||
@ -690,7 +664,7 @@ void MainWindow::setPlayState(bool _playing) {
|
||||
playing = false;
|
||||
onPlayStateChange.emit(false);
|
||||
sigpath::sourceManager.stop();
|
||||
sigpath::signalPath.inputBuffer.flush();
|
||||
sigpath::iqFrontEnd.flushInputBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
@ -702,27 +676,6 @@ bool MainWindow::sdrIsRunning() {
|
||||
return playing;
|
||||
}
|
||||
|
||||
void MainWindow::setFFTSize(int size) {
|
||||
std::lock_guard<std::mutex> lck(fft_mtx);
|
||||
fftSize = size;
|
||||
|
||||
gui::waterfall.setRawFFTSize(fftSize);
|
||||
sigpath::signalPath.setFFTSize(fftSize);
|
||||
|
||||
fftwf_destroy_plan(fftwPlan);
|
||||
fftwf_free(fft_in);
|
||||
fftwf_free(fft_out);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void MainWindow::setFFTWindow(int win) {
|
||||
std::lock_guard<std::mutex> lck(fft_mtx);
|
||||
sigpath::signalPath.setFFTWindow(win);
|
||||
}
|
||||
|
||||
bool MainWindow::isPlaying() {
|
||||
return playing;
|
||||
}
|
||||
|
@ -17,10 +17,11 @@ public:
|
||||
void draw();
|
||||
void setViewBandwidthSlider(float bandwidth);
|
||||
bool sdrIsRunning();
|
||||
void setFFTSize(int size);
|
||||
void setFFTWindow(int win);
|
||||
void setFirstMenuRender();
|
||||
|
||||
static float* acquireFFTBuffer(void* ctx);
|
||||
static void releaseFFTBuffer(void* ctx);
|
||||
|
||||
// TODO: Replace with it's own class
|
||||
void setVFO(double freq);
|
||||
|
||||
@ -33,7 +34,6 @@ public:
|
||||
Event<bool> onPlayStateChange;
|
||||
|
||||
private:
|
||||
static void fftHandler(dsp::complex_t* samples, int count, void* ctx);
|
||||
static void vfoAddedHandler(VFOManager::VFO* vfo, void* ctx);
|
||||
|
||||
// FFT Variables
|
||||
|
@ -52,6 +52,12 @@ namespace displaymenu {
|
||||
|
||||
int fftSizeId = 0;
|
||||
|
||||
const IQFrontEnd::FFTWindow fftWindowList[] = {
|
||||
IQFrontEnd::FFTWindow::RECTANGULAR,
|
||||
IQFrontEnd::FFTWindow::BLACKMAN,
|
||||
IQFrontEnd::FFTWindow::NUTTALL
|
||||
};
|
||||
|
||||
void updateFFTHoldSpeed() {
|
||||
gui::waterfall.setFFTHoldSpeed(fftHoldSpeed / (fftRate * 10.0f));
|
||||
}
|
||||
@ -89,13 +95,13 @@ namespace displaymenu {
|
||||
break;
|
||||
}
|
||||
}
|
||||
gui::mainWindow.setFFTSize(FFTSizes[fftSizeId]);
|
||||
sigpath::iqFrontEnd.setFFTSize(FFTSizes[fftSizeId]);
|
||||
|
||||
fftRate = core::configManager.conf["fftRate"];
|
||||
sigpath::signalPath.setFFTRate(fftRate);
|
||||
sigpath::iqFrontEnd.setFFTRate(fftRate);
|
||||
|
||||
selectedWindow = std::clamp<int>((int)core::configManager.conf["fftWindow"], 0, _FFT_WINDOW_COUNT - 1);
|
||||
gui::mainWindow.setFFTWindow(selectedWindow);
|
||||
selectedWindow = std::clamp<int>((int)core::configManager.conf["fftWindow"], 0, (sizeof(fftWindowList) / sizeof(IQFrontEnd::FFTWindow)) - 1);
|
||||
sigpath::iqFrontEnd.setFFTWindow(fftWindowList[selectedWindow]);
|
||||
|
||||
gui::menu.locked = core::configManager.conf["lockMenuOrder"];
|
||||
|
||||
@ -172,7 +178,7 @@ namespace displaymenu {
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::InputInt("##sdrpp_fft_rate", &fftRate, 1, 10)) {
|
||||
fftRate = std::max<int>(1, fftRate);
|
||||
sigpath::signalPath.setFFTRate(fftRate);
|
||||
sigpath::iqFrontEnd.setFFTRate(fftRate);
|
||||
updateFFTHoldSpeed();
|
||||
core::configManager.acquire();
|
||||
core::configManager.conf["fftRate"] = fftRate;
|
||||
@ -182,7 +188,7 @@ namespace displaymenu {
|
||||
ImGui::LeftLabel("FFT Size");
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::Combo("##sdrpp_fft_size", &fftSizeId, FFTSizesStr)) {
|
||||
gui::mainWindow.setFFTSize(FFTSizes[fftSizeId]);
|
||||
sigpath::iqFrontEnd.setFFTSize(FFTSizes[fftSizeId]);
|
||||
core::configManager.acquire();
|
||||
core::configManager.conf["fftSize"] = FFTSizes[fftSizeId];
|
||||
core::configManager.release(true);
|
||||
@ -190,8 +196,8 @@ namespace displaymenu {
|
||||
|
||||
ImGui::LeftLabel("FFT Window");
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::Combo("##sdrpp_fft_window", &selectedWindow, "Rectangular\0Blackman\0")) {
|
||||
gui::mainWindow.setFFTWindow(selectedWindow);
|
||||
if (ImGui::Combo("##sdrpp_fft_window", &selectedWindow, "Rectangular\0Blackman\0Nuttall\0")) {
|
||||
sigpath::iqFrontEnd.setFFTWindow(fftWindowList[selectedWindow]);
|
||||
core::configManager.acquire();
|
||||
core::configManager.conf["fftWindow"] = selectedWindow;
|
||||
core::configManager.release(true);
|
||||
|
@ -138,12 +138,12 @@ namespace sourcemenu {
|
||||
offsetMode = core::configManager.conf["offsetMode"];
|
||||
decimationPower = core::configManager.conf["decimationPower"];
|
||||
iqCorrection = core::configManager.conf["iqCorrection"];
|
||||
sigpath::signalPath.setIQCorrection(iqCorrection);
|
||||
sigpath::iqFrontEnd.setDCBlocking(iqCorrection);
|
||||
updateOffset();
|
||||
|
||||
refreshSources();
|
||||
selectSource(selected);
|
||||
sigpath::signalPath.setDecimation(decimationPower);
|
||||
sigpath::iqFrontEnd.setDecimation(1 << decimationPower);
|
||||
|
||||
sourceRegisteredHandler.handler = onSourceRegistered;
|
||||
sourceUnregisterHandler.handler = onSourceUnregister;
|
||||
@ -174,7 +174,7 @@ namespace sourcemenu {
|
||||
sigpath::sourceManager.showSelectedMenu();
|
||||
|
||||
if (ImGui::Checkbox("IQ Correction##_sdrpp_iq_corr", &iqCorrection)) {
|
||||
sigpath::signalPath.setIQCorrection(iqCorrection);
|
||||
sigpath::iqFrontEnd.setDCBlocking(iqCorrection);
|
||||
core::configManager.acquire();
|
||||
core::configManager.conf["iqCorrection"] = iqCorrection;
|
||||
core::configManager.release(true);
|
||||
@ -209,7 +209,7 @@ namespace sourcemenu {
|
||||
ImGui::LeftLabel("Decimation");
|
||||
ImGui::SetNextItemWidth(itemWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::Combo("##source_decim", &decimationPower, decimationStages)) {
|
||||
sigpath::signalPath.setDecimation(decimationPower);
|
||||
sigpath::iqFrontEnd.setDecimation(1 << decimationPower);
|
||||
core::configManager.acquire();
|
||||
core::configManager.conf["decimationPower"] = decimationPower;
|
||||
core::configManager.release(true);
|
||||
|
Reference in New Issue
Block a user