mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-10-01 09:16:39 -04:00
UDPSink plugin: implemented volume control
This commit is contained in:
parent
66a81ec611
commit
af5103552c
@ -112,8 +112,8 @@ void UDPSink::modulateSample()
|
|||||||
if (m_running.m_sampleFormat == FormatS16LE)
|
if (m_running.m_sampleFormat == FormatS16LE)
|
||||||
{
|
{
|
||||||
m_udpHandler.readSample(s);
|
m_udpHandler.readSample(s);
|
||||||
m_modSample.real(s.m_real);
|
m_modSample.real(s.m_real * m_running.m_volume);
|
||||||
m_modSample.imag(s.m_imag);
|
m_modSample.imag(s.m_imag * m_running.m_volume);
|
||||||
calculateLevel(m_modSample);
|
calculateLevel(m_modSample);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -208,6 +208,7 @@ bool UDPSink::handleMessage(const Message& cmd)
|
|||||||
m_config.m_udpAddressStr = cfg.getUDPAddress();
|
m_config.m_udpAddressStr = cfg.getUDPAddress();
|
||||||
m_config.m_udpPort = cfg.getUDPPort();
|
m_config.m_udpPort = cfg.getUDPPort();
|
||||||
m_config.m_channelMute = cfg.getChannelMute();
|
m_config.m_channelMute = cfg.getChannelMute();
|
||||||
|
m_config.m_volume = cfg.getVolume();
|
||||||
|
|
||||||
apply(cfg.getForce());
|
apply(cfg.getForce());
|
||||||
|
|
||||||
@ -218,7 +219,8 @@ bool UDPSink::handleMessage(const Message& cmd)
|
|||||||
<< " m_fmDeviation: " << m_config.m_fmDeviation
|
<< " m_fmDeviation: " << m_config.m_fmDeviation
|
||||||
<< " m_udpAddressStr: " << m_config.m_udpAddressStr
|
<< " m_udpAddressStr: " << m_config.m_udpAddressStr
|
||||||
<< " m_udpPort: " << m_config.m_udpPort
|
<< " 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;
|
return true;
|
||||||
}
|
}
|
||||||
@ -303,6 +305,7 @@ void UDPSink::configure(MessageQueue* messageQueue,
|
|||||||
QString& udpAddress,
|
QString& udpAddress,
|
||||||
int udpPort,
|
int udpPort,
|
||||||
bool channelMute,
|
bool channelMute,
|
||||||
|
Real volume,
|
||||||
bool force)
|
bool force)
|
||||||
{
|
{
|
||||||
Message* cmd = MsgUDPSinkConfigure::create(sampleFormat,
|
Message* cmd = MsgUDPSinkConfigure::create(sampleFormat,
|
||||||
@ -312,6 +315,7 @@ void UDPSink::configure(MessageQueue* messageQueue,
|
|||||||
udpAddress,
|
udpAddress,
|
||||||
udpPort,
|
udpPort,
|
||||||
channelMute,
|
channelMute,
|
||||||
|
volume,
|
||||||
force);
|
force);
|
||||||
messageQueue->push(cmd);
|
messageQueue->push(cmd);
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,7 @@ public:
|
|||||||
QString& udpAddress,
|
QString& udpAddress,
|
||||||
int udpPort,
|
int udpPort,
|
||||||
bool channelMute,
|
bool channelMute,
|
||||||
|
Real volume,
|
||||||
bool force = false);
|
bool force = false);
|
||||||
void setSpectrum(MessageQueue* messageQueue, bool enabled);
|
void setSpectrum(MessageQueue* messageQueue, bool enabled);
|
||||||
|
|
||||||
@ -89,6 +90,7 @@ private:
|
|||||||
const QString& getUDPAddress() const { return m_udpAddress; }
|
const QString& getUDPAddress() const { return m_udpAddress; }
|
||||||
int getUDPPort() const { return m_udpPort; }
|
int getUDPPort() const { return m_udpPort; }
|
||||||
bool getChannelMute() const { return m_channelMute; }
|
bool getChannelMute() const { return m_channelMute; }
|
||||||
|
Real getVolume() const { return m_volume; }
|
||||||
bool getForce() const { return m_force; }
|
bool getForce() const { return m_force; }
|
||||||
|
|
||||||
static MsgUDPSinkConfigure* create(SampleFormat
|
static MsgUDPSinkConfigure* create(SampleFormat
|
||||||
@ -99,6 +101,7 @@ private:
|
|||||||
QString& udpAddress,
|
QString& udpAddress,
|
||||||
int udpPort,
|
int udpPort,
|
||||||
bool channelMute,
|
bool channelMute,
|
||||||
|
Real volume,
|
||||||
bool force)
|
bool force)
|
||||||
{
|
{
|
||||||
return new MsgUDPSinkConfigure(sampleFormat,
|
return new MsgUDPSinkConfigure(sampleFormat,
|
||||||
@ -108,6 +111,7 @@ private:
|
|||||||
udpAddress,
|
udpAddress,
|
||||||
udpPort,
|
udpPort,
|
||||||
channelMute,
|
channelMute,
|
||||||
|
volume,
|
||||||
force);
|
force);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,6 +123,7 @@ private:
|
|||||||
QString m_udpAddress;
|
QString m_udpAddress;
|
||||||
int m_udpPort;
|
int m_udpPort;
|
||||||
bool m_channelMute;
|
bool m_channelMute;
|
||||||
|
Real m_volume;
|
||||||
bool m_force;
|
bool m_force;
|
||||||
|
|
||||||
MsgUDPSinkConfigure(SampleFormat sampleFormat,
|
MsgUDPSinkConfigure(SampleFormat sampleFormat,
|
||||||
@ -128,6 +133,7 @@ private:
|
|||||||
QString& udpAddress,
|
QString& udpAddress,
|
||||||
int udpPort,
|
int udpPort,
|
||||||
bool channelMute,
|
bool channelMute,
|
||||||
|
Real volume,
|
||||||
bool force) :
|
bool force) :
|
||||||
Message(),
|
Message(),
|
||||||
m_sampleFormat(sampleFormat),
|
m_sampleFormat(sampleFormat),
|
||||||
@ -137,6 +143,7 @@ private:
|
|||||||
m_udpAddress(udpAddress),
|
m_udpAddress(udpAddress),
|
||||||
m_udpPort(udpPort),
|
m_udpPort(udpPort),
|
||||||
m_channelMute(channelMute),
|
m_channelMute(channelMute),
|
||||||
|
m_volume(volume),
|
||||||
m_force(force)
|
m_force(force)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
@ -170,6 +177,7 @@ private:
|
|||||||
Real m_rfBandwidth;
|
Real m_rfBandwidth;
|
||||||
int m_fmDeviation;
|
int m_fmDeviation;
|
||||||
bool m_channelMute;
|
bool m_channelMute;
|
||||||
|
Real m_volume;
|
||||||
|
|
||||||
QString m_udpAddressStr;
|
QString m_udpAddressStr;
|
||||||
quint16 m_udpPort;
|
quint16 m_udpPort;
|
||||||
@ -183,6 +191,7 @@ private:
|
|||||||
m_rfBandwidth(12500),
|
m_rfBandwidth(12500),
|
||||||
m_fmDeviation(1.0),
|
m_fmDeviation(1.0),
|
||||||
m_channelMute(false),
|
m_channelMute(false),
|
||||||
|
m_volume(1.0),
|
||||||
m_udpAddressStr("127.0.0.1"),
|
m_udpAddressStr("127.0.0.1"),
|
||||||
m_udpPort(9999)
|
m_udpPort(9999)
|
||||||
{}
|
{}
|
||||||
|
@ -71,7 +71,7 @@ void UDPSinkGUI::resetToDefaults()
|
|||||||
ui->udpAddress->setText("127.0.0.1");
|
ui->udpAddress->setText("127.0.0.1");
|
||||||
ui->udpPort->setText("9999");
|
ui->udpPort->setText("9999");
|
||||||
ui->spectrumGUI->resetToDefaults();
|
ui->spectrumGUI->resetToDefaults();
|
||||||
ui->volume->setValue(20);
|
ui->volume->setValue(10);
|
||||||
|
|
||||||
blockApplySettings(false);
|
blockApplySettings(false);
|
||||||
applySettings();
|
applySettings();
|
||||||
@ -89,7 +89,7 @@ QByteArray UDPSinkGUI::serialize() const
|
|||||||
s.writeBlob(7, ui->spectrumGUI->serialize());
|
s.writeBlob(7, ui->spectrumGUI->serialize());
|
||||||
s.writeS32(8, m_channelMarker.getCenterFrequency());
|
s.writeS32(8, m_channelMarker.getCenterFrequency());
|
||||||
s.writeString(9, m_udpAddress);
|
s.writeString(9, m_udpAddress);
|
||||||
s.writeS32(10, (qint32)m_volume);
|
s.writeS32(10, ui->volume->value());
|
||||||
s.writeS32(11, m_fmDeviation);
|
s.writeS32(11, m_fmDeviation);
|
||||||
s.writeU32(12, m_channelMarker.getColor().rgb());
|
s.writeU32(12, m_channelMarker.getColor().rgb());
|
||||||
s.writeString(13, m_channelMarker.getTitle());
|
s.writeString(13, m_channelMarker.getTitle());
|
||||||
@ -164,7 +164,7 @@ bool UDPSinkGUI::deserialize(const QByteArray& data)
|
|||||||
m_channelMarker.setCenterFrequency(s32tmp);
|
m_channelMarker.setCenterFrequency(s32tmp);
|
||||||
d.readString(9, &strtmp, "127.0.0.1");
|
d.readString(9, &strtmp, "127.0.0.1");
|
||||||
ui->udpAddress->setText(strtmp);
|
ui->udpAddress->setText(strtmp);
|
||||||
d.readS32(10, &s32tmp, 20);
|
d.readS32(10, &s32tmp, 10);
|
||||||
ui->volume->setValue(s32tmp);
|
ui->volume->setValue(s32tmp);
|
||||||
d.readS32(11, &s32tmp, 2500);
|
d.readS32(11, &s32tmp, 2500);
|
||||||
ui->fmDeviation->setText(QString("%1").arg(s32tmp));
|
ui->fmDeviation->setText(QString("%1").arg(s32tmp));
|
||||||
@ -387,6 +387,7 @@ void UDPSinkGUI::applySettings(bool force)
|
|||||||
m_udpAddress,
|
m_udpAddress,
|
||||||
udpPort,
|
udpPort,
|
||||||
ui->channelMute->isChecked(),
|
ui->channelMute->isChecked(),
|
||||||
|
ui->volume->value() / 10.0f,
|
||||||
force);
|
force);
|
||||||
|
|
||||||
ui->applyBtn->setEnabled(false);
|
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)
|
void UDPSinkGUI::on_volume_valueChanged(int value)
|
||||||
{
|
{
|
||||||
ui->volume->setValue(value);
|
ui->volumeText->setText(tr("%1").arg(value/10.0, 0, 'f', 1));
|
||||||
ui->volumeText->setText(QString("%1").arg(value));
|
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,6 @@ private:
|
|||||||
Real m_inputSampleRate;
|
Real m_inputSampleRate;
|
||||||
Real m_rfBandwidth;
|
Real m_rfBandwidth;
|
||||||
int m_fmDeviation;
|
int m_fmDeviation;
|
||||||
int m_volume;
|
|
||||||
QString m_udpAddress;
|
QString m_udpAddress;
|
||||||
int m_udpPort;
|
int m_udpPort;
|
||||||
bool m_basicSettingsShown;
|
bool m_basicSettingsShown;
|
||||||
|
@ -321,6 +321,36 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="2">
|
<item row="4" column="2">
|
||||||
@ -336,16 +366,28 @@
|
|||||||
<widget class="QDial" name="volume">
|
<widget class="QDial" name="volume">
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>24</width>
|
<width>22</width>
|
||||||
<height>24</height>
|
<height>22</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>50</number>
|
||||||
|
</property>
|
||||||
|
<property name="pageStep">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="volumeText">
|
<widget class="QLabel" name="volumeText">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>20</string>
|
<string>0.0</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user