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

76 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>
#include <dsp/convert/mono_to_stereo.h>
2021-12-04 03:49:51 +00:00
namespace demod {
class NFM : public Demodulator {
public:
NFM() {}
2022-01-29 16:27:38 +00:00
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);
2021-12-04 03:49:51 +00:00
}
~NFM() {
stop();
}
2022-01-29 16:27:38 +00:00
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) {
2021-12-04 03:49:51 +00:00
this->name = name;
// Define structure
2022-06-15 14:08:28 +00:00
demod.init(input, bandwidth / 2.0, getIFSampleRate());
m2s.init(&demod.out);
2021-12-04 03:49:51 +00:00
}
void start() {
demod.start();
2022-06-15 14:08:28 +00:00
m2s.start();
2021-12-04 03:49:51 +00:00
}
void stop() {
demod.stop();
2022-06-15 14:08:28 +00:00
m2s.stop();
2021-12-04 03:49:51 +00:00
}
void showMenu() {}
void setBandwidth(double bandwidth) {
2022-06-15 14:08:28 +00:00
demod.setDeviation(bandwidth / 2.0, getIFSampleRate());
2021-12-04 03:49:51 +00:00
}
void setInput(dsp::stream<dsp::complex_t>* input) {
demod.setInput(input);
}
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 getMaxAFBandwidth() { return getIFSampleRate() / 2.0; }
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; }
2021-12-04 03:49:51 +00:00
double getAFBandwidth(double bandwidth) { return bandwidth / 2.0; }
bool getDynamicAFBandwidth() { return true; }
bool getFMIFNRAllowed() { return true; }
bool getNBAllowed() { return false; }
2022-06-15 14:08:28 +00:00
dsp::stream<dsp::stereo_t>* getOutput() { return &m2s.out; }
2021-12-04 03:49:51 +00:00
private:
2022-06-15 14:08:28 +00:00
dsp::demod::FM demod;
dsp::convert::MonoToStereo m2s;
2021-12-04 03:49:51 +00:00
std::string name;
};
}