1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-06-24 21:15:24 -04:00

WFM demod: Set fixed geometry. Audio mute

This commit is contained in:
f4exb 2017-04-26 10:04:02 +02:00
parent faffb7f7ca
commit 64de0eca3c
5 changed files with 176 additions and 24 deletions

View File

@ -65,9 +65,15 @@ WFMDemod::~WFMDemod()
DSPEngine::instance()->removeAudioSink(&m_audioFifo); DSPEngine::instance()->removeAudioSink(&m_audioFifo);
} }
void WFMDemod::configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, Real squelch) void WFMDemod::configure(
MessageQueue* messageQueue,
Real rfBandwidth,
Real afBandwidth,
Real volume,
Real squelch,
bool audioMute)
{ {
Message* cmd = MsgConfigureWFMDemod::create(rfBandwidth, afBandwidth, volume, squelch); Message* cmd = MsgConfigureWFMDemod::create(rfBandwidth, afBandwidth, volume, squelch, audioMute);
messageQueue->push(cmd); messageQueue->push(cmd);
} }
@ -98,16 +104,23 @@ void WFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
if(m_movingAverage.average() >= m_squelchLevel) if(m_movingAverage.average() >= m_squelchLevel)
m_squelchState = m_running.m_rfBandwidth / 20; // decay rate m_squelchState = m_running.m_rfBandwidth / 20; // decay rate
if(m_squelchState > 0) if (m_squelchState > 0)
{ {
m_squelchState--; m_squelchState--;
m_squelchOpen = true;
} }
else else
{ {
demod = 0; demod = 0;
m_squelchOpen = false;
} }
Complex e(demod, 0); if (m_running.m_audioMute)
{
demod = 0;
}
Complex e(demod, 0);
if(m_interpolator.decimate(&m_interpolatorDistanceRemain, e, &ci)) if(m_interpolator.decimate(&m_interpolatorDistanceRemain, e, &ci))
{ {
@ -191,11 +204,13 @@ bool WFMDemod::handleMessage(const Message& cmd)
m_config.m_afBandwidth = cfg.getAFBandwidth(); m_config.m_afBandwidth = cfg.getAFBandwidth();
m_config.m_volume = cfg.getVolume(); m_config.m_volume = cfg.getVolume();
m_config.m_squelch = cfg.getSquelch(); m_config.m_squelch = cfg.getSquelch();
m_config.m_audioMute = cfg.getAudioMute();
qDebug() << "WFMDemod::handleMessage: MsgConfigureWFMDemod: m_rfBandwidth: " << m_config.m_rfBandwidth qDebug() << "WFMDemod::handleMessage: MsgConfigureWFMDemod: m_rfBandwidth: " << m_config.m_rfBandwidth
<< " m_afBandwidth: " << m_config.m_afBandwidth << " m_afBandwidth: " << m_config.m_afBandwidth
<< " m_volume: " << m_config.m_volume << " m_volume: " << m_config.m_volume
<< " m_squelch: " << m_config.m_squelch; << " m_squelch: " << m_config.m_squelch
<< " m_audioMute: " << m_config.m_audioMute;
apply(); apply();
@ -258,5 +273,5 @@ void WFMDemod::apply()
m_running.m_squelch = m_config.m_squelch; m_running.m_squelch = m_config.m_squelch;
m_running.m_volume = m_config.m_volume; m_running.m_volume = m_config.m_volume;
m_running.m_audioSampleRate = m_config.m_audioSampleRate; m_running.m_audioSampleRate = m_config.m_audioSampleRate;
m_running.m_audioMute = m_config.m_audioMute;
} }

View File

@ -37,7 +37,13 @@ public:
WFMDemod(BasebandSampleSink* sampleSink); WFMDemod(BasebandSampleSink* sampleSink);
virtual ~WFMDemod(); virtual ~WFMDemod();
void configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, Real squelch); void configure(
MessageQueue* messageQueue,
Real rfBandwidth,
Real afBandwidth,
Real volume,
Real squelch,
bool auduiMute);
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po); virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po);
virtual void start(); virtual void start();
@ -45,6 +51,7 @@ public:
virtual bool handleMessage(const Message& cmd); virtual bool handleMessage(const Message& cmd);
Real getMagSq() const { return m_movingAverage.average(); } Real getMagSq() const { return m_movingAverage.average(); }
bool getSquelchOpen() const { return m_squelchOpen; }
private: private:
class MsgConfigureWFMDemod : public Message { class MsgConfigureWFMDemod : public Message {
@ -55,10 +62,11 @@ private:
Real getAFBandwidth() const { return m_afBandwidth; } Real getAFBandwidth() const { return m_afBandwidth; }
Real getVolume() const { return m_volume; } Real getVolume() const { return m_volume; }
Real getSquelch() const { return m_squelch; } Real getSquelch() const { return m_squelch; }
bool getAudioMute() const { return m_audioMute; }
static MsgConfigureWFMDemod* create(Real rfBandwidth, Real afBandwidth, Real volume, Real squelch) static MsgConfigureWFMDemod* create(Real rfBandwidth, Real afBandwidth, Real volume, Real squelch, bool audioMute)
{ {
return new MsgConfigureWFMDemod(rfBandwidth, afBandwidth, volume, squelch); return new MsgConfigureWFMDemod(rfBandwidth, afBandwidth, volume, squelch, audioMute);
} }
private: private:
@ -66,13 +74,15 @@ private:
Real m_afBandwidth; Real m_afBandwidth;
Real m_volume; Real m_volume;
Real m_squelch; Real m_squelch;
bool m_audioMute;
MsgConfigureWFMDemod(Real rfBandwidth, Real afBandwidth, Real volume, Real squelch) : MsgConfigureWFMDemod(Real rfBandwidth, Real afBandwidth, Real volume, Real squelch, bool audioMute) :
Message(), Message(),
m_rfBandwidth(rfBandwidth), m_rfBandwidth(rfBandwidth),
m_afBandwidth(afBandwidth), m_afBandwidth(afBandwidth),
m_volume(volume), m_volume(volume),
m_squelch(squelch) m_squelch(squelch),
m_audioMute(audioMute)
{ } { }
}; };
@ -95,6 +105,7 @@ private:
Real m_squelch; Real m_squelch;
Real m_volume; Real m_volume;
quint32 m_audioSampleRate; quint32 m_audioSampleRate;
bool m_audioMute;
Config() : Config() :
m_inputSampleRate(-1), m_inputSampleRate(-1),
@ -103,7 +114,8 @@ private:
m_afBandwidth(-1), m_afBandwidth(-1),
m_squelch(0), m_squelch(0),
m_volume(0), m_volume(0),
m_audioSampleRate(0) m_audioSampleRate(0),
m_audioMute(false)
{ } { }
}; };
@ -118,6 +130,7 @@ private:
Real m_squelchLevel; Real m_squelchLevel;
int m_squelchState; int m_squelchState;
bool m_squelchOpen;
Real m_lastArgument; Real m_lastArgument;
MovingAverage<double> m_movingAverage; MovingAverage<double> m_movingAverage;

View File

@ -192,6 +192,11 @@ void WFMDemodGUI::on_squelch_valueChanged(int value)
applySettings(); applySettings();
} }
void WFMDemodGUI::on_audioMute_toggled(bool checked)
{
m_audioMute = checked;
applySettings();
}
void WFMDemodGUI::onWidgetRolled(QWidget* widget, bool rollDown) void WFMDemodGUI::onWidgetRolled(QWidget* widget, bool rollDown)
{ {
@ -288,7 +293,8 @@ void WFMDemodGUI::applySettings()
m_rfBW[ui->rfBW->currentIndex()], m_rfBW[ui->rfBW->currentIndex()],
ui->afBW->value() * 1000.0, ui->afBW->value() * 1000.0,
ui->volume->value() / 10.0, ui->volume->value() / 10.0,
ui->squelch->value()); ui->squelch->value(),
ui->audioMute->isChecked());
} }
} }
@ -311,4 +317,17 @@ void WFMDemodGUI::tick()
Real powDb = CalcDb::dbPower(m_wfmDemod->getMagSq()); Real powDb = CalcDb::dbPower(m_wfmDemod->getMagSq());
m_channelPowerDbAvg.feed(powDb); m_channelPowerDbAvg.feed(powDb);
ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1)); ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1));
bool squelchOpen = m_wfmDemod->getSquelchOpen();
if (squelchOpen != m_squelchOpen)
{
if (squelchOpen) {
ui->audioMute->setStyleSheet("QToolButton { background-color : green; }");
} else {
ui->audioMute->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
}
m_squelchOpen = squelchOpen;
}
} }

View File

@ -45,6 +45,7 @@ private slots:
void on_afBW_valueChanged(int value); void on_afBW_valueChanged(int value);
void on_volume_valueChanged(int value); void on_volume_valueChanged(int value);
void on_squelch_valueChanged(int value); void on_squelch_valueChanged(int value);
void on_audioMute_toggled(bool checked);
void onWidgetRolled(QWidget* widget, bool rollDown); void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDoubleClicked(); void onMenuDoubleClicked();
void tick(); void tick();
@ -56,6 +57,8 @@ private:
ChannelMarker m_channelMarker; ChannelMarker m_channelMarker;
bool m_basicSettingsShown; bool m_basicSettingsShown;
bool m_doApplySettings; bool m_doApplySettings;
bool m_audioMute;
bool m_squelchOpen;
ThreadedBasebandSampleSink* m_threadedChannelizer; ThreadedBasebandSampleSink* m_threadedChannelizer;
DownChannelizer* m_channelizer; DownChannelizer* m_channelizer;

View File

@ -6,10 +6,22 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>288</width> <width>302</width>
<height>147</height> <height>170</height>
</rect> </rect>
</property> </property>
<property name="minimumSize">
<size>
<width>302</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>302</width>
<height>16777215</height>
</size>
</property>
<property name="font"> <property name="font">
<font> <font>
<family>Sans Serif</family> <family>Sans Serif</family>
@ -22,12 +34,24 @@
<widget class="QWidget" name="settingsContainer" native="true"> <widget class="QWidget" name="settingsContainer" native="true">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>0</x>
<y>10</y> <y>0</y>
<width>261</width> <width>300</width>
<height>121</height> <height>161</height>
</rect> </rect>
</property> </property>
<property name="minimumSize">
<size>
<width>300</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Settings</string> <string>Settings</string>
</property> </property>
@ -35,7 +59,16 @@
<property name="spacing"> <property name="spacing">
<number>3</number> <number>3</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number> <number>2</number>
</property> </property>
<item> <item>
@ -140,6 +173,42 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="levelMeterLAyout">
<item>
<widget class="QLabel" name="channelPowerMeter_2">
<property name="text">
<string>dB</string>
</property>
</widget>
</item>
<item>
<widget class="LevelMeterSignalDB" name="channelPowerMeter" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<family>Monospace</family>
<pointsize>8</pointsize>
</font>
</property>
<property name="toolTip">
<string>channelPowerMeterUnits</string>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<layout class="QHBoxLayout" name="afBandwidthLayout"> <layout class="QHBoxLayout" name="afBandwidthLayout">
<item> <item>
@ -209,7 +278,7 @@
<item> <item>
<layout class="QHBoxLayout" name="volumeLayout"> <layout class="QHBoxLayout" name="volumeLayout">
<item> <item>
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="volumeLabel">
<property name="text"> <property name="text">
<string>Vol</string> <string>Vol</string>
</property> </property>
@ -238,10 +307,16 @@
<widget class="QLabel" name="volumeText"> <widget class="QLabel" name="volumeText">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>50</width> <width>30</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="text"> <property name="text">
<string>2.0</string> <string>2.0</string>
</property> </property>
@ -255,7 +330,7 @@
<item> <item>
<layout class="QHBoxLayout" name="squelchLayout"> <layout class="QHBoxLayout" name="squelchLayout">
<item> <item>
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="squelchLabel">
<property name="text"> <property name="text">
<string>Sq</string> <string>Sq</string>
</property> </property>
@ -284,10 +359,16 @@
<widget class="QLabel" name="squelchText"> <widget class="QLabel" name="squelchText">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>50</width> <width>40</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="maximumSize">
<size>
<width>40</width>
<height>16777215</height>
</size>
</property>
<property name="text"> <property name="text">
<string>-40dB</string> <string>-40dB</string>
</property> </property>
@ -296,6 +377,21 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QToolButton" name="audioMute">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../sdrbase/resources/res.qrc">
<normaloff>:/sound_on.png</normaloff>
<normalon>:/sound_off.png</normalon>:/sound_on.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
@ -314,6 +410,12 @@
<header>gui/valuedial.h</header> <header>gui/valuedial.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>LevelMeterSignalDB</class>
<extends>QWidget</extends>
<header>gui/levelmeter.h</header>
<container>1</container>
</customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="../../../sdrbase/resources/res.qrc"/> <include location="../../../sdrbase/resources/res.qrc"/>