diff --git a/plugins/channelrx/udpsrc/udpsrcgui.ui b/plugins/channelrx/udpsrc/udpsrcgui.ui index c2a512440..d1bee88ca 100644 --- a/plugins/channelrx/udpsrc/udpsrcgui.ui +++ b/plugins/channelrx/udpsrc/udpsrcgui.ui @@ -351,6 +351,9 @@ 0 + + UDP <address>:<data port>/<audio port> + 00.000.000.000:0000/0000 diff --git a/plugins/channeltx/udpsink/udpsink.cpp b/plugins/channeltx/udpsink/udpsink.cpp index 51ef0ca4d..b9d03bac7 100644 --- a/plugins/channeltx/udpsink/udpsink.cpp +++ b/plugins/channeltx/udpsink/udpsink.cpp @@ -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, diff --git a/plugins/channeltx/udpsink/udpsink.h b/plugins/channeltx/udpsink/udpsink.h index dd63b750a..b8d2f41fe 100644 --- a/plugins/channeltx/udpsink/udpsink.h +++ b/plugins/channeltx/udpsink/udpsink.h @@ -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 { diff --git a/plugins/channeltx/udpsink/udpsinkgui.cpp b/plugins/channeltx/udpsink/udpsinkgui.cpp index c6f1ef56d..20e69a01b 100644 --- a/plugins/channeltx/udpsink/udpsinkgui.cpp +++ b/plugins/channeltx/udpsink/udpsinkgui.cpp @@ -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(); } diff --git a/plugins/channeltx/udpsink/udpsinkgui.h b/plugins/channeltx/udpsink/udpsinkgui.h index 4d1910896..88c9d89d2 100644 --- a/plugins/channeltx/udpsink/udpsinkgui.h +++ b/plugins/channeltx/udpsink/udpsinkgui.h @@ -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); diff --git a/plugins/channeltx/udpsink/udpsinkgui.ui b/plugins/channeltx/udpsink/udpsinkgui.ui index 5472fcaa7..b0e8a70ae 100644 --- a/plugins/channeltx/udpsink/udpsinkgui.ui +++ b/plugins/channeltx/udpsink/udpsinkgui.ui @@ -6,8 +6,8 @@ 0 0 - 342 - 400 + 388 + 403 @@ -42,13 +42,13 @@ 2 2 - 340 + 380 141 - 340 + 380 0 @@ -218,20 +218,65 @@ - - - - 0 - 22 - - + - Gain + Gi - + + + + 22 + 22 + + + + 100 + + + 1 + + + 1 + + + 10 + + + + + + + + 32 + 0 + + + + 10.0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Go + + + + + + + + 22 + 22 + + 100 @@ -241,13 +286,10 @@ 10 - - Qt::Horizontal - - + 32 @@ -827,6 +869,9 @@ 0 + + UDP <address>:<data port> + 000.000.000.000:00000