mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-02-27 16:08:44 -05:00
NFM demod: use AudioNetSink to send audio samples on the network
This commit is contained in:
parent
9b68836203
commit
f44df73590
@ -30,6 +30,7 @@
|
|||||||
#include "dsp/dspengine.h"
|
#include "dsp/dspengine.h"
|
||||||
#include "dsp/threadedbasebandsamplesink.h"
|
#include "dsp/threadedbasebandsamplesink.h"
|
||||||
#include "device/devicesourceapi.h"
|
#include "device/devicesourceapi.h"
|
||||||
|
#include "audio/audionetsink.h"
|
||||||
|
|
||||||
#include "nfmdemodgui.h"
|
#include "nfmdemodgui.h"
|
||||||
#include "nfmdemod.h"
|
#include "nfmdemod.h"
|
||||||
@ -79,7 +80,8 @@ NFMDemod::NFMDemod(DeviceSourceAPI *devieAPI) :
|
|||||||
m_afSquelch.setCoefficients(24, 600, 48000.0, 200, 0); // 0.5ms test period, 300ms average span, 48kS/s SR, 100ms attack, no decay
|
m_afSquelch.setCoefficients(24, 600, 48000.0, 200, 0); // 0.5ms test period, 300ms average span, 48kS/s SR, 100ms attack, no decay
|
||||||
|
|
||||||
DSPEngine::instance()->addAudioSink(&m_audioFifo);
|
DSPEngine::instance()->addAudioSink(&m_audioFifo);
|
||||||
m_udpBufferAudio = new UDPSink<qint16>(this, m_udpBlockSize, m_settings.m_udpPort);
|
m_audioNetSink = new AudioNetSink(this);
|
||||||
|
m_audioNetSink->setDestination(m_settings.m_udpAddress, m_settings.m_udpPort);
|
||||||
|
|
||||||
m_channelizer = new DownChannelizer(this);
|
m_channelizer = new DownChannelizer(this);
|
||||||
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
|
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
|
||||||
@ -93,7 +95,7 @@ NFMDemod::NFMDemod(DeviceSourceAPI *devieAPI) :
|
|||||||
NFMDemod::~NFMDemod()
|
NFMDemod::~NFMDemod()
|
||||||
{
|
{
|
||||||
DSPEngine::instance()->removeAudioSink(&m_audioFifo);
|
DSPEngine::instance()->removeAudioSink(&m_audioFifo);
|
||||||
delete m_udpBufferAudio;
|
delete m_audioNetSink;
|
||||||
m_deviceAPI->removeChannelAPI(this);
|
m_deviceAPI->removeChannelAPI(this);
|
||||||
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
|
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
|
||||||
delete m_threadedChannelizer;
|
delete m_threadedChannelizer;
|
||||||
@ -249,14 +251,18 @@ void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
|
|||||||
if (m_settings.m_ctcssOn && m_ctcssIndexSelected && (m_ctcssIndexSelected != m_ctcssIndex))
|
if (m_settings.m_ctcssOn && m_ctcssIndexSelected && (m_ctcssIndexSelected != m_ctcssIndex))
|
||||||
{
|
{
|
||||||
sample = 0;
|
sample = 0;
|
||||||
if (m_settings.m_copyAudioToUDP) m_udpBufferAudio->write(0);
|
if (m_settings.m_copyAudioToUDP) {
|
||||||
|
m_audioNetSink->write(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
demod = m_bandpass.filter(demod);
|
demod = m_bandpass.filter(demod);
|
||||||
Real squelchFactor = StepFunctions::smootherstep((Real) (m_squelchCount - m_squelchGate) / 480.0f);
|
Real squelchFactor = StepFunctions::smootherstep((Real) (m_squelchCount - m_squelchGate) / 480.0f);
|
||||||
sample = demod * m_settings.m_volume * squelchFactor;
|
sample = demod * m_settings.m_volume * squelchFactor;
|
||||||
if (m_settings.m_copyAudioToUDP) m_udpBufferAudio->write(demod * 5.0f * squelchFactor);
|
if (m_settings.m_copyAudioToUDP) {
|
||||||
|
m_audioNetSink->write(demod * 5.0f * squelchFactor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -272,7 +278,9 @@ void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
|
|||||||
}
|
}
|
||||||
|
|
||||||
sample = 0;
|
sample = 0;
|
||||||
if (m_settings.m_copyAudioToUDP) m_udpBufferAudio->write(0);
|
if (m_settings.m_copyAudioToUDP) {
|
||||||
|
m_audioNetSink->write(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_audioBuffer[m_audioBufferFill].l = sample;
|
m_audioBuffer[m_audioBufferFill].l = sample;
|
||||||
@ -459,8 +467,7 @@ void NFMDemod::applySettings(const NFMDemodSettings& settings, bool force)
|
|||||||
if ((settings.m_udpAddress != m_settings.m_udpAddress)
|
if ((settings.m_udpAddress != m_settings.m_udpAddress)
|
||||||
|| (settings.m_udpPort != m_settings.m_udpPort) || force)
|
|| (settings.m_udpPort != m_settings.m_udpPort) || force)
|
||||||
{
|
{
|
||||||
m_udpBufferAudio->setAddress(const_cast<QString&>(settings.m_udpAddress));
|
m_audioNetSink->setDestination(settings.m_udpAddress, settings.m_udpPort);
|
||||||
m_udpBufferAudio->setPort(settings.m_udpPort);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((settings.m_ctcssIndex != m_settings.m_ctcssIndex) || force)
|
if ((settings.m_ctcssIndex != m_settings.m_ctcssIndex) || force)
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
class DeviceSourceAPI;
|
class DeviceSourceAPI;
|
||||||
class ThreadedBasebandSampleSink;
|
class ThreadedBasebandSampleSink;
|
||||||
class DownChannelizer;
|
class DownChannelizer;
|
||||||
|
class AudioNetSink;
|
||||||
|
|
||||||
class NFMDemod : public BasebandSampleSink, public ChannelSinkAPI {
|
class NFMDemod : public BasebandSampleSink, public ChannelSinkAPI {
|
||||||
public:
|
public:
|
||||||
@ -211,7 +212,7 @@ private:
|
|||||||
uint m_audioBufferFill;
|
uint m_audioBufferFill;
|
||||||
|
|
||||||
AudioFifo m_audioFifo;
|
AudioFifo m_audioFifo;
|
||||||
UDPSink<qint16> *m_udpBufferAudio;
|
AudioNetSink *m_audioNetSink;
|
||||||
|
|
||||||
QMutex m_settingsMutex;
|
QMutex m_settingsMutex;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user