#pragma once #include "../demod.h" #include namespace demod { class WFM : public Demodulator { public: WFM() {} WFM(std::string name, ConfigManager* config, dsp::stream* input, double bandwidth, EventHandler*> outputChangeHandler, EventHandler afbwChangeHandler, double audioSR) { init(name, config, input, bandwidth, outputChangeHandler, afbwChangeHandler, audioSR); } ~WFM() { stop(); } void init(std::string name, ConfigManager* config, dsp::stream* input, double bandwidth, EventHandler*> outputChangeHandler, EventHandler afbwChangeHandler, double audioSR) { this->name = name; this->outputChangeHandler = outputChangeHandler; _config = config; // Load config _config->acquire(); bool modified = false; if (config->conf[name][getName()].contains("stereo")) { _stereo = config->conf[name][getName()]["stereo"]; } if (config->conf[name][getName()].contains("lowPass")) { _lowPass = config->conf[name][getName()]["lowPass"]; } _config->release(modified); // Define structure demod.init(input, bandwidth / 2.0f, getIFSampleRate(), _stereo, _lowPass); } void start() { demod.start(); } void stop() { demod.stop(); } void showMenu() { if (ImGui::Checkbox(("Stereo##_radio_wfm_stereo_" + name).c_str(), &_stereo)) { setStereo(_stereo); _config->acquire(); _config->conf[name][getName()]["stereo"] = _stereo; _config->release(true); } 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) { demod.setDeviation(bandwidth / 2.0f); } void setInput(dsp::stream* input) { demod.setInput(input); } void AFSampRateChanged(double newSR) {} // ============= INFO ============= const char* getName() { return "WFM"; } double getIFSampleRate() { return 250000.0; } double getAFSampleRate() { return getIFSampleRate(); } double getDefaultBandwidth() { return 150000.0; } double getMinBandwidth() { return 50000.0; } double getMaxBandwidth() { return getIFSampleRate(); } bool getBandwidthLocked() { return false; } double getMaxAFBandwidth() { return 16000.0; } double getDefaultSnapInterval() { return 100000.0; } int getVFOReference() { return ImGui::WaterfallVFO::REF_CENTER; } bool getDeempAllowed() { return true; } bool getPostProcEnabled() { return true; } int getDefaultDeemphasisMode() { return DEEMP_MODE_50US; } double getAFBandwidth(double bandwidth) { return 16000.0; } bool getDynamicAFBandwidth() { return false; } bool getFMIFNRAllowed() { return true; } bool getNBAllowed() { return false; } dsp::stream* getOutput() { return &demod.out; } // ============= DEDICATED FUNCTIONS ============= void setStereo(bool stereo) { _stereo = stereo; demod.setStereo(_stereo); } private: dsp::demod::BroadcastFM demod; ConfigManager* _config = NULL; bool _stereo = false; bool _lowPass = true; std::string name; EventHandler*> outputChangeHandler; }; }