Add software
This commit is contained in:
50
Software/CubicSDR/src/modules/modem/analog/ModemAM.cpp
Normal file
50
Software/CubicSDR/src/modules/modem/analog/ModemAM.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
// Copyright (c) Charles J. Cliffe
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#include "ModemAM.h"
|
||||
|
||||
ModemAM::ModemAM() : ModemAnalog() {
|
||||
// Create a DC blocker using 25 samples wide window
|
||||
// and 30dB reduction of the DC level.
|
||||
mDCBlock = firfilt_rrrf_create_dc_blocker (25,30.0f);
|
||||
useSignalOutput(true);
|
||||
}
|
||||
|
||||
ModemAM::~ModemAM() {
|
||||
firfilt_rrrf_destroy(mDCBlock);
|
||||
}
|
||||
|
||||
ModemBase *ModemAM::factory() {
|
||||
return new ModemAM;
|
||||
}
|
||||
|
||||
std::string ModemAM::getName() {
|
||||
return "AM";
|
||||
}
|
||||
|
||||
int ModemAM::getDefaultSampleRate() {
|
||||
return 6000;
|
||||
}
|
||||
|
||||
void ModemAM::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput* audioOut) {
|
||||
auto *amkit = (ModemKitAnalog *)kit;
|
||||
|
||||
initOutputBuffers(amkit,input);
|
||||
|
||||
if (!bufSize) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Implement an AM demodulator. Compute signal
|
||||
// amplitude followed by a DC blocker to remove
|
||||
// the DC offset.
|
||||
for (size_t i = 0; i < bufSize; i++) {
|
||||
float I = input->data[i].real;
|
||||
float Q = input->data[i].imag;
|
||||
firfilt_rrrf_push (mDCBlock,sqrt(I*I+Q*Q));
|
||||
firfilt_rrrf_execute (mDCBlock,&demodOutputData[i]);
|
||||
}
|
||||
|
||||
buildAudioOutput(amkit,audioOut,true);
|
||||
}
|
23
Software/CubicSDR/src/modules/modem/analog/ModemAM.h
Normal file
23
Software/CubicSDR/src/modules/modem/analog/ModemAM.h
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (c) Charles J. Cliffe
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#pragma once
|
||||
#include "Modem.h"
|
||||
#include "ModemAnalog.h"
|
||||
|
||||
class ModemAM : public ModemAnalog {
|
||||
public:
|
||||
ModemAM();
|
||||
~ModemAM() override;
|
||||
|
||||
std::string getName() override;
|
||||
|
||||
static ModemBase *factory();
|
||||
|
||||
int getDefaultSampleRate() override;
|
||||
|
||||
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
|
||||
|
||||
private:
|
||||
firfilt_rrrf mDCBlock;
|
||||
};
|
209
Software/CubicSDR/src/modules/modem/analog/ModemCW.cpp
Normal file
209
Software/CubicSDR/src/modules/modem/analog/ModemCW.cpp
Normal file
@ -0,0 +1,209 @@
|
||||
// Copyright (c) Charles J. Cliffe
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#include "ModemCW.h"
|
||||
|
||||
// We are given a baseband segment BW (default 500Hz) wide which we want to
|
||||
// offset by mBeepFrequency (default 650Hz). This yields a spectrum.
|
||||
//
|
||||
// | |....|....|
|
||||
// | |....|....|
|
||||
// | |....|....|
|
||||
// -----------|---|----|----|--
|
||||
// 0 150 650 1150
|
||||
//
|
||||
ModemCW::ModemCW()
|
||||
: ModemAnalog(),
|
||||
mBeepFrequency(650.0),
|
||||
mGain(15.0),
|
||||
mAutoGain(true),
|
||||
mLO(nullptr),
|
||||
mToReal(nullptr) {
|
||||
mLO = nco_crcf_create(LIQUID_NCO);
|
||||
mToReal = firhilbf_create(5, 60.0f);
|
||||
useSignalOutput(true);
|
||||
}
|
||||
|
||||
ModemCW::~ModemCW() {
|
||||
if (mLO)
|
||||
nco_crcf_destroy(mLO);
|
||||
if (mToReal)
|
||||
firhilbf_destroy(mToReal);
|
||||
}
|
||||
|
||||
ModemArgInfoList ModemCW::getSettings() {
|
||||
ModemArgInfoList args;
|
||||
|
||||
ModemArgInfo offsetArg;
|
||||
offsetArg.key = "offset";
|
||||
offsetArg.name = "Frequency Offset";
|
||||
offsetArg.value = std::to_string(mBeepFrequency);
|
||||
offsetArg.units = "Hz";
|
||||
offsetArg.description = "Frequency Offset / Beep frequency (200-1000Hz)";
|
||||
offsetArg.type = ModemArgInfo::Type::FLOAT;
|
||||
offsetArg.range = ModemRange(200.0, 1000.0);
|
||||
args.push_back(offsetArg);
|
||||
|
||||
ModemArgInfo autoGain;
|
||||
autoGain.key = "auto";
|
||||
autoGain.name = "Auto Gain";
|
||||
autoGain.value = "on";
|
||||
autoGain.type = ModemArgInfo::Type::STRING;
|
||||
std::vector<std::string> autoOpts;
|
||||
autoOpts.push_back("on");
|
||||
autoOpts.push_back("off");
|
||||
autoGain.optionNames = autoOpts;
|
||||
autoGain.options = autoOpts;
|
||||
args.push_back(autoGain);
|
||||
|
||||
ModemArgInfo gain;
|
||||
gain.key = "gain";
|
||||
gain.name = "Audio Gain";
|
||||
gain.value = "15";
|
||||
gain.units = "dB";
|
||||
gain.description = "Gain Setting (0-40dB)";
|
||||
gain.range = ModemRange(0.0, 40.0);
|
||||
gain.type = ModemArgInfo::Type::FLOAT;
|
||||
args.push_back(gain);
|
||||
return args;
|
||||
}
|
||||
|
||||
void ModemCW::writeSetting(std::string setting, std::string value) {
|
||||
if (setting == "offset") {
|
||||
mBeepFrequency = std::stof(value);
|
||||
rebuildKit();
|
||||
} else if (setting == "auto") {
|
||||
mAutoGain = (value == "on");
|
||||
} else if (setting == "gain") {
|
||||
mGain = std::stof(value);
|
||||
}
|
||||
}
|
||||
|
||||
std::string ModemCW::readSetting(std::string setting) {
|
||||
if (setting == "offset") {
|
||||
return std::to_string(mBeepFrequency);
|
||||
} else if (setting == "auto") {
|
||||
return (mAutoGain) ? "on" : "off";
|
||||
} else if (setting == "gain") {
|
||||
return std::to_string(mGain);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
ModemBase *ModemCW::factory() {
|
||||
return new ModemCW;
|
||||
}
|
||||
|
||||
std::string ModemCW::getName() {
|
||||
return "CW";
|
||||
}
|
||||
|
||||
int ModemCW::checkSampleRate(long long srate, int /* arate */) {
|
||||
if (srate < MIN_BANDWIDTH)
|
||||
return MIN_BANDWIDTH;
|
||||
return (int)srate;
|
||||
}
|
||||
|
||||
int ModemCW::getDefaultSampleRate() {
|
||||
return MIN_BANDWIDTH;
|
||||
}
|
||||
|
||||
// The modem object is asked to make a "ModemKit" given the IQ sample rate
|
||||
// and the audio sample rate. For the CW modem the IQ sample rate is small
|
||||
// or narrow bandwidth. The demodulated sample rate must be fast enough to
|
||||
// sample 200-1000Hz tones. If the IQ sample rate is less than 2000Hz then
|
||||
// one doesn't have the bandwidth for these tones. So we need to interpolate
|
||||
// the input IQ to audioOut, frequency shift, then pass the real part.
|
||||
// Simple solution is just interpolate the IQ data to the audio sample rate.
|
||||
ModemKit *ModemCW::buildKit(long long sampleRate, int audioSampleRate) {
|
||||
auto *kit = new ModemKitCW();
|
||||
float As = 60.0f;
|
||||
double ratio = double(audioSampleRate) / double(sampleRate);
|
||||
kit->sampleRate = sampleRate;
|
||||
kit->audioSampleRate = audioSampleRate;
|
||||
kit->audioResampleRatio = ratio;
|
||||
kit->mInputResampler = msresamp_cccf_create((float)ratio, As);
|
||||
return kit;
|
||||
}
|
||||
|
||||
void ModemCW::disposeKit(ModemKit *kit) {
|
||||
auto *cwkit = (ModemKitCW *) kit;
|
||||
msresamp_cccf_destroy(cwkit->mInputResampler);
|
||||
delete kit;
|
||||
}
|
||||
|
||||
void ModemCW::initOutputBuffers(ModemKitAnalog *akit, ModemIQData *input) {
|
||||
bufSize = input->data.size();
|
||||
|
||||
if (!bufSize) {
|
||||
return;
|
||||
}
|
||||
|
||||
double audio_resample_ratio = akit->audioResampleRatio;
|
||||
|
||||
size_t audio_out_size = (size_t) ceil((double) (bufSize) * audio_resample_ratio) + 512;
|
||||
|
||||
// Just make everything the audio out size
|
||||
if (mInput.size() != audio_out_size) {
|
||||
if (mInput.capacity() < audio_out_size) {
|
||||
mInput.reserve(audio_out_size);
|
||||
}
|
||||
mInput.resize(audio_out_size);
|
||||
}
|
||||
}
|
||||
|
||||
void ModemCW::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) {
|
||||
unsigned int outSize;
|
||||
float lsb;
|
||||
liquid_float_complex sig;
|
||||
auto *cwkit = (ModemKitCW *) kit;
|
||||
|
||||
initOutputBuffers(cwkit, input);
|
||||
|
||||
if (!bufSize) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Interpolate IQ samples to full audio band. We need to be able to
|
||||
// sample at 2 times the desired beep frequency.
|
||||
msresamp_cccf_execute(cwkit->mInputResampler, &input->data[0], (unsigned int)bufSize, &mInput[0], &outSize);
|
||||
|
||||
// Make the shoe fit.
|
||||
if (demodOutputData.size() != outSize) {
|
||||
demodOutputData.resize(outSize);
|
||||
}
|
||||
|
||||
// Set the LO to the desired beep frequency.
|
||||
nco_crcf_set_frequency(mLO, 2.0f * (float)M_PI * mBeepFrequency / kit->audioSampleRate);
|
||||
|
||||
// Mix up from base band by beep frequency. Extract real part
|
||||
for (unsigned int i = 0; i < outSize; i++) {
|
||||
nco_crcf_mix_up(mLO, mInput[i], &sig);
|
||||
nco_crcf_step(mLO);
|
||||
firhilbf_c2r_execute(mToReal, sig, &lsb, &demodOutputData[i]);
|
||||
}
|
||||
|
||||
// Determine gain automagically (if desired)
|
||||
if (mAutoGain) {
|
||||
aOutputCeilMA = aOutputCeilMA + (aOutputCeil - aOutputCeilMA) * 0.025f;
|
||||
aOutputCeilMAA = aOutputCeilMAA + (aOutputCeilMA - aOutputCeilMAA) * 0.025f;
|
||||
aOutputCeil = 0;
|
||||
|
||||
for (size_t i = 0; i < outSize; i++) {
|
||||
if (demodOutputData[i] > aOutputCeil) {
|
||||
aOutputCeil = demodOutputData[i];
|
||||
}
|
||||
}
|
||||
|
||||
mGain = 10.0f * std::log10(0.5f / aOutputCeilMAA);
|
||||
}
|
||||
|
||||
// Apply gain to demodulated output data
|
||||
for (size_t i = 0; i < outSize; i++) {
|
||||
demodOutputData[i] *= std::pow(10.0f, mGain / 10.0f);
|
||||
}
|
||||
|
||||
audioOut->channels = 1;
|
||||
audioOut->sampleRate = cwkit->audioSampleRate;
|
||||
audioOut->data.assign(demodOutputData.begin(), demodOutputData.end());
|
||||
}
|
54
Software/CubicSDR/src/modules/modem/analog/ModemCW.h
Normal file
54
Software/CubicSDR/src/modules/modem/analog/ModemCW.h
Normal file
@ -0,0 +1,54 @@
|
||||
// Copyright (c) Charles J. Cliffe
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Modem.h"
|
||||
#include "ModemAnalog.h"
|
||||
|
||||
class ModemKitCW : public ModemKitAnalog {
|
||||
public:
|
||||
ModemKitCW() : ModemKitAnalog() {
|
||||
};
|
||||
msresamp_cccf mInputResampler{};
|
||||
};
|
||||
|
||||
class ModemCW : public ModemAnalog {
|
||||
public:
|
||||
ModemCW();
|
||||
|
||||
~ModemCW() override;
|
||||
|
||||
std::string getName() override;
|
||||
|
||||
static ModemBase *factory();
|
||||
|
||||
int checkSampleRate(long long srate, int arate) override;
|
||||
|
||||
ModemKit *buildKit(long long srate, int arate) override;
|
||||
|
||||
void disposeKit(ModemKit *kit) override;
|
||||
|
||||
void initOutputBuffers(ModemKitAnalog *akit, ModemIQData *input) override;
|
||||
|
||||
int getDefaultSampleRate() override;
|
||||
|
||||
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
|
||||
|
||||
ModemArgInfoList getSettings() override;
|
||||
|
||||
void writeSetting(std::string setting, std::string value) override;
|
||||
|
||||
std::string readSetting(std::string setting) override;
|
||||
|
||||
// No resampling required.
|
||||
std::vector<float> *getResampledOutputData() override { return &demodOutputData; }
|
||||
|
||||
private:
|
||||
float mBeepFrequency;
|
||||
float mGain;
|
||||
bool mAutoGain;
|
||||
nco_crcf mLO;
|
||||
firhilbf mToReal;
|
||||
std::vector<liquid_float_complex> mInput;
|
||||
};
|
42
Software/CubicSDR/src/modules/modem/analog/ModemDSB.cpp
Normal file
42
Software/CubicSDR/src/modules/modem/analog/ModemDSB.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
// Copyright (c) Charles J. Cliffe
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#include "ModemDSB.h"
|
||||
|
||||
ModemDSB::ModemDSB() : ModemAnalog() {
|
||||
demodAM_DSB = ampmodem_create(0.5, LIQUID_AMPMODEM_DSB, 1);
|
||||
useSignalOutput(true);
|
||||
}
|
||||
|
||||
ModemDSB::~ModemDSB() {
|
||||
ampmodem_destroy(demodAM_DSB);
|
||||
}
|
||||
|
||||
ModemBase *ModemDSB::factory() {
|
||||
return new ModemDSB;
|
||||
}
|
||||
|
||||
std::string ModemDSB::getName() {
|
||||
return "DSB";
|
||||
}
|
||||
|
||||
int ModemDSB::getDefaultSampleRate() {
|
||||
return 5400;
|
||||
}
|
||||
|
||||
void ModemDSB::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) {
|
||||
auto *amkit = (ModemKitAnalog *)kit;
|
||||
|
||||
initOutputBuffers(amkit, input);
|
||||
|
||||
if (!bufSize) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < bufSize; i++) {
|
||||
ampmodem_demodulate(demodAM_DSB, input->data[i], &demodOutputData[i]);
|
||||
}
|
||||
|
||||
buildAudioOutput(amkit, audioOut, true);
|
||||
}
|
23
Software/CubicSDR/src/modules/modem/analog/ModemDSB.h
Normal file
23
Software/CubicSDR/src/modules/modem/analog/ModemDSB.h
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (c) Charles J. Cliffe
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#pragma once
|
||||
#include "Modem.h"
|
||||
#include "ModemAnalog.h"
|
||||
|
||||
class ModemDSB : public ModemAnalog {
|
||||
public:
|
||||
ModemDSB();
|
||||
~ModemDSB() override;
|
||||
|
||||
std::string getName() override;
|
||||
|
||||
static ModemBase *factory();
|
||||
|
||||
int getDefaultSampleRate() override;
|
||||
|
||||
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
|
||||
|
||||
private:
|
||||
ampmodem demodAM_DSB;
|
||||
};
|
39
Software/CubicSDR/src/modules/modem/analog/ModemFM.cpp
Normal file
39
Software/CubicSDR/src/modules/modem/analog/ModemFM.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
// Copyright (c) Charles J. Cliffe
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#include "ModemFM.h"
|
||||
|
||||
ModemFM::ModemFM() : ModemAnalog() {
|
||||
demodFM = freqdem_create(0.5);
|
||||
}
|
||||
|
||||
ModemFM::~ModemFM() {
|
||||
freqdem_destroy(demodFM);
|
||||
}
|
||||
|
||||
ModemBase *ModemFM::factory() {
|
||||
return new ModemFM;
|
||||
}
|
||||
|
||||
std::string ModemFM::getName() {
|
||||
return "FM";
|
||||
}
|
||||
|
||||
int ModemFM::getDefaultSampleRate() {
|
||||
return 200000;
|
||||
}
|
||||
|
||||
void ModemFM::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) {
|
||||
auto *fmkit = (ModemKitAnalog *)kit;
|
||||
|
||||
initOutputBuffers(fmkit, input);
|
||||
|
||||
if (!bufSize) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
freqdem_demodulate_block(demodFM, &input->data[0], (int)bufSize, &demodOutputData[0]);
|
||||
|
||||
buildAudioOutput(fmkit, audioOut, false);
|
||||
}
|
23
Software/CubicSDR/src/modules/modem/analog/ModemFM.h
Normal file
23
Software/CubicSDR/src/modules/modem/analog/ModemFM.h
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (c) Charles J. Cliffe
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#pragma once
|
||||
#include "Modem.h"
|
||||
#include "ModemAnalog.h"
|
||||
|
||||
class ModemFM : public ModemAnalog {
|
||||
public:
|
||||
ModemFM();
|
||||
~ModemFM() override;
|
||||
|
||||
std::string getName() override;
|
||||
|
||||
static ModemBase *factory();
|
||||
|
||||
int getDefaultSampleRate() override;
|
||||
|
||||
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
|
||||
|
||||
private:
|
||||
freqdem demodFM;
|
||||
};
|
287
Software/CubicSDR/src/modules/modem/analog/ModemFMStereo.cpp
Normal file
287
Software/CubicSDR/src/modules/modem/analog/ModemFMStereo.cpp
Normal file
@ -0,0 +1,287 @@
|
||||
// Copyright (c) Charles J. Cliffe
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#include "ModemFMStereo.h"
|
||||
|
||||
ModemFMStereo::ModemFMStereo() {
|
||||
demodFM = freqdem_create(0.5);
|
||||
_demph = 75;
|
||||
}
|
||||
|
||||
ModemFMStereo::~ModemFMStereo() {
|
||||
freqdem_destroy(demodFM);
|
||||
}
|
||||
|
||||
std::string ModemFMStereo::getType() {
|
||||
return "analog";
|
||||
}
|
||||
|
||||
std::string ModemFMStereo::getName() {
|
||||
return "FMS";
|
||||
}
|
||||
|
||||
ModemBase *ModemFMStereo::factory() {
|
||||
return new ModemFMStereo;
|
||||
}
|
||||
|
||||
int ModemFMStereo::checkSampleRate(long long sampleRate, int /* audioSampleRate */) {
|
||||
if (sampleRate < 100000) {
|
||||
return 100000;
|
||||
} else if (sampleRate < 1500) {
|
||||
return 1500;
|
||||
} else {
|
||||
return (int)sampleRate;
|
||||
}
|
||||
}
|
||||
|
||||
int ModemFMStereo::getDefaultSampleRate() {
|
||||
return 200000;
|
||||
}
|
||||
|
||||
ModemArgInfoList ModemFMStereo::getSettings() {
|
||||
ModemArgInfoList args;
|
||||
|
||||
ModemArgInfo demphArg;
|
||||
demphArg.key = "demph";
|
||||
demphArg.name = "De-emphasis";
|
||||
demphArg.value = std::to_string(_demph);
|
||||
demphArg.description = "FM Stereo De-Emphasis, typically 75us in US/Canada, 50us elsewhere.";
|
||||
|
||||
demphArg.type = ModemArgInfo::Type::STRING;
|
||||
|
||||
std::vector<std::string> demphOptNames;
|
||||
demphOptNames.push_back("None");
|
||||
demphOptNames.push_back("10us");
|
||||
demphOptNames.push_back("25us");
|
||||
demphOptNames.push_back("32us");
|
||||
demphOptNames.push_back("50us");
|
||||
demphOptNames.push_back("75us");
|
||||
demphArg.optionNames = demphOptNames;
|
||||
|
||||
std::vector<std::string> demphOpts;
|
||||
demphOpts.push_back("0");
|
||||
demphOpts.push_back("10");
|
||||
demphOpts.push_back("25");
|
||||
demphOpts.push_back("32");
|
||||
demphOpts.push_back("50");
|
||||
demphOpts.push_back("75");
|
||||
demphArg.options = demphOpts;
|
||||
|
||||
args.push_back(demphArg);
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
void ModemFMStereo::writeSetting(std::string setting, std::string value) {
|
||||
if (setting == "demph") {
|
||||
_demph = std::stoi(value);
|
||||
rebuildKit();
|
||||
}
|
||||
}
|
||||
|
||||
std::string ModemFMStereo::readSetting(std::string setting) {
|
||||
if (setting == "demph") {
|
||||
return std::to_string(_demph);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
ModemKit *ModemFMStereo::buildKit(long long sampleRate, int audioSampleRate) {
|
||||
auto *kit = new ModemKitFMStereo;
|
||||
|
||||
kit->audioResampleRatio = double(audioSampleRate) / double(sampleRate);
|
||||
kit->sampleRate = sampleRate;
|
||||
kit->audioSampleRate = audioSampleRate;
|
||||
|
||||
float As = 60.0f; // stop-band attenuation [dB]
|
||||
|
||||
kit->audioResampler = msresamp_rrrf_create((float)kit->audioResampleRatio, As);
|
||||
kit->stereoResampler = msresamp_rrrf_create((float)kit->audioResampleRatio, As);
|
||||
|
||||
// Stereo filters / shifters
|
||||
float firStereoCutoff = 16000.0f / float(audioSampleRate);
|
||||
// filter transition
|
||||
float ft = 1000.0f / float(audioSampleRate);
|
||||
// fractional timing offset
|
||||
float mu = 0.0f;
|
||||
|
||||
if (firStereoCutoff < 0) {
|
||||
firStereoCutoff = 0;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
kit->firStereoLeft = firfilt_rrrf_create(h, h_len);
|
||||
kit->firStereoRight = firfilt_rrrf_create(h, h_len);
|
||||
|
||||
// stereo pilot filter
|
||||
float bw = float(sampleRate);
|
||||
if (bw < 100000.0) {
|
||||
bw = 100000.0;
|
||||
}
|
||||
unsigned int order = 5; // filter order
|
||||
float f0 = ((float) 19000 / bw);
|
||||
float fc = ((float) 19500 / bw);
|
||||
float Ap = 1.0f;
|
||||
|
||||
kit->iirStereoPilot = iirfilt_crcf_create_prototype(LIQUID_IIRDES_CHEBY2, LIQUID_IIRDES_BANDPASS, LIQUID_IIRDES_SOS, order, fc, f0, Ap, As);
|
||||
|
||||
kit->firStereoR2C = firhilbf_create(5, 60.0f);
|
||||
kit->firStereoC2R = firhilbf_create(5, 60.0f);
|
||||
|
||||
kit->stereoPilot = nco_crcf_create(LIQUID_VCO);
|
||||
nco_crcf_reset(kit->stereoPilot);
|
||||
nco_crcf_pll_set_bandwidth(kit->stereoPilot, 0.25f);
|
||||
|
||||
kit->demph = _demph;
|
||||
|
||||
if (_demph) {
|
||||
double f = (1.0 / (2.0 * M_PI * double(_demph) * 1e-6));
|
||||
double t = 1.0 / (2.0 * M_PI * f);
|
||||
t = 1.0 / (2.0 * double(audioSampleRate) * tan(1.0 / (2.0 * double(audioSampleRate) * t)));
|
||||
|
||||
double tb = (1.0 + 2.0 * t * double(audioSampleRate));
|
||||
float b_demph[2] = { (float)(1.0 / tb), (float)(1.0 / tb) };
|
||||
float a_demph[2] = { 1.0, (float)((1.0 - 2.0 * t * double(audioSampleRate)) / tb) };
|
||||
|
||||
kit->iirDemphL = iirfilt_rrrf_create(b_demph, 2, a_demph, 2);
|
||||
kit->iirDemphR = iirfilt_rrrf_create(b_demph, 2, a_demph, 2);
|
||||
} else {
|
||||
kit->iirDemphL = nullptr;
|
||||
kit->iirDemphR = nullptr;
|
||||
kit->demph = 0;
|
||||
}
|
||||
return kit;
|
||||
}
|
||||
|
||||
void ModemFMStereo::disposeKit(ModemKit *kit) {
|
||||
auto *fmkit = (ModemKitFMStereo *)kit;
|
||||
|
||||
msresamp_rrrf_destroy(fmkit->audioResampler);
|
||||
msresamp_rrrf_destroy(fmkit->stereoResampler);
|
||||
firfilt_rrrf_destroy(fmkit->firStereoLeft);
|
||||
firfilt_rrrf_destroy(fmkit->firStereoRight);
|
||||
firhilbf_destroy(fmkit->firStereoR2C);
|
||||
firhilbf_destroy(fmkit->firStereoC2R);
|
||||
nco_crcf_destroy(fmkit->stereoPilot);
|
||||
if (fmkit->iirDemphR) { iirfilt_rrrf_destroy(fmkit->iirDemphR); }
|
||||
if (fmkit->iirDemphL) { iirfilt_rrrf_destroy(fmkit->iirDemphL); }
|
||||
}
|
||||
|
||||
|
||||
void ModemFMStereo::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) {
|
||||
auto *fmkit = (ModemKitFMStereo *)kit;
|
||||
size_t bufSize = input->data.size();
|
||||
liquid_float_complex u, v, w, x, y;
|
||||
|
||||
double audio_resample_ratio = fmkit->audioResampleRatio;
|
||||
|
||||
if (demodOutputData.size() != bufSize) {
|
||||
if (demodOutputData.capacity() < bufSize) {
|
||||
demodOutputData.reserve(bufSize);
|
||||
}
|
||||
demodOutputData.resize(bufSize);
|
||||
}
|
||||
|
||||
size_t audio_out_size = (size_t)ceil((double) (bufSize) * audio_resample_ratio) + 512;
|
||||
|
||||
freqdem_demodulate_block(demodFM, &input->data[0], (int)bufSize, &demodOutputData[0]);
|
||||
|
||||
if (resampledOutputData.size() != audio_out_size) {
|
||||
if (resampledOutputData.capacity() < audio_out_size) {
|
||||
resampledOutputData.reserve(audio_out_size);
|
||||
}
|
||||
resampledOutputData.resize(audio_out_size);
|
||||
}
|
||||
|
||||
unsigned int numAudioWritten;
|
||||
|
||||
msresamp_rrrf_execute(fmkit->audioResampler, &demodOutputData[0], (int)bufSize, &resampledOutputData[0], &numAudioWritten);
|
||||
|
||||
if (demodStereoData.size() != bufSize) {
|
||||
if (demodStereoData.capacity() < bufSize) {
|
||||
demodStereoData.reserve(bufSize);
|
||||
}
|
||||
demodStereoData.resize(bufSize);
|
||||
}
|
||||
|
||||
float phase_error = 0;
|
||||
|
||||
for (size_t i = 0; i < bufSize; i++) {
|
||||
// real -> complex
|
||||
firhilbf_r2c_execute(fmkit->firStereoR2C, demodOutputData[i], &x);
|
||||
|
||||
// 19khz pilot band-pass
|
||||
iirfilt_crcf_execute(fmkit->iirStereoPilot, x, &v);
|
||||
nco_crcf_cexpf(fmkit->stereoPilot, &w);
|
||||
|
||||
w.imag = -w.imag; // conjf(w)
|
||||
|
||||
// multiply u = v * conjf(w)
|
||||
u.real = v.real * w.real - v.imag * w.imag;
|
||||
u.imag = v.real * w.imag + v.imag * w.real;
|
||||
|
||||
// cargf(u)
|
||||
phase_error = atan2f(u.imag,u.real);
|
||||
|
||||
// step pll
|
||||
nco_crcf_pll_step(fmkit->stereoPilot, phase_error);
|
||||
nco_crcf_step(fmkit->stereoPilot);
|
||||
|
||||
// 38khz down-mix
|
||||
nco_crcf_mix_down(fmkit->stereoPilot, x, &y);
|
||||
nco_crcf_mix_down(fmkit->stereoPilot, y, &x);
|
||||
|
||||
// complex -> real
|
||||
float usb_discard;
|
||||
firhilbf_c2r_execute(fmkit->firStereoC2R, x, &demodStereoData[i], &usb_discard);
|
||||
}
|
||||
|
||||
// std::cout << "[PLL] phase error: " << phase_error;
|
||||
// std::cout << " freq:" << (((nco_crcf_get_frequency(stereoPilot) / (2.0 * M_PI)) * inp->sampleRate)) << std::endl;
|
||||
|
||||
if (audio_out_size != resampledStereoData.size()) {
|
||||
if (resampledStereoData.capacity() < audio_out_size) {
|
||||
resampledStereoData.reserve(audio_out_size);
|
||||
}
|
||||
resampledStereoData.resize(audio_out_size);
|
||||
}
|
||||
|
||||
msresamp_rrrf_execute(fmkit->stereoResampler, &demodStereoData[0], (int)bufSize, &resampledStereoData[0], &numAudioWritten);
|
||||
|
||||
audioOut->channels = 2;
|
||||
if (audioOut->data.capacity() < (numAudioWritten * 2)) {
|
||||
audioOut->data.reserve(numAudioWritten * 2);
|
||||
}
|
||||
audioOut->data.resize(numAudioWritten * 2);
|
||||
for (size_t i = 0; i < numAudioWritten; i++) {
|
||||
float l, r;
|
||||
float ld, rd;
|
||||
|
||||
if (fmkit->demph) {
|
||||
iirfilt_rrrf_execute(fmkit->iirDemphL, 0.568f * (resampledOutputData[i] - (resampledStereoData[i])), &ld);
|
||||
iirfilt_rrrf_execute(fmkit->iirDemphR, 0.568f * (resampledOutputData[i] + (resampledStereoData[i])), &rd);
|
||||
|
||||
firfilt_rrrf_push(fmkit->firStereoLeft, ld);
|
||||
firfilt_rrrf_execute(fmkit->firStereoLeft, &l);
|
||||
|
||||
firfilt_rrrf_push(fmkit->firStereoRight, rd);
|
||||
firfilt_rrrf_execute(fmkit->firStereoRight, &r);
|
||||
} else {
|
||||
firfilt_rrrf_push(fmkit->firStereoLeft, 0.568f * (resampledOutputData[i] - (resampledStereoData[i])));
|
||||
firfilt_rrrf_execute(fmkit->firStereoLeft, &l);
|
||||
|
||||
firfilt_rrrf_push(fmkit->firStereoRight, 0.568f * (resampledOutputData[i] + (resampledStereoData[i])));
|
||||
firfilt_rrrf_execute(fmkit->firStereoRight, &r);
|
||||
}
|
||||
|
||||
audioOut->data[i * 2] = l;
|
||||
audioOut->data[i * 2 + 1] = r;
|
||||
}
|
||||
}
|
62
Software/CubicSDR/src/modules/modem/analog/ModemFMStereo.h
Normal file
62
Software/CubicSDR/src/modules/modem/analog/ModemFMStereo.h
Normal file
@ -0,0 +1,62 @@
|
||||
// Copyright (c) Charles J. Cliffe
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#pragma once
|
||||
#include "Modem.h"
|
||||
|
||||
class ModemKitFMStereo: public ModemKit {
|
||||
public:
|
||||
ModemKitFMStereo() : audioResampler(nullptr), stereoResampler(nullptr), audioResampleRatio(0), firStereoLeft(nullptr), firStereoRight(nullptr), iirStereoPilot(nullptr),
|
||||
demph(0), iirDemphR(nullptr), iirDemphL(nullptr), firStereoR2C(nullptr), firStereoC2R(nullptr), stereoPilot(nullptr) {
|
||||
}
|
||||
|
||||
msresamp_rrrf audioResampler;
|
||||
msresamp_rrrf stereoResampler;
|
||||
double audioResampleRatio;
|
||||
|
||||
firfilt_rrrf firStereoLeft;
|
||||
firfilt_rrrf firStereoRight;
|
||||
iirfilt_crcf iirStereoPilot;
|
||||
|
||||
int demph;
|
||||
iirfilt_rrrf iirDemphR;
|
||||
iirfilt_rrrf iirDemphL;
|
||||
|
||||
firhilbf firStereoR2C;
|
||||
firhilbf firStereoC2R;
|
||||
|
||||
nco_crcf stereoPilot;
|
||||
};
|
||||
|
||||
|
||||
class ModemFMStereo : public Modem {
|
||||
public:
|
||||
ModemFMStereo();
|
||||
~ModemFMStereo() override;
|
||||
|
||||
std::string getType() override;
|
||||
std::string getName() override;
|
||||
|
||||
static ModemBase *factory();
|
||||
|
||||
int checkSampleRate(long long sampleRate, int audioSampleRate) override;
|
||||
int getDefaultSampleRate() override;
|
||||
|
||||
ModemArgInfoList getSettings() override;
|
||||
void writeSetting(std::string setting, std::string value) override;
|
||||
std::string readSetting(std::string setting) override;
|
||||
|
||||
ModemKit *buildKit(long long sampleRate, int audioSampleRate) override;
|
||||
void disposeKit(ModemKit *kit) override;
|
||||
|
||||
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
|
||||
|
||||
private:
|
||||
std::vector<float> demodOutputData;
|
||||
std::vector<float> demodStereoData;
|
||||
std::vector<float> resampledOutputData;
|
||||
std::vector<float> resampledStereoData;
|
||||
freqdem demodFM;
|
||||
|
||||
int _demph;
|
||||
};
|
57
Software/CubicSDR/src/modules/modem/analog/ModemIQ.cpp
Normal file
57
Software/CubicSDR/src/modules/modem/analog/ModemIQ.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
// Copyright (c) Charles J. Cliffe
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#include "ModemIQ.h"
|
||||
|
||||
ModemIQ::ModemIQ() = default;
|
||||
|
||||
std::string ModemIQ::getType() {
|
||||
return "analog";
|
||||
}
|
||||
|
||||
std::string ModemIQ::getName() {
|
||||
return "I/Q";
|
||||
}
|
||||
|
||||
ModemBase *ModemIQ::factory() {
|
||||
return new ModemIQ;
|
||||
}
|
||||
|
||||
ModemKit *ModemIQ::buildKit(long long sampleRate, int audioSampleRate) {
|
||||
auto *kit = new ModemKit;
|
||||
kit->sampleRate = sampleRate;
|
||||
kit->audioSampleRate = audioSampleRate;
|
||||
return kit;
|
||||
}
|
||||
|
||||
void ModemIQ::disposeKit(ModemKit *kit) {
|
||||
delete kit;
|
||||
}
|
||||
|
||||
int ModemIQ::checkSampleRate(long long /* sampleRate */, int audioSampleRate) {
|
||||
return audioSampleRate;
|
||||
}
|
||||
|
||||
int ModemIQ::getDefaultSampleRate() {
|
||||
return 48000;
|
||||
}
|
||||
|
||||
void ModemIQ::demodulate(ModemKit * /* kit */, ModemIQData *input, AudioThreadInput *audioOut) {
|
||||
size_t bufSize = input->data.size();
|
||||
|
||||
if (!bufSize) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
audioOut->channels = 2;
|
||||
if (audioOut->data.capacity() < (bufSize * 2)) {
|
||||
audioOut->data.reserve(bufSize * 2);
|
||||
}
|
||||
|
||||
audioOut->data.resize(bufSize * 2);
|
||||
for (size_t i = 0; i < bufSize; i++) {
|
||||
audioOut->data[i * 2] = input->data[i].imag;
|
||||
audioOut->data[i * 2 + 1] = input->data[i].real;
|
||||
}
|
||||
}
|
27
Software/CubicSDR/src/modules/modem/analog/ModemIQ.h
Normal file
27
Software/CubicSDR/src/modules/modem/analog/ModemIQ.h
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright (c) Charles J. Cliffe
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#pragma once
|
||||
#include "Modem.h"
|
||||
|
||||
class ModemIQ : public Modem {
|
||||
public:
|
||||
ModemIQ();
|
||||
|
||||
std::string getType() override;
|
||||
std::string getName() override;
|
||||
|
||||
static ModemBase *factory();
|
||||
|
||||
int checkSampleRate(long long sampleRate, int audioSampleRate) override;
|
||||
int getDefaultSampleRate() override;
|
||||
|
||||
ModemKit *buildKit(long long sampleRate, int audioSampleRate) override;
|
||||
|
||||
void disposeKit(ModemKit *kit) override;
|
||||
|
||||
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
|
||||
|
||||
private:
|
||||
|
||||
};
|
64
Software/CubicSDR/src/modules/modem/analog/ModemLSB.cpp
Normal file
64
Software/CubicSDR/src/modules/modem/analog/ModemLSB.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
// Copyright (c) Charles J. Cliffe
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#include "ModemLSB.h"
|
||||
|
||||
ModemLSB::ModemLSB() : ModemAnalog() {
|
||||
// half band filter used for side-band elimination
|
||||
ssbFilt = iirfilt_crcf_create_lowpass(6, 0.25);
|
||||
ssbShift = nco_crcf_create(LIQUID_NCO);
|
||||
nco_crcf_set_frequency(ssbShift, (float)((2.0 * M_PI) * 0.25));
|
||||
c2rFilt = firhilbf_create(5, 90.0);
|
||||
useSignalOutput(true);
|
||||
}
|
||||
|
||||
ModemBase *ModemLSB::factory() {
|
||||
return new ModemLSB;
|
||||
}
|
||||
|
||||
std::string ModemLSB::getName() {
|
||||
return "LSB";
|
||||
}
|
||||
|
||||
ModemLSB::~ModemLSB() {
|
||||
iirfilt_crcf_destroy(ssbFilt);
|
||||
nco_crcf_destroy(ssbShift);
|
||||
firhilbf_destroy(c2rFilt);
|
||||
}
|
||||
|
||||
int ModemLSB::checkSampleRate(long long sampleRate, int /* audioSampleRate */) {
|
||||
if (sampleRate < MIN_BANDWIDTH) {
|
||||
return MIN_BANDWIDTH;
|
||||
}
|
||||
if (sampleRate % 2 == 0) {
|
||||
return (int)sampleRate;
|
||||
}
|
||||
return (int)(sampleRate+1);
|
||||
}
|
||||
|
||||
int ModemLSB::getDefaultSampleRate() {
|
||||
return 5400;
|
||||
}
|
||||
|
||||
void ModemLSB::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) {
|
||||
auto *akit = (ModemKitAnalog *)kit;
|
||||
|
||||
initOutputBuffers(akit,input);
|
||||
|
||||
if (!bufSize) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
liquid_float_complex x, y;
|
||||
for (size_t i = 0; i < bufSize; i++) { // Reject upper band
|
||||
nco_crcf_step(ssbShift);
|
||||
nco_crcf_mix_up(ssbShift, input->data[i], &x);
|
||||
iirfilt_crcf_execute(ssbFilt, x, &y);
|
||||
nco_crcf_mix_down(ssbShift, y, &x);
|
||||
float usb_discard;
|
||||
firhilbf_c2r_execute(c2rFilt, x, &demodOutputData[i], &usb_discard);
|
||||
}
|
||||
|
||||
buildAudioOutput(akit, audioOut, true);
|
||||
}
|
25
Software/CubicSDR/src/modules/modem/analog/ModemLSB.h
Normal file
25
Software/CubicSDR/src/modules/modem/analog/ModemLSB.h
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright (c) Charles J. Cliffe
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#pragma once
|
||||
#include "ModemAnalog.h"
|
||||
|
||||
class ModemLSB : public ModemAnalog {
|
||||
public:
|
||||
ModemLSB();
|
||||
~ModemLSB() override;
|
||||
|
||||
std::string getName() override;
|
||||
|
||||
static ModemBase *factory();
|
||||
|
||||
int checkSampleRate(long long sampleRate, int audioSampleRate) override;
|
||||
int getDefaultSampleRate() override;
|
||||
|
||||
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
|
||||
|
||||
private:
|
||||
iirfilt_crcf ssbFilt;
|
||||
firhilbf c2rFilt;
|
||||
nco_crcf ssbShift;
|
||||
};
|
39
Software/CubicSDR/src/modules/modem/analog/ModemNBFM.cpp
Normal file
39
Software/CubicSDR/src/modules/modem/analog/ModemNBFM.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
// Copyright (c) Charles J. Cliffe
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#include "ModemNBFM.h"
|
||||
|
||||
ModemNBFM::ModemNBFM() : ModemAnalog() {
|
||||
demodFM = freqdem_create(0.5);
|
||||
}
|
||||
|
||||
ModemNBFM::~ModemNBFM() {
|
||||
freqdem_destroy(demodFM);
|
||||
}
|
||||
|
||||
ModemBase *ModemNBFM::factory() {
|
||||
return new ModemNBFM;
|
||||
}
|
||||
|
||||
std::string ModemNBFM::getName() {
|
||||
return "NBFM";
|
||||
}
|
||||
|
||||
int ModemNBFM::getDefaultSampleRate() {
|
||||
return 12500;
|
||||
}
|
||||
|
||||
void ModemNBFM::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) {
|
||||
auto *fmkit = (ModemKitAnalog *)kit;
|
||||
|
||||
initOutputBuffers(fmkit, input);
|
||||
|
||||
if (!bufSize) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
freqdem_demodulate_block(demodFM, &input->data[0], (unsigned int)bufSize, &demodOutputData[0]);
|
||||
|
||||
buildAudioOutput(fmkit, audioOut, false);
|
||||
}
|
23
Software/CubicSDR/src/modules/modem/analog/ModemNBFM.h
Normal file
23
Software/CubicSDR/src/modules/modem/analog/ModemNBFM.h
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (c) Charles J. Cliffe
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#pragma once
|
||||
#include "Modem.h"
|
||||
#include "ModemAnalog.h"
|
||||
|
||||
class ModemNBFM : public ModemAnalog {
|
||||
public:
|
||||
ModemNBFM();
|
||||
~ModemNBFM() override;
|
||||
|
||||
std::string getName() override;
|
||||
|
||||
static ModemBase *factory();
|
||||
|
||||
int getDefaultSampleRate() override;
|
||||
|
||||
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
|
||||
|
||||
private:
|
||||
freqdem demodFM;
|
||||
};
|
65
Software/CubicSDR/src/modules/modem/analog/ModemUSB.cpp
Normal file
65
Software/CubicSDR/src/modules/modem/analog/ModemUSB.cpp
Normal file
@ -0,0 +1,65 @@
|
||||
// Copyright (c) Charles J. Cliffe
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#include "ModemUSB.h"
|
||||
|
||||
ModemUSB::ModemUSB() : ModemAnalog() {
|
||||
// half band filter used for side-band elimination
|
||||
ssbFilt = iirfilt_crcf_create_lowpass(6, 0.25);
|
||||
ssbShift = nco_crcf_create(LIQUID_NCO);
|
||||
nco_crcf_set_frequency(ssbShift, (float)((2.0 * M_PI) * 0.25));
|
||||
c2rFilt = firhilbf_create(5, 90.0);
|
||||
useSignalOutput(true);
|
||||
}
|
||||
|
||||
ModemBase *ModemUSB::factory() {
|
||||
return new ModemUSB;
|
||||
}
|
||||
|
||||
std::string ModemUSB::getName() {
|
||||
return "USB";
|
||||
}
|
||||
|
||||
ModemUSB::~ModemUSB() {
|
||||
iirfilt_crcf_destroy(ssbFilt);
|
||||
nco_crcf_destroy(ssbShift);
|
||||
firhilbf_destroy(c2rFilt);
|
||||
}
|
||||
|
||||
int ModemUSB::checkSampleRate(long long sampleRate, int /* audioSampleRate */) {
|
||||
if (sampleRate < MIN_BANDWIDTH) {
|
||||
return MIN_BANDWIDTH;
|
||||
}
|
||||
if (sampleRate % 2 == 0) {
|
||||
return (int)sampleRate;
|
||||
}
|
||||
return (int)(sampleRate+1);
|
||||
}
|
||||
|
||||
int ModemUSB::getDefaultSampleRate() {
|
||||
return 5400;
|
||||
}
|
||||
|
||||
void ModemUSB::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) {
|
||||
auto *akit = (ModemKitAnalog *)kit;
|
||||
|
||||
initOutputBuffers(akit,input);
|
||||
|
||||
if (!bufSize) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
liquid_float_complex x, y;
|
||||
for (size_t i = 0; i < bufSize; i++) { // Reject lower band
|
||||
nco_crcf_step(ssbShift);
|
||||
nco_crcf_mix_down(ssbShift, input->data[i], &x);
|
||||
iirfilt_crcf_execute(ssbFilt, x, &y);
|
||||
nco_crcf_mix_up(ssbShift, y, &x);
|
||||
float lsb_discard;
|
||||
firhilbf_c2r_execute(c2rFilt, x, &lsb_discard, &demodOutputData[i]);
|
||||
}
|
||||
|
||||
buildAudioOutput(akit, audioOut, true);
|
||||
}
|
||||
|
25
Software/CubicSDR/src/modules/modem/analog/ModemUSB.h
Normal file
25
Software/CubicSDR/src/modules/modem/analog/ModemUSB.h
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright (c) Charles J. Cliffe
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#pragma once
|
||||
#include "ModemAnalog.h"
|
||||
|
||||
class ModemUSB : public ModemAnalog {
|
||||
public:
|
||||
ModemUSB();
|
||||
~ModemUSB() override;
|
||||
|
||||
std::string getName() override;
|
||||
|
||||
static ModemBase *factory();
|
||||
|
||||
int checkSampleRate(long long sampleRate, int audioSampleRate) override;
|
||||
int getDefaultSampleRate() override;
|
||||
|
||||
void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) override;
|
||||
|
||||
private:
|
||||
iirfilt_crcf ssbFilt;
|
||||
firhilbf c2rFilt;
|
||||
nco_crcf ssbShift;
|
||||
};
|
Reference in New Issue
Block a user