SDRPlusPlus/decoder_modules/radio/src/demodulators/nfm.h

81 wiersze
2.6 KiB
C
Czysty Zwykły widok Historia

2021-12-04 03:49:51 +00:00
#pragma once
#include "../demod.h"
2022-06-15 14:08:28 +00:00
#include <dsp/demod/fm.h>
2021-12-04 03:49:51 +00:00
namespace demod {
class NFM : public Demodulator {
public:
NFM() {}
2022-06-21 17:54:03 +00:00
NFM(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, double audioSR) {
init(name, config, input, bandwidth, audioSR);
2021-12-04 03:49:51 +00:00
}
2022-06-21 15:24:48 +00:00
~NFM() { stop(); }
2021-12-04 03:49:51 +00:00
2022-06-21 17:54:03 +00:00
void init(std::string name, ConfigManager* config, dsp::stream<dsp::complex_t>* input, double bandwidth, double audioSR) {
2021-12-04 03:49:51 +00:00
this->name = name;
this->_config = config;
// Load config
_config->acquire();
bool modified = false;
if (config->conf[name][getName()].contains("lowPass")) {
_lowPass = config->conf[name][getName()]["lowPass"];
}
_config->release(modified);
2021-12-04 03:49:51 +00:00
// Define structure
2022-06-21 15:24:48 +00:00
demod.init(input, getIFSampleRate(), bandwidth, _lowPass);
2021-12-04 03:49:51 +00:00
}
2022-06-21 15:24:48 +00:00
void start() { demod.start(); }
2021-12-04 03:49:51 +00:00
2022-06-21 15:24:48 +00:00
void stop() { demod.stop(); }
2021-12-04 03:49:51 +00:00
2022-06-21 15:24:48 +00:00
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);
2022-06-21 15:24:48 +00:00
}
}
2021-12-04 03:49:51 +00:00
void setBandwidth(double bandwidth) {
2022-06-21 15:24:48 +00:00
demod.setBandwidth(bandwidth);
2021-12-04 03:49:51 +00:00
}
2022-06-21 15:24:48 +00:00
void setInput(dsp::stream<dsp::complex_t>* input) { demod.setInput(input); }
2021-12-04 03:49:51 +00:00
2021-12-04 16:46:48 +00:00
void AFSampRateChanged(double newSR) {}
2021-12-04 03:49:51 +00:00
// ============= INFO =============
const char* getName() { return "FM"; }
double getIFSampleRate() { return 50000.0; }
double getAFSampleRate() { return getIFSampleRate(); }
double getDefaultBandwidth() { return 12500.0; }
double getMinBandwidth() { return 1000.0; }
double getMaxBandwidth() { return getIFSampleRate(); }
bool getBandwidthLocked() { return false; }
double getDefaultSnapInterval() { return 2500.0; }
int getVFOReference() { return ImGui::WaterfallVFO::REF_CENTER; }
bool getDeempAllowed() { return true; }
bool getPostProcEnabled() { return true; }
int getDefaultDeemphasisMode() { return DEEMP_MODE_NONE; }
bool getFMIFNRAllowed() { return true; }
bool getNBAllowed() { return false; }
2022-06-21 15:24:48 +00:00
dsp::stream<dsp::stereo_t>* getOutput() { return &demod.out; }
2021-12-04 03:49:51 +00:00
private:
2022-06-21 15:24:48 +00:00
dsp::demod::FM<dsp::stereo_t> demod;
ConfigManager* _config = NULL;
2022-06-21 15:24:48 +00:00
bool _lowPass = true;
2021-12-04 03:49:51 +00:00
std::string name;
};
}