1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-27 02:09:14 -05:00

BFM demod: implemented mono/stereo control from GUI

This commit is contained in:
f4exb 2015-12-07 08:55:22 +01:00
parent 83423e13e0
commit 508486f791
3 changed files with 50 additions and 25 deletions

View File

@ -65,9 +65,9 @@ BFMDemod::~BFMDemod()
DSPEngine::instance()->removeAudioSink(&m_audioFifo); DSPEngine::instance()->removeAudioSink(&m_audioFifo);
} }
void BFMDemod::configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, Real squelch) void BFMDemod::configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, Real squelch, bool audioStereo)
{ {
Message* cmd = MsgConfigureBFMDemod::create(rfBandwidth, afBandwidth, volume, squelch); Message* cmd = MsgConfigureBFMDemod::create(rfBandwidth, afBandwidth, volume, squelch, audioStereo);
messageQueue->push(cmd); messageQueue->push(cmd);
} }
@ -119,29 +119,42 @@ void BFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
m_m2Sample = m_m1Sample; m_m2Sample = m_m1Sample;
m_m1Sample = rf[i]; m_m1Sample = rf[i];
// TODO: conditional to stereo mode selected m_sampleBuffer.push_back(Sample(demod * (1<<15), 0.0));
quint16 sampleStereo;
// Process stereo if stereo mode is selected
if (m_running.m_audioStereo)
{
Real pilotSample; Real pilotSample;
m_pilotPLL.process(demod, pilotSample); m_pilotPLL.process(demod, pilotSample);
m_sampleBuffer.push_back(Sample(demod * (1<<15), 0.0));
//m_sampleBuffer.push_back(Sample(pilotSample * (1<<15), 0.0)); // debug pilot //m_sampleBuffer.push_back(Sample(pilotSample * (1<<15), 0.0)); // debug pilot
Complex s(demod*2.0*pilotSample, 0); Complex s(demod*2.0*pilotSample, 0);
quint16 sampleStereo;
if (m_interpolatorStereo.interpolate(&m_interpolatorStereoDistanceRemain, s, &cs)) if (m_interpolatorStereo.interpolate(&m_interpolatorStereoDistanceRemain, s, &cs))
{ {
sampleStereo = (qint16)(cs.real() * 3000 * m_running.m_volume); sampleStereo = (qint16)(cs.real() * 3000 * m_running.m_volume);
} }
}
Complex e(demod, 0); Complex e(demod, 0);
if(m_interpolator.interpolate(&m_interpolatorDistanceRemain, e, &ci)) if (m_interpolator.interpolate(&m_interpolatorDistanceRemain, e, &ci))
{ {
quint16 sample = (qint16)(ci.real() * 3000 * m_running.m_volume); quint16 sample = (qint16)(ci.real() * 3000 * m_running.m_volume);
//m_sampleBuffer.push_back(Sample(sample, sample));
if (m_running.m_audioStereo)
{
m_audioBuffer[m_audioBufferFill].l = sample + sampleStereo; m_audioBuffer[m_audioBufferFill].l = sample + sampleStereo;
m_audioBuffer[m_audioBufferFill].r = sample - sampleStereo; m_audioBuffer[m_audioBufferFill].r = sample - sampleStereo;
}
else
{
m_audioBuffer[m_audioBufferFill].l = sample;
m_audioBuffer[m_audioBufferFill].r = sample;
}
++m_audioBufferFill; ++m_audioBufferFill;
if(m_audioBufferFill >= m_audioBuffer.size()) if(m_audioBufferFill >= m_audioBuffer.size())
@ -220,13 +233,15 @@ bool BFMDemod::handleMessage(const Message& cmd)
m_config.m_afBandwidth = cfg.getAFBandwidth(); m_config.m_afBandwidth = cfg.getAFBandwidth();
m_config.m_volume = cfg.getVolume(); m_config.m_volume = cfg.getVolume();
m_config.m_squelch = cfg.getSquelch(); m_config.m_squelch = cfg.getSquelch();
m_config.m_audioStereo = cfg.getAudioStereo();
apply(); apply();
qDebug() << "BFMDemod::handleMessage: MsgConfigureBFMDemod: m_rfBandwidth: " << m_config.m_rfBandwidth qDebug() << "BFMDemod::handleMessage: MsgConfigureBFMDemod: m_rfBandwidth: " << m_config.m_rfBandwidth
<< " m_afBandwidth: " << m_config.m_afBandwidth << " m_afBandwidth: " << m_config.m_afBandwidth
<< " m_volume: " << m_config.m_volume << " m_volume: " << m_config.m_volume
<< " m_squelch: " << m_config.m_squelch; << " m_squelch: " << m_config.m_squelch
<< " m_audioStereo: " << m_config.m_audioStereo;
return true; return true;
} }
@ -245,7 +260,8 @@ bool BFMDemod::handleMessage(const Message& cmd)
void BFMDemod::apply() void BFMDemod::apply()
{ {
if (m_config.m_inputSampleRate != m_running.m_inputSampleRate) if ((m_config.m_inputSampleRate != m_running.m_inputSampleRate)
|| (m_config.m_audioStereo && (m_config.m_audioStereo != m_running.m_audioStereo)))
{ {
m_pilotPLL.configure(19000.0/m_config.m_inputSampleRate, 50.0/m_config.m_inputSampleRate, 0.01); m_pilotPLL.configure(19000.0/m_config.m_inputSampleRate, 50.0/m_config.m_inputSampleRate, 0.01);
} }
@ -309,5 +325,6 @@ void BFMDemod::apply()
m_running.m_squelch = m_config.m_squelch; m_running.m_squelch = m_config.m_squelch;
m_running.m_volume = m_config.m_volume; m_running.m_volume = m_config.m_volume;
m_running.m_audioSampleRate = m_config.m_audioSampleRate; m_running.m_audioSampleRate = m_config.m_audioSampleRate;
m_running.m_audioStereo = m_config.m_audioStereo;
} }

View File

@ -37,7 +37,7 @@ public:
BFMDemod(SampleSink* sampleSink); BFMDemod(SampleSink* sampleSink);
virtual ~BFMDemod(); virtual ~BFMDemod();
void configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, Real squelch); void configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, Real squelch, bool audioStereo);
int getSampleRate() const { return m_config.m_inputSampleRate; } int getSampleRate() const { return m_config.m_inputSampleRate; }
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po); virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po);
@ -58,10 +58,11 @@ private:
Real getAFBandwidth() const { return m_afBandwidth; } Real getAFBandwidth() const { return m_afBandwidth; }
Real getVolume() const { return m_volume; } Real getVolume() const { return m_volume; }
Real getSquelch() const { return m_squelch; } Real getSquelch() const { return m_squelch; }
bool getAudioStereo() const { return m_audioStereo; }
static MsgConfigureBFMDemod* create(Real rfBandwidth, Real afBandwidth, Real volume, Real squelch) static MsgConfigureBFMDemod* create(Real rfBandwidth, Real afBandwidth, Real volume, Real squelch, bool audioStereo)
{ {
return new MsgConfigureBFMDemod(rfBandwidth, afBandwidth, volume, squelch); return new MsgConfigureBFMDemod(rfBandwidth, afBandwidth, volume, squelch, audioStereo);
} }
private: private:
@ -69,13 +70,15 @@ private:
Real m_afBandwidth; Real m_afBandwidth;
Real m_volume; Real m_volume;
Real m_squelch; Real m_squelch;
bool m_audioStereo;
MsgConfigureBFMDemod(Real rfBandwidth, Real afBandwidth, Real volume, Real squelch) : MsgConfigureBFMDemod(Real rfBandwidth, Real afBandwidth, Real volume, Real squelch, bool audioStereo) :
Message(), Message(),
m_rfBandwidth(rfBandwidth), m_rfBandwidth(rfBandwidth),
m_afBandwidth(afBandwidth), m_afBandwidth(afBandwidth),
m_volume(volume), m_volume(volume),
m_squelch(squelch) m_squelch(squelch),
m_audioStereo(audioStereo)
{ } { }
}; };
@ -98,6 +101,7 @@ private:
Real m_squelch; Real m_squelch;
Real m_volume; Real m_volume;
quint32 m_audioSampleRate; quint32 m_audioSampleRate;
bool m_audioStereo;
Config() : Config() :
m_inputSampleRate(-1), m_inputSampleRate(-1),
@ -106,7 +110,8 @@ private:
m_afBandwidth(-1), m_afBandwidth(-1),
m_squelch(0), m_squelch(0),
m_volume(0), m_volume(0),
m_audioSampleRate(0) m_audioSampleRate(0),
m_audioStereo(false)
{ } { }
}; };

View File

@ -222,6 +222,8 @@ void BFMDemodGUI::on_audioStereo_toggled(bool stereo)
{ {
ui->audioStereo->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); ui->audioStereo->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
} }
applySettings();
} }
void BFMDemodGUI::onWidgetRolled(QWidget* widget, bool rollDown) void BFMDemodGUI::onWidgetRolled(QWidget* widget, bool rollDown)
@ -318,7 +320,8 @@ void BFMDemodGUI::applySettings()
m_rfBW[ui->rfBW->value()], m_rfBW[ui->rfBW->value()],
ui->afBW->value() * 1000.0, ui->afBW->value() * 1000.0,
ui->volume->value() / 10.0, ui->volume->value() / 10.0,
ui->squelch->value()); ui->squelch->value(),
ui->audioStereo->isChecked());
} }
} }