diff --git a/plugins/channeltx/udpsink/udpsink.cpp b/plugins/channeltx/udpsink/udpsink.cpp
index e707cb95f..6b64f74dd 100644
--- a/plugins/channeltx/udpsink/udpsink.cpp
+++ b/plugins/channeltx/udpsink/udpsink.cpp
@@ -161,7 +161,7 @@ void UDPSink::modulateSample()
if (m_squelchOpen)
{
- m_modPhasor += (m_running.m_fmDeviation / m_running.m_inputSampleRate) * (t / 32768.0) * M_PI * 2.0f;
+ 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);
calculateLevel(m_modSample);
@@ -172,6 +172,27 @@ void UDPSink::modulateSample()
m_modSample.imag(0.0f);
}
}
+ else if (m_running.m_sampleFormat == FormatAMMono)
+ {
+ FixReal t;
+ m_udpHandler.readSample(t);
+ m_inMovingAverage.feed((t*t)/1073741824.0);
+ m_inMagsq = m_inMovingAverage.average();
+
+ calculateSquelch(m_inMagsq);
+
+ 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.imag(0.0f);
+ calculateLevel(m_modSample);
+ }
+ else
+ {
+ m_modSample.real(0.0f);
+ m_modSample.imag(0.0f);
+ }
+ }
else
{
m_modSample.real(0.0f);
@@ -375,6 +396,7 @@ void UDPSink::configure(MessageQueue* messageQueue,
Real outputSampleRate,
Real rfBandwidth,
int fmDeviation,
+ Real amModFactor,
QString& udpAddress,
int udpPort,
bool channelMute,
@@ -388,6 +410,7 @@ void UDPSink::configure(MessageQueue* messageQueue,
outputSampleRate,
rfBandwidth,
fmDeviation,
+ amModFactor,
udpAddress,
udpPort,
channelMute,
diff --git a/plugins/channeltx/udpsink/udpsink.h b/plugins/channeltx/udpsink/udpsink.h
index 4033318d7..2814a01b2 100644
--- a/plugins/channeltx/udpsink/udpsink.h
+++ b/plugins/channeltx/udpsink/udpsink.h
@@ -64,6 +64,7 @@ public:
Real inputSampleRate,
Real rfBandwidth,
int fmDeviation,
+ Real amModFactor,
QString& udpAddress,
int udpPort,
bool channelMute,
@@ -93,6 +94,7 @@ private:
Real getInputSampleRate() const { return m_inputSampleRate; }
Real getRFBandwidth() const { return m_rfBandwidth; }
int getFMDeviation() const { return m_fmDeviation; }
+ Real getAMModFactor() const { return m_amModFactor; }
const QString& getUDPAddress() const { return m_udpAddress; }
int getUDPPort() const { return m_udpPort; }
bool getChannelMute() const { return m_channelMute; }
@@ -107,6 +109,7 @@ private:
Real inputSampleRate,
Real rfBandwidth,
int fmDeviation,
+ Real amModFactor,
QString& udpAddress,
int udpPort,
bool channelMute,
@@ -120,6 +123,7 @@ private:
inputSampleRate,
rfBandwidth,
fmDeviation,
+ amModFactor,
udpAddress,
udpPort,
channelMute,
@@ -135,6 +139,7 @@ private:
Real m_inputSampleRate;
Real m_rfBandwidth;
int m_fmDeviation;
+ Real m_amModFactor;
QString m_udpAddress;
int m_udpPort;
bool m_channelMute;
@@ -148,6 +153,7 @@ private:
Real inputSampleRate,
Real rfBandwidth,
int fmDeviation,
+ Real amModFactor,
QString& udpAddress,
int udpPort,
bool channelMute,
@@ -161,6 +167,7 @@ private:
m_inputSampleRate(inputSampleRate),
m_rfBandwidth(rfBandwidth),
m_fmDeviation(fmDeviation),
+ m_amModFactor(amModFactor),
m_udpAddress(udpAddress),
m_udpPort(udpPort),
m_channelMute(channelMute),
@@ -217,6 +224,7 @@ private:
qint64 m_inputFrequencyOffset;
Real m_rfBandwidth;
int m_fmDeviation;
+ Real m_amModFactor;
bool m_channelMute;
Real m_gain;
Real m_squelch; //!< squared magnitude
@@ -234,6 +242,7 @@ private:
m_inputFrequencyOffset(0),
m_rfBandwidth(12500),
m_fmDeviation(1.0),
+ m_amModFactor(0.95),
m_channelMute(false),
m_gain(1.0),
m_squelch(-50.0),
diff --git a/plugins/channeltx/udpsink/udpsinkgui.cpp b/plugins/channeltx/udpsink/udpsinkgui.cpp
index 3a6eec741..158407db7 100644
--- a/plugins/channeltx/udpsink/udpsinkgui.cpp
+++ b/plugins/channeltx/udpsink/udpsinkgui.cpp
@@ -328,6 +328,13 @@ void UDPSinkGUI::applySettings(bool force)
fmDeviation = 2500;
}
+ int amModPercent = ui->amModPercent->text().toInt(&ok);
+
+ if ((!ok) || (amModPercent < 1) || (amModPercent > 100))
+ {
+ amModPercent = 95;
+ }
+
setTitleColor(m_channelMarker.getColor());
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
ui->sampleRate->setText(QString("%1").arg(inputSampleRate, 0));
@@ -335,6 +342,7 @@ void UDPSinkGUI::applySettings(bool force)
//ui->udpAddress->setText(m_udpAddress);
ui->udpPort->setText(QString("%1").arg(udpPort));
ui->fmDeviation->setText(QString("%1").arg(fmDeviation));
+ ui->amModPercent->setText(QString("%1").arg(amModPercent));
m_channelMarker.disconnect(this, SLOT(channelMarkerChanged()));
m_channelMarker.setBandwidth((int)rfBandwidth);
connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(channelMarkerChanged()));
@@ -397,6 +405,7 @@ void UDPSinkGUI::applySettings(bool force)
inputSampleRate,
rfBandwidth,
fmDeviation,
+ amModPercent / 100.0f,
m_udpAddress,
udpPort,
ui->channelMute->isChecked(),
@@ -430,12 +439,18 @@ void UDPSinkGUI::on_deltaFrequency_changed(qint64 value)
void UDPSinkGUI::on_sampleFormat_currentIndexChanged(int index)
{
- if ((index == 1) || (index == 2)) {
+ if ((index == (int) UDPSink::FormatNFM) || (index == (int) UDPSink::FormatNFMMono)) {
ui->fmDeviation->setEnabled(true);
} else {
ui->fmDeviation->setEnabled(false);
}
+ if (index == (int) UDPSink::FormatAMMono) {
+ ui->amModPercent->setEnabled(true);
+ } else {
+ ui->amModPercent->setEnabled(false);
+ }
+
ui->applyBtn->setEnabled(true);
}
@@ -454,6 +469,11 @@ void UDPSinkGUI::on_fmDeviation_textEdited(const QString& arg1 __attribute__((un
ui->applyBtn->setEnabled(true);
}
+void UDPSinkGUI::on_amModPercent_textEdited(const QString& arg1 __attribute__((unused)))
+{
+ ui->applyBtn->setEnabled(true);
+}
+
void UDPSinkGUI::on_udpAddress_textEdited(const QString& arg1 __attribute__((unused)))
{
ui->applyBtn->setEnabled(true);
diff --git a/plugins/channeltx/udpsink/udpsinkgui.h b/plugins/channeltx/udpsink/udpsinkgui.h
index 2dc82c0a6..04470f9b6 100644
--- a/plugins/channeltx/udpsink/udpsinkgui.h
+++ b/plugins/channeltx/udpsink/udpsinkgui.h
@@ -64,6 +64,7 @@ private slots:
void on_udpAddress_textEdited(const QString& arg1);
void on_udpPort_textEdited(const QString& arg1);
void on_fmDeviation_textEdited(const QString& arg1);
+ void on_amModPercent_textEdited(const QString& arg1);
void on_applyBtn_clicked();
void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDoubleClicked();
diff --git a/plugins/channeltx/udpsink/udpsinkgui.ui b/plugins/channeltx/udpsink/udpsinkgui.ui
index 697a123d4..c88c059f0 100644
--- a/plugins/channeltx/udpsink/udpsinkgui.ui
+++ b/plugins/channeltx/udpsink/udpsinkgui.ui
@@ -100,7 +100,7 @@
-
- FM deviation in Hz (for S16LE NFM format)
+ FM deviation in Hz
00000
@@ -110,11 +110,43 @@
+ -
+
+
+ AM%
+
+
+
+ -
+
+
+
+ 60
+ 16777215
+
+
+
+ Percentage of AM modulation
+
+
+ 000
+
+
+ 95
+
+
+
-
false
+
+
+ 60
+ 16777215
+
+
Apply text input and/or samples format
@@ -700,6 +732,12 @@
-
+
+
+ 30
+ 0
+
+
Power squelch threshold (dB)