1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 09:48:45 -05:00

UDP sink plugin: implemented a gain input control for real sample input

This commit is contained in:
f4exb 2017-08-25 15:29:45 +02:00
parent a7d6b3a75d
commit a5b7428755
6 changed files with 121 additions and 46 deletions

View File

@ -351,6 +351,9 @@
<height>0</height>
</size>
</property>
<property name="statusTip">
<string>UDP &lt;address&gt;:&lt;data port&gt;/&lt;audio port&gt;</string>
</property>
<property name="text">
<string>00.000.000.000:0000/0000</string>
</property>

View File

@ -134,8 +134,8 @@ void UDPSink::modulateSample()
if (m_squelchOpen)
{
m_modSample.real(s.m_real * m_running.m_gain);
m_modSample.imag(s.m_imag * m_running.m_gain);
m_modSample.real(s.m_real * m_running.m_gainOut);
m_modSample.imag(s.m_imag * m_running.m_gainOut);
calculateLevel(m_modSample);
}
else
@ -157,8 +157,8 @@ void UDPSink::modulateSample()
if (m_squelchOpen)
{
m_modPhasor += (m_running.m_fmDeviation / m_running.m_inputSampleRate) * (t / 32768.0f) * M_PI * 2.0f;
m_modSample.real(cos(m_modPhasor) * 10362.2f * m_running.m_gain);
m_modSample.imag(sin(m_modPhasor) * 10362.2f * m_running.m_gain);
m_modSample.real(cos(m_modPhasor) * 10362.2f * m_running.m_gainOut);
m_modSample.imag(sin(m_modPhasor) * 10362.2f * m_running.m_gainOut);
calculateLevel(m_modSample);
}
else
@ -178,7 +178,7 @@ void UDPSink::modulateSample()
if (m_squelchOpen)
{
m_modSample.real(((t / 32768.0f)*m_running.m_amModFactor*m_running.m_gain + 1.0f) * 16384.0f); // modulate and scale zero frequency carrier
m_modSample.real(((t / 32768.0f)*m_running.m_amModFactor*m_running.m_gainOut + 1.0f) * 16384.0f); // modulate and scale zero frequency carrier
m_modSample.imag(0.0f);
calculateLevel(m_modSample);
}
@ -203,7 +203,7 @@ void UDPSink::modulateSample()
if (m_squelchOpen)
{
ci.real((t / 32768.0f) * m_running.m_gain);
ci.real((t / 32768.0f) * m_running.m_gainOut);
ci.imag(0.0f);
n_out = m_SSBFilter->runSSB(ci, &filtered, (m_running.m_sampleFormat == FormatUSB));
@ -319,7 +319,8 @@ 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_gain = cfg.getGain();
m_config.m_gainIn = cfg.getGainIn();
m_config.m_gainOut = cfg.getGainOut();
m_config.m_squelch = CalcDb::powerFromdB(cfg.getSquelchDB());
m_config.m_squelchGate = cfg.getSquelchGate();
m_config.m_squelchEnabled = cfg.getSquelchEnabled();
@ -336,7 +337,8 @@ 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_gain: " << m_config.m_gain
<< " m_gainIn: " << m_config.m_gainIn
<< " m_gainOut: " << m_config.m_gainOut
<< " squelchDB: " << cfg.getSquelchDB()
<< " m_squelchGate: " << m_config.m_squelchGate
<< " m_squelch: " << m_config.m_squelch
@ -438,7 +440,8 @@ void UDPSink::configure(MessageQueue* messageQueue,
const QString& udpAddress,
int udpPort,
bool channelMute,
Real gain,
Real gainIn,
Real gainOut,
Real squelchDB,
Real squelchGate,
bool squelchEnabled,
@ -454,7 +457,8 @@ void UDPSink::configure(MessageQueue* messageQueue,
udpAddress,
udpPort,
channelMute,
gain,
gainIn,
gainOut,
squelchDB,
squelchGate,
squelchEnabled,

View File

@ -66,7 +66,8 @@ public:
const QString& udpAddress,
int udpPort,
bool channelMute,
Real gain,
Real gainIn,
Real gainOut,
Real squelchDB,
Real squelchGate,
bool squelchEnabled,
@ -98,7 +99,8 @@ private:
const QString& getUDPAddress() const { return m_udpAddress; }
int getUDPPort() const { return m_udpPort; }
bool getChannelMute() const { return m_channelMute; }
Real getGain() const { return m_gain; }
Real getGainIn() const { return m_gainIn; }
Real getGainOut() const { return m_gainOut; }
Real getSquelchDB() const { return m_squelchDB; }
Real getSquelchGate() const { return m_squelchGate; }
bool getSquelchEnabled() const { return m_squelchEnabled; }
@ -115,7 +117,8 @@ private:
const QString& udpAddress,
int udpPort,
bool channelMute,
Real gain,
Real gainIn,
Real gainOut,
Real squelchDB,
Real squelchGate,
bool squelchEnabled,
@ -131,7 +134,8 @@ private:
udpAddress,
udpPort,
channelMute,
gain,
gainIn,
gainOut,
squelchDB,
squelchGate,
squelchEnabled,
@ -149,7 +153,8 @@ private:
QString m_udpAddress;
int m_udpPort;
bool m_channelMute;
Real m_gain;
Real m_gainIn;
Real m_gainOut;
Real m_squelchDB;
Real m_squelchGate;
bool m_squelchEnabled;
@ -165,7 +170,8 @@ private:
const QString& udpAddress,
int udpPort,
bool channelMute,
Real gain,
Real gainIn,
Real gainOut,
Real squelchDB,
Real squelchGate,
bool squelchEnabled,
@ -181,7 +187,8 @@ private:
m_udpAddress(udpAddress),
m_udpPort(udpPort),
m_channelMute(channelMute),
m_gain(gain),
m_gainIn(gainIn),
m_gainOut(gainOut),
m_squelchDB(squelchDB),
m_squelchGate(squelchGate),
m_squelchEnabled(squelchEnabled),
@ -239,7 +246,8 @@ private:
int m_fmDeviation;
Real m_amModFactor;
bool m_channelMute;
Real m_gain;
Real m_gainIn;
Real m_gainOut;
Real m_squelch; //!< squared magnitude
Real m_squelchGate; //!< seconds
bool m_squelchEnabled;
@ -260,7 +268,8 @@ private:
m_fmDeviation(1.0),
m_amModFactor(0.95),
m_channelMute(false),
m_gain(1.0),
m_gainIn(1.0),
m_gainOut(1.0),
m_squelch(-50.0),
m_squelchGate(0.05),
m_squelchEnabled(true),
@ -390,7 +399,7 @@ private:
if (m_running.m_stereoInput)
{
m_udpHandler.readSample(s);
t = (s.m_real + s.m_imag) / 2;
t = ((s.m_real + s.m_imag) * m_running.m_gainIn) / 2;
}
else
{

View File

@ -69,7 +69,8 @@ void UDPSinkGUI::resetToDefaults()
ui->rfBandwidth->setText("32000");
ui->fmDeviation->setText("2500");
ui->spectrumGUI->resetToDefaults();
ui->gain->setValue(10);
ui->gainIn->setValue(10);
ui->gainOut->setValue(10);
blockApplySettings(false);
applySettings();
@ -87,13 +88,14 @@ QByteArray UDPSinkGUI::serialize() const
s.writeBlob(7, ui->spectrumGUI->serialize());
s.writeS32(8, m_channelMarker.getCenterFrequency());
s.writeString(9, m_channelMarker.getUDPAddress());
s.writeS32(10, ui->gain->value());
s.writeS32(10, ui->gainOut->value());
s.writeS32(11, m_fmDeviation);
s.writeU32(12, m_channelMarker.getColor().rgb());
s.writeString(13, m_channelMarker.getTitle());
s.writeS32(14, ui->squelch->value());
s.writeS32(15, ui->squelchGate->value());
s.writeBool(16, ui->autoRWBalance->isChecked());
s.writeS32(17, ui->gainIn->value());
return s.final();
}
@ -147,8 +149,8 @@ bool UDPSinkGUI::deserialize(const QByteArray& data)
d.readString(9, &strtmp, "127.0.0.1");
m_channelMarker.setUDPAddress(strtmp);
d.readS32(10, &s32tmp, 10);
ui->gain->setValue(s32tmp);
ui->gainText->setText(tr("%1").arg(s32tmp/10.0, 0, 'f', 1));
ui->gainOut->setValue(s32tmp);
ui->gainOutText->setText(tr("%1").arg(s32tmp/10.0, 0, 'f', 1));
d.readS32(11, &s32tmp, 2500);
ui->fmDeviation->setText(QString("%1").arg(s32tmp));
@ -166,6 +168,9 @@ bool UDPSinkGUI::deserialize(const QByteArray& data)
ui->squelchGateText->setText(tr("%1").arg(s32tmp*10.0, 0, 'f', 0));
d.readBool(16, &booltmp, true);
ui->autoRWBalance->setChecked(booltmp);
d.readS32(17, &s32tmp, 10);
ui->gainIn->setValue(s32tmp);
ui->gainInText->setText(tr("%1").arg(s32tmp/10.0, 0, 'f', 1));
blockApplySettings(false);
m_channelMarker.blockSignals(false);
@ -374,7 +379,8 @@ void UDPSinkGUI::applySettings(bool force)
m_channelMarker.getUDPAddress(),
m_channelMarker.getUDPReceivePort(),
ui->channelMute->isChecked(),
ui->gain->value() / 10.0f,
ui->gainIn->value() / 10.0f,
ui->gainOut->value() / 10.0f,
ui->squelch->value() * 1.0f,
ui->squelchGate->value() * 0.01f,
ui->squelch->value() != -100,
@ -389,7 +395,8 @@ void UDPSinkGUI::applySettings(bool force)
void UDPSinkGUI::displaySettings()
{
ui->gainText->setText(tr("%1").arg(ui->gain->value()/10.0, 0, 'f', 1));
ui->gainInText->setText(tr("%1").arg(ui->gainIn->value()/10.0, 0, 'f', 1));
ui->gainOutText->setText(tr("%1").arg(ui->gainOut->value()/10.0, 0, 'f', 1));
ui->squelchText->setText(tr("%1").arg(ui->squelch->value()*1.0, 0, 'f', 0));
ui->squelchGateText->setText(tr("%1").arg(ui->squelchGate->value()*10.0, 0, 'f', 0));
ui->addressText->setText(tr("%1:%2").arg(m_channelMarker.getUDPAddress()).arg(m_channelMarker.getUDPReceivePort()));
@ -461,9 +468,15 @@ void UDPSinkGUI::on_udpPort_textEdited(const QString& arg1 __attribute__((unused
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
}
void UDPSinkGUI::on_gain_valueChanged(int value)
void UDPSinkGUI::on_gainIn_valueChanged(int value)
{
ui->gainText->setText(tr("%1").arg(value/10.0, 0, 'f', 1));
ui->gainInText->setText(tr("%1").arg(value/10.0, 0, 'f', 1));
applySettings();
}
void UDPSinkGUI::on_gainOut_valueChanged(int value)
{
ui->gainOutText->setText(tr("%1").arg(value/10.0, 0, 'f', 1));
applySettings();
}

View File

@ -68,7 +68,8 @@ private slots:
void on_applyBtn_clicked();
void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDialogCalled(const QPoint& p);
void on_gain_valueChanged(int value);
void on_gainIn_valueChanged(int value);
void on_gainOut_valueChanged(int value);
void on_squelch_valueChanged(int value);
void on_squelchGate_valueChanged(int value);
void on_channelMute_toggled(bool checked);

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>342</width>
<height>400</height>
<width>388</width>
<height>403</height>
</rect>
</property>
<property name="minimumSize">
@ -42,13 +42,13 @@
<rect>
<x>2</x>
<y>2</y>
<width>340</width>
<width>380</width>
<height>141</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>340</width>
<width>380</width>
<height>0</height>
</size>
</property>
@ -218,20 +218,65 @@
<item row="9" column="2">
<layout class="QHBoxLayout" name="GainLayout">
<item>
<widget class="QLabel" name="gainLabel">
<property name="minimumSize">
<size>
<width>0</width>
<height>22</height>
</size>
</property>
<widget class="QLabel" name="gainInLabel">
<property name="text">
<string>Gain</string>
<string>Gi</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="gain">
<widget class="QDial" name="gainIn">
<property name="maximumSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="gainInText">
<property name="minimumSize">
<size>
<width>32</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>10.0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="gainOutLabel">
<property name="text">
<string> Go</string>
</property>
</widget>
</item>
<item>
<widget class="QDial" name="gainOut">
<property name="maximumSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="maximum">
<number>100</number>
</property>
@ -241,13 +286,10 @@
<property name="value">
<number>10</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="gainText">
<widget class="QLabel" name="gainOutText">
<property name="minimumSize">
<size>
<width>32</width>
@ -827,6 +869,9 @@
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>UDP &lt;address&gt;:&lt;data port&gt;</string>
</property>
<property name="text">
<string>000.000.000.000:00000</string>
</property>