1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-18 07:35:47 -05:00

SSB demod: added display of channel power in dB. Changed minus radio button for a iconified toggle button

This commit is contained in:
f4exb 2015-10-04 10:50:26 +02:00
parent 52dafd994b
commit 7663a9bc1d
5 changed files with 311 additions and 238 deletions

View File

@ -85,7 +85,8 @@ void SSBDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
for(SampleVector::const_iterator it = begin; it < end; ++it) for(SampleVector::const_iterator it = begin; it < end; ++it)
{ {
Complex c(it->real() / 32768.0, it->imag() / 32768.0); //Complex c(it->real() / 32768.0, it->imag() / 32768.0);
Complex c(it->real(), it->imag());
c *= m_nco.nextIQ(); c *= m_nco.nextIQ();
if(m_interpolator.interpolate(&m_sampleDistanceRemain, c, &ci)) if(m_interpolator.interpolate(&m_sampleDistanceRemain, c, &ci))
@ -100,7 +101,8 @@ void SSBDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
for (int i = 0; i < n_out; i++) for (int i = 0; i < n_out; i++)
{ {
Real demod = (sideband[i].real() + sideband[i].imag()) * 0.7 * 32768.0; //Real demod = (sideband[i].real() + sideband[i].imag()) * 0.7 * 32768.0;
Real demod = (sideband[i].real() + sideband[i].imag()) * 0.7;
// Downsample by 2^(m_scaleLog2 - 1) for SSB band spectrum display // Downsample by 2^(m_scaleLog2 - 1) for SSB band spectrum display
// smart decimation with bit gain using float arithmetic (23 bits significand) // smart decimation with bit gain using float arithmetic (23 bits significand)
@ -109,7 +111,11 @@ void SSBDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
if (!(m_undersampleCount++ & decim_mask)) if (!(m_undersampleCount++ & decim_mask))
{ {
avg = (sum.real() + sum.imag()) * 0.7 * 32768.0 / decim; Real avgr = sum.real() / decim;
Real avgi = sum.imag() / decim;
m_magsq = (avgr * avgr + avgi * avgi) / (1<<30);
//avg = (sum.real() + sum.imag()) * 0.7 * 32768.0 / decim;
avg = (avgr + avgi) * 0.7;
m_sampleBuffer.push_back(Sample(avg, 0.0)); m_sampleBuffer.push_back(Sample(avg, 0.0));
sum.real() = 0.0; sum.real() = 0.0;
sum.imag() = 0.0; sum.imag() = 0.0;

View File

@ -41,6 +41,8 @@ public:
virtual void stop(); virtual void stop();
virtual bool handleMessage(const Message& cmd); virtual bool handleMessage(const Message& cmd);
Real getMagSq() const { return m_magsq; }
private: private:
class MsgConfigureSSBDemod : public Message { class MsgConfigureSSBDemod : public Message {
MESSAGE_CLASS_DECLARATION MESSAGE_CLASS_DECLARATION
@ -85,6 +87,7 @@ private:
int m_sampleRate; int m_sampleRate;
int m_frequency; int m_frequency;
bool m_usb; bool m_usb;
Real m_magsq;
NCO m_nco; NCO m_nco;
Interpolator m_interpolator; Interpolator m_interpolator;

View File

@ -11,6 +11,7 @@
#include "gui/glspectrum.h" #include "gui/glspectrum.h"
#include "plugin/pluginapi.h" #include "plugin/pluginapi.h"
#include "util/simpleserializer.h" #include "util/simpleserializer.h"
#include "util/db.h"
#include "gui/basicchannelsettingswidget.h" #include "gui/basicchannelsettingswidget.h"
#include "dsp/dspengine.h" #include "dsp/dspengine.h"
#include "mainwindow.h" #include "mainwindow.h"
@ -131,7 +132,7 @@ void SSBDemodGUI::viewChanged()
applySettings(); applySettings();
} }
void SSBDemodGUI::on_deltaMinus_clicked(bool minus) void SSBDemodGUI::on_deltaMinus_toggled(bool minus)
{ {
int deltaFrequency = m_channelMarker.getCenterFrequency(); int deltaFrequency = m_channelMarker.getCenterFrequency();
bool minusDelta = (deltaFrequency < 0); bool minusDelta = (deltaFrequency < 0);
@ -255,7 +256,8 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
m_basicSettingsShown(false), m_basicSettingsShown(false),
m_doApplySettings(true), m_doApplySettings(true),
m_rate(6000), m_rate(6000),
m_spanLog2(3) m_spanLog2(3),
m_channelPowerDbAvg(20,0)
{ {
ui->setupUi(this); ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true); setAttribute(Qt::WA_DeleteOnClose, true);
@ -277,6 +279,8 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
ui->glSpectrum->setSsbSpectrum(true); ui->glSpectrum->setSsbSpectrum(true);
ui->glSpectrum->connectTimer(m_pluginAPI->getMainWindow()->getMasterTimer()); ui->glSpectrum->connectTimer(m_pluginAPI->getMainWindow()->getMasterTimer());
connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
//m_channelMarker = new ChannelMarker(this); //m_channelMarker = new ChannelMarker(this);
m_channelMarker.setColor(Qt::green); m_channelMarker.setColor(Qt::green);
m_channelMarker.setBandwidth(m_rate); m_channelMarker.setBandwidth(m_rate);
@ -388,3 +392,9 @@ void SSBDemodGUI::enterEvent(QEvent*)
blockApplySettings(false); blockApplySettings(false);
} }
void SSBDemodGUI::tick()
{
Real powDb = CalcDb::dbPower(m_ssbDemod->getMagSq());
m_channelPowerDbAvg.feed(powDb);
ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1));
}

View File

@ -4,6 +4,7 @@
#include "gui/rollupwidget.h" #include "gui/rollupwidget.h"
#include "plugin/plugingui.h" #include "plugin/plugingui.h"
#include "dsp/channelmarker.h" #include "dsp/channelmarker.h"
#include "dsp/movingaverage.h"
class PluginAPI; class PluginAPI;
@ -38,13 +39,14 @@ public:
private slots: private slots:
void viewChanged(); void viewChanged();
void on_deltaFrequency_changed(quint64 value); void on_deltaFrequency_changed(quint64 value);
void on_deltaMinus_clicked(bool minus); void on_deltaMinus_toggled(bool minus);
void on_BW_valueChanged(int value); void on_BW_valueChanged(int value);
void on_lowCut_valueChanged(int value); void on_lowCut_valueChanged(int value);
void on_volume_valueChanged(int value); void on_volume_valueChanged(int value);
void on_spanLog2_valueChanged(int value); void on_spanLog2_valueChanged(int value);
void onWidgetRolled(QWidget* widget, bool rollDown); void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDoubleClicked(); void onMenuDoubleClicked();
void tick();
private: private:
Ui::SSBDemodGUI* ui; Ui::SSBDemodGUI* ui;
@ -54,6 +56,7 @@ private:
bool m_doApplySettings; bool m_doApplySettings;
int m_rate; int m_rate;
int m_spanLog2; int m_spanLog2;
MovingAverage<Real> m_channelPowerDbAvg;
ThreadedSampleSink* m_threadedChannelizer; ThreadedSampleSink* m_threadedChannelizer;
Channelizer* m_channelizer; Channelizer* m_channelizer;

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>302</width> <width>302</width>
<height>510</height> <height>537</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
@ -22,16 +22,19 @@
<widget class="QWidget" name="settingsContainer" native="true"> <widget class="QWidget" name="settingsContainer" native="true">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>35</x> <x>5</x>
<y>35</y> <y>35</y>
<width>242</width> <width>281</width>
<height>96</height> <height>349</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Settings</string> <string>Settings</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin"> <property name="leftMargin">
<number>2</number> <number>2</number>
</property> </property>
@ -44,74 +47,25 @@
<property name="bottomMargin"> <property name="bottomMargin">
<number>2</number> <number>2</number>
</property> </property>
<property name="spacing"> <item>
<number>3</number> <layout class="QHBoxLayout" name="deltaFrequencyLayout">
</property> <item>
<item row="2" column="1"> <widget class="QToolButton" name="deltaMinus">
<widget class="QSlider" name="BW">
<property name="minimum">
<number>-60</number>
</property>
<property name="maximum">
<number>60</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>30</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QLabel" name="volumeText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text"> <property name="text">
<string>2.0</string> <string>...</string>
</property> </property>
<property name="alignment"> <property name="icon">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <iconset>
<selectedoff>:/plus.png</selectedoff>
<selectedon>:/minus.png</selectedon>
</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="2"> <item>
<widget class="QLabel" name="BWText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>3.0k</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSlider" name="volume">
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>20</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="ValueDial" name="deltaFrequency" native="true"> <widget class="ValueDial" name="deltaFrequency" native="true">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum"> <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
@ -142,97 +96,45 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item>
<widget class="QLabel" name="deltaUnits"> <widget class="QLabel" name="deltaUnits">
<property name="text"> <property name="text">
<string>Hz </string> <string>Hz </string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item>
<widget class="QLabel" name="volumeLabel"> <widget class="QLabel" name="channelPower">
<property name="toolTip">
<string>Channel power</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text"> <property name="text">
<string>Volume</string> <string>0.0</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item>
<widget class="QLabel" name="BWLabel"> <widget class="QLabel" name="channelPowerUnits">
<property name="text"> <property name="text">
<string>Bandwidth</string> <string> dB</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> </layout>
</item>
<item>
<layout class="QHBoxLayout" name="spanLayout">
<item>
<widget class="QLabel" name="spanLabel"> <widget class="QLabel" name="spanLabel">
<property name="text"> <property name="text">
<string>Span</string> <string>Span</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item>
<widget class="QLabel" name="lowCutLabel">
<property name="text">
<string>Low cutoff</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="deltaMinus">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Minus</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSlider" name="lowCut">
<property name="minimum">
<number>-60</number>
</property>
<property name="maximum">
<number>60</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>3</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLabel" name="lowCutText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0.3k</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="spanText">
<property name="text">
<string>6.0k</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="spanLog2"> <widget class="QSlider" name="spanLog2">
<property name="minimum"> <property name="minimum">
<number>1</number> <number>1</number>
@ -260,13 +162,157 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QLabel" name="spanText">
<property name="text">
<string>6.0k</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="bqndwidthLayout">
<item>
<widget class="QLabel" name="BWLabel">
<property name="text">
<string>BW</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="BW">
<property name="minimum">
<number>-60</number>
</property>
<property name="maximum">
<number>60</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>30</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="BWText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>3.0k</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="lowCutLayout">
<item>
<widget class="QLabel" name="lowCutLabel">
<property name="text">
<string>Low cut</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lowCutText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0.3k</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="lowCut">
<property name="minimum">
<number>-60</number>
</property>
<property name="maximum">
<number>60</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>3</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="volumeLayout">
<item>
<widget class="QLabel" name="volumeLabel">
<property name="text">
<string>Vol</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="volume">
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>20</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="volumeText">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>2.0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="spectrumContainer" native="true"> <widget class="QWidget" name="spectrumContainer" native="true">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>40</x> <x>30</x>
<y>140</y> <y>390</y>
<width>218</width> <width>218</width>
<height>284</height> <height>284</height>
</rect> </rect>
@ -307,24 +353,15 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="GLSpectrumGUI" name="spectrumGUI" native="true"/> <widget class="GLSpectrumGUI" name="spectrumGUI" native="true">
<zorder>glSpectrum</zorder>
<zorder>glSpectrum</zorder>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget>
<class>GLSpectrum</class>
<extends>QWidget</extends>
<header>gui/glspectrum.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GLSpectrumGUI</class>
<extends>QWidget</extends>
<header>gui/glspectrumgui.h</header>
<container>1</container>
</customwidget>
<customwidget> <customwidget>
<class>RollupWidget</class> <class>RollupWidget</class>
<extends>QWidget</extends> <extends>QWidget</extends>
@ -337,7 +374,21 @@
<header>gui/valuedial.h</header> <header>gui/valuedial.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>GLSpectrum</class>
<extends>QWidget</extends>
<header>gui/glspectrum.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GLSpectrumGUI</class>
<extends>QWidget</extends>
<header>gui/glspectrumgui.h</header>
<container>1</container>
</customwidget>
</customwidgets> </customwidgets>
<resources/> <resources>
<include location="../../../sdrbase/resources/res.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>