mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-02-20 12:42:17 -05:00
BFM demod: fixed LSB stereo
This commit is contained in:
parent
3564b8ba58
commit
111f00b230
@ -128,7 +128,9 @@ protected:
|
|||||||
samples_out[0] = m_psin; // f Pilot
|
samples_out[0] = m_psin; // f Pilot
|
||||||
// Generate double-frequency output.
|
// Generate double-frequency output.
|
||||||
// sin(2*x) = 2 * sin(x) * cos(x)
|
// 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.
|
// Generate double-frequency output.
|
||||||
// sin(2*x) = 2 * sin(x) * cos(x)
|
// sin(2*x) = 2 * sin(x) * cos(x)
|
||||||
samples_out[1] = 2.0 * m_psin * m_pcos; // Pilot signal (2f)
|
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
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -50,7 +50,7 @@ BFMDemod::BFMDemod(SampleSink* sampleSink, RDSParser *rdsParser) :
|
|||||||
m_config.m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate(); // normally 48 kHz
|
m_config.m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate(); // normally 48 kHz
|
||||||
m_deemphasisFilterX.configure(default_deemphasis * m_config.m_audioSampleRate * 1.0e-6);
|
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_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);
|
m_phaseDiscri.setFMScaling(384000/m_fmExcursion);
|
||||||
|
|
||||||
apply();
|
apply();
|
||||||
@ -79,6 +79,7 @@ void BFMDemod::configure(MessageQueue* messageQueue,
|
|||||||
Real volume,
|
Real volume,
|
||||||
Real squelch,
|
Real squelch,
|
||||||
bool audioStereo,
|
bool audioStereo,
|
||||||
|
bool lsbStereo,
|
||||||
bool showPilot,
|
bool showPilot,
|
||||||
bool rdsActive)
|
bool rdsActive)
|
||||||
{
|
{
|
||||||
@ -87,6 +88,7 @@ void BFMDemod::configure(MessageQueue* messageQueue,
|
|||||||
volume,
|
volume,
|
||||||
squelch,
|
squelch,
|
||||||
audioStereo,
|
audioStereo,
|
||||||
|
lsbStereo,
|
||||||
showPilot,
|
showPilot,
|
||||||
rdsActive);
|
rdsActive);
|
||||||
messageQueue->push(cmd);
|
messageQueue->push(cmd);
|
||||||
@ -138,8 +140,8 @@ void BFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
|
|||||||
|
|
||||||
if (m_running.m_rdsActive)
|
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[3]), 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);
|
||||||
|
|
||||||
if (m_interpolatorRDS.interpolate(&m_interpolatorRDSDistanceRemain, r, &cr))
|
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
|
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_running.m_lsbStereo)
|
||||||
|
|
||||||
if (m_interpolatorStereo.interpolate(&m_interpolatorStereoDistanceRemain, s, &cs))
|
|
||||||
{
|
{
|
||||||
sampleStereo = cs.real();
|
// 1.17 * 0.7 = 0.819
|
||||||
m_interpolatorStereoDistanceRemain += m_interpolatorStereoDistance;
|
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
|
Real deemph_l, deemph_r; // Pre-emphasis is applied on each channel before multiplexing
|
||||||
m_deemphasisFilterX.process(ci.real() + sampleStereo, deemph_l);
|
m_deemphasisFilterX.process(ci.real() + sampleStereo, deemph_l);
|
||||||
m_deemphasisFilterY.process(ci.real() - sampleStereo, deemph_r);
|
m_deemphasisFilterY.process(ci.real() - sampleStereo, deemph_r);
|
||||||
m_audioBuffer[m_audioBufferFill].l = (qint16)(deemph_l * (1<<12) * m_running.m_volume);
|
if (m_running.m_lsbStereo)
|
||||||
m_audioBuffer[m_audioBufferFill].r = (qint16)(deemph_r * (1<<12) * m_running.m_volume);
|
{
|
||||||
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -280,6 +304,7 @@ bool BFMDemod::handleMessage(const Message& cmd)
|
|||||||
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();
|
m_config.m_audioStereo = cfg.getAudioStereo();
|
||||||
|
m_config.m_lsbStereo = cfg.getLsbStereo();
|
||||||
m_config.m_showPilot = cfg.getShowPilot();
|
m_config.m_showPilot = cfg.getShowPilot();
|
||||||
m_config.m_rdsActive = cfg.getRDSActive();
|
m_config.m_rdsActive = cfg.getRDSActive();
|
||||||
|
|
||||||
@ -290,6 +315,7 @@ bool BFMDemod::handleMessage(const Message& cmd)
|
|||||||
<< " 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
|
<< " m_audioStereo: " << m_config.m_audioStereo
|
||||||
|
<< " m_lsbStereo: " << m_config.m_lsbStereo
|
||||||
<< " m_showPilot: " << m_config.m_showPilot
|
<< " m_showPilot: " << m_config.m_showPilot
|
||||||
<< " m_rdsActive: " << m_config.m_rdsActive;
|
<< " m_rdsActive: " << m_config.m_rdsActive;
|
||||||
|
|
||||||
@ -392,6 +418,7 @@ void BFMDemod::apply()
|
|||||||
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;
|
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_showPilot = m_config.m_showPilot;
|
||||||
m_running.m_rdsActive = m_config.m_rdsActive;
|
m_running.m_rdsActive = m_config.m_rdsActive;
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,6 @@
|
|||||||
#include "rdsdemod.h"
|
#include "rdsdemod.h"
|
||||||
#include "rdsdecoder.h"
|
#include "rdsdecoder.h"
|
||||||
|
|
||||||
#define rfFilterFftLength 1024
|
|
||||||
|
|
||||||
class RDSParser;
|
class RDSParser;
|
||||||
|
|
||||||
class BFMDemod : public SampleSink {
|
class BFMDemod : public SampleSink {
|
||||||
@ -49,6 +47,7 @@ public:
|
|||||||
Real volume,
|
Real volume,
|
||||||
Real squelch,
|
Real squelch,
|
||||||
bool audioStereo,
|
bool audioStereo,
|
||||||
|
bool lsbStereo,
|
||||||
bool showPilot,
|
bool showPilot,
|
||||||
bool rdsActive);
|
bool rdsActive);
|
||||||
|
|
||||||
@ -79,6 +78,7 @@ private:
|
|||||||
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; }
|
bool getAudioStereo() const { return m_audioStereo; }
|
||||||
|
bool getLsbStereo() const { return m_lsbStereo; }
|
||||||
bool getShowPilot() const { return m_showPilot; }
|
bool getShowPilot() const { return m_showPilot; }
|
||||||
bool getRDSActive() const { return m_rdsActive; }
|
bool getRDSActive() const { return m_rdsActive; }
|
||||||
|
|
||||||
@ -87,6 +87,7 @@ private:
|
|||||||
Real volume,
|
Real volume,
|
||||||
Real squelch,
|
Real squelch,
|
||||||
bool audioStereo,
|
bool audioStereo,
|
||||||
|
bool lsbStereo,
|
||||||
bool showPilot,
|
bool showPilot,
|
||||||
bool rdsActive)
|
bool rdsActive)
|
||||||
{
|
{
|
||||||
@ -95,6 +96,7 @@ private:
|
|||||||
volume,
|
volume,
|
||||||
squelch,
|
squelch,
|
||||||
audioStereo,
|
audioStereo,
|
||||||
|
lsbStereo,
|
||||||
showPilot,
|
showPilot,
|
||||||
rdsActive);
|
rdsActive);
|
||||||
}
|
}
|
||||||
@ -105,6 +107,7 @@ private:
|
|||||||
Real m_volume;
|
Real m_volume;
|
||||||
Real m_squelch;
|
Real m_squelch;
|
||||||
bool m_audioStereo;
|
bool m_audioStereo;
|
||||||
|
bool m_lsbStereo;
|
||||||
bool m_showPilot;
|
bool m_showPilot;
|
||||||
bool m_rdsActive;
|
bool m_rdsActive;
|
||||||
|
|
||||||
@ -113,6 +116,7 @@ private:
|
|||||||
Real volume,
|
Real volume,
|
||||||
Real squelch,
|
Real squelch,
|
||||||
bool audioStereo,
|
bool audioStereo,
|
||||||
|
bool lsbStereo,
|
||||||
bool showPilot,
|
bool showPilot,
|
||||||
bool rdsActive) :
|
bool rdsActive) :
|
||||||
Message(),
|
Message(),
|
||||||
@ -121,6 +125,7 @@ private:
|
|||||||
m_volume(volume),
|
m_volume(volume),
|
||||||
m_squelch(squelch),
|
m_squelch(squelch),
|
||||||
m_audioStereo(audioStereo),
|
m_audioStereo(audioStereo),
|
||||||
|
m_lsbStereo(lsbStereo),
|
||||||
m_showPilot(showPilot),
|
m_showPilot(showPilot),
|
||||||
m_rdsActive(rdsActive)
|
m_rdsActive(rdsActive)
|
||||||
{ }
|
{ }
|
||||||
@ -146,6 +151,7 @@ private:
|
|||||||
Real m_volume;
|
Real m_volume;
|
||||||
quint32 m_audioSampleRate;
|
quint32 m_audioSampleRate;
|
||||||
bool m_audioStereo;
|
bool m_audioStereo;
|
||||||
|
bool m_lsbStereo;
|
||||||
bool m_showPilot;
|
bool m_showPilot;
|
||||||
bool m_rdsActive;
|
bool m_rdsActive;
|
||||||
|
|
||||||
@ -158,6 +164,7 @@ private:
|
|||||||
m_volume(0),
|
m_volume(0),
|
||||||
m_audioSampleRate(0),
|
m_audioSampleRate(0),
|
||||||
m_audioStereo(false),
|
m_audioStereo(false),
|
||||||
|
m_lsbStereo(false),
|
||||||
m_showPilot(false),
|
m_showPilot(false),
|
||||||
m_rdsActive(false)
|
m_rdsActive(false)
|
||||||
{ }
|
{ }
|
||||||
@ -181,6 +188,7 @@ private:
|
|||||||
|
|
||||||
Lowpass<Real> m_lowpass;
|
Lowpass<Real> m_lowpass;
|
||||||
fftfilt* m_rfFilter;
|
fftfilt* m_rfFilter;
|
||||||
|
static const int filtFftLen = 1024;
|
||||||
|
|
||||||
Real m_squelchLevel;
|
Real m_squelchLevel;
|
||||||
int m_squelchState;
|
int m_squelchState;
|
||||||
@ -198,7 +206,7 @@ private:
|
|||||||
QMutex m_settingsMutex;
|
QMutex m_settingsMutex;
|
||||||
|
|
||||||
RDSPhaseLock m_pilotPLL;
|
RDSPhaseLock m_pilotPLL;
|
||||||
Real m_pilotPLLSamples[3];
|
Real m_pilotPLLSamples[4];
|
||||||
|
|
||||||
RDSDemod m_rdsDemod;
|
RDSDemod m_rdsDemod;
|
||||||
RDSDecoder m_rdsDecoder;
|
RDSDecoder m_rdsDecoder;
|
||||||
|
@ -445,6 +445,7 @@ void BFMDemodGUI::applySettings()
|
|||||||
ui->volume->value() / 10.0,
|
ui->volume->value() / 10.0,
|
||||||
ui->squelch->value(),
|
ui->squelch->value(),
|
||||||
ui->audioStereo->isChecked(),
|
ui->audioStereo->isChecked(),
|
||||||
|
ui->lsbStereo->isChecked(),
|
||||||
ui->showPilot->isChecked(),
|
ui->showPilot->isChecked(),
|
||||||
ui->rds->isChecked());
|
ui->rds->isChecked());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user