2021-12-04 04:49:51 +01:00
|
|
|
#pragma once
|
|
|
|
#include "../demod.h"
|
2022-06-15 16:08:28 +02:00
|
|
|
#include <dsp/demod/ssb.h>
|
|
|
|
#include <dsp/convert/mono_to_stereo.h>
|
2021-12-04 04:49:51 +01:00
|
|
|
|
|
|
|
namespace demod {
|
|
|
|
class USB : public Demodulator {
|
|
|
|
public:
|
|
|
|
USB() {}
|
2021-12-19 22:11:44 +01:00
|
|
|
|
2022-01-29 17:27:38 +01:00
|
|
|
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);
|
2021-12-04 04:49:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
~USB() {
|
|
|
|
stop();
|
|
|
|
}
|
|
|
|
|
2022-01-29 17:27:38 +01: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 04:49:51 +01:00
|
|
|
this->name = name;
|
|
|
|
|
|
|
|
// Define structure
|
2022-06-17 17:34:23 +02:00
|
|
|
demod.init(input, dsp::demod::SSB::Mode::USB, bandwidth, getIFSampleRate(), 24.0 / getIFSampleRate());
|
2022-06-15 16:08:28 +02:00
|
|
|
m2s.init(&demod.out);
|
2021-12-04 04:49:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void start() {
|
|
|
|
demod.start();
|
|
|
|
m2s.start();
|
|
|
|
}
|
|
|
|
|
|
|
|
void stop() {
|
|
|
|
demod.stop();
|
|
|
|
m2s.stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
void showMenu() {
|
|
|
|
// TODO: Adjust AGC settings
|
|
|
|
}
|
|
|
|
|
|
|
|
void setBandwidth(double bandwidth) {
|
2022-06-15 16:08:28 +02:00
|
|
|
demod.setBandwidth(bandwidth);
|
2021-12-04 04:49:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void setInput(dsp::stream<dsp::complex_t>* input) {
|
|
|
|
demod.setInput(input);
|
|
|
|
}
|
|
|
|
|
2021-12-04 17:46:48 +01:00
|
|
|
void AFSampRateChanged(double newSR) {}
|
|
|
|
|
2021-12-04 04:49:51 +01:00
|
|
|
// ============= INFO =============
|
|
|
|
|
2021-12-19 22:11:44 +01:00
|
|
|
const char* getName() { return "USB"; }
|
|
|
|
double getIFSampleRate() { return 24000.0; }
|
|
|
|
double getAFSampleRate() { return getIFSampleRate(); }
|
|
|
|
double getDefaultBandwidth() { return 2800.0; }
|
|
|
|
double getMinBandwidth() { return 500.0; }
|
|
|
|
double getMaxBandwidth() { return getIFSampleRate() / 2.0; }
|
|
|
|
bool getBandwidthLocked() { return false; }
|
|
|
|
double getMaxAFBandwidth() { return getIFSampleRate() / 2.0; }
|
|
|
|
double getDefaultSnapInterval() { return 100.0; }
|
|
|
|
int getVFOReference() { return ImGui::WaterfallVFO::REF_LOWER; }
|
|
|
|
bool getDeempAllowed() { return false; }
|
|
|
|
bool getPostProcEnabled() { return true; }
|
|
|
|
int getDefaultDeemphasisMode() { return DEEMP_MODE_NONE; }
|
2021-12-04 04:49:51 +01:00
|
|
|
double getAFBandwidth(double bandwidth) { return bandwidth; }
|
2021-12-19 22:11:44 +01:00
|
|
|
bool getDynamicAFBandwidth() { return true; }
|
|
|
|
bool getFMIFNRAllowed() { return false; }
|
|
|
|
bool getNBAllowed() { return true; }
|
2021-12-04 04:49:51 +01:00
|
|
|
dsp::stream<dsp::stereo_t>* getOutput() { return &m2s.out; }
|
|
|
|
|
|
|
|
private:
|
2022-06-15 16:08:28 +02:00
|
|
|
dsp::demod::SSB demod;
|
|
|
|
dsp::convert::MonoToStereo m2s;
|
2021-12-04 04:49:51 +01:00
|
|
|
|
|
|
|
std::string name;
|
|
|
|
};
|
|
|
|
}
|