mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-01-11 18:57:11 +01:00
Radio CW demod bugfix + more cleanup
This commit is contained in:
parent
860121dad2
commit
3ab669ecda
@ -24,7 +24,7 @@ namespace demod {
|
|||||||
class Demodulator {
|
class Demodulator {
|
||||||
public:
|
public:
|
||||||
virtual ~Demodulator() {}
|
virtual ~Demodulator() {}
|
||||||
virtual void init(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, double audioSR) = 0;
|
virtual 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) = 0;
|
||||||
virtual void start() = 0;
|
virtual void start() = 0;
|
||||||
virtual void stop() = 0;
|
virtual void stop() = 0;
|
||||||
virtual void showMenu() = 0;
|
virtual void showMenu() = 0;
|
||||||
|
@ -8,17 +8,16 @@ namespace demod {
|
|||||||
public:
|
public:
|
||||||
AM() {}
|
AM() {}
|
||||||
|
|
||||||
AM(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, double audioSR) {
|
AM(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) {
|
||||||
init(name, config, input, bandwidth, outputChangeHandler, 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, 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->outputChangeHandler = outputChangeHandler;
|
|
||||||
|
|
||||||
// Define structure
|
// Define structure
|
||||||
demod.init(input);
|
demod.init(input);
|
||||||
@ -77,6 +76,5 @@ namespace demod {
|
|||||||
dsp::MonoToStereo m2s;
|
dsp::MonoToStereo m2s;
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -8,18 +8,19 @@ namespace demod {
|
|||||||
public:
|
public:
|
||||||
CW() {}
|
CW() {}
|
||||||
|
|
||||||
CW(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, double audioSR) {
|
CW(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) {
|
||||||
init(name, config, input, bandwidth, outputChangeHandler, audioSR);
|
init(name, config, input, bandwidth, outputChangeHandler, afbwChangeHandler, audioSR);
|
||||||
}
|
}
|
||||||
|
|
||||||
~CW() {
|
~CW() {
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void init(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, 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->outputChangeHandler = outputChangeHandler;
|
this->_bandwidth = bandwidth;
|
||||||
|
this->afbwChangeHandler = afbwChangeHandler;
|
||||||
|
|
||||||
// Load config
|
// Load config
|
||||||
config->acquire();
|
config->acquire();
|
||||||
@ -55,13 +56,14 @@ namespace demod {
|
|||||||
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.setFrequency(tone);
|
xlator.setFrequency(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) {}
|
void setBandwidth(double bandwidth) { _bandwidth = bandwidth; }
|
||||||
|
|
||||||
void setInput(dsp::stream<dsp::complex_t>* input) {
|
void setInput(dsp::stream<dsp::complex_t>* input) {
|
||||||
xlator.setInput(input);
|
xlator.setInput(input);
|
||||||
@ -84,7 +86,7 @@ namespace demod {
|
|||||||
bool getDeempAllowed() { return false; }
|
bool getDeempAllowed() { return false; }
|
||||||
bool getPostProcEnabled() { return true; }
|
bool getPostProcEnabled() { return true; }
|
||||||
int getDefaultDeemphasisMode() { return DEEMP_MODE_NONE; }
|
int getDefaultDeemphasisMode() { return DEEMP_MODE_NONE; }
|
||||||
double getAFBandwidth(double bandwidth) { return (bandwidth / 2.0) + 1000.0; }
|
double getAFBandwidth(double bandwidth) { return (bandwidth / 2.0) + (float)tone; }
|
||||||
bool getDynamicAFBandwidth() { return true; }
|
bool getDynamicAFBandwidth() { return true; }
|
||||||
bool getFMIFNRAllowed() { return false; }
|
bool getFMIFNRAllowed() { return false; }
|
||||||
bool getNBAllowed() { return false; }
|
bool getNBAllowed() { return false; }
|
||||||
@ -98,8 +100,10 @@ namespace demod {
|
|||||||
dsp::MonoToStereo m2s;
|
dsp::MonoToStereo m2s;
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler;
|
|
||||||
|
|
||||||
int tone = 800;
|
int tone = 800;
|
||||||
|
double _bandwidth;
|
||||||
|
|
||||||
|
EventHandler<float> afbwChangeHandler;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -8,17 +8,16 @@ namespace demod {
|
|||||||
public:
|
public:
|
||||||
DSB() {}
|
DSB() {}
|
||||||
|
|
||||||
DSB(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, double audioSR) {
|
DSB(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) {
|
||||||
init(name, config, input, bandwidth, outputChangeHandler, audioSR);
|
init(name, config, input, bandwidth, outputChangeHandler, afbwChangeHandler, audioSR);
|
||||||
}
|
}
|
||||||
|
|
||||||
~DSB() {
|
~DSB() {
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void init(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, 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->outputChangeHandler = outputChangeHandler;
|
|
||||||
|
|
||||||
// Define structure
|
// Define structure
|
||||||
demod.init(input, getIFSampleRate(), bandwidth, dsp::SSBDemod::MODE_DSB);
|
demod.init(input, getIFSampleRate(), bandwidth, dsp::SSBDemod::MODE_DSB);
|
||||||
@ -79,6 +78,5 @@ namespace demod {
|
|||||||
dsp::MonoToStereo m2s;
|
dsp::MonoToStereo m2s;
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -8,17 +8,16 @@ namespace demod {
|
|||||||
public:
|
public:
|
||||||
LSB() {}
|
LSB() {}
|
||||||
|
|
||||||
LSB(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, double audioSR) {
|
LSB(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) {
|
||||||
init(name, config, input, bandwidth, outputChangeHandler, audioSR);
|
init(name, config, input, bandwidth, outputChangeHandler, afbwChangeHandler, audioSR);
|
||||||
}
|
}
|
||||||
|
|
||||||
~LSB() {
|
~LSB() {
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void init(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, 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->outputChangeHandler = outputChangeHandler;
|
|
||||||
|
|
||||||
// Define structure
|
// Define structure
|
||||||
demod.init(input, getIFSampleRate(), bandwidth, dsp::SSBDemod::MODE_LSB);
|
demod.init(input, getIFSampleRate(), bandwidth, dsp::SSBDemod::MODE_LSB);
|
||||||
@ -79,6 +78,5 @@ namespace demod {
|
|||||||
dsp::MonoToStereo m2s;
|
dsp::MonoToStereo m2s;
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -8,17 +8,16 @@ namespace demod {
|
|||||||
public:
|
public:
|
||||||
NFM() {}
|
NFM() {}
|
||||||
|
|
||||||
NFM(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, double audioSR) {
|
NFM(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) {
|
||||||
init(name, config, input, bandwidth, outputChangeHandler, 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, 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->outputChangeHandler = outputChangeHandler;
|
|
||||||
|
|
||||||
// Define structure
|
// Define structure
|
||||||
demod.init(input, getIFSampleRate(), bandwidth / 2.0f);
|
demod.init(input, getIFSampleRate(), bandwidth / 2.0f);
|
||||||
@ -69,6 +68,5 @@ namespace demod {
|
|||||||
dsp::FMDemod demod;
|
dsp::FMDemod demod;
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -8,17 +8,16 @@ namespace demod {
|
|||||||
public:
|
public:
|
||||||
RAW() {}
|
RAW() {}
|
||||||
|
|
||||||
RAW(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, double audioSR) {
|
RAW(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) {
|
||||||
init(name, config, input, bandwidth, outputChangeHandler, audioSR);
|
init(name, config, input, bandwidth, outputChangeHandler, afbwChangeHandler, audioSR);
|
||||||
}
|
}
|
||||||
|
|
||||||
~RAW() {
|
~RAW() {
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void init(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, 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->outputChangeHandler = outputChangeHandler;
|
|
||||||
audioSampleRate = audioSR;
|
audioSampleRate = audioSR;
|
||||||
|
|
||||||
// Define structure
|
// Define structure
|
||||||
@ -71,6 +70,5 @@ namespace demod {
|
|||||||
dsp::ComplexToStereo c2s;
|
dsp::ComplexToStereo c2s;
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -8,17 +8,16 @@ namespace demod {
|
|||||||
public:
|
public:
|
||||||
USB() {}
|
USB() {}
|
||||||
|
|
||||||
USB(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, double audioSR) {
|
USB(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) {
|
||||||
init(name, config, input, bandwidth, outputChangeHandler, audioSR);
|
init(name, config, input, bandwidth, outputChangeHandler, afbwChangeHandler, audioSR);
|
||||||
}
|
}
|
||||||
|
|
||||||
~USB() {
|
~USB() {
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void init(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, 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->outputChangeHandler = outputChangeHandler;
|
|
||||||
|
|
||||||
// Define structure
|
// Define structure
|
||||||
demod.init(input, getIFSampleRate(), bandwidth, dsp::SSBDemod::MODE_USB);
|
demod.init(input, getIFSampleRate(), bandwidth, dsp::SSBDemod::MODE_USB);
|
||||||
@ -79,6 +78,5 @@ namespace demod {
|
|||||||
dsp::MonoToStereo m2s;
|
dsp::MonoToStereo m2s;
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -8,15 +8,15 @@ namespace demod {
|
|||||||
public:
|
public:
|
||||||
WFM() {}
|
WFM() {}
|
||||||
|
|
||||||
WFM(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, double audioSR) {
|
WFM(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) {
|
||||||
init(name, config, input, bandwidth, outputChangeHandler, audioSR);
|
init(name, config, input, bandwidth, outputChangeHandler, afbwChangeHandler, audioSR);
|
||||||
}
|
}
|
||||||
|
|
||||||
~WFM() {
|
~WFM() {
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void init(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, 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->outputChangeHandler = outputChangeHandler;
|
this->outputChangeHandler = outputChangeHandler;
|
||||||
_config = config;
|
_config = config;
|
||||||
|
@ -88,8 +88,11 @@ public:
|
|||||||
|
|
||||||
// Load configuration for and enabled all demodulators
|
// Load configuration for and enabled all demodulators
|
||||||
EventHandler<dsp::stream<dsp::stereo_t>*> _demodOutputChangeHandler;
|
EventHandler<dsp::stream<dsp::stereo_t>*> _demodOutputChangeHandler;
|
||||||
|
EventHandler<float> _demodAfbwChangedHandler;
|
||||||
_demodOutputChangeHandler.handler = demodOutputChangeHandler;
|
_demodOutputChangeHandler.handler = demodOutputChangeHandler;
|
||||||
_demodOutputChangeHandler.ctx = this;
|
_demodOutputChangeHandler.ctx = this;
|
||||||
|
_demodAfbwChangedHandler.handler = demodAfbwChangedHandler;
|
||||||
|
_demodAfbwChangedHandler.ctx = this;
|
||||||
for (auto& demod : demods) {
|
for (auto& demod : demods) {
|
||||||
if (!demod) { continue; }
|
if (!demod) { continue; }
|
||||||
|
|
||||||
@ -104,7 +107,7 @@ public:
|
|||||||
bw = std::clamp<double>(bw, demod->getMinBandwidth(), demod->getMaxBandwidth());
|
bw = std::clamp<double>(bw, demod->getMinBandwidth(), demod->getMaxBandwidth());
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
demod->init(name, &config, ifChain.getOutput(), bw, _demodOutputChangeHandler, stream.getSampleRate());
|
demod->init(name, &config, ifChain.getOutput(), bw, _demodOutputChangeHandler, _demodAfbwChangedHandler, stream.getSampleRate());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize audio DSP chain
|
// Initialize audio DSP chain
|
||||||
@ -614,6 +617,17 @@ private:
|
|||||||
_this->afChain.setInput(output);
|
_this->afChain.setInput(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void demodAfbwChangedHandler(float output, void* ctx) {
|
||||||
|
RadioModule* _this = (RadioModule*)ctx;
|
||||||
|
|
||||||
|
float audioBW = std::min<float>(_this->selectedDemod->getMaxAFBandwidth(), _this->selectedDemod->getAFBandwidth(_this->bandwidth));
|
||||||
|
audioBW = std::min<float>(audioBW, _this->audioSampleRate / 2.0);
|
||||||
|
|
||||||
|
_this->win.setCutoff(audioBW);
|
||||||
|
_this->win.setTransWidth(audioBW);
|
||||||
|
_this->resamp.block.updateWindow(&_this->win);
|
||||||
|
}
|
||||||
|
|
||||||
static void ifChainOutputChangeHandler(dsp::stream<dsp::complex_t>* output, void* ctx) {
|
static void ifChainOutputChangeHandler(dsp::stream<dsp::complex_t>* output, void* ctx) {
|
||||||
RadioModule* _this = (RadioModule*)ctx;
|
RadioModule* _this = (RadioModule*)ctx;
|
||||||
if (!_this->selectedDemod) { return; }
|
if (!_this->selectedDemod) { return; }
|
||||||
|
Loading…
Reference in New Issue
Block a user