Only use audio signal level for AM based modems

This commit is contained in:
Charles J. Cliffe 2016-08-13 14:50:20 -04:00
parent 9f5c674646
commit 6a9e60efa9
9 changed files with 32 additions and 15 deletions

View File

@ -139,21 +139,22 @@ void DemodulatorThread::run() {
if (audioOutputQueue != nullptr && ati && ati->data.size()) {
float accum = 0;
for (auto i : ati->data) {
accum += abMagnitude(0.948059448969, 0.392699081699, i, 0.0);
}
if (cModem->useSignalOutput()) {
for (auto i : ati->data) {
accum += abMagnitude(0.948059448969, 0.392699081699, i, 0.0);
}
float audioSignalLevel = linearToDb(accum / float(ati->data.size()));
currentSignalLevel = linearToDb(accum / float(ati->data.size()));
accum = 0;
} else {
for (auto i : inp->data) {
accum += abMagnitude(0.948059448969, 0.392699081699, i.real, i.imag);
}
for (auto i : inp->data) {
accum += abMagnitude(0.948059448969, 0.392699081699, i.real, i.imag);
}
float iqSignalLevel = linearToDb(accum / float(inp->data.size()));
currentSignalLevel = iqSignalLevel>audioSignalLevel?iqSignalLevel:audioSignalLevel;
currentSignalLevel = linearToDb(accum / float(inp->data.size()));
}
float sf = signalFloor.load(), sc = signalCeil.load(), sl = squelchLevel.load();

View File

@ -32,7 +32,7 @@ ModemArgInfo::ModemArgInfo(void) {
}
Modem::Modem() {
useSignalOutput(false);
}
Modem::~Modem() {
@ -108,3 +108,12 @@ void Modem::rebuildKit() {
void Modem::clearRebuildKit() {
refreshKit.store(false);
}
bool Modem::useSignalOutput() {
return _useSignalOutput.load();
}
void Modem::useSignalOutput(bool useOutput) {
_useSignalOutput.store(useOutput);
}

View File

@ -152,8 +152,11 @@ public:
void rebuildKit();
void clearRebuildKit();
bool useSignalOutput();
void useSignalOutput(bool useOutput);
private:
static ModemFactoryList modemFactories;
static DefaultRatesList modemDefaultRates;
std::atomic_bool refreshKit;
std::atomic_bool refreshKit, _useSignalOutput;
};

View File

@ -1,6 +1,6 @@
#include "ModemAnalog.h"
ModemAnalog::ModemAnalog() : aOutputCeil(1), aOutputCeilMA(1), aOutputCeilMAA(1) {
ModemAnalog::ModemAnalog() : Modem(), aOutputCeil(1), aOutputCeilMA(1), aOutputCeilMAA(1) {
}

View File

@ -5,7 +5,7 @@ ModemDigitalOutput::ModemDigitalOutput() {
}
ModemDigital::ModemDigital() {
ModemDigital::ModemDigital() : Modem() {
#if ENABLE_DIGITAL_LAB
digitalOut = nullptr;
#endif

View File

@ -2,6 +2,7 @@
ModemAM::ModemAM() : ModemAnalog() {
demodAM = ampmodem_create(0.5, 0.0, LIQUID_AMPMODEM_DSB, 0);
useSignalOutput(true);
}
ModemAM::~ModemAM() {

View File

@ -2,6 +2,7 @@
ModemDSB::ModemDSB() : ModemAnalog() {
demodAM_DSB = ampmodem_create(0.5, 0.0, LIQUID_AMPMODEM_DSB, 1);
useSignalOutput(true);
}
ModemDSB::~ModemDSB() {

View File

@ -11,6 +11,7 @@ ModemLSB::ModemLSB() : ModemAnalog() {
ssbShift = nco_crcf_create(LIQUID_NCO);
nco_crcf_set_frequency(ssbShift, (2.0 * M_PI) * 0.25);
c2rFilt = firhilbf_create(5, 90.0);
useSignalOutput(true);
}
ModemBase *ModemLSB::factory() {

View File

@ -11,6 +11,7 @@ ModemUSB::ModemUSB() : ModemAnalog() {
ssbShift = nco_crcf_create(LIQUID_NCO);
nco_crcf_set_frequency(ssbShift, (2.0f * M_PI) * 0.25f);
c2rFilt = firhilbf_create(5, 90.0);
useSignalOutput(true);
}
ModemBase *ModemUSB::factory() {