disable rds symbol diagram data stream when not visible

This commit is contained in:
AlexandreRouma 2024-01-29 19:15:45 +01:00
parent 14cb839863
commit 2ef8ee3629
2 changed files with 25 additions and 5 deletions

View File

@ -47,7 +47,7 @@ namespace demod {
// Init DSP // Init DSP
demod.init(input, bandwidth / 2.0f, getIFSampleRate(), _stereo, _lowPass, _rds); demod.init(input, bandwidth / 2.0f, getIFSampleRate(), _stereo, _lowPass, _rds);
rdsDemod.init(&demod.rdsOut); rdsDemod.init(&demod.rdsOut, _rdsInfo);
hs.init(&rdsDemod.out, rdsHandler, this); hs.init(&rdsDemod.out, rdsHandler, this);
reshape.init(&rdsDemod.soft, 4096, (1187 / 30) - 4096); reshape.init(&rdsDemod.soft, 4096, (1187 / 30) - 4096);
diagHandler.init(&reshape.out, _diagHandler, this); diagHandler.init(&reshape.out, _diagHandler, this);
@ -96,6 +96,7 @@ namespace demod {
// TODO: This will break when the entire radio module is disabled // TODO: This will break when the entire radio module is disabled
if (!_rds) { ImGui::BeginDisabled(); } if (!_rds) { ImGui::BeginDisabled(); }
if (ImGui::Checkbox(("Advanced RDS Info##_radio_wfm_rds_info_" + name).c_str(), &_rdsInfo)) { if (ImGui::Checkbox(("Advanced RDS Info##_radio_wfm_rds_info_" + name).c_str(), &_rdsInfo)) {
setAdvancedRds(_rdsInfo);
_config->acquire(); _config->acquire();
_config->conf[name][getName()]["rdsInfo"] = _rdsInfo; _config->conf[name][getName()]["rdsInfo"] = _rdsInfo;
_config->release(true); _config->release(true);
@ -229,13 +230,17 @@ namespace demod {
demod.setStereo(_stereo); demod.setStereo(_stereo);
} }
void setAdvancedRds(bool enabled) {
rdsDemod.setSoftEnabled(enabled);
_rdsInfo = enabled;
}
private: private:
static void rdsHandler(uint8_t* data, int count, void* ctx) { static void rdsHandler(uint8_t* data, int count, void* ctx) {
WFM* _this = (WFM*)ctx; WFM* _this = (WFM*)ctx;
_this->rdsDecode.process(data, count); _this->rdsDecode.process(data, count);
} }
// DEBUGGING ONLY
static void _diagHandler(float* data, int count, void* ctx) { static void _diagHandler(float* data, int count, void* ctx) {
WFM* _this = (WFM*)ctx; WFM* _this = (WFM*)ctx;
float* buf = _this->diag.acquireBuffer(); float* buf = _this->diag.acquireBuffer();

View File

@ -13,10 +13,13 @@ class RDSDemod : public dsp::Processor<dsp::complex_t, uint8_t> {
using base_type = dsp::Processor<dsp::complex_t, uint8_t>; using base_type = dsp::Processor<dsp::complex_t, uint8_t>;
public: public:
RDSDemod() {} RDSDemod() {}
RDSDemod(dsp::stream<dsp::complex_t>* in) { init(in); } RDSDemod(dsp::stream<dsp::complex_t>* in, bool enableSoft) { init(in, enableSoft); }
~RDSDemod() {} ~RDSDemod() {}
void init(dsp::stream<dsp::complex_t>* in) { void init(dsp::stream<dsp::complex_t>* in, bool enableSoft) {
// Save config
this->enableSoft = enableSoft;
// Initialize the DSP // Initialize the DSP
agc.init(NULL, 1.0, 1e6, 0.1); agc.init(NULL, 1.0, 1e6, 0.1);
costas.init(NULL, 0.005f); costas.init(NULL, 0.005f);
@ -37,6 +40,14 @@ public:
base_type::init(in); base_type::init(in);
} }
void setSoftEnabled(bool enable) {
assert(base_type::_block_init);
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
base_type::tempStop();
enableSoft = enable;
base_type::tempStart();
}
void reset() { void reset() {
assert(base_type::_block_init); assert(base_type::_block_init);
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx); std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
@ -70,13 +81,17 @@ public:
base_type::_in->flush(); base_type::_in->flush();
if (!base_type::out.swap(count)) { return -1; } if (!base_type::out.swap(count)) { return -1; }
if (!soft.swap(count)) { return -1; } if (enableSoft) {
if (!soft.swap(count)) { return -1; }
}
return count; return count;
} }
dsp::stream<float> soft; dsp::stream<float> soft;
private: private:
bool enableSoft = false;
dsp::loop::FastAGC<dsp::complex_t> agc; dsp::loop::FastAGC<dsp::complex_t> agc;
dsp::loop::Costas<2> costas; dsp::loop::Costas<2> costas;
dsp::tap<dsp::complex_t> taps; dsp::tap<dsp::complex_t> taps;