1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-09-27 15:26:33 -04:00

Channel analyzer: 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 05:28:11 +02:00
parent 1ac49ce8ce
commit f1cd4bf992
14 changed files with 299 additions and 5027 deletions

View File

@ -33,8 +33,8 @@ ENDIF()
##############################################################################
#include(${QT_USE_FILE})
set( QT_DEFINITIONS "${QT_DEFINITIONS} -DQT_NO_DEBUG_OUTPUT" )
#set( QT_DEFINITIONS "${QT_DEFINITIONS}" )
#set( QT_DEFINITIONS "${QT_DEFINITIONS} -DQT_NO_DEBUG_OUTPUT" )
set( QT_DEFINITIONS "${QT_DEFINITIONS}" )
add_definitions(${QT_DEFINITIONS})
if(MSVC)
@ -110,11 +110,11 @@ set(sdrbase_SOURCES
sdrbase/settings/preset.cpp
sdrbase/settings/mainsettings.cpp
sdrbase/util/db.cpp
sdrbase/util/message.cpp
sdrbase/util/messagequeue.cpp
sdrbase/util/prettyprint.cpp
sdrbase/util/syncmessenger.cpp
#sdrbase/util/miniz.cpp
sdrbase/util/samplesourceserializer.cpp
sdrbase/util/simpleserializer.cpp
#sdrbase/util/spinlock.cpp
@ -188,12 +188,12 @@ set(sdrbase_HEADERS
include/settings/preset.h
include/settings/mainsettings.h
include/util/db.h
include/util/export.h
include/util/message.h
include/util/messagequeue.h
include/util/prettyprint.h
include/util/syncmessenger.h
#include/util/miniz.h
include/util/samplesourceserializer.h
include/util/simpleserializer.h
#include/util/spinlock.h

View File

@ -81,12 +81,6 @@ If you use your own location for libhackrf install directory you need to specify
HackRF is better used with a sampling frequency over 8 MS/s. You can use the 9.6Ms/s setting that decimates nicely into integer kS/s sample rates. There are quite a few problems with narrowband work with this hardware. You may try various amplifiers settings to limit images and I/Q imbalance with varying success... The cheap RTL-SDR dongles usually do better.
<h2>FunCube Dongle</h2>
Both Pro and Pro+ are supported with the plugins in fcdpro and fcdproplus respectively. For the Pro+ the band filter selection is not effective as it is handled by the firmware using the center frequency.
The control interface is based on qthid and has been built in the software in the fcdhid library. You don't need anything else than libusb support. Library fcdlib is used to store the constants for each dongle type.
<h2>RTL-SDR</h2>
RTL-SDR based dongles are supported through the librtlsdr library that should be installed in your system for proper build of the software and operation support. Add `librtlsdr-dev` to the list of dependencies to install.
@ -124,6 +118,7 @@ Assuming Debian Jessie is used:
- The message queuing model supports a n:1 connection to an object (on its input queue) and a 1:1 connection from an object (on its output queue). Assuming a different model can cause insidious disruptions.
- As the objects input and output queues can be publicly accessed there is no strict control of which objects post messages on these queues. The correct assumption is that messages can be popped from the input queue only by its holder and that messages can be pushed on the output queue only by its holder.
- Objects managing more than one message queue (input + output for example) do not work well under stress conditions. Output queue removed from sample sources but this model has to be revised throughout the application.
- Tx tabs are just appetizers for the moment and are disabled.
<h1>Changes from SDRangelove</h1>

28
include/util/db.h Normal file
View File

@ -0,0 +1,28 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_UTIL_DB_H_
#define INCLUDE_UTIL_DB_H_
#include "dsp/dsptypes.h"
class CalcDb
{
public:
static Real dbPower(Real magsq);
};
#endif /* INCLUDE_UTIL_DB_H_ */

View File

@ -1,7 +0,0 @@
#ifndef INCLUDE_MINIZ_H
#define INCLUDE_MINIZ_H
#define MINIZ_HEADER_FILE_ONLY
#include "../../sdrapp/util/miniz.cpp"
#endif // INCLUDE_MINIZ_H

View File

@ -1,7 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
// written by Christian Daniel //
// (c) 2014 Modified by John Greb
// Copyright (C) 2015 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
@ -41,6 +39,7 @@ ChannelAnalyzer::ChannelAnalyzer(SampleSink* sampleSink) :
m_sum = 0;
m_usb = true;
m_ssb = true;
m_magsq = 0;
SSBFilter = new fftfilt(m_LowCutoff / m_sampleRate, m_Bandwidth / m_sampleRate, ssbFftLen);
DSBFilter = new fftfilt(m_Bandwidth / m_sampleRate, 2*ssbFftLen);
}
@ -94,6 +93,7 @@ void ChannelAnalyzer::feed(const SampleVector::const_iterator& begin, const Samp
if (!(m_undersampleCount++ & decim_mask))
{
m_sum /= decim;
m_magsq = m_sum.real() * m_sum.real() + m_sum.imag() * m_sum.imag();
if (m_ssb & !m_usb)
{ // invert spectrum for LSB

View File

@ -1,6 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
// written by Christian Daniel //
// Copyright (C) 2015 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
@ -39,9 +38,8 @@ public:
int spanLog2,
bool ssb);
int getSampleRate() const {
return m_sampleRate;
}
int getSampleRate() const { return m_sampleRate; }
Real getMagSq() const { return m_magsq; }
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
virtual void start();
@ -93,6 +91,7 @@ private:
int m_frequency;
bool m_usb;
bool m_ssb;
Real m_magsq;
NCO m_nco;
NCO m_nco_test;

View File

@ -1,3 +1,19 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QDockWidget>
#include <QMainWindow>
#include "ui_chanalyzergui.h"
@ -10,6 +26,7 @@
#include "gui/glscope.h"
#include "plugin/pluginapi.h"
#include "util/simpleserializer.h"
#include "util/db.h"
#include "gui/basicchannelsettingswidget.h"
#include "dsp/dspengine.h"
#include "mainwindow.h"
@ -140,12 +157,19 @@ void ChannelAnalyzerGUI::viewChanged()
applySettings();
}
void ChannelAnalyzerGUI::tick()
{
Real powDb = CalcDb::dbPower(m_channelAnalyzer->getMagSq());
m_channelPowerDbAvg.feed(powDb);
ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1));
}
void ChannelAnalyzerGUI::channelSampleRateChanged()
{
setNewRate(m_spanLog2);
}
void ChannelAnalyzerGUI::on_deltaMinus_clicked(bool minus)
void ChannelAnalyzerGUI::on_deltaMinus_toggled(bool minus)
{
int deltaFrequency = m_channelMarker.getCenterFrequency();
bool minusDelta = (deltaFrequency < 0);
@ -283,7 +307,8 @@ ChannelAnalyzerGUI::ChannelAnalyzerGUI(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);
@ -307,9 +332,10 @@ ChannelAnalyzerGUI::ChannelAnalyzerGUI(PluginAPI* pluginAPI, QWidget* parent) :
ui->glSpectrum->setDisplayWaterfall(true);
ui->glSpectrum->setDisplayMaxHold(true);
ui->glSpectrum->setSsbSpectrum(true);
ui->glSpectrum->connectTimer(m_pluginAPI->getMainWindow()->getMasterTimer());
ui->glSpectrum->connectTimer(m_pluginAPI->getMainWindow()->getMasterTimer());
ui->glScope->connectTimer(m_pluginAPI->getMainWindow()->getMasterTimer());
connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
//m_channelMarker = new ChannelMarker(this);
m_channelMarker.setColor(Qt::gray);

View File

@ -1,9 +1,26 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_CHANNELANALYZERGUI_H
#define INCLUDE_CHANNELANALYZERGUI_H
#include "gui/rollupwidget.h"
#include "plugin/plugingui.h"
#include "dsp/channelmarker.h"
#include "dsp/movingaverage.h"
class PluginAPI;
@ -40,13 +57,14 @@ private slots:
void viewChanged();
void channelSampleRateChanged();
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_spanLog2_valueChanged(int value);
void on_ssb_toggled(bool checked);
void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDoubleClicked();
void tick();
private:
Ui::ChannelAnalyzerGUI* ui;
@ -56,6 +74,7 @@ private:
bool m_doApplySettings;
int m_rate;
int m_spanLog2;
MovingAverage<Real> m_channelPowerDbAvg;
ThreadedSampleSink* m_threadedChannelizer;
Channelizer* m_channelizer;

View File

@ -55,7 +55,7 @@
<property name="verticalSpacing">
<number>3</number>
</property>
<item row="2" column="1">
<item row="2" column="2">
<widget class="QSlider" name="BW">
<property name="font">
<font>
@ -79,7 +79,7 @@
</property>
</widget>
</item>
<item row="2" column="2">
<item row="2" column="3">
<widget class="QLabel" name="BWText">
<property name="minimumSize">
<size>
@ -100,37 +100,6 @@
</property>
</widget>
</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>10</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="2" column="0">
<widget class="QLabel" name="BWLabel">
<property name="font">
@ -143,18 +112,6 @@
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="deltaUnits">
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="text">
<string>Hz</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="spanLabel">
<property name="font">
@ -179,22 +136,14 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="deltaMinus">
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<item row="1" column="4">
<widget class="QCheckBox" name="ssb">
<property name="text">
<string>Minus</string>
<string>SSB</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="3" column="2">
<widget class="QSlider" name="lowCut">
<property name="font">
<font>
@ -218,7 +167,7 @@
</property>
</widget>
</item>
<item row="3" column="2">
<item row="3" column="3">
<widget class="QLabel" name="lowCutText">
<property name="minimumSize">
<size>
@ -239,7 +188,7 @@
</property>
</widget>
</item>
<item row="1" column="2">
<item row="1" column="3">
<widget class="QLabel" name="spanText">
<property name="font">
<font>
@ -254,7 +203,7 @@
</property>
</widget>
</item>
<item row="1" column="1">
<item row="1" column="2">
<widget class="QSlider" name="spanLog2">
<property name="font">
<font>
@ -287,20 +236,7 @@
</property>
</widget>
</item>
<item row="0" column="3">
<spacer name="hSpacer1">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="3">
<item row="2" column="4">
<spacer name="hSpacer3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -313,7 +249,7 @@
</property>
</spacer>
</item>
<item row="3" column="3">
<item row="3" column="4">
<spacer name="hSpacer4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -326,13 +262,171 @@
</property>
</spacer>
</item>
<item row="1" column="3">
<widget class="QCheckBox" name="ssb">
<item row="0" column="0" colspan="2">
<layout class="QHBoxLayout" name="DeltaFrequencyLayout">
<item>
<widget class="QToolButton" name="deltaMinus">
<property name="text">
<string>SSB</string>
<string>...</string>
</property>
<property name="icon">
<iconset>
<selectedoff>:/plus.png</selectedoff>
<selectedon>:/minus.png</selectedon>
</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</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>10</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>
<zorder>hSpacer1</zorder>
</widget>
</item>
<item>
<widget class="QLabel" name="deltaUnits">
<property name="palette">
<palette>
<active>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>26</red>
<green>26</green>
<blue>26</blue>
</color>
</brush>
</colorrole>
<colorrole role="BrightText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>26</red>
<green>26</green>
<blue>26</blue>
</color>
</brush>
</colorrole>
<colorrole role="BrightText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>118</red>
<green>118</green>
<blue>117</blue>
</color>
</brush>
</colorrole>
<colorrole role="BrightText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="text">
<string> Hz</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="2">
<layout class="QHBoxLayout" name="ChannelPowerLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="channelPower">
<property name="layoutDirection">
<enum>Qt::LeftToRight</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>
</layout>
</widget>
<widget class="QWidget" name="spectrumContainer" native="true">
@ -472,6 +566,8 @@
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<resources>
<include location="../../../sdrbase/resources/res.qrc"/>
</resources>
<connections/>
</ui>

BIN
sdrbase/resources/minus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

BIN
sdrbase/resources/plus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

View File

@ -30,5 +30,7 @@
<file>stop.png</file>
<file>sdrangel_logo.png</file>
<file>sdrangel_icon.png</file>
<file>minus.png</file>
<file>plus.png</file>
</qresource>
</RCC>

30
sdrbase/util/db.cpp Normal file
View File

@ -0,0 +1,30 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "util/db.h"
#include <cmath>
Real CalcDb::dbPower(Real magsq)
{
if (magsq > 0)
{
return 10.0 * log10(magsq);
}
else
{
return 0;
}
}

File diff suppressed because it is too large Load Diff