More work

This commit is contained in:
AlexandreRouma
2022-06-21 17:24:48 +02:00
parent 834890b69a
commit f7c566f652
17 changed files with 519 additions and 218 deletions

View File

@ -1,7 +1,6 @@
#pragma once
#include "../demod.h"
#include <dsp/demod/am.h>
#include <dsp/convert/mono_to_stereo.h>
namespace demod {
class AM : public Demodulator {
@ -12,9 +11,7 @@ namespace demod {
init(name, config, input, bandwidth, outputChangeHandler, afbwChangeHandler, audioSR);
}
~AM() {
stop();
}
~AM() { stop(); }
void init(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, EventHandler<float> afbwChangeHandler, double audioSR) {
this->name = name;
@ -34,25 +31,18 @@ namespace demod {
config->release();
// Define structure
demod.init(input, carrierAgc ? dsp::demod::AM::AGCMode::CARRIER : dsp::demod::AM::AGCMode::AUDIO, agcAttack / getIFSampleRate(), agcDecay / getIFSampleRate(), 100.0 / getIFSampleRate());
m2s.init(&demod.out);
demod.init(input, carrierAgc ? dsp::demod::AM<dsp::stereo_t>::AGCMode::CARRIER : dsp::demod::AM<dsp::stereo_t>::AGCMode::AUDIO, bandwidth, agcAttack / getIFSampleRate(), agcDecay / getIFSampleRate(), 100.0 / getIFSampleRate(), getIFSampleRate());
}
void start() {
demod.start();
m2s.start();
}
void start() { demod.start(); }
void stop() {
demod.stop();
m2s.stop();
}
void stop() { demod.stop(); }
void showMenu() {
float menuWidth = ImGui::GetContentRegionAvail().x;
ImGui::LeftLabel("AGC Attack");
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
if (ImGui::SliderFloat(("##_radio_am_agc_attack_" + name).c_str(), &agcAttack, 1.0f, 100.0f)) {
if (ImGui::SliderFloat(("##_radio_am_agc_attack_" + name).c_str(), &agcAttack, 1.0f, 200.0f)) {
demod.setAGCAttack(agcAttack / getIFSampleRate());
_config->acquire();
_config->conf[name][getName()]["agcAttack"] = agcAttack;
@ -66,19 +56,17 @@ namespace demod {
_config->conf[name][getName()]["agcDecay"] = agcDecay;
_config->release(true);
}
if (ImGui::Checkbox(("Carrier AGC (W.I.P.)##_radio_am_carrier_agc_" + name).c_str(), &carrierAgc)) {
demod.setAGCMode(carrierAgc ? dsp::demod::AM::AGCMode::CARRIER : dsp::demod::AM::AGCMode::AUDIO);
if (ImGui::Checkbox(("Carrier AGC##_radio_am_carrier_agc_" + name).c_str(), &carrierAgc)) {
demod.setAGCMode(carrierAgc ? dsp::demod::AM<dsp::stereo_t>::AGCMode::CARRIER : dsp::demod::AM<dsp::stereo_t>::AGCMode::AUDIO);
_config->acquire();
_config->conf[name][getName()]["carrierAgc"] = carrierAgc;
_config->release(true);
}
}
void setBandwidth(double bandwidth) {}
void setBandwidth(double bandwidth) { demod.setBandwidth(bandwidth); }
void setInput(dsp::stream<dsp::complex_t>* input) {
demod.setInput(input);
}
void setInput(dsp::stream<dsp::complex_t>* input) { demod.setInput(input); }
void AFSampRateChanged(double newSR) {}
@ -101,11 +89,10 @@ namespace demod {
bool getDynamicAFBandwidth() { return true; }
bool getFMIFNRAllowed() { return false; }
bool getNBAllowed() { return false; }
dsp::stream<dsp::stereo_t>* getOutput() { return &m2s.out; }
dsp::stream<dsp::stereo_t>* getOutput() { return &demod.out; }
private:
dsp::demod::AM demod;
dsp::convert::MonoToStereo m2s;
dsp::demod::AM<dsp::stereo_t> demod;
ConfigManager* _config = NULL;

View File

@ -1,9 +1,6 @@
#pragma once
#include "../demod.h"
#include <dsp/channel/frequency_xlator.h>
#include <dsp/convert/complex_to_real.h>
#include <dsp/convert/mono_to_stereo.h>
#include <dsp/loop/agc.h>
#include <dsp/demod/cw.h>
namespace demod {
class CW : public Demodulator {
@ -21,7 +18,6 @@ namespace demod {
void init(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, EventHandler<float> afbwChangeHandler, double audioSR) {
this->name = name;
this->_config = config;
this->_bandwidth = bandwidth;
this->afbwChangeHandler = afbwChangeHandler;
// Load config
@ -38,32 +34,19 @@ namespace demod {
config->release();
// Define structure
xlator.init(input, tone, getIFSampleRate());
c2r.init(&xlator.out);
agc.init(&c2r.out, 1.0, agcAttack / getIFSampleRate(), agcDecay / getIFSampleRate(), 10e6, 10.0);
m2s.init(&agc.out);
demod.init(input, tone, agcAttack / getIFSampleRate(), agcDecay / getIFSampleRate(), getIFSampleRate());
}
void start() {
xlator.start();
c2r.start();
agc.start();
m2s.start();
}
void start() { demod.start(); }
void stop() {
xlator.stop();
c2r.stop();
agc.stop();
m2s.stop();
}
void stop() { demod.stop(); }
void showMenu() {
float menuWidth = ImGui::GetContentRegionAvail().x;
ImGui::LeftLabel("AGC Attack");
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
if (ImGui::SliderFloat(("##_radio_cw_agc_attack_" + name).c_str(), &agcAttack, 1.0f, 100.0f)) {
agc.setAttack(agcAttack / getIFSampleRate());
if (ImGui::SliderFloat(("##_radio_cw_agc_attack_" + name).c_str(), &agcAttack, 1.0f, 200.0f)) {
demod.setAGCAttack(agcAttack / getIFSampleRate());
_config->acquire();
_config->conf[name][getName()]["agcAttack"] = agcAttack;
_config->release(true);
@ -71,7 +54,7 @@ namespace demod {
ImGui::LeftLabel("AGC Decay");
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
if (ImGui::SliderFloat(("AGC Decay##_radio_cw_agc_decay_" + name).c_str(), &agcDecay, 1.0f, 20.0f)) {
agc.setDecay(agcDecay / getIFSampleRate());
demod.setAGCDecay(agcDecay / getIFSampleRate());
_config->acquire();
_config->conf[name][getName()]["agcDecay"] = agcDecay;
_config->release(true);
@ -80,19 +63,16 @@ namespace demod {
ImGui::FillWidth();
if (ImGui::InputInt(("Stereo##_radio_cw_tone_" + name).c_str(), &tone, 10, 100)) {
tone = std::clamp<int>(tone, 250, 1250);
xlator.setOffset(tone, getIFSampleRate());
afbwChangeHandler.handler(getAFBandwidth(_bandwidth), afbwChangeHandler.ctx);
demod.setTone(tone);
_config->acquire();
_config->conf[name][getName()]["tone"] = tone;
_config->release(true);
}
}
void setBandwidth(double bandwidth) { _bandwidth = bandwidth; }
void setBandwidth(double bandwidth) {}
void setInput(dsp::stream<dsp::complex_t>* input) {
xlator.setInput(input);
}
void setInput(dsp::stream<dsp::complex_t>* input) { demod.setInput(input); }
void AFSampRateChanged(double newSR) {}
@ -115,21 +95,17 @@ namespace demod {
bool getDynamicAFBandwidth() { return true; }
bool getFMIFNRAllowed() { return false; }
bool getNBAllowed() { return false; }
dsp::stream<dsp::stereo_t>* getOutput() { return &m2s.out; }
dsp::stream<dsp::stereo_t>* getOutput() { return &demod.out; }
private:
ConfigManager* _config = NULL;
dsp::channel::FrequencyXlator xlator;
dsp::convert::ComplexToReal c2r;
dsp::loop::AGC<float> agc;
dsp::convert::MonoToStereo m2s;
dsp::demod::CW<dsp::stereo_t> demod;
std::string name;
float agcAttack = 50.0f;
float agcAttack = 100.0f;
float agcDecay = 5.0f;
int tone = 800;
double _bandwidth;
EventHandler<float> afbwChangeHandler;
};

View File

@ -1,7 +1,6 @@
#pragma once
#include "../demod.h"
#include <dsp/demod/ssb.h>
#include <dsp/convert/mono_to_stereo.h>
namespace demod {
class DSB : public Demodulator {
@ -31,25 +30,18 @@ namespace demod {
config->release();
// Define structure
demod.init(input, dsp::demod::SSB::Mode::DSB, bandwidth, getIFSampleRate(), agcAttack / getIFSampleRate(), agcDecay / getIFSampleRate());
m2s.init(&demod.out);
demod.init(input, dsp::demod::SSB<dsp::stereo_t>::Mode::DSB, bandwidth, getIFSampleRate(), agcAttack / getIFSampleRate(), agcDecay / getIFSampleRate());
}
void start() {
demod.start();
m2s.start();
}
void start() { demod.start(); }
void stop() {
demod.stop();
m2s.stop();
}
void stop() { demod.stop(); }
void showMenu() {
float menuWidth = ImGui::GetContentRegionAvail().x;
ImGui::LeftLabel("AGC Attack");
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
if (ImGui::SliderFloat(("##_radio_dsb_agc_attack_" + name).c_str(), &agcAttack, 1.0f, 100.0f)) {
if (ImGui::SliderFloat(("##_radio_dsb_agc_attack_" + name).c_str(), &agcAttack, 1.0f, 200.0f)) {
demod.setAGCAttack(agcAttack / getIFSampleRate());
_config->acquire();
_config->conf[name][getName()]["agcAttack"] = agcAttack;
@ -65,13 +57,9 @@ namespace demod {
}
}
void setBandwidth(double bandwidth) {
demod.setBandwidth(bandwidth);
}
void setBandwidth(double bandwidth) { demod.setBandwidth(bandwidth); }
void setInput(dsp::stream<dsp::complex_t>* input) {
demod.setInput(input);
}
void setInput(dsp::stream<dsp::complex_t>* input) { demod.setInput(input); }
void AFSampRateChanged(double newSR) {}
@ -94,11 +82,10 @@ namespace demod {
bool getDynamicAFBandwidth() { return true; }
bool getFMIFNRAllowed() { return false; }
bool getNBAllowed() { return true; }
dsp::stream<dsp::stereo_t>* getOutput() { return &m2s.out; }
dsp::stream<dsp::stereo_t>* getOutput() { return &demod.out; }
private:
dsp::demod::SSB demod;
dsp::convert::MonoToStereo m2s;
dsp::demod::SSB<dsp::stereo_t> demod;
ConfigManager* _config;

View File

@ -1,7 +1,6 @@
#pragma once
#include "../demod.h"
#include <dsp/demod/ssb.h>
#include <dsp/convert/mono_to_stereo.h>
namespace demod {
class LSB : public Demodulator {
@ -31,25 +30,18 @@ namespace demod {
config->release();
// Define structure
demod.init(input, dsp::demod::SSB::Mode::LSB, bandwidth, getIFSampleRate(), agcAttack / getIFSampleRate(), agcDecay / getIFSampleRate());
m2s.init(&demod.out);
demod.init(input, dsp::demod::SSB<dsp::stereo_t>::Mode::LSB, bandwidth, getIFSampleRate(), agcAttack / getIFSampleRate(), agcDecay / getIFSampleRate());
}
void start() {
demod.start();
m2s.start();
}
void start() { demod.start(); }
void stop() {
demod.stop();
m2s.stop();
}
void stop() { demod.stop(); }
void showMenu() {
float menuWidth = ImGui::GetContentRegionAvail().x;
ImGui::LeftLabel("AGC Attack");
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
if (ImGui::SliderFloat(("##_radio_lsb_agc_attack_" + name).c_str(), &agcAttack, 1.0f, 100.0f)) {
if (ImGui::SliderFloat(("##_radio_lsb_agc_attack_" + name).c_str(), &agcAttack, 1.0f, 200.0f)) {
demod.setAGCAttack(agcAttack / getIFSampleRate());
_config->acquire();
_config->conf[name][getName()]["agcAttack"] = agcAttack;
@ -65,13 +57,9 @@ namespace demod {
}
}
void setBandwidth(double bandwidth) {
demod.setBandwidth(bandwidth);
}
void setBandwidth(double bandwidth) { demod.setBandwidth(bandwidth); }
void setInput(dsp::stream<dsp::complex_t>* input) {
demod.setInput(input);
}
void setInput(dsp::stream<dsp::complex_t>* input) { demod.setInput(input); }
void AFSampRateChanged(double newSR) {}
@ -94,11 +82,10 @@ namespace demod {
bool getDynamicAFBandwidth() { return true; }
bool getFMIFNRAllowed() { return false; }
bool getNBAllowed() { return true; }
dsp::stream<dsp::stereo_t>* getOutput() { return &m2s.out; }
dsp::stream<dsp::stereo_t>* getOutput() { return &demod.out; }
private:
dsp::demod::SSB demod;
dsp::convert::MonoToStereo m2s;
dsp::demod::SSB<dsp::stereo_t> demod;
ConfigManager* _config;

View File

@ -1,7 +1,6 @@
#pragma once
#include "../demod.h"
#include <dsp/demod/fm.h>
#include <dsp/convert/mono_to_stereo.h>
namespace demod {
class NFM : public Demodulator {
@ -12,37 +11,33 @@ namespace demod {
init(name, config, input, bandwidth, outputChangeHandler, afbwChangeHandler, audioSR);
}
~NFM() {
stop();
}
~NFM() { stop(); }
void init(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, EventHandler<float> afbwChangeHandler, double audioSR) {
this->name = name;
// Define structure
demod.init(input, bandwidth / 2.0, getIFSampleRate());
m2s.init(&demod.out);
demod.init(input, getIFSampleRate(), bandwidth, _lowPass);
}
void start() {
demod.start();
m2s.start();
}
void start() { demod.start(); }
void stop() {
demod.stop();
m2s.stop();
}
void stop() { demod.stop(); }
void showMenu() {}
void showMenu() {
if (ImGui::Checkbox(("Low Pass##_radio_wfm_lowpass_" + name).c_str(), &_lowPass)) {
demod.setLowPass(_lowPass);
// _config->acquire();
// _config->conf[name][getName()]["lowPass"] = _lowPass;
// _config->release(true);
}
}
void setBandwidth(double bandwidth) {
demod.setDeviation(bandwidth / 2.0, getIFSampleRate());
demod.setBandwidth(bandwidth);
}
void setInput(dsp::stream<dsp::complex_t>* input) {
demod.setInput(input);
}
void setInput(dsp::stream<dsp::complex_t>* input) { demod.setInput(input); }
void AFSampRateChanged(double newSR) {}
@ -65,11 +60,12 @@ namespace demod {
bool getDynamicAFBandwidth() { return true; }
bool getFMIFNRAllowed() { return true; }
bool getNBAllowed() { return false; }
dsp::stream<dsp::stereo_t>* getOutput() { return &m2s.out; }
dsp::stream<dsp::stereo_t>* getOutput() { return &demod.out; }
private:
dsp::demod::FM demod;
dsp::convert::MonoToStereo m2s;
dsp::demod::FM<dsp::stereo_t> demod;
bool _lowPass = true;
std::string name;
};

View File

@ -31,25 +31,18 @@ namespace demod {
config->release();
// Define structure
demod.init(input, dsp::demod::SSB::Mode::USB, bandwidth, getIFSampleRate(), agcAttack / getIFSampleRate(), agcDecay / getIFSampleRate());
m2s.init(&demod.out);
demod.init(input, dsp::demod::SSB<dsp::stereo_t>::Mode::USB, bandwidth, getIFSampleRate(), agcAttack / getIFSampleRate(), agcDecay / getIFSampleRate());
}
void start() {
demod.start();
m2s.start();
}
void start() { demod.start(); }
void stop() {
demod.stop();
m2s.stop();
}
void stop() { demod.stop(); }
void showMenu() {
float menuWidth = ImGui::GetContentRegionAvail().x;
ImGui::LeftLabel("AGC Attack");
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
if (ImGui::SliderFloat(("##_radio_usb_agc_attack_" + name).c_str(), &agcAttack, 1.0f, 100.0f)) {
if (ImGui::SliderFloat(("##_radio_usb_agc_attack_" + name).c_str(), &agcAttack, 1.0f, 200.0f)) {
demod.setAGCAttack(agcAttack / getIFSampleRate());
_config->acquire();
_config->conf[name][getName()]["agcAttack"] = agcAttack;
@ -65,13 +58,9 @@ namespace demod {
}
}
void setBandwidth(double bandwidth) {
demod.setBandwidth(bandwidth);
}
void setBandwidth(double bandwidth) { demod.setBandwidth(bandwidth); }
void setInput(dsp::stream<dsp::complex_t>* input) {
demod.setInput(input);
}
void setInput(dsp::stream<dsp::complex_t>* input) { demod.setInput(input); }
void AFSampRateChanged(double newSR) {}
@ -94,11 +83,10 @@ namespace demod {
bool getDynamicAFBandwidth() { return true; }
bool getFMIFNRAllowed() { return false; }
bool getNBAllowed() { return true; }
dsp::stream<dsp::stereo_t>* getOutput() { return &m2s.out; }
dsp::stream<dsp::stereo_t>* getOutput() { return &demod.out; }
private:
dsp::demod::SSB demod;
dsp::convert::MonoToStereo m2s;
dsp::demod::SSB<dsp::stereo_t> demod;
ConfigManager* _config;