1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-06-24 13:05:21 -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);
}
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);
}
@ -98,16 +104,23 @@ void WFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
if(m_movingAverage.average() >= m_squelchLevel)
m_squelchState = m_running.m_rfBandwidth / 20; // decay rate
if(m_squelchState > 0)
if (m_squelchState > 0)
{
m_squelchState--;
m_squelchOpen = true;
}
else
{
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))
{
@ -191,11 +204,13 @@ bool WFMDemod::handleMessage(const Message& cmd)
m_config.m_afBandwidth = cfg.getAFBandwidth();
m_config.m_volume = cfg.getVolume();
m_config.m_squelch = cfg.getSquelch();
m_config.m_audioMute = cfg.getAudioMute();
qDebug() << "WFMDemod::handleMessage: MsgConfigureWFMDemod: m_rfBandwidth: " << m_config.m_rfBandwidth
<< " m_afBandwidth: " << m_config.m_afBandwidth
<< " 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();
@ -258,5 +273,5 @@ void WFMDemod::apply()
m_running.m_squelch = m_config.m_squelch;
m_running.m_volume = m_config.m_volume;
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);
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 start();
@ -45,6 +51,7 @@ public:
virtual bool handleMessage(const Message& cmd);
Real getMagSq() const { return m_movingAverage.average(); }
bool getSquelchOpen() const { return m_squelchOpen; }
private:
class MsgConfigureWFMDemod : public Message {
@ -55,10 +62,11 @@ private:
Real getAFBandwidth() const { return m_afBandwidth; }
Real getVolume() const { return m_volume; }
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:
@ -66,13 +74,15 @@ private:
Real m_afBandwidth;
Real m_volume;
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(),
m_rfBandwidth(rfBandwidth),
m_afBandwidth(afBandwidth),
m_volume(volume),
m_squelch(squelch)
m_squelch(squelch),
m_audioMute(audioMute)
{ }
};
@ -95,6 +105,7 @@ private:
Real m_squelch;
Real m_volume;
quint32 m_audioSampleRate;
bool m_audioMute;
Config() :
m_inputSampleRate(-1),
@ -103,7 +114,8 @@ private:
m_afBandwidth(-1),
m_squelch(0),
m_volume(0),
m_audioSampleRate(0)
m_audioSampleRate(0),
m_audioMute(false)
{ }
};
@ -118,6 +130,7 @@ private:
Real m_squelchLevel;
int m_squelchState;
bool m_squelchOpen;
Real m_lastArgument;
MovingAverage<double> m_movingAverage;

View File

@ -192,6 +192,11 @@ void WFMDemodGUI::on_squelch_valueChanged(int value)
applySettings();
}
void WFMDemodGUI::on_audioMute_toggled(bool checked)
{
m_audioMute = checked;
applySettings();
}
void WFMDemodGUI::onWidgetRolled(QWidget* widget, bool rollDown)
{
@ -288,7 +293,8 @@ void WFMDemodGUI::applySettings()
m_rfBW[ui->rfBW->currentIndex()],
ui->afBW->value() * 1000.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());
m_channelPowerDbAvg.feed(powDb);
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_volume_valueChanged(int value);
void on_squelch_valueChanged(int value);
void on_audioMute_toggled(bool checked);
void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDoubleClicked();
void tick();
@ -56,6 +57,8 @@ private:
ChannelMarker m_channelMarker;
bool m_basicSettingsShown;
bool m_doApplySettings;
bool m_audioMute;
bool m_squelchOpen;
ThreadedBasebandSampleSink* m_threadedChannelizer;
DownChannelizer* m_channelizer;

View File

@ -6,10 +6,22 @@
<rect>
<x>0</x>
<y>0</y>
<width>288</width>
<height>147</height>
<width>302</width>
<height>170</height>
</rect>
</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">
<font>
<family>Sans Serif</family>
@ -22,12 +34,24 @@
<widget class="QWidget" name="settingsContainer" native="true">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>261</width>
<height>121</height>
<x>0</x>
<y>0</y>
<width>300</width>
<height>161</height>
</rect>
</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">
<string>Settings</string>
</property>
@ -35,7 +59,16 @@
<property name="spacing">
<number>3</number>
</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>
</property>
<item>
@ -140,6 +173,42 @@
</item>
</layout>
</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>
<layout class="QHBoxLayout" name="afBandwidthLayout">
<item>
@ -209,7 +278,7 @@
<item>
<layout class="QHBoxLayout" name="volumeLayout">
<item>
<widget class="QLabel" name="label_3">
<widget class="QLabel" name="volumeLabel">
<property name="text">
<string>Vol</string>
</property>
@ -238,10 +307,16 @@
<widget class="QLabel" name="volumeText">
<property name="minimumSize">
<size>
<width>50</width>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>2.0</string>
</property>
@ -255,7 +330,7 @@
<item>
<layout class="QHBoxLayout" name="squelchLayout">
<item>
<widget class="QLabel" name="label_4">
<widget class="QLabel" name="squelchLabel">
<property name="text">
<string>Sq</string>
</property>
@ -284,10 +359,16 @@
<widget class="QLabel" name="squelchText">
<property name="minimumSize">
<size>
<width>50</width>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>-40dB</string>
</property>
@ -296,6 +377,21 @@
</property>
</widget>
</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>
</item>
</layout>
@ -314,6 +410,12 @@
<header>gui/valuedial.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>LevelMeterSignalDB</class>
<extends>QWidget</extends>
<header>gui/levelmeter.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../../sdrbase/resources/res.qrc"/>