Skip to content

Commit

Permalink
Merge pull request #1855 from srcejon/freq_scanner
Browse files Browse the repository at this point in the history
Add separate audio bandwidth setting to AM Demod
  • Loading branch information
f4exb authored Oct 23, 2023
2 parents 11685fa + 0fc5eb8 commit dc7dd0c
Show file tree
Hide file tree
Showing 13 changed files with 175 additions and 49 deletions.
11 changes: 11 additions & 0 deletions plugins/channelrx/demodam/amdemod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ void AMDemod::applySettings(const AMDemodSettings& settings, bool force)
qDebug() << "AMDemod::applySettings:"
<< " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset
<< " m_rfBandwidth: " << settings.m_rfBandwidth
<< " m_afBandwidth: " << settings.m_afBandwidth
<< " m_volume: " << settings.m_volume
<< " m_squelch: " << settings.m_squelch
<< " m_audioMute: " << settings.m_audioMute
Expand All @@ -238,6 +239,9 @@ void AMDemod::applySettings(const AMDemodSettings& settings, bool force)
if ((m_settings.m_rfBandwidth != settings.m_rfBandwidth) || force) {
reverseAPIKeys.append("rfBandwidth");
}
if ((m_settings.m_afBandwidth != settings.m_afBandwidth) || force) {
reverseAPIKeys.append("afBandwidth");
}
if ((m_settings.m_bandpassEnable != settings.m_bandpassEnable) || force) {
reverseAPIKeys.append("bandpassEnable");
}
Expand Down Expand Up @@ -411,6 +415,9 @@ void AMDemod::webapiUpdateChannelSettings(
if (channelSettingsKeys.contains("rfBandwidth")) {
settings.m_rfBandwidth = response.getAmDemodSettings()->getRfBandwidth();
}
if (channelSettingsKeys.contains("afBandwidth")) {
settings.m_afBandwidth = response.getAmDemodSettings()->getAfBandwidth();
}
if (channelSettingsKeys.contains("rgbColor")) {
settings.m_rgbColor = response.getAmDemodSettings()->getRgbColor();
}
Expand Down Expand Up @@ -483,6 +490,7 @@ void AMDemod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& respo
response.getAmDemodSettings()->setAudioMute(settings.m_audioMute ? 1 : 0);
response.getAmDemodSettings()->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
response.getAmDemodSettings()->setRfBandwidth(settings.m_rfBandwidth);
response.getAmDemodSettings()->setAfBandwidth(settings.m_afBandwidth);
response.getAmDemodSettings()->setRgbColor(settings.m_rgbColor);
response.getAmDemodSettings()->setSquelch(settings.m_squelch);
response.getAmDemodSettings()->setVolume(settings.m_volume);
Expand Down Expand Up @@ -634,6 +642,9 @@ void AMDemod::webapiFormatChannelSettings(
if (channelSettingsKeys.contains("rfBandwidth") || force) {
swgAMDemodSettings->setRfBandwidth(settings.m_rfBandwidth);
}
if (channelSettingsKeys.contains("afBandwidth") || force) {
swgAMDemodSettings->setAfBandwidth(settings.m_afBandwidth);
}
if (channelSettingsKeys.contains("rgbColor") || force) {
swgAMDemodSettings->setRgbColor(settings.m_rgbColor);
}
Expand Down
21 changes: 17 additions & 4 deletions plugins/channelrx/demodam/amdemodgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,18 @@ void AMDemodGUI::on_bandpassEnable_toggled(bool checked)

void AMDemodGUI::on_rfBW_valueChanged(int value)
{
ui->rfBWText->setText(QString("%1 kHz").arg(value / 10.0, 0, 'f', 1));
m_channelMarker.setBandwidth(value * 100);
m_settings.m_rfBandwidth = value * 100;
applySettings();
ui->rfBWText->setText(QString("%1 kHz").arg(value / 10.0, 0, 'f', 1));
m_channelMarker.setBandwidth(value * 100);
m_settings.m_rfBandwidth = value * 100;
ui->afBW->setMaximum(value);
applySettings();
}

void AMDemodGUI::on_afBW_valueChanged(int value)
{
ui->afBWText->setText(QString("%1 kHz").arg(value / 10.0, 0, 'f', 1));
m_settings.m_afBandwidth = value * 100;
applySettings();
}

void AMDemodGUI::on_volume_valueChanged(int value)
Expand Down Expand Up @@ -354,6 +362,10 @@ void AMDemodGUI::displaySettings()
ui->rfBW->setValue(displayValue);
ui->rfBWText->setText(QString("%1 kHz").arg(displayValue / 10.0, 0, 'f', 1));

displayValue = m_settings.m_afBandwidth / 100.0;
ui->afBW->setValue(displayValue);
ui->afBWText->setText(QString("%1 kHz").arg(displayValue / 10.0, 0, 'f', 1));

ui->volume->setValue(m_settings.m_volume * 10.0);
ui->volumeText->setText(QString("%1").arg(m_settings.m_volume, 0, 'f', 1));

Expand Down Expand Up @@ -503,6 +515,7 @@ void AMDemodGUI::makeUIConnections()
QObject::connect(ui->ssb, &QToolButton::toggled, this, &AMDemodGUI::on_ssb_toggled);
QObject::connect(ui->bandpassEnable, &ButtonSwitch::toggled, this, &AMDemodGUI::on_bandpassEnable_toggled);
QObject::connect(ui->rfBW, &QSlider::valueChanged, this, &AMDemodGUI::on_rfBW_valueChanged);
QObject::connect(ui->afBW, &QSlider::valueChanged, this, &AMDemodGUI::on_afBW_valueChanged);
QObject::connect(ui->volume, &QSlider::valueChanged, this, &AMDemodGUI::on_volume_valueChanged);
QObject::connect(ui->squelch, &QSlider::valueChanged, this, &AMDemodGUI::on_squelch_valueChanged);
QObject::connect(ui->audioMute, &QToolButton::toggled, this, &AMDemodGUI::on_audioMute_toggled);
Expand Down
1 change: 1 addition & 0 deletions plugins/channelrx/demodam/amdemodgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ private slots:
void on_ssb_toggled(bool checked);
void on_bandpassEnable_toggled(bool checked);
void on_rfBW_valueChanged(int value);
void on_afBW_valueChanged(int value);
void on_volume_valueChanged(int value);
void on_squelch_valueChanged(int value);
void on_audioMute_toggled(bool checked);
Expand Down
76 changes: 64 additions & 12 deletions plugins/channelrx/demodam/amdemodgui.ui
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,51 @@
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="rfBW">
<property name="toolTip">
<string>Demodulator (RF) bandwidth</string>
</property>
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>400</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>50</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="rfBWText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>5.0 kHz</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="ButtonSwitch" name="bandpassEnable">
<property name="toolTip">
Expand All @@ -295,9 +340,16 @@
</widget>
</item>
<item>
<widget class="QSlider" name="rfBW">
<widget class="QLabel" name="afBWLabel">
<property name="text">
<string>AF BW</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="afBW">
<property name="toolTip">
<string>Demodulator (RF) bandwidth</string>
<string>Audio bandwidth</string>
</property>
<property name="minimum">
<number>10</number>
Expand All @@ -317,7 +369,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="rfBWText">
<widget class="QLabel" name="afBWText">
<property name="minimumSize">
<size>
<width>50</width>
Expand Down Expand Up @@ -434,10 +486,9 @@
</widget>
<customwidgets>
<customwidget>
<class>ValueDialZ</class>
<extends>QWidget</extends>
<header>gui/valuedialz.h</header>
<container>1</container>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
<customwidget>
<class>RollupContents</class>
Expand All @@ -446,15 +497,16 @@
<container>1</container>
</customwidget>
<customwidget>
<class>LevelMeterSignalDB</class>
<class>ValueDialZ</class>
<extends>QWidget</extends>
<header>gui/levelmeter.h</header>
<header>gui/valuedialz.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
<class>LevelMeterSignalDB</class>
<extends>QWidget</extends>
<header>gui/levelmeter.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
Expand Down
5 changes: 5 additions & 0 deletions plugins/channelrx/demodam/amdemodsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void AMDemodSettings::resetToDefaults()
m_volume = 2.0;
m_audioMute = false;
m_bandpassEnable = false;
m_afBandwidth = 5000;
m_rgbColor = QColor(255, 255, 0).rgb();
m_title = "AM Demodulator";
m_audioDeviceName = AudioDeviceManager::m_defaultDeviceName;
Expand Down Expand Up @@ -69,6 +70,7 @@ QByteArray AMDemodSettings::serialize() const
s.writeU32(7, m_rgbColor);
s.writeBool(8, m_bandpassEnable);
s.writeString(9, m_title);
s.writeReal(10, m_afBandwidth);
s.writeString(11, m_audioDeviceName);
s.writeBool(12, m_pll);
s.writeS32(13, (int) m_syncAMOperation);
Expand All @@ -85,6 +87,7 @@ QByteArray AMDemodSettings::serialize() const
s.writeS32(20, m_workspaceIndex);
s.writeBlob(21, m_geometryBytes);
s.writeBool(22, m_hidden);
s.writeBool(23, m_audioMute);

return s.final();
}
Expand Down Expand Up @@ -124,6 +127,7 @@ bool AMDemodSettings::deserialize(const QByteArray& data)
d.readU32(7, &m_rgbColor);
d.readBool(8, &m_bandpassEnable, false);
d.readString(9, &m_title, "AM Demodulator");
d.readReal(10, &m_afBandwidth, 5000);
d.readString(11, &m_audioDeviceName, AudioDeviceManager::m_defaultDeviceName);
d.readBool(12, &m_pll, false);
d.readS32(13, &tmp, 0);
Expand Down Expand Up @@ -152,6 +156,7 @@ bool AMDemodSettings::deserialize(const QByteArray& data)
d.readS32(20, &m_workspaceIndex, 0);
d.readBlob(21, &m_geometryBytes);
d.readBool(22, &m_hidden, false);
d.readBool(23, &m_audioMute);

return true;
}
Expand Down
1 change: 1 addition & 0 deletions plugins/channelrx/demodam/amdemodsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct AMDemodSettings
Real m_volume;
bool m_audioMute;
bool m_bandpassEnable;
Real m_afBandwidth; //!< High frequency for bandpass
quint32 m_rgbColor;
QString m_title;
Serializable *m_channelMarker;
Expand Down
12 changes: 7 additions & 5 deletions plugins/channelrx/demodam/amdemodsink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,19 +273,21 @@ void AMDemodSink::applySettings(const AMDemodSettings& settings, bool force)
<< " m_squelch: " << settings.m_squelch
<< " m_audioMute: " << settings.m_audioMute
<< " m_bandpassEnable: " << settings.m_bandpassEnable
<< " m_afBandwidth: " << settings.m_afBandwidth
<< " m_audioDeviceName: " << settings.m_audioDeviceName
<< " m_pll: " << settings.m_pll
<< " m_syncAMOperation: " << (int) settings.m_syncAMOperation
<< " force: " << force;

if((m_settings.m_rfBandwidth != settings.m_rfBandwidth) ||
(m_settings.m_bandpassEnable != settings.m_bandpassEnable) || force)
(m_settings.m_bandpassEnable != settings.m_bandpassEnable) ||
(m_settings.m_afBandwidth != settings.m_afBandwidth) || force)
{
m_interpolator.create(16, m_channelSampleRate, settings.m_rfBandwidth / 2.2f);
m_interpolatorDistanceRemain = 0;
m_interpolatorDistance = (Real) m_channelSampleRate / (Real) m_audioSampleRate;
m_bandpass.create(301, m_audioSampleRate, 300.0, settings.m_rfBandwidth / 2.0f);
m_lowpass.create(301, m_audioSampleRate, settings.m_rfBandwidth / 2.0f);
m_bandpass.create(301, m_audioSampleRate, 300.0, settings.m_afBandwidth / 2.0f);
m_lowpass.create(301, m_audioSampleRate, settings.m_afBandwidth / 2.0f);
DSBFilter->create_dsb_filter((2.0f * settings.m_rfBandwidth) / (float) m_audioSampleRate);
}

Expand Down Expand Up @@ -326,8 +328,8 @@ void AMDemodSink::applyAudioSampleRate(int sampleRate)
m_interpolator.create(16, m_channelSampleRate, m_settings.m_rfBandwidth / 2.2f);
m_interpolatorDistanceRemain = 0;
m_interpolatorDistance = (Real) m_channelSampleRate / (Real) sampleRate;
m_bandpass.create(301, sampleRate, 300.0, m_settings.m_rfBandwidth / 2.0f);
m_lowpass.create(301, sampleRate, m_settings.m_rfBandwidth / 2.0f);
m_bandpass.create(301, sampleRate, 300.0, m_settings.m_afBandwidth / 2.0f);
m_lowpass.create(301, sampleRate, m_settings.m_afBandwidth / 2.0f);
m_audioFifo.setSize(sampleRate);
m_squelchDelayLine.resize(sampleRate/5);
DSBFilter->create_dsb_filter((2.0f * m_settings.m_rfBandwidth) / (float) sampleRate);
Expand Down
7 changes: 7 additions & 0 deletions plugins/channelrx/demodam/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,10 @@ This is the volume of the audio signal from 0.0 (mute) to 10.0 (maximum). It can
<h3>10: Squelch threshold</h3>

This is the squelch threshold in dB. The average total power received in the signal bandwidth before demodulation is compared to this value and the squelch input is open above this value. It can be varied continuously in 0.1 dB steps from 0.0 to -100.0 dB using the dial button.

<h3>11: Audio bandwidth</h3>

Specifies cutoff frequency of low pass (or band pass if boxcar (7) enabled) filter applied to audio.
In many use cases, this can be the same as the RF bandwidth (8). However, where offset carrier is used
(a.k.a CLIMAX as used by some ATC ground stations), this can reduce noise, when the RF bandwidth is set around ~20kHz
to cope with the offset, but the audio is only ~5-6kHz wide.
1 change: 1 addition & 0 deletions plugins/channelrx/freqscanner/freqscanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <QNetworkReply>
#include <QBuffer>
#include <QThread>
#include <QRegExp>

#include <stdio.h>
#include <complex.h>
Expand Down
1 change: 1 addition & 0 deletions plugins/channelrx/freqscanner/freqscannergui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <QMenu>
#include <QTableWidget>
#include <QTableWidgetItem>
#include <QRegExp>

#include "device/deviceset.h"
#include "device/deviceuiset.h"
Expand Down
4 changes: 4 additions & 0 deletions swagger/sdrangel/api/swagger/include/AMDemod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ AMDemodSettings:
description: channel RF bandwidth in Hz (floors to next 100 Hz)
type: number
format: float
afBandwidth:
description: AF bandwidth in Hz
type: number
format: float
squelch:
description: power squelch threshold in decibels
type: number
Expand Down
Loading

0 comments on commit dc7dd0c

Please sign in to comment.