1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-23 08:28:36 -05:00

UDPSink plugin: implemented AM

This commit is contained in:
f4exb 2017-08-19 01:46:52 +02:00
parent b3bd9967a4
commit 9ac435d491
5 changed files with 94 additions and 3 deletions

View File

@ -161,7 +161,7 @@ void UDPSink::modulateSample()
if (m_squelchOpen) 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.real(cos(m_modPhasor) * 10362.2f * m_running.m_gain);
m_modSample.imag(sin(m_modPhasor) * 10362.2f * m_running.m_gain); m_modSample.imag(sin(m_modPhasor) * 10362.2f * m_running.m_gain);
calculateLevel(m_modSample); calculateLevel(m_modSample);
@ -172,6 +172,27 @@ void UDPSink::modulateSample()
m_modSample.imag(0.0f); 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 else
{ {
m_modSample.real(0.0f); m_modSample.real(0.0f);
@ -375,6 +396,7 @@ void UDPSink::configure(MessageQueue* messageQueue,
Real outputSampleRate, Real outputSampleRate,
Real rfBandwidth, Real rfBandwidth,
int fmDeviation, int fmDeviation,
Real amModFactor,
QString& udpAddress, QString& udpAddress,
int udpPort, int udpPort,
bool channelMute, bool channelMute,
@ -388,6 +410,7 @@ void UDPSink::configure(MessageQueue* messageQueue,
outputSampleRate, outputSampleRate,
rfBandwidth, rfBandwidth,
fmDeviation, fmDeviation,
amModFactor,
udpAddress, udpAddress,
udpPort, udpPort,
channelMute, channelMute,

View File

@ -64,6 +64,7 @@ public:
Real inputSampleRate, Real inputSampleRate,
Real rfBandwidth, Real rfBandwidth,
int fmDeviation, int fmDeviation,
Real amModFactor,
QString& udpAddress, QString& udpAddress,
int udpPort, int udpPort,
bool channelMute, bool channelMute,
@ -93,6 +94,7 @@ private:
Real getInputSampleRate() const { return m_inputSampleRate; } Real getInputSampleRate() const { return m_inputSampleRate; }
Real getRFBandwidth() const { return m_rfBandwidth; } Real getRFBandwidth() const { return m_rfBandwidth; }
int getFMDeviation() const { return m_fmDeviation; } int getFMDeviation() const { return m_fmDeviation; }
Real getAMModFactor() const { return m_amModFactor; }
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; }
@ -107,6 +109,7 @@ private:
Real inputSampleRate, Real inputSampleRate,
Real rfBandwidth, Real rfBandwidth,
int fmDeviation, int fmDeviation,
Real amModFactor,
QString& udpAddress, QString& udpAddress,
int udpPort, int udpPort,
bool channelMute, bool channelMute,
@ -120,6 +123,7 @@ private:
inputSampleRate, inputSampleRate,
rfBandwidth, rfBandwidth,
fmDeviation, fmDeviation,
amModFactor,
udpAddress, udpAddress,
udpPort, udpPort,
channelMute, channelMute,
@ -135,6 +139,7 @@ private:
Real m_inputSampleRate; Real m_inputSampleRate;
Real m_rfBandwidth; Real m_rfBandwidth;
int m_fmDeviation; int m_fmDeviation;
Real m_amModFactor;
QString m_udpAddress; QString m_udpAddress;
int m_udpPort; int m_udpPort;
bool m_channelMute; bool m_channelMute;
@ -148,6 +153,7 @@ private:
Real inputSampleRate, Real inputSampleRate,
Real rfBandwidth, Real rfBandwidth,
int fmDeviation, int fmDeviation,
Real amModFactor,
QString& udpAddress, QString& udpAddress,
int udpPort, int udpPort,
bool channelMute, bool channelMute,
@ -161,6 +167,7 @@ private:
m_inputSampleRate(inputSampleRate), m_inputSampleRate(inputSampleRate),
m_rfBandwidth(rfBandwidth), m_rfBandwidth(rfBandwidth),
m_fmDeviation(fmDeviation), m_fmDeviation(fmDeviation),
m_amModFactor(amModFactor),
m_udpAddress(udpAddress), m_udpAddress(udpAddress),
m_udpPort(udpPort), m_udpPort(udpPort),
m_channelMute(channelMute), m_channelMute(channelMute),
@ -217,6 +224,7 @@ private:
qint64 m_inputFrequencyOffset; qint64 m_inputFrequencyOffset;
Real m_rfBandwidth; Real m_rfBandwidth;
int m_fmDeviation; int m_fmDeviation;
Real m_amModFactor;
bool m_channelMute; bool m_channelMute;
Real m_gain; Real m_gain;
Real m_squelch; //!< squared magnitude Real m_squelch; //!< squared magnitude
@ -234,6 +242,7 @@ private:
m_inputFrequencyOffset(0), m_inputFrequencyOffset(0),
m_rfBandwidth(12500), m_rfBandwidth(12500),
m_fmDeviation(1.0), m_fmDeviation(1.0),
m_amModFactor(0.95),
m_channelMute(false), m_channelMute(false),
m_gain(1.0), m_gain(1.0),
m_squelch(-50.0), m_squelch(-50.0),

View File

@ -328,6 +328,13 @@ void UDPSinkGUI::applySettings(bool force)
fmDeviation = 2500; fmDeviation = 2500;
} }
int amModPercent = ui->amModPercent->text().toInt(&ok);
if ((!ok) || (amModPercent < 1) || (amModPercent > 100))
{
amModPercent = 95;
}
setTitleColor(m_channelMarker.getColor()); setTitleColor(m_channelMarker.getColor());
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency()); ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
ui->sampleRate->setText(QString("%1").arg(inputSampleRate, 0)); ui->sampleRate->setText(QString("%1").arg(inputSampleRate, 0));
@ -335,6 +342,7 @@ void UDPSinkGUI::applySettings(bool force)
//ui->udpAddress->setText(m_udpAddress); //ui->udpAddress->setText(m_udpAddress);
ui->udpPort->setText(QString("%1").arg(udpPort)); ui->udpPort->setText(QString("%1").arg(udpPort));
ui->fmDeviation->setText(QString("%1").arg(fmDeviation)); ui->fmDeviation->setText(QString("%1").arg(fmDeviation));
ui->amModPercent->setText(QString("%1").arg(amModPercent));
m_channelMarker.disconnect(this, SLOT(channelMarkerChanged())); m_channelMarker.disconnect(this, SLOT(channelMarkerChanged()));
m_channelMarker.setBandwidth((int)rfBandwidth); m_channelMarker.setBandwidth((int)rfBandwidth);
connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(channelMarkerChanged())); connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(channelMarkerChanged()));
@ -397,6 +405,7 @@ void UDPSinkGUI::applySettings(bool force)
inputSampleRate, inputSampleRate,
rfBandwidth, rfBandwidth,
fmDeviation, fmDeviation,
amModPercent / 100.0f,
m_udpAddress, m_udpAddress,
udpPort, udpPort,
ui->channelMute->isChecked(), ui->channelMute->isChecked(),
@ -430,12 +439,18 @@ void UDPSinkGUI::on_deltaFrequency_changed(qint64 value)
void UDPSinkGUI::on_sampleFormat_currentIndexChanged(int index) 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); ui->fmDeviation->setEnabled(true);
} else { } else {
ui->fmDeviation->setEnabled(false); ui->fmDeviation->setEnabled(false);
} }
if (index == (int) UDPSink::FormatAMMono) {
ui->amModPercent->setEnabled(true);
} else {
ui->amModPercent->setEnabled(false);
}
ui->applyBtn->setEnabled(true); ui->applyBtn->setEnabled(true);
} }
@ -454,6 +469,11 @@ void UDPSinkGUI::on_fmDeviation_textEdited(const QString& arg1 __attribute__((un
ui->applyBtn->setEnabled(true); 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))) void UDPSinkGUI::on_udpAddress_textEdited(const QString& arg1 __attribute__((unused)))
{ {
ui->applyBtn->setEnabled(true); ui->applyBtn->setEnabled(true);

View File

@ -64,6 +64,7 @@ private slots:
void on_udpAddress_textEdited(const QString& arg1); void on_udpAddress_textEdited(const QString& arg1);
void on_udpPort_textEdited(const QString& arg1); void on_udpPort_textEdited(const QString& arg1);
void on_fmDeviation_textEdited(const QString& arg1); void on_fmDeviation_textEdited(const QString& arg1);
void on_amModPercent_textEdited(const QString& arg1);
void on_applyBtn_clicked(); void on_applyBtn_clicked();
void onWidgetRolled(QWidget* widget, bool rollDown); void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDoubleClicked(); void onMenuDoubleClicked();

View File

@ -100,7 +100,7 @@
<item> <item>
<widget class="QLineEdit" name="fmDeviation"> <widget class="QLineEdit" name="fmDeviation">
<property name="toolTip"> <property name="toolTip">
<string>FM deviation in Hz (for S16LE NFM format)</string> <string>FM deviation in Hz</string>
</property> </property>
<property name="inputMask"> <property name="inputMask">
<string>00000</string> <string>00000</string>
@ -110,11 +110,43 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QLabel" name="amModPercentLabel">
<property name="text">
<string>AM%</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="amModPercent">
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Percentage of AM modulation</string>
</property>
<property name="inputMask">
<string>000</string>
</property>
<property name="text">
<string>95</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="applyBtn"> <widget class="QPushButton" name="applyBtn">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip"> <property name="toolTip">
<string>Apply text input and/or samples format</string> <string>Apply text input and/or samples format</string>
</property> </property>
@ -700,6 +732,12 @@
</item> </item>
<item> <item>
<widget class="QSlider" name="squelch"> <widget class="QSlider" name="squelch">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="toolTip"> <property name="toolTip">
<string>Power squelch threshold (dB)</string> <string>Power squelch threshold (dB)</string>
</property> </property>