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;