mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-25 12:07:49 +02:00
Save before changes
This commit is contained in:
@ -7,12 +7,115 @@
|
||||
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
||||
#define DEEMP_LIST "50µS\00075µS\000none\000"
|
||||
|
||||
mod::API_t* API;
|
||||
MOD_INFO {
|
||||
/* Name: */ "radio",
|
||||
/* Description: */ "Radio module for SDR++",
|
||||
/* Author: */ "Ryzerth",
|
||||
/* Version: */ "0.2.5"
|
||||
};
|
||||
|
||||
ConfigManager config;
|
||||
bool firstInit = true;
|
||||
class RadioModule {
|
||||
public:
|
||||
RadioModule(std::string name) {
|
||||
this->name = name;
|
||||
demod = 1;
|
||||
bandWidth = 200000;
|
||||
bandWidthMin = 100000;
|
||||
bandWidthMax = 200000;
|
||||
sigPath.init(name, 200000, 1000);
|
||||
sigPath.start();
|
||||
sigPath.setDemodulator(SigPath::DEMOD_FM, bandWidth);
|
||||
}
|
||||
|
||||
~RadioModule() {
|
||||
// TODO: Implement destructor
|
||||
}
|
||||
|
||||
private:
|
||||
static void menuHandler(void* ctx) {
|
||||
RadioModule* _this = (RadioModule*)ctx;
|
||||
float menuColumnWidth = ImGui::GetContentRegionAvailWidth();
|
||||
|
||||
ImGui::BeginGroup();
|
||||
|
||||
// TODO: Change VFO ref in signal path
|
||||
|
||||
ImGui::Columns(4, CONCAT("RadioModeColumns##_", _this->name), false);
|
||||
if (ImGui::RadioButton(CONCAT("NFM##_", _this->name), _this->demod == 0) && _this->demod != 0) {
|
||||
_this->demod = 0;
|
||||
_this->bandWidth = 16000;
|
||||
_this->bandWidthMin = 8000;
|
||||
_this->bandWidthMax = 16000;
|
||||
_this->sigPath.setDemodulator(SigPath::DEMOD_NFM, _this->bandWidth);
|
||||
}
|
||||
if (ImGui::RadioButton(CONCAT("WFM##_", _this->name), _this->demod == 1) && _this->demod != 1) {
|
||||
_this->demod = 1;
|
||||
_this->bandWidth = 200000;
|
||||
_this->bandWidthMin = 100000;
|
||||
_this->bandWidthMax = 200000;
|
||||
_this->sigPath.setDemodulator(SigPath::DEMOD_FM, _this->bandWidth);
|
||||
}
|
||||
ImGui::NextColumn();
|
||||
if (ImGui::RadioButton(CONCAT("AM##_", _this->name), _this->demod == 2) && _this->demod != 2) {
|
||||
_this->demod = 2;
|
||||
_this->bandWidth = 12500;
|
||||
_this->bandWidthMin = 6250;
|
||||
_this->bandWidthMax = 12500;
|
||||
_this->sigPath.setDemodulator(SigPath::DEMOD_AM, _this->bandWidth);
|
||||
}
|
||||
if (ImGui::RadioButton(CONCAT("DSB##_", _this->name), _this->demod == 3) && _this->demod != 3) {
|
||||
_this->demod = 3;
|
||||
_this->bandWidth = 6000;
|
||||
_this->bandWidthMin = 3000;
|
||||
_this->bandWidthMax = 6000;
|
||||
_this->sigPath.setDemodulator(SigPath::DEMOD_DSB, _this->bandWidth);
|
||||
}
|
||||
ImGui::NextColumn();
|
||||
if (ImGui::RadioButton(CONCAT("USB##_", _this->name), _this->demod == 4) && _this->demod != 4) {
|
||||
_this->demod = 4;
|
||||
_this->bandWidth = 3000;
|
||||
_this->bandWidthMin = 1500;
|
||||
_this->bandWidthMax = 3000;
|
||||
_this->sigPath.setDemodulator(SigPath::DEMOD_USB, _this->bandWidth);
|
||||
}
|
||||
if (ImGui::RadioButton(CONCAT("CW##_", _this->name), _this->demod == 5) && _this->demod != 5) { _this->demod = 5; };
|
||||
ImGui::NextColumn();
|
||||
if (ImGui::RadioButton(CONCAT("LSB##_", _this->name), _this->demod == 6) && _this->demod != 6) {
|
||||
_this->demod = 6;
|
||||
_this->bandWidth = 3000;
|
||||
_this->bandWidthMin = 1500;
|
||||
_this->bandWidthMax = 3000;
|
||||
_this->sigPath.setDemodulator(SigPath::DEMOD_LSB, _this->bandWidth);
|
||||
}
|
||||
if (ImGui::RadioButton(CONCAT("RAW##_", _this->name), _this->demod == 7) && _this->demod != 7) {
|
||||
_this->demod = 7;
|
||||
_this->bandWidth = 10000;
|
||||
_this->bandWidthMin = 3000;
|
||||
_this->bandWidthMax = 10000;
|
||||
_this->sigPath.setDemodulator(SigPath::DEMOD_RAW, _this->bandWidth);
|
||||
};
|
||||
ImGui::Columns(1, CONCAT("EndRadioModeColumns##_", _this->name), false);
|
||||
|
||||
ImGui::EndGroup();
|
||||
|
||||
ImGui::Text("WFM Deemphasis");
|
||||
ImGui::SameLine();
|
||||
ImGui::PushItemWidth(menuColumnWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::Combo(CONCAT("##_deemp_select_", _this->name), &_this->deemp, DEEMP_LIST)) {
|
||||
_this->sigPath.setDeemphasis(_this->deemp);
|
||||
}
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
ImGui::Text("Bandwidth");
|
||||
ImGui::SameLine();
|
||||
ImGui::PushItemWidth(menuColumnWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::InputInt(CONCAT("##_bw_select_", _this->name), &_this->bandWidth, 100, 1000)) {
|
||||
_this->bandWidth = std::clamp<int>(_this->bandWidth, _this->bandWidthMin, _this->bandWidthMax);
|
||||
_this->sigPath.setBandwidth(_this->bandWidth);
|
||||
}
|
||||
ImGui::PopItemWidth();
|
||||
}
|
||||
|
||||
struct RadioContext_t {
|
||||
std::string name;
|
||||
int demod = 1;
|
||||
int deemp = 0;
|
||||
@ -20,117 +123,21 @@ struct RadioContext_t {
|
||||
int bandWidthMin;
|
||||
int bandWidthMax;
|
||||
SigPath sigPath;
|
||||
|
||||
};
|
||||
|
||||
MOD_EXPORT void* _INIT_(mod::API_t* _API, ImGuiContext* imctx, std::string _name) {
|
||||
API = _API;
|
||||
RadioContext_t* ctx = new RadioContext_t;
|
||||
|
||||
ctx->name = _name;
|
||||
|
||||
ctx->demod = 1;
|
||||
ctx->bandWidth = 200000;
|
||||
ctx->bandWidthMin = 100000;
|
||||
ctx->bandWidthMax = 200000;
|
||||
ctx->sigPath.init(_name, 200000, 1000);
|
||||
ctx->sigPath.start();
|
||||
ctx->sigPath.setDemodulator(SigPath::DEMOD_FM, ctx->bandWidth);
|
||||
ImGui::SetCurrentContext(imctx);
|
||||
return ctx;
|
||||
MOD_EXPORT void _INIT_() {
|
||||
// Do your one time init here
|
||||
}
|
||||
|
||||
MOD_EXPORT void _NEW_FRAME_(RadioContext_t* ctx) {
|
||||
|
||||
MOD_EXPORT void* _CREATE_INSTANCE_(std::string name) {
|
||||
return new RadioModule(name);
|
||||
}
|
||||
|
||||
MOD_EXPORT void _DRAW_MENU_(RadioContext_t* ctx) {
|
||||
float menuColumnWidth = ImGui::GetContentRegionAvailWidth();
|
||||
|
||||
ImGui::BeginGroup();
|
||||
|
||||
// TODO: Change VFO ref in signal path
|
||||
|
||||
ImGui::Columns(4, CONCAT("RadioModeColumns##_", ctx->name), false);
|
||||
if (ImGui::RadioButton(CONCAT("NFM##_", ctx->name), ctx->demod == 0) && ctx->demod != 0) {
|
||||
ctx->demod = 0;
|
||||
ctx->bandWidth = 16000;
|
||||
ctx->bandWidthMin = 8000;
|
||||
ctx->bandWidthMax = 16000;
|
||||
ctx->sigPath.setDemodulator(SigPath::DEMOD_NFM, ctx->bandWidth);
|
||||
}
|
||||
if (ImGui::RadioButton(CONCAT("WFM##_", ctx->name), ctx->demod == 1) && ctx->demod != 1) {
|
||||
ctx->demod = 1;
|
||||
ctx->bandWidth = 200000;
|
||||
ctx->bandWidthMin = 100000;
|
||||
ctx->bandWidthMax = 200000;
|
||||
ctx->sigPath.setDemodulator(SigPath::DEMOD_FM, ctx->bandWidth);
|
||||
}
|
||||
ImGui::NextColumn();
|
||||
if (ImGui::RadioButton(CONCAT("AM##_", ctx->name), ctx->demod == 2) && ctx->demod != 2) {
|
||||
ctx->demod = 2;
|
||||
ctx->bandWidth = 12500;
|
||||
ctx->bandWidthMin = 6250;
|
||||
ctx->bandWidthMax = 12500;
|
||||
ctx->sigPath.setDemodulator(SigPath::DEMOD_AM, ctx->bandWidth);
|
||||
}
|
||||
if (ImGui::RadioButton(CONCAT("DSB##_", ctx->name), ctx->demod == 3) && ctx->demod != 3) {
|
||||
ctx->demod = 3;
|
||||
ctx->bandWidth = 6000;
|
||||
ctx->bandWidthMin = 3000;
|
||||
ctx->bandWidthMax = 6000;
|
||||
ctx->sigPath.setDemodulator(SigPath::DEMOD_DSB, ctx->bandWidth);
|
||||
}
|
||||
ImGui::NextColumn();
|
||||
if (ImGui::RadioButton(CONCAT("USB##_", ctx->name), ctx->demod == 4) && ctx->demod != 4) {
|
||||
ctx->demod = 4;
|
||||
ctx->bandWidth = 3000;
|
||||
ctx->bandWidthMin = 1500;
|
||||
ctx->bandWidthMax = 3000;
|
||||
ctx->sigPath.setDemodulator(SigPath::DEMOD_USB, ctx->bandWidth);
|
||||
}
|
||||
if (ImGui::RadioButton(CONCAT("CW##_", ctx->name), ctx->demod == 5) && ctx->demod != 5) { ctx->demod = 5; };
|
||||
ImGui::NextColumn();
|
||||
if (ImGui::RadioButton(CONCAT("LSB##_", ctx->name), ctx->demod == 6) && ctx->demod != 6) {
|
||||
ctx->demod = 6;
|
||||
ctx->bandWidth = 3000;
|
||||
ctx->bandWidthMin = 1500;
|
||||
ctx->bandWidthMax = 3000;
|
||||
ctx->sigPath.setDemodulator(SigPath::DEMOD_LSB, ctx->bandWidth);
|
||||
}
|
||||
if (ImGui::RadioButton(CONCAT("RAW##_", ctx->name), ctx->demod == 7) && ctx->demod != 7) {
|
||||
ctx->demod = 7;
|
||||
ctx->bandWidth = 10000;
|
||||
ctx->bandWidthMin = 3000;
|
||||
ctx->bandWidthMax = 10000;
|
||||
ctx->sigPath.setDemodulator(SigPath::DEMOD_RAW, ctx->bandWidth);
|
||||
};
|
||||
ImGui::Columns(1, CONCAT("EndRadioModeColumns##_", ctx->name), false);
|
||||
|
||||
ImGui::EndGroup();
|
||||
|
||||
ImGui::Text("WFM Deemphasis");
|
||||
ImGui::SameLine();
|
||||
ImGui::PushItemWidth(menuColumnWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::Combo(CONCAT("##_deemp_select_", ctx->name), &ctx->deemp, DEEMP_LIST)) {
|
||||
ctx->sigPath.setDeemphasis(ctx->deemp);
|
||||
}
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
ImGui::Text("Bandwidth");
|
||||
ImGui::SameLine();
|
||||
ImGui::PushItemWidth(menuColumnWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::InputInt(CONCAT("##_bw_select_", ctx->name), &ctx->bandWidth, 100, 1000)) {
|
||||
ctx->bandWidth = std::clamp<int>(ctx->bandWidth, ctx->bandWidthMin, ctx->bandWidthMax);
|
||||
ctx->sigPath.setBandwidth(ctx->bandWidth);
|
||||
}
|
||||
ImGui::PopItemWidth();
|
||||
MOD_EXPORT void _DELETE_INSTANCE_(void* instance) {
|
||||
delete (RadioModule*)instance;
|
||||
}
|
||||
|
||||
MOD_EXPORT void _HANDLE_EVENT_(RadioContext_t* ctx, int eventId) {
|
||||
|
||||
}
|
||||
|
||||
MOD_EXPORT void _STOP_(RadioContext_t* ctx) {
|
||||
API->removeVFO(ctx->name);
|
||||
delete ctx;
|
||||
MOD_EXPORT void _STOP_() {
|
||||
// Do your one shutdown here
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
#include <path.h>
|
||||
#include <signal_path/audio.h>
|
||||
|
||||
SigPath::SigPath() {
|
||||
|
||||
@ -23,7 +24,7 @@ void SigPath::init(std::string vfoName, uint64_t sampleRate, int blockSize) {
|
||||
this->blockSize = blockSize;
|
||||
this->vfoName = vfoName;
|
||||
|
||||
vfo = sigpath::vfoManager.createVFO(vfoName, mod::API_t::REF_CENTER, 0, 200000, 200000, 1000);
|
||||
vfo = sigpath::vfoManager.createVFO(vfoName, ImGui::WaterfallVFO::REF_CENTER, 0, 200000, 200000, 1000);
|
||||
|
||||
_demod = DEMOD_FM;
|
||||
_deemp = DEEMP_50US;
|
||||
@ -40,8 +41,9 @@ void SigPath::init(std::string vfoName, uint64_t sampleRate, int blockSize) {
|
||||
|
||||
audioResamp.init(&demod.output, 200000, 48000, 800);
|
||||
deemp.init(&audioResamp.output, 800, 50e-6, 48000);
|
||||
outputSampleRate = API->registerMonoStream(&deemp.output, vfoName, vfoName, sampleRateChangeHandler, this);
|
||||
API->setBlockSize(vfoName, audioResamp.getOutputBlockSize());
|
||||
|
||||
outputSampleRate = audio::registerMonoStream(&deemp.output, vfoName, vfoName, sampleRateChangeHandler, this);
|
||||
audio::setBlockSize(vfoName, audioResamp.getOutputBlockSize());
|
||||
|
||||
setDemodulator(_demod, bandwidth);
|
||||
}
|
||||
@ -101,7 +103,7 @@ void SigPath::setDemodulator(int demId, float bandWidth) {
|
||||
audioBw = std::min<float>(bandwidth, outputSampleRate / 2.0f);
|
||||
audioResamp.setInputSampleRate(200000, vfo->getOutputBlockSize(), audioBw, audioBw);
|
||||
deemp.bypass = (_deemp == DEEMP_NONE);
|
||||
vfo->setReference(mod::API_t::REF_CENTER);
|
||||
vfo->setReference(ImGui::WaterfallVFO::REF_CENTER);
|
||||
demod.start();
|
||||
}
|
||||
else if (demId == DEMOD_NFM) {
|
||||
@ -113,7 +115,7 @@ void SigPath::setDemodulator(int demId, float bandWidth) {
|
||||
audioBw = std::min<float>(bandwidth, outputSampleRate / 2.0f);
|
||||
audioResamp.setInputSampleRate(16000, vfo->getOutputBlockSize(), audioBw, audioBw);
|
||||
deemp.bypass = true;
|
||||
vfo->setReference(mod::API_t::REF_CENTER);
|
||||
vfo->setReference(ImGui::WaterfallVFO::REF_CENTER);
|
||||
demod.start();
|
||||
}
|
||||
else if (demId == DEMOD_AM) {
|
||||
@ -123,7 +125,7 @@ void SigPath::setDemodulator(int demId, float bandWidth) {
|
||||
audioBw = std::min<float>(bandwidth, outputSampleRate / 2.0f);
|
||||
audioResamp.setInputSampleRate(12500, vfo->getOutputBlockSize(), audioBw, audioBw);
|
||||
deemp.bypass = true;
|
||||
vfo->setReference(mod::API_t::REF_CENTER);
|
||||
vfo->setReference(ImGui::WaterfallVFO::REF_CENTER);
|
||||
amDemod.start();
|
||||
}
|
||||
else if (demId == DEMOD_USB) {
|
||||
@ -134,7 +136,7 @@ void SigPath::setDemodulator(int demId, float bandWidth) {
|
||||
audioBw = std::min<float>(bandwidth, outputSampleRate / 2.0f);
|
||||
audioResamp.setInputSampleRate(6000, vfo->getOutputBlockSize(), audioBw, audioBw);
|
||||
deemp.bypass = true;
|
||||
vfo->setReference(mod::API_t::REF_LOWER);
|
||||
vfo->setReference(ImGui::WaterfallVFO::REF_LOWER);
|
||||
ssbDemod.start();
|
||||
}
|
||||
else if (demId == DEMOD_LSB) {
|
||||
@ -145,7 +147,7 @@ void SigPath::setDemodulator(int demId, float bandWidth) {
|
||||
audioBw = std::min<float>(bandwidth, outputSampleRate / 2.0f);
|
||||
audioResamp.setInputSampleRate(6000, vfo->getOutputBlockSize(), audioBw, audioBw);
|
||||
deemp.bypass = true;
|
||||
vfo->setReference(mod::API_t::REF_UPPER);
|
||||
vfo->setReference(ImGui::WaterfallVFO::REF_UPPER);
|
||||
ssbDemod.start();
|
||||
}
|
||||
else if (demId == DEMOD_DSB) {
|
||||
@ -156,7 +158,7 @@ void SigPath::setDemodulator(int demId, float bandWidth) {
|
||||
audioBw = std::min<float>(bandwidth, outputSampleRate / 2.0f);
|
||||
audioResamp.setInputSampleRate(6000, vfo->getOutputBlockSize(), audioBw, audioBw);
|
||||
deemp.bypass = true;
|
||||
vfo->setReference(mod::API_t::REF_CENTER);
|
||||
vfo->setReference(ImGui::WaterfallVFO::REF_CENTER);
|
||||
ssbDemod.start();
|
||||
}
|
||||
else if (demId == DEMOD_RAW) {
|
||||
@ -165,7 +167,7 @@ void SigPath::setDemodulator(int demId, float bandWidth) {
|
||||
//audioResamp.setInput(&cpx2stereo.output);
|
||||
audioBw = std::min<float>(bandwidth, outputSampleRate / 2.0f);
|
||||
audioResamp.setInputSampleRate(10000, vfo->getOutputBlockSize(), audioBw, audioBw);
|
||||
vfo->setReference(mod::API_t::REF_LOWER);
|
||||
vfo->setReference(ImGui::WaterfallVFO::REF_LOWER);
|
||||
cpx2stereo.start();
|
||||
}
|
||||
else {
|
||||
@ -249,5 +251,5 @@ void SigPath::start() {
|
||||
demod.start();
|
||||
audioResamp.start();
|
||||
deemp.start();
|
||||
API->startStream(vfoName);
|
||||
audio::startStream(vfoName);
|
||||
}
|
Reference in New Issue
Block a user