mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-02-03 09:44:26 -05:00
Worker thread demod spawn, abstract Modem
This commit is contained in:
parent
39c42c2b82
commit
31bf65259d
@ -82,6 +82,7 @@ class DemodulatorThreadPostIQData: public ReferenceCounter {
|
||||
public:
|
||||
std::vector<liquid_float_complex> data;
|
||||
long long sampleRate;
|
||||
std::string modemType;
|
||||
Modem *modem;
|
||||
ModemKit *modemKit;
|
||||
|
||||
|
@ -18,6 +18,7 @@ void DemodulatorWorkerThread::run() {
|
||||
|
||||
while (!terminated) {
|
||||
bool filterChanged = false;
|
||||
bool makeDemod = false;
|
||||
DemodulatorWorkerThreadCommand filterCommand;
|
||||
DemodulatorWorkerThreadCommand command;
|
||||
|
||||
@ -29,6 +30,10 @@ void DemodulatorWorkerThread::run() {
|
||||
filterChanged = true;
|
||||
filterCommand = command;
|
||||
break;
|
||||
case DemodulatorWorkerThreadCommand::DEMOD_WORKER_THREAD_CMD_MAKE_DEMOD:
|
||||
makeDemod = true;
|
||||
filterCommand = command;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -46,44 +51,16 @@ void DemodulatorWorkerThread::run() {
|
||||
result.iqResampler = msresamp_crcf_create(result.iqResampleRatio, As);
|
||||
}
|
||||
|
||||
if (makeDemod) {
|
||||
cModem = Modem::makeModem(filterCommand.demodType);
|
||||
}
|
||||
|
||||
if (filterCommand.bandwidth && filterCommand.audioSampleRate) {
|
||||
// result.audioResamplerRatio = (double) (filterCommand.audioSampleRate) / (double) filterCommand.bandwidth;
|
||||
// result.audioResampler = msresamp_rrrf_create(result.audioResamplerRatio, As);
|
||||
// result.stereoResampler = msresamp_rrrf_create(result.audioResamplerRatio, As);
|
||||
// result.audioSampleRate = filterCommand.audioSampleRate;
|
||||
|
||||
/* // Stereo filters / shifters
|
||||
double firStereoCutoff = ((double) 16000 / (double) filterCommand.audioSampleRate);
|
||||
float ft = ((double) 1000 / (double) filterCommand.audioSampleRate); // filter transition
|
||||
float mu = 0.0f; // fractional timing offset
|
||||
|
||||
if (firStereoCutoff < 0) {
|
||||
firStereoCutoff = 0;
|
||||
result.modem = cModem;
|
||||
if (cModem != nullptr) {
|
||||
cModemKit = cModem->buildKit(filterCommand.bandwidth, filterCommand.audioSampleRate);
|
||||
}
|
||||
|
||||
if (firStereoCutoff > 0.5) {
|
||||
firStereoCutoff = 0.5;
|
||||
}
|
||||
|
||||
unsigned int h_len = estimate_req_filter_len(ft, As);
|
||||
float *h = new float[h_len];
|
||||
liquid_firdes_kaiser(h_len, firStereoCutoff, As, mu, h);
|
||||
|
||||
result.firStereoLeft = firfilt_rrrf_create(h, h_len);
|
||||
result.firStereoRight = firfilt_rrrf_create(h, h_len);
|
||||
|
||||
float bw = filterCommand.bandwidth;
|
||||
if (bw < 100000.0) {
|
||||
bw = 100000.0;
|
||||
}
|
||||
// stereo pilot filter
|
||||
unsigned int order = 5; // filter order
|
||||
float f0 = ((double) 19000 / bw);
|
||||
float fc = ((double) 19500 / bw);
|
||||
float Ap = 1.0f;
|
||||
As = 60.0f;
|
||||
|
||||
result.iirStereoPilot = iirfilt_crcf_create_prototype(LIQUID_IIRDES_CHEBY2, LIQUID_IIRDES_BANDPASS, LIQUID_IIRDES_SOS, order, fc, f0, Ap, As); */
|
||||
result.modemKit = cModemKit;
|
||||
}
|
||||
|
||||
if (filterCommand.bandwidth) {
|
||||
|
@ -41,16 +41,16 @@ public:
|
||||
class DemodulatorWorkerThreadCommand {
|
||||
public:
|
||||
enum DemodulatorThreadCommandEnum {
|
||||
DEMOD_WORKER_THREAD_CMD_NULL, DEMOD_WORKER_THREAD_CMD_BUILD_FILTERS
|
||||
DEMOD_WORKER_THREAD_CMD_NULL, DEMOD_WORKER_THREAD_CMD_BUILD_FILTERS, DEMOD_WORKER_THREAD_CMD_MAKE_DEMOD
|
||||
};
|
||||
|
||||
DemodulatorWorkerThreadCommand() :
|
||||
cmd(DEMOD_WORKER_THREAD_CMD_NULL), frequency(0), sampleRate(0), bandwidth(0), audioSampleRate(0) {
|
||||
cmd(DEMOD_WORKER_THREAD_CMD_NULL), frequency(0), sampleRate(0), bandwidth(0), audioSampleRate(0), demodType("") {
|
||||
|
||||
}
|
||||
|
||||
DemodulatorWorkerThreadCommand(DemodulatorThreadCommandEnum cmd) :
|
||||
cmd(cmd), frequency(0), sampleRate(0), bandwidth(0), audioSampleRate(0) {
|
||||
cmd(cmd), frequency(0), sampleRate(0), bandwidth(0), audioSampleRate(0), demodType("") {
|
||||
|
||||
}
|
||||
|
||||
@ -60,6 +60,7 @@ public:
|
||||
long long sampleRate;
|
||||
unsigned int bandwidth;
|
||||
unsigned int audioSampleRate;
|
||||
std::string demodType;
|
||||
};
|
||||
|
||||
typedef ThreadQueue<DemodulatorWorkerThreadCommand> DemodulatorThreadWorkerCommandQueue;
|
||||
@ -87,4 +88,6 @@ protected:
|
||||
|
||||
DemodulatorThreadWorkerCommandQueue *commandQueue;
|
||||
DemodulatorThreadWorkerResultQueue *resultQueue;
|
||||
Modem *cModem;
|
||||
ModemKit *cModemKit;
|
||||
};
|
||||
|
@ -10,18 +10,10 @@ ModemFactoryList Modem::getFactories() {
|
||||
return modemFactories;
|
||||
}
|
||||
|
||||
Modem *Modem::factory() {
|
||||
Modem *Modem::makeModem(std::string modemType) {
|
||||
if (modemFactories.find(modemType) != modemFactories.end()) {
|
||||
return modemFactories[modemType]->factory();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ModemKit *Modem::buildKit(long long sampleRate, int audioSampleRate) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Modem::disposeKit(ModemKit *kit) {
|
||||
return;
|
||||
}
|
||||
|
||||
void Modem::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) {
|
||||
return;
|
||||
}
|
||||
|
@ -36,12 +36,13 @@ class Modem {
|
||||
public:
|
||||
static void addModemFactory(std::string modemName, Modem *factorySingle);
|
||||
static ModemFactoryList getFactories();
|
||||
static Modem *makeModem(std::string modemType);
|
||||
|
||||
virtual Modem *factory();
|
||||
virtual Modem *factory() = 0;
|
||||
|
||||
virtual ModemKit *buildKit(long long sampleRate, int audioSampleRate);
|
||||
virtual void disposeKit(ModemKit *kit);
|
||||
virtual void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut);
|
||||
virtual ModemKit *buildKit(long long sampleRate, int audioSampleRate) = 0;
|
||||
virtual void disposeKit(ModemKit *kit) = 0;
|
||||
virtual void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) = 0;
|
||||
private:
|
||||
static ModemFactoryList modemFactories;
|
||||
};
|
Loading…
Reference in New Issue
Block a user