mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-21 19:31:54 -05:00
Moving signal ceil/floor for squelch
This commit is contained in:
parent
a8c4621c82
commit
dedac01709
@ -1402,7 +1402,11 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
|
||||
demodWaterfallCanvas->setBandwidth(demodBw);
|
||||
demodSpectrumCanvas->setBandwidth(demodBw);
|
||||
}
|
||||
|
||||
demodSignalMeter->setLevel(demod->getSignalLevel());
|
||||
demodSignalMeter->setMin(demod->getSignalFloor());
|
||||
demodSignalMeter->setMax(demod->getSignalCeil());
|
||||
|
||||
demodGainMeter->setLevel(demod->getGain());
|
||||
if (demodSignalMeter->inputChanged()) {
|
||||
demod->setSquelchLevel(demodSignalMeter->getInputValue());
|
||||
|
@ -257,6 +257,14 @@ float DemodulatorInstance::getSignalLevel() {
|
||||
return demodulatorThread->getSignalLevel();
|
||||
}
|
||||
|
||||
float DemodulatorInstance::getSignalFloor() {
|
||||
return demodulatorThread->getSignalFloor();
|
||||
}
|
||||
|
||||
float DemodulatorInstance::getSignalCeil() {
|
||||
return demodulatorThread->getSignalCeil();
|
||||
}
|
||||
|
||||
void DemodulatorInstance::setSquelchLevel(float signal_level_in) {
|
||||
demodulatorThread->setSquelchLevel(signal_level_in);
|
||||
wxGetApp().getDemodMgr().setLastSquelchLevel(signal_level_in);
|
||||
|
@ -63,6 +63,8 @@ public:
|
||||
void setSquelchEnabled(bool state);
|
||||
|
||||
float getSignalLevel();
|
||||
float getSignalFloor();
|
||||
float getSignalCeil();
|
||||
void setSquelchLevel(float signal_level_in);
|
||||
float getSquelchLevel();
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
DemodulatorThread::DemodulatorThread(DemodulatorInstance *parent)
|
||||
: IOThread(), outputBuffers("DemodulatorThreadBuffers"), squelchLevel(-100),
|
||||
signalLevel(-100), squelchEnabled(false) {
|
||||
signalLevel(-100), signalFloor(-30), signalCeil(30), squelchEnabled(false) {
|
||||
|
||||
demodInstance = parent;
|
||||
muted.store(false);
|
||||
@ -114,6 +114,33 @@ void DemodulatorThread::run() {
|
||||
currentSignalLevel = DEMOD_SIGNAL_MIN+1;
|
||||
}
|
||||
|
||||
float sampleTime = float(inp->data.size()) / float(inp->sampleRate);
|
||||
float sf = signalFloor.load(), sc = signalCeil.load(), sl = squelchLevel.load();
|
||||
|
||||
if (currentSignalLevel > sc) {
|
||||
sc = currentSignalLevel;
|
||||
}
|
||||
|
||||
if (currentSignalLevel < sf) {
|
||||
sf = currentSignalLevel;
|
||||
}
|
||||
|
||||
if (sl+1.0f > sc) {
|
||||
sc = sl+1.0f;
|
||||
}
|
||||
|
||||
if ((sf+2.0f) > sc) {
|
||||
sc = sf+2.0f;
|
||||
}
|
||||
|
||||
sc -= (sc - (currentSignalLevel + 2.0f)) * sampleTime * 0.15f;
|
||||
sf += ((currentSignalLevel - 5.0f) - sf) * sampleTime * 0.15f;
|
||||
|
||||
signalFloor.store(sf);
|
||||
signalCeil.store(sc);
|
||||
|
||||
// std::cout << "sf:" << sf << "sc: " << sc << std::endl;
|
||||
|
||||
std::vector<liquid_float_complex> *inputData;
|
||||
|
||||
inputData = &inp->data;
|
||||
@ -330,6 +357,14 @@ float DemodulatorThread::getSignalLevel() {
|
||||
return signalLevel.load();
|
||||
}
|
||||
|
||||
float DemodulatorThread::getSignalFloor() {
|
||||
return signalFloor.load();
|
||||
}
|
||||
|
||||
float DemodulatorThread::getSignalCeil() {
|
||||
return signalCeil.load();
|
||||
}
|
||||
|
||||
void DemodulatorThread::setSquelchLevel(float signal_level_in) {
|
||||
if (!squelchEnabled) {
|
||||
squelchEnabled = true;
|
||||
|
@ -30,6 +30,8 @@ public:
|
||||
bool isMuted();
|
||||
|
||||
float getSignalLevel();
|
||||
float getSignalCeil();
|
||||
float getSignalFloor();
|
||||
void setSquelchLevel(float signal_level_in);
|
||||
float getSquelchLevel();
|
||||
|
||||
@ -46,7 +48,7 @@ protected:
|
||||
std::atomic_bool muted;
|
||||
|
||||
std::atomic<float> squelchLevel;
|
||||
std::atomic<float> signalLevel;
|
||||
std::atomic<float> signalLevel, signalFloor, signalCeil;
|
||||
bool squelchEnabled, squelchBreak;
|
||||
|
||||
Modem *cModem = nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user