1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00

FreeDV demod: stats in the GUI (3) and other fixes. SSB UI deserialization: fixed spectrum setting

This commit is contained in:
f4exb 2019-02-28 02:42:19 +01:00
parent ac5b6c184a
commit 37916cb568
8 changed files with 137 additions and 33 deletions

View File

@ -54,7 +54,7 @@ FreeDVDemod::FreeDVStats::FreeDVStats()
void FreeDVDemod::FreeDVStats::init()
{
m_sync = 0;
m_sync = false;
m_snrEst = -20;
m_clockOffset = 0;
m_freqOffset = 0;
@ -76,7 +76,7 @@ void FreeDVDemod::FreeDVStats::collect(struct freedv *freeDV)
m_clockOffset = stats.clock_offset;
m_freqOffset = stats.foff;
m_syncMetric = stats.sync_metric;
m_sync = stats.sync;
m_sync = stats.sync != 0;
m_snrEst = stats.snr_est;
if (m_berFrameCount >= m_fps)
@ -85,8 +85,8 @@ void FreeDVDemod::FreeDVStats::collect(struct freedv *freeDV)
m_ber = m_ber < 0 ? 0 : m_ber;
m_berFrameCount = 0;
m_lastTotalBitErrors = m_totalBitErrors;
qDebug("FreeDVStats::collect: demod sync: %d sync metric: %f demod snr: %3.2f dB BER: %d clock offset: %f freq offset: %f",
m_sync, m_syncMetric, m_snrEst, m_ber, m_clockOffset, m_freqOffset);
// qDebug("FreeDVStats::collect: demod sync: %s sync metric: %f demod snr: %3.2f dB BER: %d clock offset: %f freq offset: %f",
// m_sync ? "ok" : "ko", m_syncMetric, m_snrEst, m_ber, m_clockOffset, m_freqOffset);
}
m_berFrameCount++;
@ -486,8 +486,9 @@ void FreeDVDemod::applyFreeDVMode(FreeDVDemodSettings::FreeDVMode mode)
uint32_t modemSampleRate = FreeDVDemodSettings::getModSampleRate(mode);
m_settingsMutex.lock();
SSBFilter->create_filter(m_lowCutoff / (float) modemSampleRate, m_hiCutoff / (float) modemSampleRate);
// baseband interpolator and filter
// baseband interpolator
if (modemSampleRate != m_modemSampleRate)
{
MsgConfigureChannelizer* channelConfigMsg = MsgConfigureChannelizer::create(
@ -498,7 +499,6 @@ void FreeDVDemod::applyFreeDVMode(FreeDVDemodSettings::FreeDVMode mode)
//m_interpolatorConsumed = false;
m_interpolatorDistance = (Real) m_inputSampleRate / (Real) modemSampleRate;
m_interpolator.create(16, m_inputSampleRate, m_hiCutoff * 1.5f, 2.0f);
SSBFilter->create_filter(m_lowCutoff / (float) modemSampleRate, m_hiCutoff / (float) modemSampleRate);
int agcNbSamples = (modemSampleRate / 1000) * (1<<m_settings.m_agcTimeLog2);
int agcThresholdGate = (modemSampleRate / 1000) * m_settings.m_agcThresholdGate; // ms
@ -571,6 +571,7 @@ void FreeDVDemod::applyFreeDVMode(FreeDVDemodSettings::FreeDVMode mode)
freedv_set_squelch_en(m_freeDV, 0);
freedv_set_clip(m_freeDV, 0);
freedv_set_ext_vco(m_freeDV, 0);
freedv_set_sync(m_freeDV, manualsync);
int nSpeechSamples = freedv_get_n_speech_samples(m_freeDV);
int nMaxModemSamples = freedv_get_n_max_modem_samples(m_freeDV);
@ -578,10 +579,6 @@ void FreeDVDemod::applyFreeDVMode(FreeDVDemodSettings::FreeDVMode mode)
int Rs = freedv_get_modem_symbol_rate(m_freeDV);
m_freeDVStats.init();
if (m_nin > 0) {
m_freeDVStats.m_fps = m_modemSampleRate / m_nin;
}
if (nSpeechSamples != m_nSpeechSamples)
{
if (m_speechOut) {
@ -606,9 +603,15 @@ void FreeDVDemod::applyFreeDVMode(FreeDVDemodSettings::FreeDVMode mode)
m_iModem = 0;
m_nin = freedv_nin(m_freeDV);
if (m_nin > 0) {
m_freeDVStats.m_fps = m_modemSampleRate / m_nin;
}
qDebug() << "FreeDVMod::applyFreeDVMode:"
<< " fdv_mode: " << fdv_mode
<< " m_modemSampleRate: " << m_modemSampleRate
<< " m_lowCutoff: " << m_lowCutoff
<< " m_hiCutoff: " << m_hiCutoff
<< " Fs: " << Fs
<< " Rs: " << Rs
<< " m_nSpeechSamples: " << m_nSpeechSamples

View File

@ -163,6 +163,9 @@ public:
}
void getSNRLevels(double& avg, double& peak, int& nbSamples);
int getBER() const { return m_freeDVStats.m_ber; }
float getFrequencyOffset() const { return m_freeDVStats.m_freqOffset; }
bool isSync() const { return m_freeDVStats.m_sync; }
virtual int webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
@ -198,7 +201,7 @@ private:
void init();
void collect(struct freedv *freedv);
int m_sync;
bool m_sync;
float m_snrEst;
float m_clockOffset;
float m_freqOffset;

View File

@ -83,14 +83,14 @@ bool FreeDVDemodGUI::deserialize(const QByteArray& data)
if(m_settings.deserialize(data))
{
displaySettings();
applySettings(true); // will have true
applyBandwidths(5 - ui->spanLog2->value(), true); // does applySettings(true)
return true;
}
else
{
m_settings.resetToDefaults();
displaySettings();
applySettings(true); // will have true
applyBandwidths(5 - ui->spanLog2->value(), true); // does applySettings(true)
return false;
}
}
@ -300,7 +300,7 @@ FreeDVDemodGUI::FreeDVDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, B
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
ui->channelPowerMeter->setColorTheme(LevelMeterSignalDB::ColorGreenAndBlue);
ui->snrMeter->setColorTheme(LevelMeterSignalDB::ColorCyanAndBlue);
ui->snrMeter->setRange(-20, 30);
ui->snrMeter->setRange(-10, 30);
ui->snrMeter->setAverageSmoothing(2);
m_channelMarker.setVisible(true); // activate signal on the last setting only
@ -472,20 +472,32 @@ void FreeDVDemodGUI::tick()
(FreeDVDemodSettings::m_mminPowerThresholdDBf + powDbPeak) / FreeDVDemodSettings::m_mminPowerThresholdDBf,
nbMagsqSamples);
if (m_tickCount % 4 == 0) {
ui->channelPower->setText(tr("%1 dB").arg(powDbAvg, 0, 'f', 1));
}
double snrAvg, snrPeak;
int nbSNRSamples;
m_freeDVDemod->getSNRLevels(snrAvg, snrPeak, nbSNRSamples);
ui->snrMeter->levelChanged(
(20.0f + snrAvg) / 50.0f,
(20.0f + snrPeak) / 50.0f,
(10.0f + snrAvg) / 40.0f,
(10.0f + snrPeak) / 40.0f,
nbSNRSamples
);
ui->berText->setText(tr("%1").arg(m_freeDVDemod->getBER()));
float freqOffset = m_freeDVDemod->getFrequencyOffset();
int freqOffsetInt = freqOffset < -999 ? -999 : freqOffset > 999 ? 999 : freqOffset;
ui->freqOffset->setText(tr("%1Hz").arg(freqOffsetInt));
if (m_freeDVDemod->isSync()) {
ui->syncLabel->setStyleSheet("QLabel { background-color : green; }");
} else {
ui->syncLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }");
}
if (m_tickCount % 4 == 0) {
ui->channelPower->setText(tr("%1 dB").arg(powDbAvg, 0, 'f', 1));
ui->snrText->setText(tr("%1 dB").arg(snrAvg < -90 ? -90 : snrAvg > 90 ? 90 : snrAvg, 0, 'f', 1));
}
bool squelchOpen = m_freeDVDemod->getAudioActive();
if (squelchOpen != m_squelchOpen)

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>412</width>
<height>476</height>
<width>442</width>
<height>523</height>
</rect>
</property>
<property name="sizePolicy">
@ -36,7 +36,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>410</width>
<width>441</width>
<height>171</height>
</rect>
</property>
@ -520,6 +520,12 @@
</item>
<item>
<widget class="LevelMeterSignalDB" name="snrMeter" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>180</width>
@ -532,12 +538,34 @@
<pointsize>8</pointsize>
</font>
</property>
<property name="toolTip">
<string>SNR estimation</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="snrUnits">
<widget class="QLabel" name="snrText">
<property name="minimumSize">
<size>
<width>52</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>SNR estimation</string>
</property>
<property name="text">
<string>dB</string>
<string>-10.0 dB</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
@ -550,22 +578,78 @@
</item>
<item>
<widget class="QLabel" name="berText">
<property name="minimumSize">
<size>
<width>16</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Bit Error Rate (bits/s)</string>
</property>
<property name="text">
<string>00</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="syncLabel">
<property name="minimumSize">
<size>
<width>12</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Sync indicator (OFDM only)</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="text">
<string>Syn</string>
<string>S</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="synText">
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="freqOffsetLabel">
<property name="text">
<string>00</string>
<string>Df</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="freqOffset">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Frequency offset estimation</string>
</property>
<property name="text">
<string>-100Hz</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>

View File

@ -67,14 +67,14 @@ bool SSBDemodGUI::deserialize(const QByteArray& data)
if(m_settings.deserialize(data))
{
displaySettings();
applySettings(true); // will have true
applyBandwidths(5 - ui->spanLog2->value(), true); // does applySettings(true)
return true;
}
else
{
m_settings.resetToDefaults();
displaySettings();
applySettings(true); // will have true
applyBandwidths(5 - ui->spanLog2->value(), true); // does applySettings(true)
return false;
}
}

View File

@ -10,7 +10,7 @@
const PluginDescriptor SSBPlugin::m_pluginDescriptor = {
QString("SSB Demodulator"),
QString("4.3.2"),
QString("4.5.0"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,

View File

@ -616,6 +616,7 @@ void FreeDVMod::applyFreeDVMode(FreeDVModSettings::FreeDVMode mode)
int modemSampleRate = FreeDVModSettings::getModSampleRate(mode);
m_settingsMutex.lock();
m_SSBFilter->create_filter(m_lowCutoff / modemSampleRate, m_hiCutoff / modemSampleRate);
// baseband interpolator and filter
if (modemSampleRate != m_modemSampleRate)
@ -628,7 +629,6 @@ void FreeDVMod::applyFreeDVMode(FreeDVModSettings::FreeDVMode mode)
m_interpolatorConsumed = false;
m_interpolatorDistance = (Real) modemSampleRate / (Real) m_outputSampleRate;
m_interpolator.create(48, modemSampleRate, m_hiCutoff, 3.0);
m_SSBFilter->create_filter(m_lowCutoff / modemSampleRate, m_hiCutoff / modemSampleRate);
m_modemSampleRate = modemSampleRate;
if (getMessageQueueToGUI())
@ -722,6 +722,8 @@ void FreeDVMod::applyFreeDVMode(FreeDVModSettings::FreeDVMode mode)
qDebug() << "FreeDVMod::applyFreeDVMode:"
<< " fdv_mode: " << fdv_mode
<< " m_modemSampleRate: " << m_modemSampleRate
<< " m_lowCutoff: " << m_lowCutoff
<< " m_hiCutoff: " << m_hiCutoff
<< " Fs: " << Fs
<< " Rs: " << Rs
<< " m_nSpeechSamples: " << m_nSpeechSamples

View File

@ -454,7 +454,7 @@
</size>
</property>
<property name="toolTip">
<string>Open record file (48 kHz 32 bit float LE mono)</string>
<string>Open record file (8 kHz 16 bit signed integer LE mono)</string>
</property>
<property name="text">
<string/>