mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-16 05:11:49 -05:00
Corrected NFM demod. Implemented phase discriminator object in WFM demod
This commit is contained in:
parent
3028357718
commit
90552271f8
@ -18,6 +18,8 @@
|
|||||||
#ifndef INCLUDE_DSP_PHASEDISCRI_H_
|
#ifndef INCLUDE_DSP_PHASEDISCRI_H_
|
||||||
#define INCLUDE_DSP_PHASEDISCRI_H_
|
#define INCLUDE_DSP_PHASEDISCRI_H_
|
||||||
|
|
||||||
|
#include "dsp/dsptypes.h"
|
||||||
|
|
||||||
class PhaseDiscriminators
|
class PhaseDiscriminators
|
||||||
{
|
{
|
||||||
public:
|
public:
|
@ -331,6 +331,7 @@ void NFMDemod::apply()
|
|||||||
m_interpolator.create(16, m_config.m_inputSampleRate, m_config.m_rfBandwidth / 2.2);
|
m_interpolator.create(16, m_config.m_inputSampleRate, m_config.m_rfBandwidth / 2.2);
|
||||||
m_interpolatorDistanceRemain = 0;
|
m_interpolatorDistanceRemain = 0;
|
||||||
m_interpolatorDistance = (Real) m_config.m_inputSampleRate / (Real) m_config.m_audioSampleRate;
|
m_interpolatorDistance = (Real) m_config.m_inputSampleRate / (Real) m_config.m_audioSampleRate;
|
||||||
|
m_fmExcursion = m_config.m_rfBandwidth / 2.0f;
|
||||||
m_phaseDiscri.setFMScaling(m_config.m_inputSampleRate / m_fmExcursion);
|
m_phaseDiscri.setFMScaling(m_config.m_inputSampleRate / m_fmExcursion);
|
||||||
m_settingsMutex.unlock();
|
m_settingsMutex.unlock();
|
||||||
}
|
}
|
||||||
@ -341,8 +342,6 @@ void NFMDemod::apply()
|
|||||||
m_settingsMutex.lock();
|
m_settingsMutex.lock();
|
||||||
m_lowpass.create(301, m_config.m_audioSampleRate, 250.0);
|
m_lowpass.create(301, m_config.m_audioSampleRate, 250.0);
|
||||||
m_bandpass.create(301, m_config.m_audioSampleRate, 300.0, m_config.m_afBandwidth);
|
m_bandpass.create(301, m_config.m_audioSampleRate, 300.0, m_config.m_afBandwidth);
|
||||||
m_fmExcursion = m_config.m_afBandwidth / 2.0f;
|
|
||||||
m_phaseDiscri.setFMScaling(m_config.m_inputSampleRate / m_fmExcursion);
|
|
||||||
m_settingsMutex.unlock();
|
m_settingsMutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#ifndef INCLUDE_NFMDEMOD_H
|
#ifndef INCLUDE_NFMDEMOD_H
|
||||||
#define INCLUDE_NFMDEMOD_H
|
#define INCLUDE_NFMDEMOD_H
|
||||||
|
|
||||||
|
#include <dsp/phasediscri.h>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "dsp/samplesink.h"
|
#include "dsp/samplesink.h"
|
||||||
@ -29,7 +30,6 @@
|
|||||||
#include "dsp/agc.h"
|
#include "dsp/agc.h"
|
||||||
#include "dsp/ctcssdetector.h"
|
#include "dsp/ctcssdetector.h"
|
||||||
#include "dsp/afsquelch.h"
|
#include "dsp/afsquelch.h"
|
||||||
#include "dsp/phasediscri.hpp"
|
|
||||||
#include "audio/audiofifo.h"
|
#include "audio/audiofifo.h"
|
||||||
#include "util/message.h"
|
#include "util/message.h"
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QSlider" name="volume">
|
<widget class="QSlider" name="volume">
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>40</number>
|
<number>100</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="pageStep">
|
<property name="pageStep">
|
||||||
<number>1</number>
|
<number>1</number>
|
||||||
|
@ -42,6 +42,7 @@ WFMDemod::WFMDemod(SampleSink* sampleSink) :
|
|||||||
m_config.m_volume = 2.0;
|
m_config.m_volume = 2.0;
|
||||||
m_config.m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate();
|
m_config.m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate();
|
||||||
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, rfFilterFftLength);
|
||||||
|
m_phaseDiscri.setFMScaling(384000/75000);
|
||||||
|
|
||||||
apply();
|
apply();
|
||||||
|
|
||||||
@ -101,20 +102,19 @@ void WFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
|
|||||||
// Alternative without atan
|
// Alternative without atan
|
||||||
// http://www.embedded.com/design/configurable-systems/4212086/DSP-Tricks--Frequency-demodulation-algorithms-
|
// http://www.embedded.com/design/configurable-systems/4212086/DSP-Tricks--Frequency-demodulation-algorithms-
|
||||||
// in addition it needs scaling by instantaneous magnitude squared and volume (0..10) adjustment factor
|
// in addition it needs scaling by instantaneous magnitude squared and volume (0..10) adjustment factor
|
||||||
|
/*
|
||||||
Real ip = rf[i].real() - m_m2Sample.real();
|
Real ip = rf[i].real() - m_m2Sample.real();
|
||||||
Real qp = rf[i].imag() - m_m2Sample.imag();
|
Real qp = rf[i].imag() - m_m2Sample.imag();
|
||||||
Real h1 = m_m1Sample.real() * qp;
|
Real h1 = m_m1Sample.real() * qp;
|
||||||
Real h2 = m_m1Sample.imag() * ip;
|
Real h2 = m_m1Sample.imag() * ip;
|
||||||
demod = (h1 - h2) / (msq * 10.0);
|
demod = (h1 - h2) / (msq * 10.0);*/
|
||||||
|
demod = m_phaseDiscri.phaseDiscriminator2(rf[i]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
demod = 0;
|
demod = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_m2Sample = m_m1Sample;
|
|
||||||
m_m1Sample = rf[i];
|
|
||||||
|
|
||||||
Complex e(demod, 0);
|
Complex e(demod, 0);
|
||||||
|
|
||||||
if(m_interpolator.interpolate(&m_interpolatorDistanceRemain, e, &ci))
|
if(m_interpolator.interpolate(&m_interpolatorDistanceRemain, e, &ci))
|
||||||
@ -168,7 +168,7 @@ void WFMDemod::start()
|
|||||||
{
|
{
|
||||||
m_squelchState = 0;
|
m_squelchState = 0;
|
||||||
m_audioFifo.clear();
|
m_audioFifo.clear();
|
||||||
m_m1Sample = 0;
|
m_phaseDiscri.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WFMDemod::stop()
|
void WFMDemod::stop()
|
||||||
@ -254,6 +254,8 @@ void WFMDemod::apply()
|
|||||||
Real lowCut = -(m_config.m_rfBandwidth / 2.0) / m_config.m_inputSampleRate;
|
Real lowCut = -(m_config.m_rfBandwidth / 2.0) / m_config.m_inputSampleRate;
|
||||||
Real hiCut = (m_config.m_rfBandwidth / 2.0) / m_config.m_inputSampleRate;
|
Real hiCut = (m_config.m_rfBandwidth / 2.0) / m_config.m_inputSampleRate;
|
||||||
m_rfFilter->create_filter(lowCut, hiCut);
|
m_rfFilter->create_filter(lowCut, hiCut);
|
||||||
|
m_fmExcursion = m_config.m_rfBandwidth / 2.0;
|
||||||
|
m_phaseDiscri.setFMScaling(m_config.m_inputSampleRate / m_fmExcursion);
|
||||||
m_settingsMutex.unlock();
|
m_settingsMutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "dsp/lowpass.h"
|
#include "dsp/lowpass.h"
|
||||||
#include "dsp/movingaverage.h"
|
#include "dsp/movingaverage.h"
|
||||||
#include "dsp/fftfilt.h"
|
#include "dsp/fftfilt.h"
|
||||||
|
#include "dsp/phasediscri.h"
|
||||||
#include "audio/audiofifo.h"
|
#include "audio/audiofifo.h"
|
||||||
#include "util/message.h"
|
#include "util/message.h"
|
||||||
|
|
||||||
@ -120,9 +121,8 @@ private:
|
|||||||
int m_squelchState;
|
int m_squelchState;
|
||||||
|
|
||||||
Real m_lastArgument;
|
Real m_lastArgument;
|
||||||
Complex m_m1Sample; //!< x^-1 sample
|
|
||||||
Complex m_m2Sample; //!< x^-1 sample
|
|
||||||
MovingAverage<Real> m_movingAverage;
|
MovingAverage<Real> m_movingAverage;
|
||||||
|
Real m_fmExcursion;
|
||||||
|
|
||||||
AudioVector m_audioBuffer;
|
AudioVector m_audioBuffer;
|
||||||
uint m_audioBufferFill;
|
uint m_audioBufferFill;
|
||||||
@ -132,6 +132,8 @@ private:
|
|||||||
SampleVector m_sampleBuffer;
|
SampleVector m_sampleBuffer;
|
||||||
QMutex m_settingsMutex;
|
QMutex m_settingsMutex;
|
||||||
|
|
||||||
|
PhaseDiscriminators m_phaseDiscri;
|
||||||
|
|
||||||
void apply();
|
void apply();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user