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

BFM demod: fixed LSB stereo

This commit is contained in:
f4exb 2015-12-26 00:19:41 +01:00
parent 3564b8ba58
commit 111f00b230
4 changed files with 55 additions and 15 deletions

View File

@ -128,7 +128,9 @@ protected:
samples_out[0] = m_psin; // f Pilot
// Generate double-frequency output.
// sin(2*x) = 2 * sin(x) * cos(x)
samples_out[1] = 2.0 * m_psin * m_pcos; // 2f Pilot
samples_out[1] = 2.0 * m_psin * m_pcos; // 2f Pilot sin
// cos(2*x) = 2 * cos(x) * cos(x) - 1
samples_out[2] = (2.0 * m_pcos * m_pcos) - 1.0; // 2f Pilot cos
}
};
@ -150,6 +152,8 @@ protected:
// Generate double-frequency output.
// sin(2*x) = 2 * sin(x) * cos(x)
samples_out[1] = 2.0 * m_psin * m_pcos; // Pilot signal (2f)
samples_out[2] = m_phase; // Pilot phase
// cos(2*x) = 2 * cos(x) * cos(x) - 1
samples_out[2] = (2.0 * m_pcos * m_pcos) - 1.0; // 2f Pilot cos
samples_out[3] = m_phase; // Pilot phase
}
};

View File

@ -50,7 +50,7 @@ BFMDemod::BFMDemod(SampleSink* sampleSink, RDSParser *rdsParser) :
m_config.m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate(); // normally 48 kHz
m_deemphasisFilterX.configure(default_deemphasis * m_config.m_audioSampleRate * 1.0e-6);
m_deemphasisFilterY.configure(default_deemphasis * m_config.m_audioSampleRate * 1.0e-6);
m_rfFilter = new fftfilt(-50000.0 / 384000.0, 50000.0 / 384000.0, rfFilterFftLength);
m_rfFilter = new fftfilt(-50000.0 / 384000.0, 50000.0 / 384000.0, filtFftLen);
m_phaseDiscri.setFMScaling(384000/m_fmExcursion);
apply();
@ -79,6 +79,7 @@ void BFMDemod::configure(MessageQueue* messageQueue,
Real volume,
Real squelch,
bool audioStereo,
bool lsbStereo,
bool showPilot,
bool rdsActive)
{
@ -87,6 +88,7 @@ void BFMDemod::configure(MessageQueue* messageQueue,
volume,
squelch,
audioStereo,
lsbStereo,
showPilot,
rdsActive);
messageQueue->push(cmd);
@ -138,8 +140,8 @@ void BFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
if (m_running.m_rdsActive)
{
//Complex r(demod * 2.0 * std::cos(3.0 * m_pilotPLLSamples[2]), 0.0);
Complex r(demod * 2.0 * std::cos(3.0 * m_pilotPLLSamples[2]), 0.0);
//Complex r(demod * 2.0 * std::cos(3.0 * m_pilotPLLSamples[3]), 0.0);
Complex r(demod * 2.0 * std::cos(3.0 * m_pilotPLLSamples[3]), 0.0);
if (m_interpolatorRDS.interpolate(&m_interpolatorRDSDistanceRemain, r, &cr))
{
@ -173,12 +175,26 @@ void BFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
m_sampleBuffer.push_back(Sample(m_pilotPLLSamples[1] * (1<<15), 0.0)); // debug 38 kHz pilot
}
Complex s(demod * 1.17 * m_pilotPLLSamples[1], 0);
if (m_interpolatorStereo.interpolate(&m_interpolatorStereoDistanceRemain, s, &cs))
if (m_running.m_lsbStereo)
{
sampleStereo = cs.real();
m_interpolatorStereoDistanceRemain += m_interpolatorStereoDistance;
// 1.17 * 0.7 = 0.819
Complex s(demod * m_pilotPLLSamples[1], demod * m_pilotPLLSamples[2]);
if (m_interpolatorStereo.interpolate(&m_interpolatorStereoDistanceRemain, s, &cs))
{
sampleStereo = cs.real() + cs.imag();
m_interpolatorStereoDistanceRemain += m_interpolatorStereoDistance;
}
}
else
{
Complex s(demod * 1.17 * m_pilotPLLSamples[1], 0);
if (m_interpolatorStereo.interpolate(&m_interpolatorStereoDistanceRemain, s, &cs))
{
sampleStereo = cs.real();
m_interpolatorStereoDistanceRemain += m_interpolatorStereoDistance;
}
}
}
@ -191,8 +207,16 @@ void BFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
Real deemph_l, deemph_r; // Pre-emphasis is applied on each channel before multiplexing
m_deemphasisFilterX.process(ci.real() + sampleStereo, deemph_l);
m_deemphasisFilterY.process(ci.real() - sampleStereo, deemph_r);
m_audioBuffer[m_audioBufferFill].l = (qint16)(deemph_l * (1<<12) * m_running.m_volume);
m_audioBuffer[m_audioBufferFill].r = (qint16)(deemph_r * (1<<12) * m_running.m_volume);
if (m_running.m_lsbStereo)
{
m_audioBuffer[m_audioBufferFill].l = (qint16)(deemph_l * (1<<12) * m_running.m_volume);
m_audioBuffer[m_audioBufferFill].r = (qint16)(deemph_r * (1<<12) * m_running.m_volume);
}
else
{
m_audioBuffer[m_audioBufferFill].l = (qint16)(deemph_l * (1<<12) * m_running.m_volume);
m_audioBuffer[m_audioBufferFill].r = (qint16)(deemph_r * (1<<12) * m_running.m_volume);
}
}
else
{
@ -280,6 +304,7 @@ bool BFMDemod::handleMessage(const Message& cmd)
m_config.m_volume = cfg.getVolume();
m_config.m_squelch = cfg.getSquelch();
m_config.m_audioStereo = cfg.getAudioStereo();
m_config.m_lsbStereo = cfg.getLsbStereo();
m_config.m_showPilot = cfg.getShowPilot();
m_config.m_rdsActive = cfg.getRDSActive();
@ -290,6 +315,7 @@ bool BFMDemod::handleMessage(const Message& cmd)
<< " m_volume: " << m_config.m_volume
<< " m_squelch: " << m_config.m_squelch
<< " m_audioStereo: " << m_config.m_audioStereo
<< " m_lsbStereo: " << m_config.m_lsbStereo
<< " m_showPilot: " << m_config.m_showPilot
<< " m_rdsActive: " << m_config.m_rdsActive;
@ -392,6 +418,7 @@ void BFMDemod::apply()
m_running.m_volume = m_config.m_volume;
m_running.m_audioSampleRate = m_config.m_audioSampleRate;
m_running.m_audioStereo = m_config.m_audioStereo;
m_running.m_lsbStereo = m_config.m_lsbStereo;
m_running.m_showPilot = m_config.m_showPilot;
m_running.m_rdsActive = m_config.m_rdsActive;
}

View File

@ -34,8 +34,6 @@
#include "rdsdemod.h"
#include "rdsdecoder.h"
#define rfFilterFftLength 1024
class RDSParser;
class BFMDemod : public SampleSink {
@ -49,6 +47,7 @@ public:
Real volume,
Real squelch,
bool audioStereo,
bool lsbStereo,
bool showPilot,
bool rdsActive);
@ -79,6 +78,7 @@ private:
Real getVolume() const { return m_volume; }
Real getSquelch() const { return m_squelch; }
bool getAudioStereo() const { return m_audioStereo; }
bool getLsbStereo() const { return m_lsbStereo; }
bool getShowPilot() const { return m_showPilot; }
bool getRDSActive() const { return m_rdsActive; }
@ -87,6 +87,7 @@ private:
Real volume,
Real squelch,
bool audioStereo,
bool lsbStereo,
bool showPilot,
bool rdsActive)
{
@ -95,6 +96,7 @@ private:
volume,
squelch,
audioStereo,
lsbStereo,
showPilot,
rdsActive);
}
@ -105,6 +107,7 @@ private:
Real m_volume;
Real m_squelch;
bool m_audioStereo;
bool m_lsbStereo;
bool m_showPilot;
bool m_rdsActive;
@ -113,6 +116,7 @@ private:
Real volume,
Real squelch,
bool audioStereo,
bool lsbStereo,
bool showPilot,
bool rdsActive) :
Message(),
@ -121,6 +125,7 @@ private:
m_volume(volume),
m_squelch(squelch),
m_audioStereo(audioStereo),
m_lsbStereo(lsbStereo),
m_showPilot(showPilot),
m_rdsActive(rdsActive)
{ }
@ -146,6 +151,7 @@ private:
Real m_volume;
quint32 m_audioSampleRate;
bool m_audioStereo;
bool m_lsbStereo;
bool m_showPilot;
bool m_rdsActive;
@ -158,6 +164,7 @@ private:
m_volume(0),
m_audioSampleRate(0),
m_audioStereo(false),
m_lsbStereo(false),
m_showPilot(false),
m_rdsActive(false)
{ }
@ -181,6 +188,7 @@ private:
Lowpass<Real> m_lowpass;
fftfilt* m_rfFilter;
static const int filtFftLen = 1024;
Real m_squelchLevel;
int m_squelchState;
@ -198,7 +206,7 @@ private:
QMutex m_settingsMutex;
RDSPhaseLock m_pilotPLL;
Real m_pilotPLLSamples[3];
Real m_pilotPLLSamples[4];
RDSDemod m_rdsDemod;
RDSDecoder m_rdsDecoder;

View File

@ -445,6 +445,7 @@ void BFMDemodGUI::applySettings()
ui->volume->value() / 10.0,
ui->squelch->value(),
ui->audioStereo->isChecked(),
ui->lsbStereo->isChecked(),
ui->showPilot->isChecked(),
ui->rds->isChecked());
}