diff --git a/.github/workflows/build_all.yml b/.github/workflows/build_all.yml index eca6ceb1..d6f62335 100644 --- a/.github/workflows/build_all.yml +++ b/.github/workflows/build_all.yml @@ -95,18 +95,18 @@ jobs: - name: Install SDRplay API run: wget https://www.sdrplay.com/software/SDRplay_RSP_API-MacOSX-3.07.3.pkg && sudo installer -pkg SDRplay_RSP_API-MacOSX-3.07.3.pkg -target / - - name: Install libiio - run: git clone https://github.com/analogdevicesinc/libiio && cd libiio && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j3 && sudo make install && cd ../../ + # - name: Install libiio + # run: git clone https://github.com/analogdevicesinc/libiio && cd libiio && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j3 && sudo make install && cd ../../ - - name: Install libad9361 - run: git clone https://github.com/analogdevicesinc/libad9361-iio && cd libad9361-iio && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j3 && sudo make install && cd ../../ + # - name: Install libad9361 + # run: git clone https://github.com/analogdevicesinc/libad9361-iio && cd libad9361-iio && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j3 && sudo make install && cd ../../ - name: Install LimeSuite run: git clone https://github.com/myriadrf/LimeSuite && cd LimeSuite && mkdir builddir && cd builddir && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j3 && sudo make install && cd ../../ - name: Prepare CMake working-directory: ${{runner.workspace}}/build - run: cmake $GITHUB_WORKSPACE -DOPT_BUILD_PLUTOSDR_SOURCE=ON -DOPT_BUILD_SOAPY_SOURCE=OFF -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_AUDIO_SINK=OFF -DOPT_BUILD_PORTAUDIO_SINK=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=OFF -DUSE_BUNDLE_DEFAULTS=ON -DCMAKE_BUILD_TYPE=Release + run: cmake $GITHUB_WORKSPACE -DOPT_BUILD_PLUTOSDR_SOURCE=OFF -DOPT_BUILD_SOAPY_SOURCE=OFF -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_AUDIO_SINK=OFF -DOPT_BUILD_PORTAUDIO_SINK=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=OFF -DUSE_BUNDLE_DEFAULTS=ON -DCMAKE_BUILD_TYPE=Release - name: Build working-directory: ${{runner.workspace}}/build diff --git a/core/src/dsp/demod/am.h b/core/src/dsp/demod/am.h index cee59603..fca79a73 100644 --- a/core/src/dsp/demod/am.h +++ b/core/src/dsp/demod/am.h @@ -1,6 +1,7 @@ #pragma once #include "../processor.h" #include "../loop/agc.h" +#include "../correction/dc_blocker.h" namespace dsp::demod { class AM : public Processor { @@ -13,13 +14,14 @@ namespace dsp::demod { AM() {} - AM(stream* in, AGCMode agcMode, double agcRate) { init(in, agcMode, agcRate); } + AM(stream* in, AGCMode agcMode, double agcAttack, double agcDecay, double dcBlockRate) { init(in, agcMode, agcAttack, agcDecay, dcBlockRate); } - void init(stream* in, AGCMode agcMode, double agcRate) { + void init(stream* in, AGCMode agcMode, double agcAttack, double agcDecay, double dcBlockRate) { _agcMode = agcMode; - carrierAgc.init(NULL, 1.0, agcRate, 10e6, 10.0); - audioAgc.init(NULL, 1.0, agcRate, 10e6, 10.0); + carrierAgc.init(NULL, 1.0, agcAttack, agcDecay, 10e6, 10.0); + audioAgc.init(NULL, 1.0, agcAttack, agcDecay, 10e6, 10.0); + dcBlock.init(NULL, dcBlockRate); base_type::init(in); } @@ -33,11 +35,24 @@ namespace dsp::demod { base_type::tempStart(); } - void setAGCRate(double agcRate) { + void setAGCAttack(double attack) { assert(base_type::_block_init); std::lock_guard lck(base_type::ctrlMtx); - carrierAgc.setRate(agcRate); - audioAgc.setRate(agcRate); + carrierAgc.setAttack(attack); + audioAgc.setAttack(attack); + } + + void setAGCDecay(double decay) { + assert(base_type::_block_init); + std::lock_guard lck(base_type::ctrlMtx); + carrierAgc.setDecay(decay); + audioAgc.setDecay(decay); + } + + void setDCBlockRate(double rate) { + assert(base_type::_block_init); + std::lock_guard lck(base_type::ctrlMtx); + dcBlock.setRate(rate); } void reset() { @@ -46,6 +61,7 @@ namespace dsp::demod { base_type::tempStop(); carrierAgc.reset(); audioAgc.reset(); + dcBlock.reset(); base_type::tempStart(); } @@ -56,19 +72,14 @@ namespace dsp::demod { in = carrierAgc.out.writeBuf; } - // Get magnitude of each sample (TODO: use block instead) + // Get magnitude of each sample and remove DC (TODO: use block instead) volk_32fc_magnitude_32f(out, (lv_32fc_t*)in, count); + dcBlock.process(count, out, out); // Apply audio AGC if needed if (_agcMode == AGCMode::AUDIO) { audioAgc.process(count, out, out); } - else { - // TODO: Find a volk function for it - for (int i = 0; i < count; i++) { - out[i] -= 1.0; - } - } return count; } @@ -89,6 +100,7 @@ namespace dsp::demod { loop::AGC carrierAgc; loop::AGC audioAgc; + correction::DCBlocker dcBlock; }; } \ No newline at end of file diff --git a/core/src/dsp/demod/ssb.h b/core/src/dsp/demod/ssb.h index ed4378bc..1d53816d 100644 --- a/core/src/dsp/demod/ssb.h +++ b/core/src/dsp/demod/ssb.h @@ -16,29 +16,17 @@ namespace dsp::demod { SSB() {} - /** Calls the init function - */ - SSB(stream* in, Mode mode, double bandwidth, double samplerate, double agcRate) { init(in, mode, bandwidth, samplerate, agcRate); } + SSB(stream* in, Mode mode, double bandwidth, double samplerate, double agcAttack, double agcDecay) { init(in, mode, bandwidth, samplerate, agcAttack, agcDecay); } - /** Initialize the SSB/DSB Demodulator - * \param in Input stream - * \param mode Demodulation mode, can be USB, LSB or DSB - * \param bandwidth Bandwidth needed to shift back the IQ correctly - * \param samplerate Samplerate of the IQ data - * \param agcRate Speed at which the AGC corrects the audio level. This is NOT automatically scaled to the samplerate. - */ - void init(stream* in, Mode mode, double bandwidth, double samplerate, double agcRate) { + void init(stream* in, Mode mode, double bandwidth, double samplerate, double agcAttack, double agcDecay) { _mode = mode; _bandwidth = bandwidth; _samplerate = samplerate; xlator.init(NULL, getTranslation(), _samplerate); - agc.init(NULL, 1.0, agcRate, 10e6, 10.0); + agc.init(NULL, 1.0, agcAttack, agcDecay, 10e6, 10.0); base_type::init(in); } - /** Set demodulation mode - * \param mode Either USB, LSB or DSB - */ void setMode(Mode mode) { assert(base_type::_block_init); std::lock_guard lck(base_type::ctrlMtx); @@ -48,9 +36,6 @@ namespace dsp::demod { base_type::tempStart(); } - /** Set bandwidth - * \param bandwidth Bandwidth in Hz - */ void setBandwidth(double bandwidth) { assert(base_type::_block_init); std::lock_guard lck(base_type::ctrlMtx); @@ -60,9 +45,6 @@ namespace dsp::demod { base_type::tempStart(); } - /** Set samplerate - * \param samplerate Samplerate in Hz - */ void setSamplerate(double samplerate) { assert(base_type::_block_init); std::lock_guard lck(base_type::ctrlMtx); @@ -72,20 +54,18 @@ namespace dsp::demod { base_type::tempStart(); } - /** Set AGC rate - * \param agcRate AGC rate in units per second - */ - void setAGCRate(double agcRate) { + void setAGCAttack(double attack) { assert(base_type::_block_init); std::lock_guard lck(base_type::ctrlMtx); - agc.setRate(agcRate); + agc.setAttack(attack); + } + + void setAGCDecay(double decay) { + assert(base_type::_block_init); + std::lock_guard lck(base_type::ctrlMtx); + agc.setDecay(decay); } - /** Process data - * \param count Number of samples - * \param in Input buffer - * \param out Output buffer - */ int process(int count, const complex_t* in, float* out) { // Move back sideband xlator.process(count, in, xlator.out.writeBuf); diff --git a/core/src/dsp/loop/agc.h b/core/src/dsp/loop/agc.h index 1cd58ab5..9c5a6ed7 100644 --- a/core/src/dsp/loop/agc.h +++ b/core/src/dsp/loop/agc.h @@ -8,12 +8,14 @@ namespace dsp::loop { public: AGC() {} - AGC(stream* in, double setPoint, double rate, double maxGain, double maxOutputAmp, double initGain = 1.0) { init(in, setPoint, rate, maxGain, maxOutputAmp, initGain); } + AGC(stream* in, double setPoint, double attack, double decay, double maxGain, double maxOutputAmp, double initGain = 1.0) { init(in, setPoint, attack, decay, maxGain, maxOutputAmp, initGain); } - void init(stream* in, double setPoint, double rate, double maxGain, double maxOutputAmp, double initGain = 1.0) { + void init(stream* in, double setPoint, double attack, double decay, double maxGain, double maxOutputAmp, double initGain = 1.0) { _setPoint = setPoint; - _rate = rate; - _invRate = 1.0f - _rate; + _attack = attack; + _invAttack = 1.0f - _attack; + _decay = decay; + _invDecay = 1.0f - _decay; _maxGain = maxGain; _maxOutputAmp = maxOutputAmp; _initGain = initGain; @@ -27,11 +29,18 @@ namespace dsp::loop { _setPoint = setPoint; } - void setRate(double rate) { + void setAttack(double attack) { assert(base_type::_block_init); std::lock_guard lck(base_type::ctrlMtx); - _rate = rate; - _invRate = 1.0f - _rate; + _attack = attack; + _invAttack = 1.0f - _attack; + } + + void setDecay(double decay) { + assert(base_type::_block_init); + std::lock_guard lck(base_type::ctrlMtx); + _decay = decay; + _invDecay = 1.0f - _decay; } void setMaxGain(double maxGain) { @@ -72,7 +81,7 @@ namespace dsp::loop { // Update average amplitude if (inAmp != 0.0f) { - amp = (amp * _invRate) + (inAmp * _rate); + amp = (inAmp > amp) ? ((amp * _invAttack) + (inAmp * _attack)) : ((amp * _invDecay) + (inAmp * _decay)); gain = std::min(_setPoint / amp, _maxGain); } @@ -95,8 +104,10 @@ namespace dsp::loop { protected: float _setPoint; - float _rate; - float _invRate; + float _attack; + float _invAttack; + float _decay; + float _invDecay; float _maxGain; float _maxOutputAmp; float _initGain; diff --git a/decoder_modules/radio/src/demodulators/am.h b/decoder_modules/radio/src/demodulators/am.h index 808dc7e1..2bafeba6 100644 --- a/decoder_modules/radio/src/demodulators/am.h +++ b/decoder_modules/radio/src/demodulators/am.h @@ -18,9 +18,23 @@ namespace demod { void init(std::string name, ConfigManager* config, dsp::stream* input, double bandwidth, EventHandler*> outputChangeHandler, EventHandler afbwChangeHandler, double audioSR) { this->name = name; + _config = config; + + // Load config + config->acquire(); + if (config->conf[name][getName()].contains("agcAttack")) { + agcAttack = config->conf[name][getName()]["agcAttack"]; + } + if (config->conf[name][getName()].contains("agcDecay")) { + agcDecay = config->conf[name][getName()]["agcDecay"]; + } + if (config->conf[name][getName()].contains("carrierAgc")) { + carrierAgc = config->conf[name][getName()]["carrierAgc"]; + } + config->release(); // Define structure - demod.init(input, dsp::demod::AM::AGCMode::CARRIER, 24.0 / getIFSampleRate()); + 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); } @@ -35,7 +49,29 @@ namespace demod { } void showMenu() { - // TODO: Adjust AGC settings + 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, 50.0f)) { + demod.setAGCAttack(agcAttack / getIFSampleRate()); + _config->acquire(); + _config->conf[name][getName()]["agcAttack"] = agcAttack; + _config->release(true); + } + ImGui::LeftLabel("AGC Decay"); + ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX()); + if (ImGui::SliderFloat(("AGC Decay##_radio_am_agc_decay_" + name).c_str(), &agcDecay, 1.0f, 50.0f)) { + demod.setAGCDecay(agcDecay / getIFSampleRate()); + _config->acquire(); + _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); + _config->acquire(); + _config->conf[name][getName()]["carrierAgc"] = carrierAgc; + _config->release(true); + } } void setBandwidth(double bandwidth) {} @@ -71,6 +107,12 @@ namespace demod { dsp::demod::AM demod; dsp::convert::MonoToStereo m2s; + ConfigManager* _config = NULL; + + float agcAttack = 40.0f; + float agcDecay = 5.0f; + bool carrierAgc = false; + std::string name; }; } \ No newline at end of file diff --git a/decoder_modules/radio/src/demodulators/cw.h b/decoder_modules/radio/src/demodulators/cw.h index 095167ea..67b392eb 100644 --- a/decoder_modules/radio/src/demodulators/cw.h +++ b/decoder_modules/radio/src/demodulators/cw.h @@ -26,6 +26,12 @@ namespace demod { // Load config config->acquire(); + if (config->conf[name][getName()].contains("agcAttack")) { + agcAttack = config->conf[name][getName()]["agcAttack"]; + } + if (config->conf[name][getName()].contains("agcDecay")) { + agcDecay = config->conf[name][getName()]["agcDecay"]; + } if (config->conf[name][getName()].contains("tone")) { tone = config->conf[name][getName()]["tone"]; } @@ -34,7 +40,7 @@ namespace demod { // Define structure xlator.init(input, tone, getIFSampleRate()); c2r.init(&xlator.out); - agc.init(&c2r.out, 1.0, 24.0 / getIFSampleRate(), 10e6, 10.0); + agc.init(&c2r.out, 1.0, agcAttack / getIFSampleRate(), agcDecay / getIFSampleRate(), 10e6, 10.0); m2s.init(&agc.out); } @@ -53,6 +59,23 @@ namespace demod { } 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, 50.0f)) { + agc.setAttack(agcAttack / getIFSampleRate()); + _config->acquire(); + _config->conf[name][getName()]["agcAttack"] = agcAttack; + _config->release(true); + } + ImGui::LeftLabel("AGC Decay"); + ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX()); + if (ImGui::SliderFloat(("AGC Decay##_radio_cw_agc_decay_" + name).c_str(), &agcDecay, 1.0f, 50.0f)) { + agc.setDecay(agcDecay / getIFSampleRate()); + _config->acquire(); + _config->conf[name][getName()]["agcDecay"] = agcDecay; + _config->release(true); + } ImGui::LeftLabel("Tone Frequency"); ImGui::FillWidth(); if (ImGui::InputInt(("Stereo##_radio_cw_tone_" + name).c_str(), &tone, 10, 100)) { @@ -103,6 +126,8 @@ namespace demod { std::string name; + float agcAttack = 40.0f; + float agcDecay = 5.0f; int tone = 800; double _bandwidth; diff --git a/decoder_modules/radio/src/demodulators/dsb.h b/decoder_modules/radio/src/demodulators/dsb.h index 7488c7e5..50cab857 100644 --- a/decoder_modules/radio/src/demodulators/dsb.h +++ b/decoder_modules/radio/src/demodulators/dsb.h @@ -18,9 +18,20 @@ namespace demod { void init(std::string name, ConfigManager* config, dsp::stream* input, double bandwidth, EventHandler*> outputChangeHandler, EventHandler afbwChangeHandler, double audioSR) { this->name = name; + _config = config; + + // Load config + config->acquire(); + if (config->conf[name][getName()].contains("agcAttack")) { + agcAttack = config->conf[name][getName()]["agcAttack"]; + } + if (config->conf[name][getName()].contains("agcDecay")) { + agcDecay = config->conf[name][getName()]["agcDecay"]; + } + config->release(); // Define structure - demod.init(input, dsp::demod::SSB::Mode::DSB, bandwidth, getIFSampleRate(), 24.0 / getIFSampleRate()); + demod.init(input, dsp::demod::SSB::Mode::DSB, bandwidth, getIFSampleRate(), agcAttack / getIFSampleRate(), agcDecay / getIFSampleRate()); m2s.init(&demod.out); } @@ -35,7 +46,23 @@ namespace demod { } void showMenu() { - // TODO: Adjust AGC settings + 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, 50.0f)) { + demod.setAGCAttack(agcAttack / getIFSampleRate()); + _config->acquire(); + _config->conf[name][getName()]["agcAttack"] = agcAttack; + _config->release(true); + } + ImGui::LeftLabel("AGC Decay"); + ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX()); + if (ImGui::SliderFloat(("AGC Decay##_radio_dsb_agc_decay_" + name).c_str(), &agcDecay, 1.0f, 50.0f)) { + demod.setAGCDecay(agcDecay / getIFSampleRate()); + _config->acquire(); + _config->conf[name][getName()]["agcDecay"] = agcDecay; + _config->release(true); + } } void setBandwidth(double bandwidth) { @@ -73,6 +100,11 @@ namespace demod { dsp::demod::SSB demod; dsp::convert::MonoToStereo m2s; + ConfigManager* _config; + + float agcAttack = 40.0f; + float agcDecay = 5.0f; + std::string name; }; } \ No newline at end of file diff --git a/decoder_modules/radio/src/demodulators/lsb.h b/decoder_modules/radio/src/demodulators/lsb.h index bab3450c..3652374d 100644 --- a/decoder_modules/radio/src/demodulators/lsb.h +++ b/decoder_modules/radio/src/demodulators/lsb.h @@ -18,9 +18,20 @@ namespace demod { void init(std::string name, ConfigManager* config, dsp::stream* input, double bandwidth, EventHandler*> outputChangeHandler, EventHandler afbwChangeHandler, double audioSR) { this->name = name; + _config = config; + + // Load config + config->acquire(); + if (config->conf[name][getName()].contains("agcAttack")) { + agcAttack = config->conf[name][getName()]["agcAttack"]; + } + if (config->conf[name][getName()].contains("agcDecay")) { + agcDecay = config->conf[name][getName()]["agcDecay"]; + } + config->release(); // Define structure - demod.init(input, dsp::demod::SSB::Mode::LSB, bandwidth, getIFSampleRate(), 24.0 / getIFSampleRate()); + demod.init(input, dsp::demod::SSB::Mode::LSB, bandwidth, getIFSampleRate(), agcAttack / getIFSampleRate(), agcDecay / getIFSampleRate()); m2s.init(&demod.out); } @@ -35,7 +46,23 @@ namespace demod { } void showMenu() { - // TODO: Adjust AGC settings + 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, 50.0f)) { + demod.setAGCAttack(agcAttack / getIFSampleRate()); + _config->acquire(); + _config->conf[name][getName()]["agcAttack"] = agcAttack; + _config->release(true); + } + ImGui::LeftLabel("AGC Decay"); + ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX()); + if (ImGui::SliderFloat(("AGC Decay##_radio_lsb_agc_decay_" + name).c_str(), &agcDecay, 1.0f, 50.0f)) { + demod.setAGCDecay(agcDecay / getIFSampleRate()); + _config->acquire(); + _config->conf[name][getName()]["agcDecay"] = agcDecay; + _config->release(true); + } } void setBandwidth(double bandwidth) { @@ -73,6 +100,11 @@ namespace demod { dsp::demod::SSB demod; dsp::convert::MonoToStereo m2s; + ConfigManager* _config; + + float agcAttack = 40.0f; + float agcDecay = 5.0f; + std::string name; }; } \ No newline at end of file diff --git a/decoder_modules/radio/src/demodulators/usb.h b/decoder_modules/radio/src/demodulators/usb.h index b25456b4..a802d855 100644 --- a/decoder_modules/radio/src/demodulators/usb.h +++ b/decoder_modules/radio/src/demodulators/usb.h @@ -18,9 +18,20 @@ namespace demod { void init(std::string name, ConfigManager* config, dsp::stream* input, double bandwidth, EventHandler*> outputChangeHandler, EventHandler afbwChangeHandler, double audioSR) { this->name = name; + _config = config; + + // Load config + config->acquire(); + if (config->conf[name][getName()].contains("agcAttack")) { + agcAttack = config->conf[name][getName()]["agcAttack"]; + } + if (config->conf[name][getName()].contains("agcDecay")) { + agcDecay = config->conf[name][getName()]["agcDecay"]; + } + config->release(); // Define structure - demod.init(input, dsp::demod::SSB::Mode::USB, bandwidth, getIFSampleRate(), 24.0 / getIFSampleRate()); + demod.init(input, dsp::demod::SSB::Mode::USB, bandwidth, getIFSampleRate(), agcAttack / getIFSampleRate(), agcDecay / getIFSampleRate()); m2s.init(&demod.out); } @@ -35,7 +46,23 @@ namespace demod { } void showMenu() { - // TODO: Adjust AGC settings + 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, 50.0f)) { + demod.setAGCAttack(agcAttack / getIFSampleRate()); + _config->acquire(); + _config->conf[name][getName()]["agcAttack"] = agcAttack; + _config->release(true); + } + ImGui::LeftLabel("AGC Decay"); + ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX()); + if (ImGui::SliderFloat(("AGC Decay##_radio_usb_agc_decay_" + name).c_str(), &agcDecay, 1.0f, 50.0f)) { + demod.setAGCDecay(agcDecay / getIFSampleRate()); + _config->acquire(); + _config->conf[name][getName()]["agcDecay"] = agcDecay; + _config->release(true); + } } void setBandwidth(double bandwidth) { @@ -73,6 +100,11 @@ namespace demod { dsp::demod::SSB demod; dsp::convert::MonoToStereo m2s; + ConfigManager* _config; + + float agcAttack = 40.0f; + float agcDecay = 5.0f; + std::string name; }; } \ No newline at end of file diff --git a/decoder_modules/radio/src/demodulators/wfm.h b/decoder_modules/radio/src/demodulators/wfm.h index 59d4dbc7..43e2999d 100644 --- a/decoder_modules/radio/src/demodulators/wfm.h +++ b/decoder_modules/radio/src/demodulators/wfm.h @@ -26,10 +26,13 @@ namespace demod { if (config->conf[name][getName()].contains("stereo")) { _stereo = config->conf[name][getName()]["stereo"]; } + if (config->conf[name][getName()].contains("lowPass")) { + _lowPass = config->conf[name][getName()]["lowPass"]; + } _config->release(modified); // Define structure - demod.init(input, bandwidth / 2.0f, getIFSampleRate(), _stereo); + demod.init(input, bandwidth / 2.0f, getIFSampleRate(), _stereo, _lowPass); } void start() { @@ -49,6 +52,9 @@ namespace demod { } 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); } }