1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-10 10:33:29 -05:00

UDPSource and UDPSink plugins: UI refactoring

This commit is contained in:
f4exb 2017-08-17 12:57:45 +02:00
parent ca722811cd
commit c601d8dbaa
10 changed files with 269 additions and 235 deletions

View File

@ -30,6 +30,7 @@ MESSAGE_CLASS_DEFINITION(UDPSrc::MsgUDPSrcSpectrum, Message)
UDPSrc::UDPSrc(MessageQueue* uiMessageQueue, UDPSrcGUI* udpSrcGUI, BasebandSampleSink* spectrum) :
m_udpPort(9999),
m_gain(1.0),
m_audioActive(false),
m_audioStereo(false),
m_volume(20),
@ -65,7 +66,6 @@ UDPSrc::UDPSrc(MessageQueue* uiMessageQueue, UDPSrcGUI* udpSrcGUI, BasebandSampl
m_last = 0;
m_this = 0;
m_scale = 0;
m_boost = 0;
m_magsq = 0;
UDPFilter = new fftfilt(0.0, (m_rfBandwidth / 2.0) / m_outputSampleRate, udpBlockSize);
@ -116,7 +116,7 @@ void UDPSrc::configure(MessageQueue* messageQueue,
void UDPSrc::configureImmediate(MessageQueue* messageQueue,
bool audioActive,
bool audioStereo,
int boost,
Real boost,
int volume)
{
Message* cmd = MsgUDPSrcConfigureImmediate::create(
@ -141,7 +141,6 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
m_sampleBuffer.clear();
m_settingsMutex.lock();
int rescale = (1 << m_boost);
for(SampleVector::const_iterator it = begin; it < end; ++it)
{
@ -150,8 +149,8 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
if(m_interpolator.decimate(&m_sampleDistanceRemain, c, &ci))
{
m_magsq = ((ci.real()*ci.real() + ci.imag()*ci.imag())*rescale*rescale) / (1<<30);
Sample s(ci.real() * rescale, ci.imag() * rescale);
m_magsq = ((ci.real()*ci.real() + ci.imag()*ci.imag())*m_gain*m_gain) / (1<<30);
Sample s(ci.real() * m_gain, ci.imag() * m_gain);
m_sampleBuffer.push_back(s);
m_sampleDistanceRemain += m_inputSampleRate / m_outputSampleRate;
@ -298,9 +297,9 @@ bool UDPSrc::handleMessage(const Message& cmd)
m_audioStereo = cfg.getAudioStereo();
}
if (cfg.getBoost() != m_boost)
if (cfg.getGain() != m_gain)
{
m_boost = cfg.getBoost();
m_gain = cfg.getGain();
}
if (cfg.getVolume() != m_volume)
@ -313,7 +312,7 @@ bool UDPSrc::handleMessage(const Message& cmd)
qDebug() << "UDPSrc::handleMessage: MsgUDPSrcConfigureImmediate: "
<< " m_audioActive: " << m_audioActive
<< " m_audioStereo: " << m_audioStereo
<< " m_boost: " << m_boost
<< " m_gain: " << m_gain
<< " m_volume: " << m_volume;
return true;
@ -377,7 +376,6 @@ bool UDPSrc::handleMessage(const Message& cmd)
qDebug() << "UDPSrc::handleMessage: MsgUDPSrcConfigure: m_sampleFormat: " << m_sampleFormat
<< " m_outputSampleRate: " << m_outputSampleRate
<< " m_rfBandwidth: " << m_rfBandwidth
<< " m_boost: " << m_boost
<< " m_udpAddressStr: " << m_udpAddressStr
<< " m_udpPort: " << m_udpPort
<< " m_audioPort: " << m_audioPort;

View File

@ -70,7 +70,7 @@ public:
void configureImmediate(MessageQueue* messageQueue,
bool audioActive,
bool audioStereo,
int boost,
Real gain,
int volume);
void setSpectrum(MessageQueue* messageQueue, bool enabled);
double getMagSq() const { return m_magsq; }
@ -147,7 +147,7 @@ protected:
MESSAGE_CLASS_DECLARATION
public:
int getBoost() const { return m_boost; }
Real getGain() const { return m_gain; }
int getVolume() const { return m_volume; }
bool getAudioActive() const { return m_audioActive; }
bool getAudioStereo() const { return m_audioStereo; }
@ -166,7 +166,7 @@ protected:
}
private:
int m_boost;
Real m_gain;
int m_volume;
bool m_audioActive;
bool m_audioStereo;
@ -174,10 +174,10 @@ protected:
MsgUDPSrcConfigureImmediate(
bool audioActive,
bool audioStereo,
int boost,
Real gain,
int volume) :
Message(),
m_boost(boost),
m_gain(gain),
m_volume(volume),
m_audioActive(audioActive),
m_audioStereo(audioStereo)
@ -216,7 +216,7 @@ protected:
QString m_udpAddressStr;
quint16 m_udpPort;
quint16 m_audioPort;
int m_boost;
Real m_gain;
bool m_audioActive;
bool m_audioStereo;
int m_volume;

View File

@ -77,7 +77,7 @@ void UDPSrcGUI::resetToDefaults()
ui->udpPort->setText("9999");
ui->audioPort->setText("9999");
ui->spectrumGUI->resetToDefaults();
ui->boost->setValue(1);
ui->gain->setValue(10);
ui->volume->setValue(20);
ui->audioActive->setChecked(false);
ui->audioStereo->setChecked(false);
@ -97,7 +97,7 @@ QByteArray UDPSrcGUI::serialize() const
s.writeReal(5, m_rfBandwidth);
s.writeS32(6, m_udpPort);
s.writeBlob(7, ui->spectrumGUI->serialize());
s.writeS32(8, (qint32)m_boost);
s.writeS32(8, ui->gain->value());
s.writeS32(9, m_channelMarker.getCenterFrequency());
s.writeString(10, m_udpAddress);
s.writeBool(11, m_audioActive);
@ -171,8 +171,9 @@ bool UDPSrcGUI::deserialize(const QByteArray& data)
ui->udpPort->setText(QString("%1").arg(s32tmp));
d.readBlob(7, &bytetmp);
ui->spectrumGUI->deserialize(bytetmp);
d.readS32(8, &s32tmp, 1);
ui->boost->setValue(s32tmp);
d.readS32(16, &s32tmp, 10);
ui->gain->setValue(s32tmp);
ui->gainText->setText(tr("%1").arg(s32tmp/10.0, 0, 'f', 1));
d.readS32(9, &s32tmp, 0);
m_channelMarker.setCenterFrequency(s32tmp);
d.readString(10, &strtmp, "127.0.0.1");
@ -181,6 +182,7 @@ bool UDPSrcGUI::deserialize(const QByteArray& data)
ui->audioActive->setChecked(booltmp);
d.readS32(12, &s32tmp, 20);
ui->volume->setValue(s32tmp);
ui->volumeText->setText(QString("%1").arg(s32tmp));
d.readS32(13, &s32tmp, 9998);
ui->audioPort->setText(QString("%1").arg(s32tmp));
d.readBool(14, &booltmp, false);
@ -215,9 +217,14 @@ void UDPSrcGUI::channelMarkerChanged()
void UDPSrcGUI::tick()
{
double powDb = CalcDb::dbPower(m_udpSrc->getMagSq());
m_channelPowerDbAvg.feed(powDb);
ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1));
if (m_tickCount % 4 == 0)
{
m_channelPowerAvg.feed(m_udpSrc->getMagSq());
double powDb = CalcDb::dbPower(m_channelPowerAvg.average());
ui->channelPower->setText(QString::number(powDb, 'f', 1));
}
m_tickCount++;
}
UDPSrcGUI::UDPSrcGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget* parent) :
@ -227,8 +234,9 @@ UDPSrcGUI::UDPSrcGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget*
m_deviceAPI(deviceAPI),
m_udpSrc(0),
m_channelMarker(this),
m_channelPowerDbAvg(40,0),
m_boost(1),
m_channelPowerAvg(4, 1e-10),
m_tickCount(0),
m_gain(1.0),
m_volume(20),
m_basicSettingsShown(false),
m_doApplySettings(true)
@ -273,6 +281,7 @@ UDPSrcGUI::UDPSrcGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget*
ui->spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum);
displaySettings();
applySettingsImmediate();
applySettings();
}
@ -294,19 +303,25 @@ void UDPSrcGUI::blockApplySettings(bool block)
m_doApplySettings = !block;
}
void UDPSrcGUI::displaySettings()
{
ui->gainText->setText(tr("%1").arg(ui->gain->value()/10.0, 0, 'f', 1));
ui->volumeText->setText(QString("%1").arg(ui->volume->value()));
}
void UDPSrcGUI::applySettingsImmediate()
{
if (m_doApplySettings)
{
m_audioActive = ui->audioActive->isChecked();
m_audioStereo = ui->audioStereo->isChecked();
m_boost = ui->boost->value();
m_gain = ui->gain->value() / 10.0;
m_volume = ui->volume->value();
m_udpSrc->configureImmediate(m_udpSrc->getInputMessageQueue(),
m_audioActive,
m_audioStereo,
m_boost,
m_gain,
m_volume);
}
}
@ -355,8 +370,6 @@ void UDPSrcGUI::applySettings()
fmDeviation = 2500;
}
int boost = ui->boost->value();
setTitleColor(m_channelMarker.getColor());
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
ui->sampleRate->setText(QString("%1").arg(outputSampleRate, 0));
@ -365,7 +378,6 @@ void UDPSrcGUI::applySettings()
ui->udpPort->setText(QString("%1").arg(udpPort));
ui->audioPort->setText(QString("%1").arg(audioPort));
ui->fmDeviation->setText(QString("%1").arg(fmDeviation));
ui->boost->setValue(boost);
m_channelMarker.disconnect(this, SLOT(channelMarkerChanged()));
m_channelMarker.setBandwidth((int)rfBandwidth);
connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(channelMarkerChanged()));
@ -423,7 +435,6 @@ void UDPSrcGUI::applySettings()
m_fmDeviation = fmDeviation;
m_udpPort = udpPort;
m_audioPort = audioPort;
m_boost = boost;
m_udpSrc->configure(m_udpSrc->getInputMessageQueue(),
sampleFormat,
@ -499,10 +510,9 @@ void UDPSrcGUI::on_audioStereo_toggled(bool stereo __attribute__((unused)))
applySettingsImmediate();
}
void UDPSrcGUI::on_boost_valueChanged(int value)
void UDPSrcGUI::on_gain_valueChanged(int value)
{
ui->boost->setValue(value);
ui->boostText->setText(QString("%1").arg(value));
ui->gainText->setText(tr("%1").arg(value/10.0, 0, 'f', 1));
applySettingsImmediate();
}

View File

@ -72,7 +72,7 @@ private slots:
void on_applyBtn_clicked();
void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDoubleClicked();
void on_boost_valueChanged(int value);
void on_gain_valueChanged(int value);
void on_volume_valueChanged(int value);
void tick();
@ -82,14 +82,15 @@ private:
DeviceSourceAPI* m_deviceAPI;
UDPSrc* m_udpSrc;
ChannelMarker m_channelMarker;
MovingAverage<double> m_channelPowerDbAvg;
MovingAverage<double> m_channelPowerAvg;
uint32_t m_tickCount;
// settings
UDPSrc::SampleFormat m_sampleFormat;
Real m_outputSampleRate;
Real m_rfBandwidth;
int m_fmDeviation;
int m_boost;
Real m_gain;
bool m_audioActive;
bool m_audioStereo;
int m_volume;
@ -110,6 +111,7 @@ private:
void blockApplySettings(bool block);
void applySettings();
void applySettingsImmediate();
void displaySettings();
void leaveEvent(QEvent*);
void enterEvent(QEvent*);

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>316</width>
<width>351</width>
<height>355</height>
</rect>
</property>
@ -36,13 +36,13 @@
<rect>
<x>2</x>
<y>2</y>
<width>312</width>
<width>340</width>
<height>142</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>312</width>
<width>340</width>
<height>0</height>
</size>
</property>
@ -65,13 +65,6 @@
<property name="spacing">
<number>3</number>
</property>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Format</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="ChannelPowerLayout">
<item>
@ -89,14 +82,23 @@
</item>
<item>
<widget class="QLabel" name="channelPower">
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Channel power</string>
<string>Channel output power (dB)</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>0.0</string>
<string>-100.0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
@ -109,47 +111,6 @@
</item>
</layout>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Rate (Hz)</string>
</property>
</widget>
</item>
<item row="6" column="1">
<layout class="QHBoxLayout" name="BoostLayout">
<item>
<widget class="QLabel" name="boostLabel">
<property name="text">
<string>Boost</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="boost">
<property name="toolTip">
<string>Signal boost factor</string>
</property>
<property name="maximum">
<number>3</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="boostText">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout" name="DeltaFrequencyLayout">
<property name="topMargin">
@ -277,7 +238,7 @@
</item>
</layout>
</item>
<item row="5" column="0">
<item row="6" column="0">
<layout class="QHBoxLayout" name="PortLayout">
<item>
<widget class="QLabel" name="udpPortlabel">
@ -321,29 +282,12 @@
</item>
</layout>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_3">
<property name="text">
<string>RF BW (Hz)</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="rfBandwidth">
<property name="toolTip">
<string>Signal bandwidth</string>
</property>
<property name="text">
<string>32000</string>
</property>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<layout class="QHBoxLayout" name="AudioPortLayout">
<item>
<widget class="QLabel" name="fmDevLabel">
<property name="text">
<string>FMd (Hz)</string>
<string>FMd</string>
</property>
</widget>
</item>
@ -395,17 +339,92 @@
</item>
</layout>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="sampleRate">
<property name="toolTip">
<string>Samples rate</string>
</property>
<item row="4" column="0">
<layout class="QHBoxLayout" name="AddressLayout">
<item>
<widget class="QLabel" name="Addresslabel">
<property name="text">
<string>48000</string>
<string>Addr</string>
</property>
</widget>
</item>
<item row="2" column="0">
<item>
<widget class="QLineEdit" name="udpAddress">
<property name="toolTip">
<string>Remote address</string>
</property>
<property name="inputMask">
<string>000.000.000.000</string>
</property>
<property name="text">
<string>127.0.0.1</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="8" column="0">
<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="toolTip">
<string>Audio volume</string>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="pageStep">
<number>1</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>18</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>20</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="FormatLayout">
<item>
<widget class="QLabel" name="label">
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Fmt</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="sampleFormat">
<property name="toolTip">
<string>Samples format</string>
@ -455,43 +474,63 @@
</item>
</widget>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="AddressLayout">
</layout>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="SampleRateLayout">
<item>
<widget class="QLabel" name="Addresslabel">
<widget class="QLabel" name="sampleRateLabel">
<property name="text">
<string>Addr</string>
<string>SRout</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="udpAddress">
<widget class="QLineEdit" name="sampleRate">
<property name="toolTip">
<string>Remote address</string>
</property>
<property name="inputMask">
<string>000.000.000.000</string>
<string>Output sample rate (S/s)</string>
</property>
<property name="text">
<string>127.0.0.1</string>
<string>48000</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="7" column="0">
<layout class="QHBoxLayout" name="VolumeLayout">
<item row="4" column="1">
<layout class="QHBoxLayout" name="RFBandwidthLayout">
<item>
<widget class="QLabel" name="volumeLabel">
<widget class="QLabel" name="rfBandwidthLabel">
<property name="text">
<string>Vol</string>
<string>RFBW</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="volume">
<widget class="QLineEdit" name="rfBandwidth">
<property name="toolTip">
<string>Audio volume</string>
<string>Signal bandwidth (Hz)</string>
</property>
<property name="text">
<string>32000</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="1">
<layout class="QHBoxLayout" name="GainLayout">
<item>
<widget class="QLabel" name="gainLabel">
<property name="text">
<string>Gain</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="gain">
<property name="toolTip">
<string>Output linear gain</string>
</property>
<property name="maximum">
<number>100</number>
@ -500,7 +539,7 @@
<number>1</number>
</property>
<property name="value">
<number>20</number>
<number>10</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -508,9 +547,21 @@
</widget>
</item>
<item>
<widget class="QLabel" name="volumeText">
<widget class="QLabel" name="gainText">
<property name="minimumSize">
<size>
<width>28</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Output linear gain</string>
</property>
<property name="text">
<string>20</string>
<string>00.0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
@ -601,11 +652,6 @@
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>sampleFormat</tabstop>
<tabstop>sampleRate</tabstop>
<tabstop>rfBandwidth</tabstop>
</tabstops>
<resources>
<include location="../../../sdrbase/resources/res.qrc"/>
</resources>

View File

@ -128,8 +128,8 @@ void UDPSink::modulateSample()
if (m_squelchOpen)
{
m_modSample.real(s.m_real * m_running.m_volume);
m_modSample.imag(s.m_imag * m_running.m_volume);
m_modSample.real(s.m_real * m_running.m_gain);
m_modSample.imag(s.m_imag * m_running.m_gain);
calculateLevel(m_modSample);
}
else
@ -230,7 +230,7 @@ bool UDPSink::handleMessage(const Message& cmd)
m_config.m_udpAddressStr = cfg.getUDPAddress();
m_config.m_udpPort = cfg.getUDPPort();
m_config.m_channelMute = cfg.getChannelMute();
m_config.m_volume = cfg.getVolume();
m_config.m_gain = cfg.getGain();
m_config.m_squelch = CalcDb::powerFromdB(cfg.getSquelchDB());
apply(cfg.getForce());
@ -243,7 +243,7 @@ bool UDPSink::handleMessage(const Message& cmd)
<< " m_udpAddressStr: " << m_config.m_udpAddressStr
<< " m_udpPort: " << m_config.m_udpPort
<< " m_channelMute: " << m_config.m_channelMute
<< " m_volume: " << m_config.m_volume
<< " m_gain: " << m_config.m_gain
<< " squelchDB: " << cfg.getSquelchDB()
<< " m_squelch: " << m_config.m_squelch;
@ -330,7 +330,7 @@ void UDPSink::configure(MessageQueue* messageQueue,
QString& udpAddress,
int udpPort,
bool channelMute,
Real volume,
Real gain,
Real squelchDB,
bool force)
{
@ -341,7 +341,7 @@ void UDPSink::configure(MessageQueue* messageQueue,
udpAddress,
udpPort,
channelMute,
volume,
gain,
squelchDB,
force);
messageQueue->push(cmd);

View File

@ -67,7 +67,7 @@ public:
QString& udpAddress,
int udpPort,
bool channelMute,
Real volume,
Real gain,
Real squelchDB,
bool force = false);
void setSpectrum(MessageQueue* messageQueue, bool enabled);
@ -93,7 +93,7 @@ private:
const QString& getUDPAddress() const { return m_udpAddress; }
int getUDPPort() const { return m_udpPort; }
bool getChannelMute() const { return m_channelMute; }
Real getVolume() const { return m_volume; }
Real getGain() const { return m_gain; }
Real getSquelchDB() const { return m_squelchDB; }
bool getForce() const { return m_force; }
@ -105,7 +105,7 @@ private:
QString& udpAddress,
int udpPort,
bool channelMute,
Real volume,
Real gain,
Real squelchDB,
bool force)
{
@ -116,7 +116,7 @@ private:
udpAddress,
udpPort,
channelMute,
volume,
gain,
squelchDB,
force);
}
@ -129,7 +129,7 @@ private:
QString m_udpAddress;
int m_udpPort;
bool m_channelMute;
Real m_volume;
Real m_gain;
Real m_squelchDB;
bool m_force;
@ -140,7 +140,7 @@ private:
QString& udpAddress,
int udpPort,
bool channelMute,
Real volume,
Real gain,
Real squelchDB,
bool force) :
Message(),
@ -151,7 +151,7 @@ private:
m_udpAddress(udpAddress),
m_udpPort(udpPort),
m_channelMute(channelMute),
m_volume(volume),
m_gain(gain),
m_squelchDB(squelchDB),
m_force(force)
{ }
@ -186,7 +186,7 @@ private:
Real m_rfBandwidth;
int m_fmDeviation;
bool m_channelMute;
Real m_volume;
Real m_gain;
Real m_squelch; //!< squared magnitude
QString m_udpAddressStr;
@ -201,7 +201,7 @@ private:
m_rfBandwidth(12500),
m_fmDeviation(1.0),
m_channelMute(false),
m_volume(1.0),
m_gain(1.0),
m_squelch(-50.0),
m_udpAddressStr("127.0.0.1"),
m_udpPort(9999)

View File

@ -71,7 +71,7 @@ void UDPSinkGUI::resetToDefaults()
ui->udpAddress->setText("127.0.0.1");
ui->udpPort->setText("9999");
ui->spectrumGUI->resetToDefaults();
ui->volume->setValue(10);
ui->gain->setValue(10);
blockApplySettings(false);
applySettings();
@ -89,7 +89,7 @@ QByteArray UDPSinkGUI::serialize() const
s.writeBlob(7, ui->spectrumGUI->serialize());
s.writeS32(8, m_channelMarker.getCenterFrequency());
s.writeString(9, m_udpAddress);
s.writeS32(10, ui->volume->value());
s.writeS32(10, ui->gain->value());
s.writeS32(11, m_fmDeviation);
s.writeU32(12, m_channelMarker.getColor().rgb());
s.writeString(13, m_channelMarker.getTitle());
@ -166,8 +166,8 @@ bool UDPSinkGUI::deserialize(const QByteArray& data)
d.readString(9, &strtmp, "127.0.0.1");
ui->udpAddress->setText(strtmp);
d.readS32(10, &s32tmp, 10);
ui->volume->setValue(s32tmp);
ui->volumeText->setText(tr("%1").arg(s32tmp/10.0, 0, 'f', 1));
ui->gain->setValue(s32tmp);
ui->gainText->setText(tr("%1").arg(s32tmp/10.0, 0, 'f', 1));
d.readS32(11, &s32tmp, 2500);
ui->fmDeviation->setText(QString("%1").arg(s32tmp));
@ -218,9 +218,9 @@ UDPSinkGUI::UDPSinkGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget*
ui(new Ui::UDPSinkGUI),
m_pluginAPI(pluginAPI),
m_deviceAPI(deviceAPI),
m_channelPowerAvg(20, 1e-10),
m_inPowerAvg(50, 1e-10),
m_powDisplayCount(0),
m_channelPowerAvg(4, 1e-10),
m_inPowerAvg(4, 1e-10),
m_tickCount(0),
m_channelMarker(this),
m_basicSettingsShown(false),
m_doApplySettings(true)
@ -265,6 +265,7 @@ UDPSinkGUI::UDPSinkGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget*
ui->spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum);
displaySettings();
applySettings(true);
connect(m_udpSink->getOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
@ -395,7 +396,7 @@ void UDPSinkGUI::applySettings(bool force)
m_udpAddress,
udpPort,
ui->channelMute->isChecked(),
ui->volume->value() / 10.0f,
ui->gain->value() / 10.0f,
ui->squelch->value() * 1.0f,
force);
@ -405,7 +406,7 @@ void UDPSinkGUI::applySettings(bool force)
void UDPSinkGUI::displaySettings()
{
ui->volumeText->setText(tr("%1").arg(ui->volume->value()/10.0, 0, 'f', 1));
ui->gainText->setText(tr("%1").arg(ui->gain->value()/10.0, 0, 'f', 1));
ui->squelchText->setText(tr("%1").arg(ui->squelch->value()*1.0, 0, 'f', 0));
}
@ -458,7 +459,7 @@ void UDPSinkGUI::on_udpPort_textEdited(const QString& arg1 __attribute__((unused
void UDPSinkGUI::on_volume_valueChanged(int value)
{
ui->volumeText->setText(tr("%1").arg(value/10.0, 0, 'f', 1));
ui->gainText->setText(tr("%1").arg(value/10.0, 0, 'f', 1));
applySettings();
}
@ -515,18 +516,12 @@ void UDPSinkGUI::tick()
m_channelPowerAvg.feed(m_udpSink->getMagSq());
m_inPowerAvg.feed(m_udpSink->getInMagSq());
if (m_powDisplayCount < 3)
{
m_powDisplayCount++;
}
else
if (m_tickCount % 4 == 0)
{
double powDb = CalcDb::dbPower(m_channelPowerAvg.average());
ui->channelPower->setText(tr("%1 dB").arg(powDb, 0, 'f', 1));
double inPowDb = CalcDb::dbPower(m_inPowerAvg.average());
ui->inputPower->setText(tr("%1").arg(inPowDb, 0, 'f', 1));
m_powDisplayCount = 0;
}
int32_t bufferGauge = m_udpSink->getBufferGauge();
@ -540,5 +535,7 @@ void UDPSinkGUI::tick()
} else {
ui->channelMute->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
}
m_tickCount++;
}

View File

@ -82,7 +82,7 @@ private:
UDPSink* m_udpSink;
MovingAverage<double> m_channelPowerAvg;
MovingAverage<double> m_inPowerAvg;
int m_powDisplayCount;
uint32_t m_tickCount;
ChannelMarker m_channelMarker;
// settings

View File

@ -641,25 +641,16 @@
</layout>
</item>
<item row="8" column="2">
<layout class="QHBoxLayout" name="VolumeLayout">
<layout class="QHBoxLayout" name="GainLayout">
<item>
<widget class="QLabel" name="volumeLabel">
<widget class="QLabel" name="gainLabel">
<property name="text">
<string>Gain</string>
</property>
</widget>
</item>
<item>
<widget class="QDial" name="volume">
<property name="maximumSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="toolTip">
<string>Linear gain</string>
</property>
<widget class="QSlider" name="gain">
<property name="maximum">
<number>100</number>
</property>
@ -669,10 +660,13 @@
<property name="value">
<number>10</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="volumeText">
<widget class="QLabel" name="gainText">
<property name="minimumSize">
<size>
<width>32</width>
@ -690,19 +684,6 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="4" column="2">