added rx888

This commit is contained in:
Ryzerth
2020-11-12 00:53:38 +01:00
parent 0a5fd5c271
commit 02ae50905d
37 changed files with 6038 additions and 85 deletions

View File

@ -1,13 +1,8 @@
#pragma once
#include <dsp/filter.h>
#include <dsp/resampling.h>
#include <dsp/source.h>
#include <dsp/math.h>
#include <dsp/demodulator.h>
#include <dsp/routing.h>
#include <dsp/sink.h>
#include <dsp/vfo.h>
#include <map>
#include <dsp/sink.h>
#include <module.h>
class SignalPath {

View File

@ -4,4 +4,5 @@ namespace sigpath {
SignalPath signalPath;
VFOManager vfoManager;
SourceManager sourceManager;
SinkManager sinkManager;
};

View File

@ -2,10 +2,12 @@
#include <signal_path/dsp.h>
#include <signal_path/vfo_manager.h>
#include <signal_path/source.h>
#include <signal_path/sink.h>
#include <module.h>
namespace sigpath {
SDRPP_EXPORT SignalPath signalPath;
SDRPP_EXPORT VFOManager vfoManager;
SDRPP_EXPORT SourceManager sourceManager;
SDRPP_EXPORT SinkManager sinkManager;
};

View File

@ -0,0 +1,98 @@
#include <signal_path/sink.h>
#include <spdlog/spdlog.h>
#include <core.h>
SinkManager::SinkManager() {
}
SinkManager::Stream::Stream(dsp::stream<dsp::stereo_t>* in, const Event<float>::EventHandler& srChangeHandler, float sampleRate) {
_in = in;
srChange.bindHandler(srChangeHandler);
_sampleRate = sampleRate;
splitter.init(_in);
}
void SinkManager::Stream::setInput(dsp::stream<dsp::stereo_t>* in) {
std::lock_guard<std::mutex> lck(ctrlMtx);
_in = in;
splitter.setInput(_in);
}
dsp::stream<dsp::stereo_t>* SinkManager::Stream::bindStream() {
dsp::stream<dsp::stereo_t>* stream = new dsp::stream<dsp::stereo_t>;
splitter.bindStream(stream);
return stream;
}
void SinkManager::Stream::unbindStream(dsp::stream<dsp::stereo_t>* stream) {
splitter.unbindStream(stream);
delete stream;
}
void SinkManager::Stream::setSampleRate(float sampleRate) {
std::lock_guard<std::mutex> lck(ctrlMtx);
_sampleRate = sampleRate;
srChange.emit(sampleRate);
}
void SinkManager::registerSinkProvider(std::string name, SinkProvider provider) {
if (providers.find(name) != providers.end()) {
spdlog::error("Cannot create sink provider '{0}', this name is already taken", name);
return;
}
providers[name] = provider;
}
void SinkManager::registerStream(std::string name, SinkManager::Stream* stream) {
if (streams.find(name) != streams.end()) {
spdlog::error("Cannot register stream '{0}', this name is already taken", name);
return;
}
core::configManager.aquire();
std::string providerName = core::configManager.conf["defaultSink"];
core::configManager.release();
SinkManager::SinkProvider provider;
if (providers.find(providerName) == providers.end()) {
// TODO: get default
}
else {
provider = providers[providerName];
}
stream->sink = provider.create(stream, provider.ctx);
}
void SinkManager::unregisterStream(std::string name) {
if (streams.find(name) == streams.end()) {
spdlog::error("Cannot unregister stream '{0}', this stream doesn't exist", name);
return;
}
SinkManager::Stream* stream = streams[name];
delete stream->sink;
delete stream;
}
dsp::stream<dsp::stereo_t>* SinkManager::bindStream(std::string name) {
if (streams.find(name) == streams.end()) {
spdlog::error("Cannot bind to stream '{0}'. Stream doesn't exist", name);
return NULL;
}
return streams[name]->bindStream();
}
void SinkManager::unbindStream(std::string name, dsp::stream<dsp::stereo_t>* stream) {
if (streams.find(name) == streams.end()) {
spdlog::error("Cannot unbind from stream '{0}'. Stream doesn't exist", name);
return;
}
streams[name]->unbindStream(stream);
}
void SinkManager::showMenu() {
for (auto const& [name, stream] : streams) {
}
}

View File

@ -0,0 +1,65 @@
#pragma once
#include <map>
#include <string>
#include <dsp/stream.h>
#include <dsp/types.h>
#include <dsp/routing.h>
#include <mutex>
#include <event.h>
class SinkManager {
public:
SinkManager();
class Sink {
public:
virtual void menuHandler() = 0;
};
class Stream {
public:
Stream(dsp::stream<dsp::stereo_t>* in, const Event<float>::EventHandler& srChangeHandler, float sampleRate);
void setInput(dsp::stream<dsp::stereo_t>* in);
dsp::stream<dsp::stereo_t>* bindStream();
void unbindStream(dsp::stream<dsp::stereo_t>* stream);
friend SinkManager;
friend SinkManager::Sink;
Event<float> srChange;
private:
void setSampleRate(float sampleRate);
dsp::stream<dsp::stereo_t>* _in;
dsp::Splitter<dsp::stereo_t> splitter;
SinkManager::Sink* sink;
std::mutex ctrlMtx;
float _sampleRate;
};
struct SinkProvider {
SinkManager::Sink* (*create)(SinkManager::Stream* stream, void* ctx);
void* ctx;
};
void registerSinkProvider(std::string name, SinkProvider provider);
void registerStream(std::string name, Stream* stream);
void unregisterStream(std::string name);
dsp::stream<dsp::stereo_t>* bindStream(std::string name);
void unbindStream(std::string name, dsp::stream<dsp::stereo_t>* stream);
void showMenu();
private:
// TODO: Replace with std::unordered_map
std::map<std::string, SinkProvider> providers;
std::map<std::string, Stream*> streams;
};