1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00

Deep redesign: SSB audio FIFO on object stack

This commit is contained in:
f4exb 2015-08-24 02:40:02 +02:00
parent 11cc3044f8
commit 67866854ca
9 changed files with 26 additions and 32 deletions

View File

@ -220,7 +220,6 @@ AMDemodGUI::AMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
AMDemodGUI::~AMDemodGUI()
{
m_pluginAPI->removeChannelInstance(this);
DSPEngine::instance()->removeAudioSink(m_audioFifo);
DSPEngine::instance()->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;

View File

@ -7,7 +7,6 @@
class PluginAPI;
class ChannelMarker;
class AudioFifo;
class ThreadedSampleSink;
class Channelizer;
class AMDemod;
@ -51,7 +50,6 @@ private:
bool m_basicSettingsShown;
bool m_doApplySettings;
AudioFifo* m_audioFifo;
ThreadedSampleSink* m_threadedChannelizer;
Channelizer* m_channelizer;
AMDemod* m_amDemod;

View File

@ -166,7 +166,6 @@ bool ChannelAnalyzer::handleMessage(const Message& cmd)
m_Bandwidth = band;
m_LowCutoff = lowCutoff;
//m_interpolator.create(16, m_sampleRate, band * 2.0f);
SSBFilter->create_filter(m_LowCutoff / m_sampleRate, m_Bandwidth / m_sampleRate);
DSBFilter->create_dsb_filter(m_Bandwidth / m_sampleRate);

View File

@ -21,15 +21,12 @@
#include <vector>
#include "dsp/samplesink.h"
#include "dsp/nco.h"
#include "dsp/interpolator.h"
#include "dsp/fftfilt.h"
#include "audio/audiofifo.h"
#include "util/message.h"
#define ssbFftLen 1024
//class AudioFifo;
class ChannelAnalyzer : public SampleSink {
public:
ChannelAnalyzer(SampleSink* m_sampleSink);

View File

@ -8,7 +8,6 @@
class PluginAPI;
class ChannelMarker;
class AudioFifo;
class ThreadedSampleSink;
class Channelizer;
class NFMDemod;
@ -54,7 +53,6 @@ private:
bool m_basicSettingsShown;
bool m_doApplySettings;
AudioFifo* m_audioFifo;
ThreadedSampleSink* m_threadedChannelizer;
Channelizer* m_channelizer;
NFMDemod* m_nfmDemod;

View File

@ -21,13 +21,14 @@
#include <stdio.h>
#include "ssbdemod.h"
#include "audio/audiooutput.h"
#include "dsp/dspengine.h"
#include "dsp/channelizer.h"
MESSAGE_CLASS_DEFINITION(SSBDemod::MsgConfigureSSBDemod, Message)
SSBDemod::SSBDemod(AudioFifo* audioFifo, SampleSink* sampleSink) :
SSBDemod::SSBDemod(SampleSink* sampleSink) :
m_sampleSink(sampleSink),
m_audioFifo(audioFifo)
m_audioFifo(4, 24000)
{
setObjectName("SSBDemod");
@ -38,21 +39,29 @@ SSBDemod::SSBDemod(AudioFifo* audioFifo, SampleSink* sampleSink) :
m_sampleRate = 96000;
m_frequency = 0;
m_nco.setFreq(m_frequency, m_sampleRate);
m_interpolator.create(16, m_sampleRate, 5000);
m_sampleDistanceRemain = (Real)m_sampleRate / 48000.0;
m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate();
m_audioBuffer.resize(512);
m_interpolator.create(16, m_sampleRate, 5000);
m_sampleDistanceRemain = (Real) m_sampleRate / m_audioSampleRate;
m_audioBuffer.resize(1<<9);
m_audioBufferFill = 0;
m_undersampleCount = 0;
m_usb = true;
SSBFilter = new fftfilt(m_LowCutoff / 48000.0, m_Bandwidth / 48000.0, ssbFftLen);
// if (!USBFilter) segfault;
SSBFilter = new fftfilt(m_LowCutoff / m_audioSampleRate, m_Bandwidth / m_audioSampleRate, ssbFftLen);
DSPEngine::instance()->addAudioSink(&m_audioFifo);
}
SSBDemod::~SSBDemod()
{
if (SSBFilter) delete SSBFilter;
if (SSBFilter)
{
delete SSBFilter;
}
DSPEngine::instance()->removeAudioSink(&m_audioFifo);
}
void SSBDemod::configure(MessageQueue* messageQueue, Real Bandwidth, Real LowCutoff, Real volume, int spanLog2)
@ -78,7 +87,7 @@ void SSBDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iter
if(m_interpolator.interpolate(&m_sampleDistanceRemain, c, &ci))
{
n_out = SSBFilter->runSSB(ci, &sideband, m_usb);
m_sampleDistanceRemain += (Real)m_sampleRate / 48000.0;
m_sampleDistanceRemain += (Real)m_sampleRate / m_audioSampleRate;
}
else
{
@ -109,7 +118,7 @@ void SSBDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iter
if (m_audioBufferFill >= m_audioBuffer.size())
{
uint res = m_audioFifo->write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 1);
uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 1);
if (res != m_audioBufferFill)
{
@ -121,7 +130,7 @@ void SSBDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iter
}
}
if (m_audioFifo->write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 0) != m_audioBufferFill)
if (m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 0) != m_audioBufferFill)
{
qDebug("SSBDemod::feed: lost samples");
}
@ -156,7 +165,7 @@ bool SSBDemod::handleMessage(const Message& cmd)
m_sampleRate = notif.getSampleRate();
m_nco.setFreq(-notif.getFrequencyOffset(), m_sampleRate);
m_interpolator.create(16, m_sampleRate, m_Bandwidth);
m_sampleDistanceRemain = m_sampleRate / 48000.0;
m_sampleDistanceRemain = m_sampleRate / m_audioSampleRate;
qDebug() << "SSBDemod::handleMessage: MsgChannelizerNotification: m_sampleRate: " << m_sampleRate
<< " frequencyOffset" << notif.getFrequencyOffset();
@ -187,7 +196,7 @@ bool SSBDemod::handleMessage(const Message& cmd)
m_LowCutoff = lowCutoff;
m_interpolator.create(16, m_sampleRate, band * 2.0f);
SSBFilter->create_filter(m_LowCutoff / 48000.0f, m_Bandwidth / 48000.0f);
SSBFilter->create_filter(m_LowCutoff / (float) m_audioSampleRate, m_Bandwidth / (float) m_audioSampleRate);
m_volume = cfg.getVolume();
m_volume *= m_volume * 0.1;

View File

@ -28,11 +28,9 @@
#define ssbFftLen 1024
class AudioFifo;
class SSBDemod : public SampleSink {
public:
SSBDemod(AudioFifo* audioFifo, SampleSink* sampleSink);
SSBDemod(SampleSink* sampleSink);
virtual ~SSBDemod();
void configure(MessageQueue* messageQueue, Real Bandwidth, Real LowCutoff, Real volume, int spanLog2);
@ -97,7 +95,8 @@ private:
AudioVector m_audioBuffer;
uint m_audioBufferFill;
AudioFifo* m_audioFifo;
AudioFifo m_audioFifo;
quint32 m_audioSampleRate;
};
#endif // INCLUDE_SSBDEMOD_H

View File

@ -255,12 +255,10 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
m_audioFifo = new AudioFifo(4, 48000 / 2);
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
m_ssbDemod = new SSBDemod(m_audioFifo, m_spectrumVis);
m_ssbDemod = new SSBDemod(m_spectrumVis);
m_channelizer = new Channelizer(m_ssbDemod);
m_threadedChannelizer = new ThreadedSampleSink(m_channelizer, this);
DSPEngine::instance()->addAudioSink(m_audioFifo);
DSPEngine::instance()->addThreadedSink(m_threadedChannelizer);
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
@ -289,13 +287,11 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
SSBDemodGUI::~SSBDemodGUI()
{
m_pluginAPI->removeChannelInstance(this);
DSPEngine::instance()->removeAudioSink(m_audioFifo);
DSPEngine::instance()->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
delete m_ssbDemod;
delete m_spectrumVis;
delete m_audioFifo;
delete m_channelMarker;
delete ui;
}

View File

@ -54,7 +54,6 @@ private:
int m_rate;
int m_spanLog2;
AudioFifo* m_audioFifo;
ThreadedSampleSink* m_threadedChannelizer;
Channelizer* m_channelizer;
SSBDemod* m_ssbDemod;