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

In some audio demods. Reapply audio sample rate only if channel sample rate effectively changes. Implements #791

This commit is contained in:
f4exb 2021-03-03 01:45:59 +01:00
parent ef1419d66e
commit c984dcc632
14 changed files with 105 additions and 14 deletions

View File

@ -36,6 +36,7 @@ AMDemodBaseband::AMDemodBaseband() :
DSPEngine::instance()->getAudioDeviceManager()->addAudioSink(m_sink.getAudioFifo(), getInputMessageQueue());
m_sink.applyAudioSampleRate(DSPEngine::instance()->getAudioDeviceManager()->getOutputSampleRate());
m_channelSampleRate = 0;
}
AMDemodBaseband::~AMDemodBaseband()
@ -50,6 +51,7 @@ void AMDemodBaseband::reset()
QMutexLocker mutexLocker(&m_mutex);
m_inputMessageQueue.clear();
m_sampleFifo.reset();
m_channelSampleRate = 0;
}
void AMDemodBaseband::startWork()
@ -148,7 +150,12 @@ bool AMDemodBaseband::handleMessage(const Message& cmd)
m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(notif.getSampleRate()));
m_channelizer->setBasebandSampleRate(notif.getSampleRate());
m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply in case of channel sample rate change
if (m_channelSampleRate != m_channelizer->getChannelSampleRate())
{
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply when channel sample rate changes
m_channelSampleRate = m_channelizer->getChannelSampleRate();
}
return true;
}
@ -164,7 +171,12 @@ void AMDemodBaseband::applySettings(const AMDemodSettings& settings, bool force)
{
m_channelizer->setChannelization(m_sink.getAudioSampleRate(), settings.m_inputFrequencyOffset);
m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply in case of channel sample rate change
if (m_channelSampleRate != m_channelizer->getChannelSampleRate())
{
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply when channel sample rate changes
m_channelSampleRate = m_channelizer->getChannelSampleRate();
}
}
if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force)

View File

@ -78,6 +78,7 @@ public:
private:
SampleSinkFifo m_sampleFifo;
DownChannelizer *m_channelizer;
int m_channelSampleRate;
AMDemodSink m_sink;
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
AMDemodSettings m_settings;

View File

@ -46,6 +46,7 @@ BFMDemodBaseband::BFMDemodBaseband() :
DSPEngine::instance()->getAudioDeviceManager()->addAudioSink(m_sink.getAudioFifo(), getInputMessageQueue());
m_sink.applyAudioSampleRate(DSPEngine::instance()->getAudioDeviceManager()->getOutputSampleRate());
m_channelSampleRate = 0;
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
}
@ -60,6 +61,7 @@ void BFMDemodBaseband::reset()
{
QMutexLocker mutexLocker(&m_mutex);
m_sampleFifo.reset();
m_channelSampleRate = 0;
}
void BFMDemodBaseband::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end)
@ -126,7 +128,12 @@ bool BFMDemodBaseband::handleMessage(const Message& cmd)
m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(notif.getSampleRate()));
m_channelizer->setBasebandSampleRate(notif.getSampleRate());
m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply in case of channel sample rate change
if (m_channelSampleRate != m_channelizer->getChannelSampleRate())
{
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply when channel sample rate changes
m_channelSampleRate = m_channelizer->getChannelSampleRate();
}
if (getMessageQueueToGUI())
{
@ -155,7 +162,12 @@ void BFMDemodBaseband::applySettings(const BFMDemodSettings& settings, bool forc
{
m_channelizer->setChannelization(BFMDemodSettings::requiredBW(settings.m_rfBandwidth), settings.m_inputFrequencyOffset);
m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply in case of channel sample rate change
if (m_channelSampleRate != m_channelizer->getChannelSampleRate())
{
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply when channel sample rate changea
m_channelSampleRate = m_channelizer->getChannelSampleRate();
}
if (getMessageQueueToGUI())
{

View File

@ -83,6 +83,7 @@ public:
private:
SampleSinkFifo m_sampleFifo;
DownChannelizer *m_channelizer;
int m_channelSampleRate;
BFMDemodSink m_sink;
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
BFMDemodSettings m_settings;

View File

@ -44,6 +44,7 @@ DSDDemodBaseband::DSDDemodBaseband() :
m_sink.applyAudioSampleRate(DSPEngine::instance()->getAudioDeviceManager()->getOutputSampleRate());
DSPEngine::instance()->getAudioDeviceManager()->addAudioSink(m_sink.getAudioFifo2(), getInputMessageQueue());
m_sink.applyAudioSampleRate(DSPEngine::instance()->getAudioDeviceManager()->getOutputSampleRate());
m_channelSampleRate = 0;
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
}
@ -59,6 +60,7 @@ void DSDDemodBaseband::reset()
{
QMutexLocker mutexLocker(&m_mutex);
m_sampleFifo.reset();
m_channelSampleRate = 0;
}
void DSDDemodBaseband::setChannel(ChannelAPI *channel)
@ -130,7 +132,12 @@ bool DSDDemodBaseband::handleMessage(const Message& cmd)
m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(notif.getSampleRate()));
m_channelizer->setBasebandSampleRate(notif.getSampleRate());
m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply in case of channel sample rate change
if (m_channelSampleRate != m_channelizer->getChannelSampleRate())
{
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply when channel sample rate changes
m_channelSampleRate = m_channelizer->getChannelSampleRate();
}
return true;
}
@ -146,7 +153,12 @@ void DSDDemodBaseband::applySettings(const DSDDemodSettings& settings, bool forc
{
m_channelizer->setChannelization(m_sink.getAudioSampleRate(), settings.m_inputFrequencyOffset);
m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply in case of channel sample rate change
if (m_channelSampleRate != m_channelizer->getChannelSampleRate())
{
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply when channel sample rate changes
m_channelSampleRate = m_channelizer->getChannelSampleRate();
}
}
if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force)

View File

@ -77,6 +77,7 @@ public:
private:
SampleSinkFifo m_sampleFifo;
DownChannelizer *m_channelizer;
int m_channelSampleRate;
DSDDemodSink m_sink;
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
DSDDemodSettings m_settings;

View File

@ -42,6 +42,7 @@ NFMDemodBaseband::NFMDemodBaseband() :
DSPEngine::instance()->getAudioDeviceManager()->addAudioSink(m_sink.getAudioFifo(), getInputMessageQueue());
m_sink.applyAudioSampleRate(DSPEngine::instance()->getAudioDeviceManager()->getOutputSampleRate());
m_channelSampleRate = 0;
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
}
@ -56,6 +57,7 @@ void NFMDemodBaseband::reset()
{
QMutexLocker mutexLocker(&m_mutex);
m_sampleFifo.reset();
m_channelSampleRate = 0;
}
void NFMDemodBaseband::setChannel(ChannelAPI *channel)
@ -127,7 +129,12 @@ bool NFMDemodBaseband::handleMessage(const Message& cmd)
m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(notif.getSampleRate()));
m_channelizer->setBasebandSampleRate(notif.getSampleRate());
m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply in case of channel sample rate change
if (m_channelSampleRate != m_channelizer->getChannelSampleRate())
{
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply when channel sample rate changes
m_channelSampleRate = m_channelizer->getChannelSampleRate();
}
return true;
}
@ -143,7 +150,12 @@ void NFMDemodBaseband::applySettings(const NFMDemodSettings& settings, bool forc
{
m_channelizer->setChannelization(m_sink.getAudioSampleRate(), settings.m_inputFrequencyOffset);
m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply in case of channel sample rate change
if (m_channelSampleRate != m_channelizer->getChannelSampleRate())
{
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply when channel sample rate changes
m_channelSampleRate = m_channelizer->getChannelSampleRate();
}
}
if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force)

View File

@ -75,6 +75,7 @@ public:
private:
SampleSinkFifo m_sampleFifo;
DownChannelizer *m_channelizer;
int m_channelSampleRate;
NFMDemodSink m_sink;
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
NFMDemodSettings m_settings;

View File

@ -46,6 +46,7 @@ SSBDemodBaseband::SSBDemodBaseband() :
DSPEngine::instance()->getAudioDeviceManager()->addAudioSink(m_sink.getAudioFifo(), getInputMessageQueue());
m_audioSampleRate = DSPEngine::instance()->getAudioDeviceManager()->getOutputSampleRate();
m_sink.applyAudioSampleRate(m_audioSampleRate);
m_channelSampleRate = 0;
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
}
@ -61,6 +62,7 @@ void SSBDemodBaseband::reset()
QMutexLocker mutexLocker(&m_mutex);
m_sink.applyAudioSampleRate(DSPEngine::instance()->getAudioDeviceManager()->getOutputSampleRate());
m_sampleFifo.reset();
m_channelSampleRate = 0;
}
void SSBDemodBaseband::setChannel(ChannelAPI *channel)
@ -132,7 +134,12 @@ bool SSBDemodBaseband::handleMessage(const Message& cmd)
m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(notif.getSampleRate()));
m_channelizer->setBasebandSampleRate(notif.getSampleRate());
m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
m_sink.applyAudioSampleRate(m_audioSampleRate); // reapply in case of channel sample rate change
if (m_channelSampleRate != m_channelizer->getChannelSampleRate())
{
m_sink.applyAudioSampleRate(m_audioSampleRate); // reapply when channel sample rate changes
m_channelSampleRate = m_channelizer->getChannelSampleRate();
}
return true;
}
@ -148,7 +155,12 @@ void SSBDemodBaseband::applySettings(const SSBDemodSettings& settings, bool forc
{
m_channelizer->setChannelization(m_audioSampleRate, settings.m_inputFrequencyOffset);
m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
m_sink.applyAudioSampleRate(m_audioSampleRate); // reapply in case of channel sample rate change
if (m_channelSampleRate != m_channelizer->getChannelSampleRate())
{
m_sink.applyAudioSampleRate(m_audioSampleRate); // reapply when channel sample rate changes
m_channelSampleRate = m_channelizer->getChannelSampleRate();
}
}
if ((settings.m_spanLog2 != m_settings.m_spanLog2) || force)

View File

@ -79,6 +79,7 @@ private:
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
SSBDemodSettings m_settings;
unsigned int m_audioSampleRate;
int m_channelSampleRate;
MessageQueue *m_messageQueueToGUI;
SpectrumVis *m_spectrumVis;
QMutex m_mutex;

View File

@ -38,6 +38,7 @@ VORDemodSCBaseband::VORDemodSCBaseband() :
DSPEngine::instance()->getAudioDeviceManager()->addAudioSink(m_sink.getAudioFifo(), getInputMessageQueue());
m_sink.applyAudioSampleRate(DSPEngine::instance()->getAudioDeviceManager()->getOutputSampleRate());
m_channelSampleRate = 0;
}
VORDemodSCBaseband::~VORDemodSCBaseband()
@ -52,6 +53,7 @@ void VORDemodSCBaseband::reset()
QMutexLocker mutexLocker(&m_mutex);
m_inputMessageQueue.clear();
m_sampleFifo.reset();
m_channelSampleRate = 0;
}
void VORDemodSCBaseband::startWork()
@ -145,7 +147,12 @@ bool VORDemodSCBaseband::handleMessage(const Message& cmd)
m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(notif.getSampleRate()));
m_channelizer->setBasebandSampleRate(notif.getSampleRate());
m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply in case of channel sample rate change
if (m_channelSampleRate != m_channelizer->getChannelSampleRate())
{
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply when channel sample rate changes
m_channelSampleRate = m_channelizer->getChannelSampleRate();
}
return true;
}
@ -161,7 +168,12 @@ void VORDemodSCBaseband::applySettings(const VORDemodSCSettings& settings, bool
{
m_channelizer->setChannelization(m_sink.getAudioSampleRate(), settings.m_inputFrequencyOffset);
m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply in case of channel sample rate change
if (m_channelSampleRate != m_channelizer->getChannelSampleRate())
{
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply when channel sample rate changes
m_channelSampleRate = m_channelizer->getChannelSampleRate();
}
}
if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force)

View File

@ -74,6 +74,7 @@ public:
private:
SampleSinkFifo m_sampleFifo;
DownChannelizer * m_channelizer;
int m_channelSampleRate;
VORDemodSCSink m_sink;
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
VORDemodSCSettings m_settings;

View File

@ -42,6 +42,7 @@ WFMDemodBaseband::WFMDemodBaseband() :
DSPEngine::instance()->getAudioDeviceManager()->addAudioSink(m_sink.getAudioFifo(), getInputMessageQueue());
m_sink.applyAudioSampleRate(DSPEngine::instance()->getAudioDeviceManager()->getOutputSampleRate());
m_channelSampleRate = 0;
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
}
@ -56,6 +57,7 @@ void WFMDemodBaseband::reset()
{
QMutexLocker mutexLocker(&m_mutex);
m_sampleFifo.reset();
m_channelSampleRate = 0;
}
void WFMDemodBaseband::setChannel(ChannelAPI *channel)
@ -127,7 +129,12 @@ bool WFMDemodBaseband::handleMessage(const Message& cmd)
m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(notif.getSampleRate()));
m_channelizer->setBasebandSampleRate(notif.getSampleRate());
m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply in case of channel sample rate change
if (m_channelSampleRate != m_channelizer->getChannelSampleRate())
{
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply when channel sample rate changes
m_channelSampleRate = m_channelizer->getChannelSampleRate();
}
return true;
}
@ -144,7 +151,12 @@ void WFMDemodBaseband::applySettings(const WFMDemodSettings& settings, bool forc
{
m_channelizer->setChannelization(WFMDemodSettings::requiredBW(settings.m_rfBandwidth), settings.m_inputFrequencyOffset);
m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply in case of channel sample rate change
if (m_channelSampleRate != m_channelizer->getChannelSampleRate())
{
m_sink.applyAudioSampleRate(m_sink.getAudioSampleRate()); // reapply when channel sample rate changes
m_channelSampleRate = m_channelizer->getChannelSampleRate();
}
}
if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force)

View File

@ -75,6 +75,7 @@ public:
private:
SampleSinkFifo m_sampleFifo;
DownChannelizer *m_channelizer;
int m_channelSampleRate;
WFMDemodSink m_sink;
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
WFMDemodSettings m_settings;