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

@ -2,10 +2,14 @@
#include "../processor.h" #include "../processor.h"
#include "../loop/agc.h" #include "../loop/agc.h"
#include "../correction/dc_blocker.h" #include "../correction/dc_blocker.h"
#include "../convert/mono_to_stereo.h"
#include "../filter/fir.h"
#include "../taps/low_pass.h"
namespace dsp::demod { namespace dsp::demod {
class AM : public Processor<dsp::complex_t, float> { template <class T>
using base_type = Processor<dsp::complex_t, float>; class AM : public Processor<dsp::complex_t, T> {
using base_type = Processor<dsp::complex_t, T>;
public: public:
enum AGCMode { enum AGCMode {
CARRIER, CARRIER,
@ -14,17 +18,30 @@ namespace dsp::demod {
AM() {} AM() {}
AM(stream<complex_t>* in, AGCMode agcMode, double agcAttack, double agcDecay, double dcBlockRate) { init(in, agcMode, agcAttack, agcDecay, dcBlockRate); } AM(stream<complex_t>* in, AGCMode agcMode, double bandwidth, double agcAttack, double agcDecay, double dcBlockRate, double samplerate) { init(in, agcMode, bandwidth, agcAttack, agcDecay, dcBlockRate, samplerate); }
void init(stream<complex_t>* in, AGCMode agcMode, double agcAttack, double agcDecay, double dcBlockRate) { ~AM() {
if (!base_type::_block_init) { return; }
base_type::stop();
taps::free(lpfTaps);
}
void init(stream<complex_t>* in, AGCMode agcMode, double bandwidth, double agcAttack, double agcDecay, double dcBlockRate, double samplerate) {
_agcMode = agcMode; _agcMode = agcMode;
_bandwidth = bandwidth;
_samplerate = samplerate;
carrierAgc.init(NULL, 1.0, agcAttack, agcDecay, 10e6, 10.0); carrierAgc.init(NULL, 1.0, agcAttack, agcDecay, 10e6, 10.0);
audioAgc.init(NULL, 1.0, agcAttack, agcDecay, 10e6, 10.0); audioAgc.init(NULL, 1.0, agcAttack, agcDecay, 10e6, 10.0);
dcBlock.init(NULL, dcBlockRate); dcBlock.init(NULL, dcBlockRate);
lpfTaps = taps::lowPass(bandwidth / 2.0, (bandwidth / 2.0) * 0.1, samplerate);
lpf.init(NULL, lpfTaps);
audioAgc.out.free(); if constexpr (std::is_same_v<T, float>) {
audioAgc.out.free();
}
dcBlock.out.free(); dcBlock.out.free();
lpf.out.free();
base_type::init(in); base_type::init(in);
} }
@ -38,6 +55,17 @@ namespace dsp::demod {
base_type::tempStart(); base_type::tempStart();
} }
void setBandwidth(double bandwidth) {
assert(base_type::_block_init);
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
if (bandwidth == _bandwidth) { return; }
_bandwidth = bandwidth;
std::lock_guard<std::mutex> lck2(lpfMtx);
taps::free(lpfTaps);
lpfTaps = taps::lowPass(_bandwidth / 2.0, (_bandwidth / 2.0) * 0.1, _samplerate);
lpf.setTaps(lpfTaps);
}
void setAGCAttack(double attack) { void setAGCAttack(double attack) {
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);
@ -58,6 +86,8 @@ namespace dsp::demod {
dcBlock.setRate(rate); dcBlock.setRate(rate);
} }
// TODO: Implement setSamplerate
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);
@ -68,20 +98,35 @@ namespace dsp::demod {
base_type::tempStart(); base_type::tempStart();
} }
int process(int count, complex_t* in, float* out) { int process(int count, complex_t* in, T* out) {
// Apply carrier AGC if needed // Apply carrier AGC if needed
if (_agcMode == AGCMode::CARRIER) { if (_agcMode == AGCMode::CARRIER) {
carrierAgc.process(count, in, carrierAgc.out.writeBuf); carrierAgc.process(count, in, carrierAgc.out.writeBuf);
in = carrierAgc.out.writeBuf; in = carrierAgc.out.writeBuf;
} }
// Get magnitude of each sample and remove DC (TODO: use block instead) if constexpr (std::is_same_v<T, float>) {
volk_32fc_magnitude_32f(out, (lv_32fc_t*)in, count); volk_32fc_magnitude_32f(out, (lv_32fc_t*)in, count);
dcBlock.process(count, out, out); dcBlock.process(count, out, out);
if (_agcMode == AGCMode::AUDIO) {
// Apply audio AGC if needed audioAgc.process(count, out, out);
if (_agcMode == AGCMode::AUDIO) { }
audioAgc.process(count, out, out); {
std::lock_guard<std::mutex> lck(lpfMtx);
lpf.process(count, out, out);
}
}
if constexpr (std::is_same_v<T, stereo_t>) {
volk_32fc_magnitude_32f(audioAgc.out.writeBuf, (lv_32fc_t*)in, count);
dcBlock.process(count, audioAgc.out.writeBuf, audioAgc.out.writeBuf);
if (_agcMode == AGCMode::AUDIO) {
audioAgc.process(count, audioAgc.out.writeBuf, audioAgc.out.writeBuf);
}
{
std::lock_guard<std::mutex> lck(lpfMtx);
lpf.process(count, audioAgc.out.writeBuf, audioAgc.out.writeBuf);
}
convert::MonoToStereo::process(count, audioAgc.out.writeBuf, out);
} }
return count; return count;
@ -101,9 +146,15 @@ namespace dsp::demod {
protected: protected:
AGCMode _agcMode; AGCMode _agcMode;
double _samplerate;
double _bandwidth;
loop::AGC<complex_t> carrierAgc; loop::AGC<complex_t> carrierAgc;
loop::AGC<float> audioAgc; loop::AGC<float> audioAgc;
correction::DCBlocker<float> dcBlock; correction::DCBlocker<float> dcBlock;
tap<float> lpfTaps;
filter::FIR<float, float> lpf;
std::mutex lpfMtx;
}; };
} }

View File

@ -1,5 +1,5 @@
#pragma once #pragma once
#include "fm.h" #include "quadrature.h"
#include "../taps/low_pass.h" #include "../taps/low_pass.h"
#include "../taps/band_pass.h" #include "../taps/band_pass.h"
#include "../filter/fir.h" #include "../filter/fir.h"
@ -193,7 +193,7 @@ namespace dsp::demod {
bool _stereo; bool _stereo;
bool _lowPass = true; bool _lowPass = true;
FM demod; Quadrature demod;
tap<complex_t> pilotFirTaps; tap<complex_t> pilotFirTaps;
filter::FIR<complex_t, complex_t> pilotFir; filter::FIR<complex_t, complex_t> pilotFir;
convert::RealToComplex rtoc; convert::RealToComplex rtoc;

87
core/src/dsp/demod/cw.h Normal file
View File

@ -0,0 +1,87 @@
#pragma once
#include "../processor.h"
#include "../channel/frequency_xlator.h"
#include "../convert/complex_to_real.h"
#include "../loop/agc.h"
#include "../convert/mono_to_stereo.h"
namespace dsp::demod {
template <class T>
class CW : public Processor<complex_t, T> {
using base_type = Processor<complex_t, T>;
public:
CW() {}
CW(stream<complex_t>* in, double tone, double agcAttack, double agcDecay, double samplerate) { init(in, tone, agcAttack, agcDecay, samplerate); }
void init(stream<complex_t>* in, double tone, double agcAttack, double agcDecay, double samplerate) {
_tone = tone;
xlator.init(NULL, tone, samplerate);
agc.init(NULL, 1.0, agcAttack, agcDecay, 10e6, 10.0);
if constexpr (std::is_same_v<T, float>) {
agc.out.free();
}
base_type::init(in);
}
void setTone(double tone) {
assert(base_type::_block_init);
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
_tone = tone;
xlator.setOffset(_tone);
}
void setAGCAttack(double attack) {
assert(base_type::_block_init);
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
agc.setAttack(attack);
}
void setAGCDecay(double decay) {
assert(base_type::_block_init);
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
agc.setDecay(decay);
}
void setSamplerate(double samplerate) {
assert(base_type::_block_init);
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
xlator.setOffset(_tone, samplerate);
}
inline int process(int count, const complex_t* in, T* out) {
xlator.process(count, in, xlator.out.writeBuf);
if constexpr (std::is_same_v<T, float>) {
dsp::convert::ComplexToReal::process(count, xlator.out.writeBuf, out);
agc.process(count, out, out);
}
if constexpr (std::is_same_v<T, stereo_t>) {
dsp::convert::ComplexToReal::process(count, xlator.out.writeBuf, agc.out.writeBuf);
agc.process(count, agc.out.writeBuf, agc.out.writeBuf);
convert::MonoToStereo::process(count, agc.out.writeBuf, out);
}
return count;
}
int run() {
int count = base_type::_in->read();
if (count < 0) { return -1; }
process(count, base_type::_in->readBuf, base_type::out.writeBuf);
base_type::_in->flush();
if (!base_type::out.swap(count)) { return -1; }
return count;
}
private:
double _tone;
dsp::channel::FrequencyXlator xlator;
dsp::loop::AGC<float> agc;
};
}

View File

@ -1,54 +1,98 @@
#pragma once #pragma once
#include "../processor.h" #include "../processor.h"
#include "../math/fast_atan2.h" #include "quadrature.h"
#include "../math/freq_to_omega.h" #include "../filter/fir.h"
#include "../math/norm_phase_diff.h" #include "../taps/low_pass.h"
#include "../convert/mono_to_stereo.h"
namespace dsp::demod { namespace dsp::demod {
class FM : public Processor<complex_t, float> { template <class T>
using base_type = Processor<complex_t, float>; class FM : public dsp::Processor<dsp::complex_t, T> {
using base_type = dsp::Processor<dsp::complex_t, T>;
public: public:
FM() {} FM() {}
FM(stream<complex_t>* in, double deviation) { init(in, deviation); } FM(dsp::stream<dsp::complex_t>* in, double samplerate, double bandwidth, bool lowPass) { init(in, samplerate, bandwidth, lowPass); }
FM(stream<complex_t>* in, double deviation, double samplerate) { init(in, deviation, samplerate); } ~FM() {
if (!base_type::_block_init) { return; }
base_type::stop();
virtual void init(stream<complex_t>* in, double deviation) { dsp::taps::free(lpfTaps);
_invDeviation = 1.0 / deviation;
base_type::init(in);
} }
virtual void init(stream<complex_t>* in, double deviation, double samplerate) { void init(dsp::stream<dsp::complex_t>* in, double samplerate, double bandwidth, bool lowPass) {
init(in, math::freqToOmega(deviation, samplerate)); _samplerate = samplerate;
} _bandwidth = bandwidth;
_lowPass = lowPass;
void setDeviation(double deviation) { demod.init(NULL, bandwidth / 2.0, _samplerate);
assert(base_type::_block_init); lpfTaps = dsp::taps::lowPass(_bandwidth / 2.0, (_bandwidth / 2.0) * 0.1, _samplerate);
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx); lpf.init(NULL, lpfTaps);
_invDeviation = 1.0 / deviation;
}
void setDeviation(double deviation, double samplerate) { if constexpr (std::is_same_v<T, float>) {
assert(base_type::_block_init); demod.out.free();
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
_invDeviation = 1.0 / math::freqToOmega(deviation, samplerate);
}
inline int process(int count, complex_t* in, float* out) {
for (int i = 0; i < count; i++) {
float cphase = in[i].phase();
out[i] = math::normPhaseDiff(cphase - phase) * _invDeviation;
phase = cphase;
} }
return count; lpf.out.free();
}
void setSamplerate(double samplerate) {
assert(base_type::_block_init);
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
base_type::tempStop();
_samplerate = samplerate;
demod.setDeviation(_bandwidth / 2.0, _samplerate);
dsp::taps::free(lpfTaps);
lpfTaps = dsp::taps::lowPass(_bandwidth / 2.0, (_bandwidth / 2.0) * 0.1, _samplerate);
lpf.setTaps(lpfTaps);
base_type::tempStart();
}
void setBandwidth(double bandwidth) {
assert(base_type::_block_init);
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
if (bandwidth == _bandwidth) { return; }
_bandwidth = bandwidth;
std::lock_guard<std::mutex> lck2(lpfMtx);
demod.setDeviation(_bandwidth / 2.0, _samplerate);
dsp::taps::free(lpfTaps);
lpfTaps = dsp::taps::lowPass(_bandwidth / 2, (_bandwidth / 2) * 0.1, _samplerate);
lpf.setTaps(lpfTaps);
}
void setLowPass(bool lowPass) {
assert(base_type::_block_init);
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
std::lock_guard<std::mutex> lck2(lpfMtx);
_lowPass = lowPass;
lpf.reset();
} }
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);
phase = 0.0f; base_type::tempStop();
demod.reset();
lpf.reset();
base_type::tempStart();
}
inline int process(int count, dsp::complex_t* in, T* out) {
if constexpr (std::is_same_v<T, float>) {
demod.process(count, in, out);
if (_lowPass) {
std::lock_guard<std::mutex> lck(lpfMtx);
lpf.process(count, out, out);
}
}
if constexpr (std::is_same_v<T, stereo_t>) {
demod.process(count, in, demod.out.writeBuf);
if (_lowPass) {
std::lock_guard<std::mutex> lck(lpfMtx);
lpf.process(count, demod.out.writeBuf, demod.out.writeBuf);
}
convert::MonoToStereo::process(count, demod.out.writeBuf, out);
}
return count;
} }
int run() { int run() {
@ -62,8 +106,14 @@ namespace dsp::demod {
return count; return count;
} }
protected: private:
float _invDeviation; double _samplerate;
float phase = 0.0f; double _bandwidth;
bool _lowPass;
Quadrature demod;
tap<float> lpfTaps;
filter::FIR<float, float> lpf;
std::mutex lpfMtx;
}; };
} }

View File

@ -0,0 +1,114 @@
#pragma once
#include "../processor.h"
#include "fm.h"
#include "../filter/fir.h"
#include "../taps/low_pass.h"
#include "../convert/mono_to_stereo.h"
namespace dsp::demod {
template <class T>
class NarrowFM : public dsp::Processor<dsp::complex_t, T> {
using base_type = dsp::Processor<dsp::complex_t, T>;
public:
NarrowFM() {}
NarrowFM(dsp::stream<dsp::complex_t>* in, double samplerate, double bandwidth, bool lowPass) { init(in, samplerate, bandwidth, lowPass); }
~NarrowFM() {
if (!base_type::_block_init) { return; }
base_type::stop();
dsp::taps::free(lpfTaps);
}
void init(dsp::stream<dsp::complex_t>* in, double samplerate, double bandwidth, bool lowPass) {
_samplerate = samplerate;
_bandwidth = bandwidth;
_lowPass = lowPass;
demod.init(NULL, bandwidth / 2.0, _samplerate);
lpfTaps = dsp::taps::lowPass(_bandwidth / 2, (_bandwidth / 2) * 0.1, _samplerate);
lpf.init(NULL, lpfTaps);
if constexpr (std::is_same_v<T, float>) {
demod.out.free();
}
lpf.out.free();
}
void setSamplerate(double samplerate) {
assert(base_type::_block_init);
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
base_type::tempStop();
_samplerate = samplerate;
demod.setDeviation(_bandwidth / 2.0, _samplerate);
dsp::taps::free(lpfTaps);
lpfTaps = dsp::taps::lowPass(_bandwidth / 2, (_bandwidth / 2) * 0.1, _samplerate);
lpf.setTaps(lpfTaps);
base_type::tempStart();
}
void setBandwidth(double bandwidth) {
assert(base_type::_block_init);
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
if (bandwidth == _bandwidth) { return; }
_bandwidth = bandwidth;
demod.setDeviation(_bandwidth / 2.0, _samplerate);
dsp::taps::free(lpfTaps);
lpfTaps = dsp::taps::lowPass(_bandwidth / 2, (_bandwidth / 2) * 0.1, _samplerate);
lpf.setTaps(lpfTaps);
}
void setLowPass(bool lowPass) {
assert(base_type::_block_init);
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
_lowPass = lowPass;
lpf.reset();
}
void reset() {
assert(base_type::_block_init);
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
base_type::tempStop();
demod.reset();
lpf.reset();
base_type::tempStart();
}
inline int process(int count, dsp::complex_t* in, float* out) {
if constexpr (std::is_same_v<T, float>) {
demod.process(count, in, out);
if (_lowPass) {
lpf.process(count, out, out);
}
}
if constexpr (std::is_same_v<T, stereo_t>) {
demod.process(count, in, demod.out.writeBuf);
if (_lowPass) {
lpf.process(count, demod.out.writeBuf, demod.out.writeBuf);
}
convert::MonoToStereo::process(count, demod.out.writeBuf, out);
}
return count;
}
int run() {
int count = base_type::_in->read();
if (count < 0) { return -1; }
process(count, base_type::_in->readBuf, base_type::out.writeBuf);
base_type::_in->flush();
if (!base_type::out.swap(count)) { return -1; }
return count;
}
private:
double _samplerate;
double _bandwidth;
bool _lowPass;
dsp::demod::FM demod;
dsp::tap<float> lpfTaps;
dsp::filter::FIR<float, float> lpf;
};
}

View File

@ -0,0 +1,69 @@
#pragma once
#include "../processor.h"
#include "../math/fast_atan2.h"
#include "../math/freq_to_omega.h"
#include "../math/norm_phase_diff.h"
namespace dsp::demod {
class Quadrature : public Processor<complex_t, float> {
using base_type = Processor<complex_t, float>;
public:
Quadrature() {}
Quadrature(stream<complex_t>* in, double deviation) { init(in, deviation); }
Quadrature(stream<complex_t>* in, double deviation, double samplerate) { init(in, deviation, samplerate); }
virtual void init(stream<complex_t>* in, double deviation) {
_invDeviation = 1.0 / deviation;
base_type::init(in);
}
virtual void init(stream<complex_t>* in, double deviation, double samplerate) {
init(in, math::freqToOmega(deviation, samplerate));
}
void setDeviation(double deviation) {
assert(base_type::_block_init);
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
_invDeviation = 1.0 / deviation;
}
void setDeviation(double deviation, double samplerate) {
assert(base_type::_block_init);
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
_invDeviation = 1.0 / math::freqToOmega(deviation, samplerate);
}
inline int process(int count, complex_t* in, float* out) {
for (int i = 0; i < count; i++) {
float cphase = in[i].phase();
out[i] = math::normPhaseDiff(cphase - phase) * _invDeviation;
phase = cphase;
}
return count;
}
void reset() {
assert(base_type::_block_init);
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
phase = 0.0f;
}
int run() {
int count = base_type::_in->read();
if (count < 0) { return -1; }
process(count, base_type::_in->readBuf, base_type::out.writeBuf);
base_type::_in->flush();
if (!base_type::out.swap(count)) { return -1; }
return count;
}
protected:
float _invDeviation;
float phase = 0.0f;
};
}

View File

@ -3,10 +3,12 @@
#include "../channel/frequency_xlator.h" #include "../channel/frequency_xlator.h"
#include "../convert/complex_to_real.h" #include "../convert/complex_to_real.h"
#include "../loop/agc.h" #include "../loop/agc.h"
#include "../convert/mono_to_stereo.h"
namespace dsp::demod { namespace dsp::demod {
class SSB : public Processor<complex_t, float> { template <class T>
using base_type = Processor<complex_t, float>; class SSB : public Processor<complex_t, T> {
using base_type = Processor<complex_t, T>;
public: public:
enum Mode { enum Mode {
USB, USB,
@ -26,7 +28,9 @@ namespace dsp::demod {
xlator.init(NULL, getTranslation(), _samplerate); xlator.init(NULL, getTranslation(), _samplerate);
agc.init(NULL, 1.0, agcAttack, agcDecay, 10e6, 10.0); agc.init(NULL, 1.0, agcAttack, agcDecay, 10e6, 10.0);
agc.out.free(); if constexpr (std::is_same_v<T, float>) {
agc.out.free();
}
base_type::init(in); base_type::init(in);
} }
@ -70,15 +74,19 @@ namespace dsp::demod {
agc.setDecay(decay); agc.setDecay(decay);
} }
int process(int count, const complex_t* in, float* out) { int process(int count, const complex_t* in, T* out) {
// Move back sideband // Move back sideband
xlator.process(count, in, xlator.out.writeBuf); xlator.process(count, in, xlator.out.writeBuf);
// Extract the real component if constexpr (std::is_same_v<T, float>) {
convert::ComplexToReal::process(count, xlator.out.writeBuf, out); convert::ComplexToReal::process(count, xlator.out.writeBuf, out);
agc.process(count, out, out);
// Apply AGC }
agc.process(count, out, out); if constexpr (std::is_same_v<T, stereo_t>) {
convert::ComplexToReal::process(count, xlator.out.writeBuf, agc.out.writeBuf);
agc.process(count, agc.out.writeBuf, agc.out.writeBuf);
convert::MonoToStereo::process(count, agc.out.writeBuf, out);
}
return count; return count;
} }

View File

@ -17,7 +17,7 @@ namespace dsp::sink {
int count = base_type::_in->read(); int count = base_type::_in->read();
if (count < 0) { return -1; } if (count < 0) { return -1; }
if (data.write(_in->readBuf, count) < 0) { return -1; } if (data.write(base_type::_in->readBuf, count) < 0) { return -1; }
base_type::_in->flush(); base_type::_in->flush();
return count; return count;

View File

@ -259,6 +259,7 @@ void MainWindow::vfoAddedHandler(VFOManager::VFO* vfo, void* ctx) {
void MainWindow::draw() { void MainWindow::draw() {
ImGui::Begin("Main", NULL, WINDOW_FLAGS); ImGui::Begin("Main", NULL, WINDOW_FLAGS);
ImVec4 textCol = ImGui::GetStyleColorVec4(ImGuiCol_Text);
ImGui::WaterfallVFO* vfo = NULL; ImGui::WaterfallVFO* vfo = NULL;
if (gui::waterfall.selectedVFO != "") { if (gui::waterfall.selectedVFO != "") {
@ -332,7 +333,7 @@ void MainWindow::draw() {
// ImGui::BeginChild("TopBarChild", ImVec2(0, 49.0f * style::uiScale), false, ImGuiWindowFlags_HorizontalScrollbar); // ImGui::BeginChild("TopBarChild", ImVec2(0, 49.0f * style::uiScale), false, ImGuiWindowFlags_HorizontalScrollbar);
ImVec2 btnSize(30 * style::uiScale, 30 * style::uiScale); ImVec2 btnSize(30 * style::uiScale, 30 * style::uiScale);
ImGui::PushID(ImGui::GetID("sdrpp_menu_btn")); ImGui::PushID(ImGui::GetID("sdrpp_menu_btn"));
if (ImGui::ImageButton(icons::MENU, btnSize, ImVec2(0, 0), ImVec2(1, 1), 5) || ImGui::IsKeyPressed(ImGuiKey_Menu, false)) { if (ImGui::ImageButton(icons::MENU, btnSize, ImVec2(0, 0), ImVec2(1, 1), 5, ImVec4(0, 0, 0, 0), textCol) || ImGui::IsKeyPressed(ImGuiKey_Menu, false)) {
showMenu = !showMenu; showMenu = !showMenu;
core::configManager.acquire(); core::configManager.acquire();
core::configManager.conf["showMenu"] = showMenu; core::configManager.conf["showMenu"] = showMenu;
@ -346,14 +347,14 @@ void MainWindow::draw() {
if (playButtonLocked && !tmpPlaySate) { style::beginDisabled(); } if (playButtonLocked && !tmpPlaySate) { style::beginDisabled(); }
if (playing) { if (playing) {
ImGui::PushID(ImGui::GetID("sdrpp_stop_btn")); ImGui::PushID(ImGui::GetID("sdrpp_stop_btn"));
if (ImGui::ImageButton(icons::STOP, btnSize, ImVec2(0, 0), ImVec2(1, 1), 5) || ImGui::IsKeyPressed(ImGuiKey_End, false)) { if (ImGui::ImageButton(icons::STOP, btnSize, ImVec2(0, 0), ImVec2(1, 1), 5, ImVec4(0, 0, 0, 0), textCol) || ImGui::IsKeyPressed(ImGuiKey_End, false)) {
setPlayState(false); setPlayState(false);
} }
ImGui::PopID(); ImGui::PopID();
} }
else { // TODO: Might need to check if there even is a device else { // TODO: Might need to check if there even is a device
ImGui::PushID(ImGui::GetID("sdrpp_play_btn")); ImGui::PushID(ImGui::GetID("sdrpp_play_btn"));
if (ImGui::ImageButton(icons::PLAY, btnSize, ImVec2(0, 0), ImVec2(1, 1), 5) || ImGui::IsKeyPressed(ImGuiKey_End, false)) { if (ImGui::ImageButton(icons::PLAY, btnSize, ImVec2(0, 0), ImVec2(1, 1), 5, ImVec4(0, 0, 0, 0), textCol) || ImGui::IsKeyPressed(ImGuiKey_End, false)) {
setPlayState(true); setPlayState(true);
} }
ImGui::PopID(); ImGui::PopID();
@ -381,7 +382,7 @@ void MainWindow::draw() {
ImGui::SetCursorPosY(origY); ImGui::SetCursorPosY(origY);
if (tuningMode == tuner::TUNER_MODE_CENTER) { if (tuningMode == tuner::TUNER_MODE_CENTER) {
ImGui::PushID(ImGui::GetID("sdrpp_ena_st_btn")); ImGui::PushID(ImGui::GetID("sdrpp_ena_st_btn"));
if (ImGui::ImageButton(icons::CENTER_TUNING, btnSize, ImVec2(0, 0), ImVec2(1, 1), 5)) { if (ImGui::ImageButton(icons::CENTER_TUNING, btnSize, ImVec2(0, 0), ImVec2(1, 1), 5, ImVec4(0, 0, 0, 0), textCol)) {
tuningMode = tuner::TUNER_MODE_NORMAL; tuningMode = tuner::TUNER_MODE_NORMAL;
gui::waterfall.VFOMoveSingleClick = false; gui::waterfall.VFOMoveSingleClick = false;
core::configManager.acquire(); core::configManager.acquire();
@ -392,7 +393,7 @@ void MainWindow::draw() {
} }
else { // TODO: Might need to check if there even is a device else { // TODO: Might need to check if there even is a device
ImGui::PushID(ImGui::GetID("sdrpp_dis_st_btn")); ImGui::PushID(ImGui::GetID("sdrpp_dis_st_btn"));
if (ImGui::ImageButton(icons::NORMAL_TUNING, btnSize, ImVec2(0, 0), ImVec2(1, 1), 5)) { if (ImGui::ImageButton(icons::NORMAL_TUNING, btnSize, ImVec2(0, 0), ImVec2(1, 1), 5, ImVec4(0, 0, 0, 0), textCol)) {
tuningMode = tuner::TUNER_MODE_CENTER; tuningMode = tuner::TUNER_MODE_CENTER;
gui::waterfall.VFOMoveSingleClick = true; gui::waterfall.VFOMoveSingleClick = true;
tuner::tune(tuner::TUNER_MODE_CENTER, gui::waterfall.selectedVFO, gui::freqSelect.frequency); tuner::tune(tuner::TUNER_MODE_CENTER, gui::waterfall.selectedVFO, gui::freqSelect.frequency);

View File

@ -239,7 +239,7 @@ void SinkManager::setStreamSink(std::string name, std::string providerName) {
} }
} }
void SinkManager::showVolumeSlider(std::string name, std::string prefix, float width, float btnHeight, int btwBorder, bool sameLine) { void SinkManager::showVolumeSlider(std::string name, std::string prefix, float width, float btnHeight, int btnBorder, bool sameLine) {
// TODO: Replace map with some hashmap for it to be faster // TODO: Replace map with some hashmap for it to be faster
float height = ImGui::GetTextLineHeightWithSpacing() + 2; float height = ImGui::GetTextLineHeightWithSpacing() + 2;
float sliderHeight = height; float sliderHeight = height;
@ -254,11 +254,11 @@ void SinkManager::showVolumeSlider(std::string name, std::string prefix, float w
float dummy = 0.0f; float dummy = 0.0f;
style::beginDisabled(); style::beginDisabled();
ImGui::PushID(ImGui::GetID(("sdrpp_unmute_btn_" + name).c_str())); ImGui::PushID(ImGui::GetID(("sdrpp_unmute_btn_" + name).c_str()));
ImGui::ImageButton(icons::MUTED, ImVec2(height, height), ImVec2(0, 0), ImVec2(1, 1), btwBorder); ImGui::ImageButton(icons::MUTED, ImVec2(height, height), ImVec2(0, 0), ImVec2(1, 1), btnBorder, ImVec4(0, 0, 0, 0), ImGui::GetStyleColorVec4(ImGuiCol_Text));
ImGui::PopID(); ImGui::PopID();
ImGui::SameLine(); ImGui::SameLine();
ImGui::SetNextItemWidth(width - height - sliderOffset); ImGui::SetNextItemWidth(width - height - sliderOffset);
ImGui::SetCursorPosY(ypos + ((height - sliderHeight) / 2.0f) + btwBorder); ImGui::SetCursorPosY(ypos + ((height - sliderHeight) / 2.0f) + btnBorder);
ImGui::SliderFloat((prefix + name).c_str(), &dummy, 0.0f, 1.0f, ""); ImGui::SliderFloat((prefix + name).c_str(), &dummy, 0.0f, 1.0f, "");
style::endDisabled(); style::endDisabled();
if (sameLine) { ImGui::SetCursorPosY(ypos); } if (sameLine) { ImGui::SetCursorPosY(ypos); }
@ -269,7 +269,7 @@ void SinkManager::showVolumeSlider(std::string name, std::string prefix, float w
if (stream->volumeAjust.getMuted()) { if (stream->volumeAjust.getMuted()) {
ImGui::PushID(ImGui::GetID(("sdrpp_unmute_btn_" + name).c_str())); ImGui::PushID(ImGui::GetID(("sdrpp_unmute_btn_" + name).c_str()));
if (ImGui::ImageButton(icons::MUTED, ImVec2(height, height), ImVec2(0, 0), ImVec2(1, 1), btwBorder)) { if (ImGui::ImageButton(icons::MUTED, ImVec2(height, height), ImVec2(0, 0), ImVec2(1, 1), btnBorder, ImVec4(0, 0, 0, 0), ImGui::GetStyleColorVec4(ImGuiCol_Text))) {
stream->volumeAjust.setMuted(false); stream->volumeAjust.setMuted(false);
core::configManager.acquire(); core::configManager.acquire();
saveStreamConfig(name); saveStreamConfig(name);
@ -279,7 +279,7 @@ void SinkManager::showVolumeSlider(std::string name, std::string prefix, float w
} }
else { else {
ImGui::PushID(ImGui::GetID(("sdrpp_mute_btn_" + name).c_str())); ImGui::PushID(ImGui::GetID(("sdrpp_mute_btn_" + name).c_str()));
if (ImGui::ImageButton(icons::UNMUTED, ImVec2(height, height), ImVec2(0, 0), ImVec2(1, 1), btwBorder)) { if (ImGui::ImageButton(icons::UNMUTED, ImVec2(height, height), ImVec2(0, 0), ImVec2(1, 1), btnBorder, ImVec4(0, 0, 0, 0), ImGui::GetStyleColorVec4(ImGuiCol_Text))) {
stream->volumeAjust.setMuted(true); stream->volumeAjust.setMuted(true);
core::configManager.acquire(); core::configManager.acquire();
saveStreamConfig(name); saveStreamConfig(name);
@ -291,7 +291,7 @@ void SinkManager::showVolumeSlider(std::string name, std::string prefix, float w
ImGui::SameLine(); ImGui::SameLine();
ImGui::SetNextItemWidth(width - height - sliderOffset); ImGui::SetNextItemWidth(width - height - sliderOffset);
ImGui::SetCursorPosY(ypos + ((height - sliderHeight) / 2.0f) + btwBorder); ImGui::SetCursorPosY(ypos + ((height - sliderHeight) / 2.0f) + btnBorder);
if (ImGui::SliderFloat((prefix + name).c_str(), &stream->guiVolume, 0.0f, 1.0f, "")) { if (ImGui::SliderFloat((prefix + name).c_str(), &stream->guiVolume, 0.0f, 1.0f, "")) {
stream->setVolume(stream->guiVolume); stream->setVolume(stream->guiVolume);
core::configManager.acquire(); core::configManager.acquire();

View File

@ -101,7 +101,7 @@ public:
void setStreamSink(std::string name, std::string providerName); void setStreamSink(std::string name, std::string providerName);
void showVolumeSlider(std::string name, std::string prefix, float width, float btnHeight = -1.0f, int btwBorder = 0, bool sameLine = false); void showVolumeSlider(std::string name, std::string prefix, float width, float btnHeight = -1.0f, int btnBorder = 0, bool sameLine = false);
dsp::stream<dsp::stereo_t>* bindStream(std::string name); dsp::stream<dsp::stereo_t>* bindStream(std::string name);
void unbindStream(std::string name, dsp::stream<dsp::stereo_t>* stream); void unbindStream(std::string name, dsp::stream<dsp::stereo_t>* stream);

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,6 @@
#pragma once #pragma once
#include "../demod.h" #include "../demod.h"
#include <dsp/demod/fm.h> #include <dsp/demod/fm.h>
#include <dsp/convert/mono_to_stereo.h>
namespace demod { namespace demod {
class NFM : public Demodulator { class NFM : public Demodulator {
@ -12,37 +11,33 @@ namespace demod {
init(name, config, input, bandwidth, outputChangeHandler, afbwChangeHandler, audioSR); init(name, config, input, bandwidth, outputChangeHandler, afbwChangeHandler, audioSR);
} }
~NFM() { ~NFM() { stop(); }
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) { 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->name = name;
// Define structure // Define structure
demod.init(input, bandwidth / 2.0, getIFSampleRate()); demod.init(input, getIFSampleRate(), bandwidth, _lowPass);
m2s.init(&demod.out);
} }
void start() { void start() { demod.start(); }
demod.start();
m2s.start();
}
void stop() { void stop() { demod.stop(); }
demod.stop();
m2s.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) { void setBandwidth(double bandwidth) {
demod.setDeviation(bandwidth / 2.0, getIFSampleRate()); demod.setBandwidth(bandwidth);
} }
void setInput(dsp::stream<dsp::complex_t>* input) { void setInput(dsp::stream<dsp::complex_t>* input) { demod.setInput(input); }
demod.setInput(input);
}
void AFSampRateChanged(double newSR) {} void AFSampRateChanged(double newSR) {}
@ -65,11 +60,12 @@ namespace demod {
bool getDynamicAFBandwidth() { return true; } bool getDynamicAFBandwidth() { return true; }
bool getFMIFNRAllowed() { return true; } bool getFMIFNRAllowed() { return true; }
bool getNBAllowed() { 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: private:
dsp::demod::FM demod; dsp::demod::FM<dsp::stereo_t> demod;
dsp::convert::MonoToStereo m2s;
bool _lowPass = true;
std::string name; std::string name;
}; };

View File

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