1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-17 23:28:50 -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)
{
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();
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++)
{
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
// 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))
{
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));
sum.real() = 0.0;
sum.imag() = 0.0;

View File

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

View File

@ -11,6 +11,7 @@
#include "gui/glspectrum.h"
#include "plugin/pluginapi.h"
#include "util/simpleserializer.h"
#include "util/db.h"
#include "gui/basicchannelsettingswidget.h"
#include "dsp/dspengine.h"
#include "mainwindow.h"
@ -131,7 +132,7 @@ void SSBDemodGUI::viewChanged()
applySettings();
}
void SSBDemodGUI::on_deltaMinus_clicked(bool minus)
void SSBDemodGUI::on_deltaMinus_toggled(bool minus)
{
int deltaFrequency = m_channelMarker.getCenterFrequency();
bool minusDelta = (deltaFrequency < 0);
@ -255,7 +256,8 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
m_basicSettingsShown(false),
m_doApplySettings(true),
m_rate(6000),
m_spanLog2(3)
m_spanLog2(3),
m_channelPowerDbAvg(20,0)
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
@ -277,6 +279,8 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
ui->glSpectrum->setSsbSpectrum(true);
ui->glSpectrum->connectTimer(m_pluginAPI->getMainWindow()->getMasterTimer());
connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
//m_channelMarker = new ChannelMarker(this);
m_channelMarker.setColor(Qt::green);
m_channelMarker.setBandwidth(m_rate);
@ -388,3 +392,9 @@ void SSBDemodGUI::enterEvent(QEvent*)
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 "plugin/plugingui.h"
#include "dsp/channelmarker.h"
#include "dsp/movingaverage.h"
class PluginAPI;
@ -38,13 +39,14 @@ public:
private slots:
void viewChanged();
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_lowCut_valueChanged(int value);
void on_volume_valueChanged(int value);
void on_spanLog2_valueChanged(int value);
void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDoubleClicked();
void tick();
private:
Ui::SSBDemodGUI* ui;
@ -54,6 +56,7 @@ private:
bool m_doApplySettings;
int m_rate;
int m_spanLog2;
MovingAverage<Real> m_channelPowerDbAvg;
ThreadedSampleSink* m_threadedChannelizer;
Channelizer* m_channelizer;

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>302</width>
<height>510</height>
<height>537</height>
</rect>
</property>
<property name="minimumSize">
@ -22,16 +22,19 @@
<widget class="QWidget" name="settingsContainer" native="true">
<property name="geometry">
<rect>
<x>35</x>
<x>5</x>
<y>35</y>
<width>242</width>
<height>96</height>
<width>281</width>
<height>349</height>
</rect>
</property>
<property name="windowTitle">
<string>Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
@ -44,229 +47,272 @@
<property name="bottomMargin">
<number>2</number>
</property>
<property name="spacing">
<number>3</number>
</property>
<item row="2" column="1">
<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>
<layout class="QHBoxLayout" name="deltaFrequencyLayout">
<item>
<widget class="QToolButton" name="deltaMinus">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<selectedoff>:/plus.png</selectedoff>
<selectedon>:/minus.png</selectedon>
</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="ValueDial" name="deltaFrequency" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>32</width>
<height>16</height>
</size>
</property>
<property name="font">
<font>
<family>Monospace</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="cursor">
<cursorShape>SizeVerCursor</cursorShape>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>Demod shift frequency from center in Hz</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="deltaUnits">
<property name="text">
<string>Hz </string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="channelPower">
<property name="toolTip">
<string>Channel power</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>0.0</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="channelPowerUnits">
<property name="text">
<string> dB</string>
</property>
</widget>
</item>
</layout>
</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">
<string>2.0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<item>
<layout class="QHBoxLayout" name="spanLayout">
<item>
<widget class="QLabel" name="spanLabel">
<property name="text">
<string>Span</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="spanLog2">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>5</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>3</number>
</property>
<property name="sliderPosition">
<number>3</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="invertedAppearance">
<bool>true</bool>
</property>
<property name="invertedControls">
<bool>true</bool>
</property>
</widget>
</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 row="2" column="2">
<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 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 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>
<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 row="0" column="1">
<widget class="ValueDial" name="deltaFrequency" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>32</width>
<height>16</height>
</size>
</property>
<property name="font">
<font>
<family>Monospace</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="cursor">
<cursorShape>SizeVerCursor</cursorShape>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>Demod shift frequency from center in Hz</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="deltaUnits">
<property name="text">
<string>Hz</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="volumeLabel">
<property name="text">
<string>Volume</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="BWLabel">
<property name="text">
<string>Bandwidth</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="spanLabel">
<property name="text">
<string>Span</string>
</property>
</widget>
</item>
<item row="3" column="0">
<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">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>5</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>3</number>
</property>
<property name="sliderPosition">
<number>3</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="invertedAppearance">
<bool>true</bool>
</property>
<property name="invertedControls">
<bool>true</bool>
</property>
</widget>
<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>
</widget>
<widget class="QWidget" name="spectrumContainer" native="true">
<property name="geometry">
<rect>
<x>40</x>
<y>140</y>
<x>30</x>
<y>390</y>
<width>218</width>
<height>284</height>
</rect>
@ -307,24 +353,15 @@
</widget>
</item>
<item>
<widget class="GLSpectrumGUI" name="spectrumGUI" native="true"/>
<widget class="GLSpectrumGUI" name="spectrumGUI" native="true">
<zorder>glSpectrum</zorder>
<zorder>glSpectrum</zorder>
</widget>
</item>
</layout>
</widget>
</widget>
<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>
<class>RollupWidget</class>
<extends>QWidget</extends>
@ -337,7 +374,21 @@
<header>gui/valuedial.h</header>
<container>1</container>
</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>
<resources/>
<resources>
<include location="../../../sdrbase/resources/res.qrc"/>
</resources>
<connections/>
</ui>