UDPSink plugin: implemented volume control

This commit is contained in:
f4exb 2017-08-17 00:16:17 +02:00
parent 66a81ec611
commit af5103552c
5 changed files with 66 additions and 12 deletions

View File

@ -112,8 +112,8 @@ void UDPSink::modulateSample()
if (m_running.m_sampleFormat == FormatS16LE)
{
m_udpHandler.readSample(s);
m_modSample.real(s.m_real);
m_modSample.imag(s.m_imag);
m_modSample.real(s.m_real * m_running.m_volume);
m_modSample.imag(s.m_imag * m_running.m_volume);
calculateLevel(m_modSample);
}
else
@ -208,6 +208,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();
apply(cfg.getForce());
@ -218,7 +219,8 @@ bool UDPSink::handleMessage(const Message& cmd)
<< " m_fmDeviation: " << m_config.m_fmDeviation
<< " m_udpAddressStr: " << m_config.m_udpAddressStr
<< " m_udpPort: " << m_config.m_udpPort
<< " m_channelMute: " << m_config.m_channelMute;
<< " m_channelMute: " << m_config.m_channelMute
<< " m_volume: " << m_config.m_volume;
return true;
}
@ -303,6 +305,7 @@ void UDPSink::configure(MessageQueue* messageQueue,
QString& udpAddress,
int udpPort,
bool channelMute,
Real volume,
bool force)
{
Message* cmd = MsgUDPSinkConfigure::create(sampleFormat,
@ -312,6 +315,7 @@ void UDPSink::configure(MessageQueue* messageQueue,
udpAddress,
udpPort,
channelMute,
volume,
force);
messageQueue->push(cmd);
}

View File

@ -65,6 +65,7 @@ public:
QString& udpAddress,
int udpPort,
bool channelMute,
Real volume,
bool force = false);
void setSpectrum(MessageQueue* messageQueue, bool enabled);
@ -89,6 +90,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; }
bool getForce() const { return m_force; }
static MsgUDPSinkConfigure* create(SampleFormat
@ -99,6 +101,7 @@ private:
QString& udpAddress,
int udpPort,
bool channelMute,
Real volume,
bool force)
{
return new MsgUDPSinkConfigure(sampleFormat,
@ -108,6 +111,7 @@ private:
udpAddress,
udpPort,
channelMute,
volume,
force);
}
@ -119,6 +123,7 @@ private:
QString m_udpAddress;
int m_udpPort;
bool m_channelMute;
Real m_volume;
bool m_force;
MsgUDPSinkConfigure(SampleFormat sampleFormat,
@ -128,6 +133,7 @@ private:
QString& udpAddress,
int udpPort,
bool channelMute,
Real volume,
bool force) :
Message(),
m_sampleFormat(sampleFormat),
@ -137,6 +143,7 @@ private:
m_udpAddress(udpAddress),
m_udpPort(udpPort),
m_channelMute(channelMute),
m_volume(volume),
m_force(force)
{ }
};
@ -170,6 +177,7 @@ private:
Real m_rfBandwidth;
int m_fmDeviation;
bool m_channelMute;
Real m_volume;
QString m_udpAddressStr;
quint16 m_udpPort;
@ -183,6 +191,7 @@ private:
m_rfBandwidth(12500),
m_fmDeviation(1.0),
m_channelMute(false),
m_volume(1.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(20);
ui->volume->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, (qint32)m_volume);
s.writeS32(10, ui->volume->value());
s.writeS32(11, m_fmDeviation);
s.writeU32(12, m_channelMarker.getColor().rgb());
s.writeString(13, m_channelMarker.getTitle());
@ -164,7 +164,7 @@ bool UDPSinkGUI::deserialize(const QByteArray& data)
m_channelMarker.setCenterFrequency(s32tmp);
d.readString(9, &strtmp, "127.0.0.1");
ui->udpAddress->setText(strtmp);
d.readS32(10, &s32tmp, 20);
d.readS32(10, &s32tmp, 10);
ui->volume->setValue(s32tmp);
d.readS32(11, &s32tmp, 2500);
ui->fmDeviation->setText(QString("%1").arg(s32tmp));
@ -387,6 +387,7 @@ void UDPSinkGUI::applySettings(bool force)
m_udpAddress,
udpPort,
ui->channelMute->isChecked(),
ui->volume->value() / 10.0f,
force);
ui->applyBtn->setEnabled(false);
@ -442,8 +443,7 @@ void UDPSinkGUI::on_udpPort_textEdited(const QString& arg1 __attribute__((unused
void UDPSinkGUI::on_volume_valueChanged(int value)
{
ui->volume->setValue(value);
ui->volumeText->setText(QString("%1").arg(value));
ui->volumeText->setText(tr("%1").arg(value/10.0, 0, 'f', 1));
applySettings();
}

View File

@ -87,7 +87,6 @@ private:
Real m_inputSampleRate;
Real m_rfBandwidth;
int m_fmDeviation;
int m_volume;
QString m_udpAddress;
int m_udpPort;
bool m_basicSettingsShown;

View File

@ -321,6 +321,36 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Sq</string>
</property>
</widget>
</item>
<item>
<widget class="QDial" name="dial">
<property name="maximumSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="toolTip">
<string>Power squelch threshold (dB)</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="toolTip">
<string>Power squelch threshold (dB)</string>
</property>
<property name="text">
<string>-00</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="2">
@ -336,16 +366,28 @@
<widget class="QDial" name="volume">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="maximum">
<number>50</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="volumeText">
<property name="text">
<string>20</string>
<string>0.0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>