new FM IF noise reduction + bugfix

This commit is contained in:
AlexandreRouma
2021-12-08 02:10:41 +01:00
parent 1594051a5d
commit 2a5671878f
13 changed files with 177 additions and 5 deletions

View File

@ -37,6 +37,7 @@ namespace demod {
virtual bool getPostProcEnabled() = 0;
virtual int getDefaultDeemphasisMode() = 0;
virtual double getAFBandwidth(double bandwidth) = 0;
virtual bool getFMIFNRAllowed() = 0;
virtual bool getDynamicAFBandwidth() = 0;
virtual dsp::stream<dsp::stereo_t>* getOutput() = 0;

View File

@ -67,6 +67,7 @@ namespace demod {
int getDefaultDeemphasisMode() { return DEEMP_MODE_NONE; }
double getAFBandwidth(double bandwidth) { return bandwidth / 2.0; }
bool getDynamicAFBandwidth() { return true; }
bool getFMIFNRAllowed() { return false; }
dsp::stream<dsp::stereo_t>* getOutput() { return &m2s.out; }
private:

View File

@ -68,6 +68,7 @@ namespace demod {
int getDefaultDeemphasisMode() { return DEEMP_MODE_NONE; }
double getAFBandwidth(double bandwidth) { return (bandwidth / 2.0) + 1000.0; }
bool getDynamicAFBandwidth() { return true; }
bool getFMIFNRAllowed() { return false; }
dsp::stream<dsp::stereo_t>* getOutput() { return &m2s.out; }
private:

View File

@ -69,6 +69,7 @@ namespace demod {
int getDefaultDeemphasisMode() { return DEEMP_MODE_NONE; }
double getAFBandwidth(double bandwidth) { return bandwidth / 2.0; }
bool getDynamicAFBandwidth() { return true; }
bool getFMIFNRAllowed() { return false; }
dsp::stream<dsp::stereo_t>* getOutput() { return &m2s.out; }
private:

View File

@ -69,6 +69,7 @@ namespace demod {
int getDefaultDeemphasisMode() { return DEEMP_MODE_NONE; }
double getAFBandwidth(double bandwidth) { return bandwidth; }
bool getDynamicAFBandwidth() { return true; }
bool getFMIFNRAllowed() { return false; }
dsp::stream<dsp::stereo_t>* getOutput() { return &m2s.out; }
private:

View File

@ -61,6 +61,7 @@ namespace demod {
int getDefaultDeemphasisMode() { return DEEMP_MODE_NONE; }
double getAFBandwidth(double bandwidth) { return bandwidth / 2.0; }
bool getDynamicAFBandwidth() { return true; }
bool getFMIFNRAllowed() { return true; }
dsp::stream<dsp::stereo_t>* getOutput() { return &demod.out; }
private:

View File

@ -62,6 +62,7 @@ namespace demod {
int getDefaultDeemphasisMode() { return DEEMP_MODE_NONE; }
double getAFBandwidth(double bandwidth) { return bandwidth; }
bool getDynamicAFBandwidth() { return false; }
bool getFMIFNRAllowed() { return false; }
dsp::stream<dsp::stereo_t>* getOutput() { return &c2s.out; }
private:

View File

@ -69,6 +69,7 @@ namespace demod {
int getDefaultDeemphasisMode() { return DEEMP_MODE_NONE; }
double getAFBandwidth(double bandwidth) { return bandwidth; }
bool getDynamicAFBandwidth() { return true; }
bool getFMIFNRAllowed() { return false; }
dsp::stream<dsp::stereo_t>* getOutput() { return &m2s.out; }
private:

View File

@ -85,6 +85,7 @@ namespace demod {
int getDefaultDeemphasisMode() { return DEEMP_MODE_50US; }
double getAFBandwidth(double bandwidth) { return 16000.0; }
bool getDynamicAFBandwidth() { return false; }
bool getFMIFNRAllowed() { return true; }
dsp::stream<dsp::stereo_t>* getOutput() { return stereo ? demodStereo.out : &demod.out; }
// ============= DEDICATED FUNCTIONS =============

View File

@ -59,8 +59,10 @@ public:
ifChainOutputChanged.handler = ifChainOutputChangeHandler;
ifChain.init(vfo->output, &ifChainOutputChanged);
fmnr.block.init(NULL, 64);
squelch.block.init(NULL, MIN_SQUELCH);
ifChain.add(&fmnr);
ifChain.add(&squelch);
// Load configuration for and enabled all demodulators
@ -254,6 +256,13 @@ private:
}
if (!_this->squelchEnabled && _this->enabled) { style::endDisabled(); }
// FM IF Noise Reduction
if (_this->FMIFNRAllowed) {
if (ImGui::Checkbox("IF Noise Reduction##_radio_fmifnr_ena_", &_this->FMIFNREnabled)) {
_this->setFMIFNREnabled(_this->FMIFNREnabled);
}
}
// Demodulator specific menu
_this->selectedDemod->showMenu();
@ -300,7 +309,9 @@ private:
deempMode = DEEMP_MODE_NONE;
squelchEnabled = false;
postProcEnabled = selectedDemod->getPostProcEnabled();
if (config.conf[name][selectedDemod->getName()].contains("snapInterval")) {
FMIFNRAllowed = selectedDemod->getFMIFNRAllowed();
FMIFNREnabled = false;
if (config.conf[name][selectedDemod->getName()].contains("bandwidth")) {
bandwidth = config.conf[name][selectedDemod->getName()]["bandwidth"];
bandwidth = std::clamp<double>(bandwidth, minBandwidth, maxBandwidth);
}
@ -316,6 +327,9 @@ private:
if (config.conf[name][selectedDemod->getName()].contains("deempMode")) {
deempMode = config.conf[name][selectedDemod->getName()]["deempMode"];
}
if (config.conf[name][selectedDemod->getName()].contains("FMIFNREnabled")) {
FMIFNREnabled = config.conf[name][selectedDemod->getName()]["FMIFNREnabled"];
}
deempMode = std::clamp<int>(deempMode, 0, _DEEMP_MODE_COUNT-1);
// Configure VFO
@ -326,7 +340,10 @@ private:
vfo->setSampleRate(selectedDemod->getIFSampleRate(), bandwidth);
}
// Configure IF chain
// Configure FM IF Noise Reduction
setFMIFNREnabled(FMIFNRAllowed ? FMIFNREnabled : false);
// Configure squelch
squelch.block.setLevel(squelchLevel);
setSquelchEnabled(squelchEnabled);
@ -439,6 +456,17 @@ private:
config.release(true);
}
void setFMIFNREnabled(bool enabled) {
FMIFNREnabled = enabled;
if (!selectedDemod) { return; }
ifChain.setState(&fmnr, FMIFNREnabled);
// Save config
config.acquire();
config.conf[name][selectedDemod->getName()]["FMIFNREnabled"] = FMIFNREnabled;
config.release(true);
}
static void vfoUserChangedBandwidthHandler(double newBw, void* ctx) {
RadioModule* _this = (RadioModule*)ctx;
_this->setBandwidth(newBw);
@ -521,6 +549,7 @@ private:
// IF chain
dsp::Chain<dsp::complex_t> ifChain;
dsp::ChainLink<dsp::FMIFNoiseReduction, dsp::complex_t> fmnr;
dsp::ChainLink<dsp::Squelch, dsp::complex_t> squelch;
// Audio chain
@ -547,6 +576,8 @@ private:
int deempMode = DEEMP_MODE_NONE;
bool deempAllowed;
bool postProcEnabled;
bool FMIFNRAllowed;
bool FMIFNREnabled = false;
const double MIN_SQUELCH = -100.0;
const double MAX_SQUELCH = 0.0;