Minor warning/formatting clean-up

This commit is contained in:
Charles J. Cliffe 2021-03-19 22:42:42 -04:00
parent 95b7a86ed9
commit a174db1725
2 changed files with 87 additions and 98 deletions

View File

@ -18,8 +18,7 @@ ModemCW::ModemCW()
mGain(15.0), mGain(15.0),
mAutoGain(true), mAutoGain(true),
mLO(nullptr), mLO(nullptr),
mToReal(nullptr) mToReal(nullptr) {
{
mLO = nco_crcf_create(LIQUID_NCO); mLO = nco_crcf_create(LIQUID_NCO);
mToReal = firhilbf_create(5, 60.0f); mToReal = firhilbf_create(5, 60.0f);
useSignalOutput(true); useSignalOutput(true);
@ -32,8 +31,7 @@ ModemCW::~ModemCW() {
firhilbf_destroy(mToReal); firhilbf_destroy(mToReal);
} }
ModemArgInfoList ModemCW::getSettings() ModemArgInfoList ModemCW::getSettings() {
{
ModemArgInfoList args; ModemArgInfoList args;
ModemArgInfo offsetArg; ModemArgInfo offsetArg;
@ -41,7 +39,7 @@ ModemArgInfoList ModemCW::getSettings()
offsetArg.name = "Frequency Offset"; offsetArg.name = "Frequency Offset";
offsetArg.value = std::to_string(mBeepFrequency); offsetArg.value = std::to_string(mBeepFrequency);
offsetArg.units = "Hz"; offsetArg.units = "Hz";
offsetArg.description = "Frequency Offset / Beep frequency"; offsetArg.description = "Frequency Offset / Beep frequency (200-1000Hz)";
offsetArg.type = ModemArgInfo::FLOAT; offsetArg.type = ModemArgInfo::FLOAT;
offsetArg.range = ModemRange(200.0, 1000.0); offsetArg.range = ModemRange(200.0, 1000.0);
args.push_back(offsetArg); args.push_back(offsetArg);
@ -63,36 +61,30 @@ ModemArgInfoList ModemCW::getSettings()
gain.name = "Audio Gain"; gain.name = "Audio Gain";
gain.value = "15"; gain.value = "15";
gain.units = "dB"; gain.units = "dB";
gain.description = "Gain Setting"; gain.description = "Gain Setting (0-40dB)";
gain.range = ModemRange(0.0, 40.0); gain.range = ModemRange(0.0, 40.0);
gain.type = ModemArgInfo::FLOAT; gain.type = ModemArgInfo::FLOAT;
args.push_back(gain); args.push_back(gain);
return args; return args;
} }
void ModemCW::writeSetting(std::string setting, std::string value) void ModemCW::writeSetting(std::string setting, std::string value) {
{
if (setting == "offset") { if (setting == "offset") {
mBeepFrequency = std::stof(value); mBeepFrequency = std::stof(value);
rebuildKit(); rebuildKit();
} else } else if (setting == "auto") {
if (setting == "auto") { mAutoGain = (value == "on");
mAutoGain = (value=="on")?true:false; } else if (setting == "gain") {
} else
if (setting == "gain") {
mGain = std::stof(value); mGain = std::stof(value);
} }
} }
std::string ModemCW::readSetting(std::string setting) std::string ModemCW::readSetting(std::string setting) {
{
if (setting == "offset") { if (setting == "offset") {
return std::to_string(mBeepFrequency); return std::to_string(mBeepFrequency);
} else } else if (setting == "auto") {
if (setting == "auto") {
return (mAutoGain) ? "on" : "off"; return (mAutoGain) ? "on" : "off";
} else } else if (setting == "gain") {
if (setting == "gain") {
return std::to_string(mGain); return std::to_string(mGain);
} }
return ""; return "";
@ -106,8 +98,7 @@ std::string ModemCW::getName() {
return "CW"; return "CW";
} }
int ModemCW::checkSampleRate (long long srate, int arate) int ModemCW::checkSampleRate(long long srate, int /* arate */) {
{
if (srate < MIN_BANDWIDTH) if (srate < MIN_BANDWIDTH)
return MIN_BANDWIDTH; return MIN_BANDWIDTH;
return srate; return srate;
@ -124,8 +115,7 @@ int ModemCW::getDefaultSampleRate() {
// one doesn't have the bandwidth for these tones. So we need to interpolate // 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. // 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. // Simple solution is just interpolate the IQ data to the audio sample rate.
ModemKit *ModemCW::buildKit (long long sampleRate, int audioSampleRate) ModemKit *ModemCW::buildKit(long long sampleRate, int audioSampleRate) {
{
ModemKitCW *kit = new ModemKitCW(); ModemKitCW *kit = new ModemKitCW();
float As = 60.0f; float As = 60.0f;
double ratio = double(audioSampleRate) / double(sampleRate); double ratio = double(audioSampleRate) / double(sampleRate);
@ -136,15 +126,13 @@ ModemKit *ModemCW::buildKit (long long sampleRate, int audioSampleRate)
return kit; return kit;
} }
void ModemCW::disposeKit (ModemKit *kit) void ModemCW::disposeKit(ModemKit *kit) {
{
ModemKitCW *cwkit = (ModemKitCW *) kit; ModemKitCW *cwkit = (ModemKitCW *) kit;
msresamp_cccf_destroy(cwkit->mInputResampler); msresamp_cccf_destroy(cwkit->mInputResampler);
delete kit; delete kit;
} }
void ModemCW::initOutputBuffers(ModemKitAnalog *akit, ModemIQData *input) void ModemCW::initOutputBuffers(ModemKitAnalog *akit, ModemIQData *input) {
{
bufSize = input->data.size(); bufSize = input->data.size();
if (!bufSize) { if (!bufSize) {
@ -189,7 +177,7 @@ void ModemCW::demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *au
nco_crcf_set_frequency(mLO, 2.0 * M_PI * mBeepFrequency / kit->audioSampleRate); nco_crcf_set_frequency(mLO, 2.0 * M_PI * mBeepFrequency / kit->audioSampleRate);
// Mix up from base band by beep frequency. Extract real part // Mix up from base band by beep frequency. Extract real part
for (int i = 0; i < outSize; i++) { for (unsigned int i = 0; i < outSize; i++) {
nco_crcf_mix_up(mLO, mInput[i], &sig); nco_crcf_mix_up(mLO, mInput[i], &sig);
nco_crcf_step(mLO); nco_crcf_step(mLO);
firhilbf_c2r_execute(mToReal, sig, &lsb, &demodOutputData[i]); firhilbf_c2r_execute(mToReal, sig, &lsb, &demodOutputData[i]);

View File

@ -2,11 +2,11 @@
// SPDX-License-Identifier: GPL-2.0+ // SPDX-License-Identifier: GPL-2.0+
#pragma once #pragma once
#include "Modem.h" #include "Modem.h"
#include "ModemAnalog.h" #include "ModemAnalog.h"
class ModemKitCW : public ModemKitAnalog class ModemKitCW : public ModemKitAnalog {
{
public: public:
ModemKitCW() : ModemKitAnalog() { ModemKitCW() : ModemKitAnalog() {
}; };
@ -16,6 +16,7 @@ public:
class ModemCW : public ModemAnalog { class ModemCW : public ModemAnalog {
public: public:
ModemCW(); ModemCW();
~ModemCW(); ~ModemCW();
std::string getName(); std::string getName();
@ -44,9 +45,9 @@ public:
std::vector<float> *getResampledOutputData() { return &demodOutputData; } std::vector<float> *getResampledOutputData() { return &demodOutputData; }
private: private:
bool mAutoGain;
float mGain;
float mBeepFrequency; float mBeepFrequency;
float mGain;
bool mAutoGain;
nco_crcf mLO; nco_crcf mLO;
firhilbf mToReal; firhilbf mToReal;
std::vector<liquid_float_complex> mInput; std::vector<liquid_float_complex> mInput;