1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 01:55:48 -05:00

WFM demod: implemented copy audio to UDP

This commit is contained in:
f4exb 2017-11-21 23:30:09 +01:00
parent a1f6d29f03
commit cf2f099c37
7 changed files with 45 additions and 6 deletions

View File

@ -34,9 +34,9 @@ struct SSBDemodSettings
bool m_audioFlipChannels;
bool m_dsb;
bool m_audioMute;
bool m_copyAudioToUDP;
bool m_agc;
bool m_agcClamping;
bool m_copyAudioToUDP;
int m_agcTimeLog2;
int m_agcPowerThreshold;
int m_agcThresholdGate;

View File

@ -34,6 +34,7 @@ MESSAGE_CLASS_DEFINITION(WFMDemod::MsgConfigureWFMDemod, Message)
MESSAGE_CLASS_DEFINITION(WFMDemod::MsgConfigureChannelizer, Message)
const QString WFMDemod::m_channelID = "de.maintech.sdrangelove.channel.wfm";
const int WFMDemod::m_udpBlockSize = 512;
WFMDemod::WFMDemod(DeviceSourceAPI* deviceAPI) :
m_deviceAPI(deviceAPI),
@ -60,6 +61,7 @@ WFMDemod::WFMDemod(DeviceSourceAPI* deviceAPI) :
m_movingAverage.resize(16, 0);
DSPEngine::instance()->addAudioSink(&m_audioFifo);
m_udpBufferAudio = new UDPSink<qint16>(this, m_udpBlockSize, m_settings.m_udpPort);
m_channelizer = new DownChannelizer(this);
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
@ -82,6 +84,8 @@ WFMDemod::~WFMDemod()
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
delete m_udpBufferAudio;
}
void WFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool firstOfBurst __attribute__((unused)))
@ -141,10 +145,13 @@ void WFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
if(m_interpolator.decimate(&m_interpolatorDistanceRemain, e, &ci))
{
quint16 sample = (qint16)(ci.real() * 3276.8f * m_settings.m_volume);
qint16 sample = (qint16)(ci.real() * 3276.8f * m_settings.m_volume);
m_sampleBuffer.push_back(Sample(sample, sample));
m_audioBuffer[m_audioBufferFill].l = sample;
m_audioBuffer[m_audioBufferFill].r = sample;
if (m_settings.m_copyAudioToUDP) { m_udpBufferAudio->write(sample); }
++m_audioBufferFill;
if(m_audioBufferFill >= m_audioBuffer.size())
@ -176,7 +183,7 @@ void WFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
m_audioBufferFill = 0;
}
if(m_sampleSink != NULL)
if(m_sampleSink != 0)
{
m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), false);
}
@ -303,5 +310,12 @@ void WFMDemod::applySettings(const WFMDemodSettings& settings, bool force)
m_squelchLevel *= m_squelchLevel;
}
if ((m_settings.m_udpAddress != settings.m_udpAddress)
|| (m_settings.m_udpPort != settings.m_udpPort) || force)
{
m_udpBufferAudio->setAddress(const_cast<QString&>(settings.m_udpAddress));
m_udpBufferAudio->setPort(settings.m_udpPort);
}
m_settings = settings;
}

View File

@ -150,6 +150,7 @@ private:
AudioVector m_audioBuffer;
uint m_audioBufferFill;
UDPSink<qint16> *m_udpBufferAudio;
BasebandSampleSink* m_sampleSink;
AudioFifo m_audioFifo;
@ -158,7 +159,9 @@ private:
PhaseDiscriminators m_phaseDiscri;
void applySettings(const WFMDemodSettings& settings, bool force = false);
static const int m_udpBlockSize;
void applySettings(const WFMDemodSettings& settings, bool force = false);
};
#endif // INCLUDE_WFMDEMOD_H

View File

@ -131,6 +131,12 @@ void WFMDemodGUI::on_audioMute_toggled(bool checked)
applySettings();
}
void WFMDemodGUI::on_copyAudioToUDP_toggled(bool checked)
{
m_settings.m_copyAudioToUDP = checked;
applySettings();
}
void WFMDemodGUI::onWidgetRolled(QWidget* widget __attribute__((unused)), bool rollDown __attribute__((unused)))
{
}
@ -269,7 +275,7 @@ void WFMDemodGUI::displaySettings()
void WFMDemodGUI::displayUDPAddress()
{
//ui->copyAudioToUDP->setToolTip(QString("Copy audio output to UDP %1:%2").arg(m_channelMarker.getUDPAddress()).arg(m_channelMarker.getUDPSendPort()));
ui->copyAudioToUDP->setToolTip(QString("Copy audio output to UDP %1:%2").arg(m_settings.m_udpAddress).arg(m_settings.m_udpPort));
}
void WFMDemodGUI::leaveEvent(QEvent*)

View File

@ -82,6 +82,7 @@ private slots:
void on_volume_valueChanged(int value);
void on_squelch_valueChanged(int value);
void on_audioMute_toggled(bool checked);
void on_copyAudioToUDP_toggled(bool copy);
void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDialogCalled(const QPoint& p);
void tick();

View File

@ -374,6 +374,16 @@
</property>
</widget>
</item>
<item>
<widget class="ButtonSwitch" name="copyAudioToUDP">
<property name="toolTip">
<string>Copy audio to UDP</string>
</property>
<property name="text">
<string>U</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="audioMute">
<property name="text">
@ -413,6 +423,11 @@
<header>gui/valuedialz.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../sdrgui/resources/res.qrc"/>

View File

@ -8,7 +8,7 @@
const PluginDescriptor WFMPlugin::m_pluginDescriptor = {
QString("WFM Demodulator"),
QString("3.8.2"),
QString("3.8.5"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,