Radio CW demod bugfix + more cleanup

This commit is contained in:
AlexandreRouma
2022-01-29 17:27:38 +01:00
parent 860121dad2
commit 3ab669ecda
10 changed files with 48 additions and 42 deletions

View File

@ -8,17 +8,16 @@ namespace demod {
public:
AM() {}
AM(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, double audioSR) {
init(name, config, input, bandwidth, outputChangeHandler, 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, afbwChangeHandler, audioSR);
}
~AM() {
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->outputChangeHandler = outputChangeHandler;
// Define structure
demod.init(input);
@ -77,6 +76,5 @@ namespace demod {
dsp::MonoToStereo m2s;
std::string name;
EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler;
};
}

View File

@ -8,18 +8,19 @@ namespace demod {
public:
CW() {}
CW(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, double audioSR) {
init(name, config, input, bandwidth, outputChangeHandler, 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, afbwChangeHandler, audioSR);
}
~CW() {
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->_config = config;
this->outputChangeHandler = outputChangeHandler;
this->_bandwidth = bandwidth;
this->afbwChangeHandler = afbwChangeHandler;
// Load config
config->acquire();
@ -55,13 +56,14 @@ namespace demod {
if (ImGui::InputInt(("Stereo##_radio_cw_tone_" + name).c_str(), &tone, 10, 100)) {
tone = std::clamp<int>(tone, 250, 1250);
xlator.setFrequency(tone);
afbwChangeHandler.handler(getAFBandwidth(_bandwidth), afbwChangeHandler.ctx);
_config->acquire();
_config->conf[name][getName()]["tone"] = tone;
_config->release(true);
}
}
void setBandwidth(double bandwidth) {}
void setBandwidth(double bandwidth) { _bandwidth = bandwidth; }
void setInput(dsp::stream<dsp::complex_t>* input) {
xlator.setInput(input);
@ -84,7 +86,7 @@ namespace demod {
bool getDeempAllowed() { return false; }
bool getPostProcEnabled() { return true; }
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 getFMIFNRAllowed() { return false; }
bool getNBAllowed() { return false; }
@ -98,8 +100,10 @@ namespace demod {
dsp::MonoToStereo m2s;
std::string name;
EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler;
int tone = 800;
double _bandwidth;
EventHandler<float> afbwChangeHandler;
};
}

View File

@ -8,17 +8,16 @@ namespace demod {
public:
DSB() {}
DSB(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, double audioSR) {
init(name, config, input, bandwidth, outputChangeHandler, 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, afbwChangeHandler, audioSR);
}
~DSB() {
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->outputChangeHandler = outputChangeHandler;
// Define structure
demod.init(input, getIFSampleRate(), bandwidth, dsp::SSBDemod::MODE_DSB);
@ -79,6 +78,5 @@ namespace demod {
dsp::MonoToStereo m2s;
std::string name;
EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler;
};
}

View File

@ -8,17 +8,16 @@ namespace demod {
public:
LSB() {}
LSB(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, double audioSR) {
init(name, config, input, bandwidth, outputChangeHandler, 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, afbwChangeHandler, audioSR);
}
~LSB() {
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->outputChangeHandler = outputChangeHandler;
// Define structure
demod.init(input, getIFSampleRate(), bandwidth, dsp::SSBDemod::MODE_LSB);
@ -79,6 +78,5 @@ namespace demod {
dsp::MonoToStereo m2s;
std::string name;
EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler;
};
}

View File

@ -8,17 +8,16 @@ namespace demod {
public:
NFM() {}
NFM(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, double audioSR) {
init(name, config, input, bandwidth, outputChangeHandler, 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, afbwChangeHandler, audioSR);
}
~NFM() {
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->outputChangeHandler = outputChangeHandler;
// Define structure
demod.init(input, getIFSampleRate(), bandwidth / 2.0f);
@ -69,6 +68,5 @@ namespace demod {
dsp::FMDemod demod;
std::string name;
EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler;
};
}

View File

@ -8,17 +8,16 @@ namespace demod {
public:
RAW() {}
RAW(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, double audioSR) {
init(name, config, input, bandwidth, outputChangeHandler, 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, afbwChangeHandler, audioSR);
}
~RAW() {
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->outputChangeHandler = outputChangeHandler;
audioSampleRate = audioSR;
// Define structure
@ -71,6 +70,5 @@ namespace demod {
dsp::ComplexToStereo c2s;
std::string name;
EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler;
};
}

View File

@ -8,17 +8,16 @@ namespace demod {
public:
USB() {}
USB(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, double audioSR) {
init(name, config, input, bandwidth, outputChangeHandler, 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, afbwChangeHandler, audioSR);
}
~USB() {
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->outputChangeHandler = outputChangeHandler;
// Define structure
demod.init(input, getIFSampleRate(), bandwidth, dsp::SSBDemod::MODE_USB);
@ -79,6 +78,5 @@ namespace demod {
dsp::MonoToStereo m2s;
std::string name;
EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler;
};
}

View File

@ -8,15 +8,15 @@ namespace demod {
public:
WFM() {}
WFM(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, EventHandler<dsp::stream<dsp::stereo_t>*> outputChangeHandler, double audioSR) {
init(name, config, input, bandwidth, outputChangeHandler, 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, afbwChangeHandler, audioSR);
}
~WFM() {
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->outputChangeHandler = outputChangeHandler;
_config = config;