mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-28 05:17:50 +02:00
Save before changes
This commit is contained in:
@ -40,7 +40,7 @@ void SignalPath::setSampleRate(float sampleRate) {
|
||||
fftBlockDec.setSkip(skip);
|
||||
dynSplit.setBlockSize(inputBlockSize);
|
||||
|
||||
mod::broadcastEvent(mod::EVENT_STREAM_PARAM_CHANGED);
|
||||
// TODO: Tell modules that the block size has changed
|
||||
|
||||
for (auto const& [name, vfo] : vfos) {
|
||||
vfo.vfo->setInputSampleRate(sampleRate, inputBlockSize);
|
||||
@ -87,6 +87,7 @@ dsp::VFO* SignalPath::addVFO(std::string name, float outSampleRate, float bandwi
|
||||
void SignalPath::removeVFO(std::string name) {
|
||||
if (vfos.find(name) == vfos.end()) {
|
||||
return;
|
||||
|
||||
}
|
||||
dynSplit.stop();
|
||||
VFO_t vfo = vfos[name];
|
||||
@ -96,4 +97,10 @@ void SignalPath::removeVFO(std::string name) {
|
||||
delete vfo.inputStream;
|
||||
dynSplit.start();
|
||||
vfos.erase(name);
|
||||
}
|
||||
|
||||
void SignalPath::setInput(dsp::stream<dsp::complex_t>* input) {
|
||||
dcBiasRemover.stop();
|
||||
dcBiasRemover.setInput(input);
|
||||
dcBiasRemover.start();
|
||||
}
|
@ -22,6 +22,7 @@ public:
|
||||
void setFFTRate(float rate);
|
||||
dsp::VFO* addVFO(std::string name, float outSampleRate, float bandwidth, float offset);
|
||||
void removeVFO(std::string name);
|
||||
void setInput(dsp::stream<dsp::complex_t>* input);
|
||||
|
||||
private:
|
||||
struct VFO_t {
|
||||
|
@ -3,4 +3,5 @@
|
||||
namespace sigpath {
|
||||
SignalPath signalPath;
|
||||
VFOManager vfoManager;
|
||||
SourceManager sourceManager;
|
||||
};
|
@ -1,9 +1,12 @@
|
||||
#pragma once
|
||||
#include <signal_path/dsp.h>
|
||||
#include <signal_path/vfo_manager.h>
|
||||
#include <signal_path/source.h>
|
||||
#include <io/soapy.h>
|
||||
#include <module.h>
|
||||
|
||||
namespace sigpath {
|
||||
SDRPP_EXPORT SignalPath signalPath;
|
||||
SDRPP_EXPORT VFOManager vfoManager;
|
||||
SDRPP_EXPORT SourceManager sourceManager;
|
||||
};
|
58
core/src/signal_path/source.cpp
Normal file
58
core/src/signal_path/source.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
#include <signal_path/source.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <signal_path/signal_path.h>
|
||||
|
||||
SourceManager::SourceManager() {
|
||||
|
||||
}
|
||||
|
||||
void SourceManager::registerSource(std::string name, SourceHandler* handler) {
|
||||
if (sources.find(name) != sources.end()) {
|
||||
spdlog::error("Tried to register new source with existing name: {0}", name);
|
||||
return;
|
||||
}
|
||||
sources[name] = handler;
|
||||
sourceNames.push_back(name);
|
||||
}
|
||||
|
||||
void SourceManager::selectSource(std::string name) {
|
||||
if (sources.find(name) == sources.end()) {
|
||||
spdlog::error("Tried to select non existant source: {0}", name);
|
||||
return;
|
||||
}
|
||||
if (selectedName != "") {
|
||||
sources[selectedName]->deselectHandler(sources[selectedName]->ctx);
|
||||
}
|
||||
selectedHandler = sources[name];
|
||||
selectedHandler->selectHandler(selectedHandler->ctx);
|
||||
selectedName = name;
|
||||
sigpath::signalPath.setInput(selectedHandler->stream);
|
||||
}
|
||||
|
||||
void SourceManager::showSelectedMenu() {
|
||||
if (selectedHandler == NULL) {
|
||||
return;
|
||||
}
|
||||
selectedHandler->menuHandler(selectedHandler->ctx);
|
||||
}
|
||||
|
||||
void SourceManager::start() {
|
||||
if (selectedHandler == NULL) {
|
||||
return;
|
||||
}
|
||||
selectedHandler->startHandler(selectedHandler->ctx);
|
||||
}
|
||||
|
||||
void SourceManager::stop() {
|
||||
if (selectedHandler == NULL) {
|
||||
return;
|
||||
}
|
||||
selectedHandler->stopHandler(selectedHandler->ctx);
|
||||
}
|
||||
|
||||
void SourceManager::tune(double freq) {
|
||||
if (selectedHandler == NULL) {
|
||||
return;
|
||||
}
|
||||
selectedHandler->tuneHandler(freq, selectedHandler->ctx);
|
||||
}
|
37
core/src/signal_path/source.h
Normal file
37
core/src/signal_path/source.h
Normal file
@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <dsp/stream.h>
|
||||
#include <dsp/types.h>
|
||||
|
||||
class SourceManager {
|
||||
public:
|
||||
SourceManager();
|
||||
|
||||
struct SourceHandler {
|
||||
dsp::stream<dsp::complex_t>* stream;
|
||||
void (*menuHandler)(void* ctx);
|
||||
void (*selectHandler)(void* ctx);
|
||||
void (*deselectHandler)(void* ctx);
|
||||
void (*startHandler)(void* ctx);
|
||||
void (*stopHandler)(void* ctx);
|
||||
void (*tuneHandler)(double freq, void* ctx);
|
||||
void* ctx;
|
||||
};
|
||||
|
||||
void registerSource(std::string name, SourceHandler* handler);
|
||||
void selectSource(std::string name);
|
||||
void showSelectedMenu();
|
||||
void start();
|
||||
void stop();
|
||||
void tune(double freq);
|
||||
|
||||
std::vector<std::string> sourceNames;
|
||||
|
||||
private:
|
||||
std::map<std::string, SourceHandler*> sources;
|
||||
std::string selectedName;
|
||||
SourceHandler* selectedHandler = NULL;
|
||||
|
||||
};
|
Reference in New Issue
Block a user