Code cleanups.
This commit is contained in:
parent
f119f2f72c
commit
351e22f9bb
|
@ -296,7 +296,7 @@ void LowPassFilterRC::process(const SampleVector& samples_in,
|
||||||
|
|
||||||
|
|
||||||
// Process samples in-place.
|
// Process samples in-place.
|
||||||
void LowPassFilterRC::processInPlace(SampleVector& samples)
|
void LowPassFilterRC::process_inplace(SampleVector& samples)
|
||||||
{
|
{
|
||||||
Sample a1 = - exp(-1/m_timeconst);;
|
Sample a1 = - exp(-1/m_timeconst);;
|
||||||
Sample b0 = 1 + a1;
|
Sample b0 = 1 + a1;
|
||||||
|
@ -435,7 +435,7 @@ void HighPassFilterIir::process(const SampleVector& samples_in,
|
||||||
|
|
||||||
|
|
||||||
// Process samples in-place.
|
// Process samples in-place.
|
||||||
void HighPassFilterIir::processInPlace(SampleVector& samples)
|
void HighPassFilterIir::process_inplace(SampleVector& samples)
|
||||||
{
|
{
|
||||||
unsigned int n = samples.size();
|
unsigned int n = samples.size();
|
||||||
|
|
||||||
|
|
4
Filter.h
4
Filter.h
|
@ -107,7 +107,7 @@ public:
|
||||||
void process(const SampleVector& samples_in, SampleVector& samples_out);
|
void process(const SampleVector& samples_in, SampleVector& samples_out);
|
||||||
|
|
||||||
/** Process samples in-place. */
|
/** Process samples in-place. */
|
||||||
void processInPlace(SampleVector& samples);
|
void process_inplace(SampleVector& samples);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double m_timeconst;
|
double m_timeconst;
|
||||||
|
@ -154,7 +154,7 @@ public:
|
||||||
void process(const SampleVector& samples_in, SampleVector& samples_out);
|
void process(const SampleVector& samples_in, SampleVector& samples_out);
|
||||||
|
|
||||||
/** Process samples in-place. */
|
/** Process samples in-place. */
|
||||||
void processInPlace(SampleVector& samples);
|
void process_inplace(SampleVector& samples);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Sample b0, b1, b2, a1, a2;
|
Sample b0, b1, b2, a1, a2;
|
||||||
|
|
24
FmDecode.cc
24
FmDecode.cc
|
@ -230,6 +230,7 @@ FmDecoder::FmDecoder(double sample_rate_if,
|
||||||
|
|
||||||
// Initialize member fields
|
// Initialize member fields
|
||||||
: m_sample_rate_if(sample_rate_if)
|
: m_sample_rate_if(sample_rate_if)
|
||||||
|
, m_sample_rate_baseband(sample_rate_if / downsample)
|
||||||
, m_tuning_table_size(64)
|
, m_tuning_table_size(64)
|
||||||
, m_tuning_shift(lrint(-64.0 * tuning_offset / sample_rate_if))
|
, m_tuning_shift(lrint(-64.0 * tuning_offset / sample_rate_if))
|
||||||
, m_freq_dev(freq_dev)
|
, m_freq_dev(freq_dev)
|
||||||
|
@ -253,29 +254,30 @@ FmDecoder::FmDecoder(double sample_rate_if,
|
||||||
, m_resample_baseband(8 * downsample, 0.4 / downsample, downsample, true)
|
, m_resample_baseband(8 * downsample, 0.4 / downsample, downsample, true)
|
||||||
|
|
||||||
// Construct PilotPhaseLock
|
// Construct PilotPhaseLock
|
||||||
, m_pilotpll(19000 * downsample / sample_rate_if, // freq
|
, m_pilotpll(pilot_freq / m_sample_rate_baseband, // freq
|
||||||
50 * downsample / sample_rate_if, // bandwidth
|
50 / m_sample_rate_baseband, // bandwidth
|
||||||
0.04) // minsignal
|
0.04) // minsignal
|
||||||
|
|
||||||
// Construct DownsampleFilter for mono channel
|
// Construct DownsampleFilter for mono channel
|
||||||
, m_resample_mono(
|
, m_resample_mono(
|
||||||
int(sample_rate_if / downsample / 1000.0), // filter_order
|
int(m_sample_rate_baseband / 1000.0), // filter_order
|
||||||
bandwidth_pcm * downsample / sample_rate_if, // cutoff
|
bandwidth_pcm / m_sample_rate_baseband, // cutoff
|
||||||
sample_rate_if / downsample / sample_rate_pcm, // downsample
|
m_sample_rate_baseband / sample_rate_pcm, // downsample
|
||||||
false) // integer_factor
|
false) // integer_factor
|
||||||
|
|
||||||
// Construct DownsampleFilter for stereo channel
|
// Construct DownsampleFilter for stereo channel
|
||||||
, m_resample_stereo(
|
, m_resample_stereo(
|
||||||
int(sample_rate_if / downsample / 1000.0), // filter_order
|
int(m_sample_rate_baseband / 1000.0), // filter_order
|
||||||
bandwidth_pcm * downsample / sample_rate_if, // cutoff
|
bandwidth_pcm / m_sample_rate_baseband, // cutoff
|
||||||
sample_rate_if / downsample / sample_rate_pcm, // downsample
|
m_sample_rate_baseband / sample_rate_pcm, // downsample
|
||||||
false) // integer_factor
|
false) // integer_factor
|
||||||
|
|
||||||
// Construct HighPassFilterIir
|
// Construct HighPassFilterIir
|
||||||
, m_dcblock_mono(30.0 / sample_rate_pcm)
|
, m_dcblock_mono(30.0 / sample_rate_pcm)
|
||||||
|
|
||||||
// Construct LowwPassFilterRC
|
// Construct LowwPassFilterRC
|
||||||
, m_deemph_mono((deemphasis == 0) ? 1.0 : (deemphasis * sample_rate_pcm * 1.0e-6))
|
, m_deemph_mono((deemphasis == 0) ?
|
||||||
|
1.0 : (deemphasis * sample_rate_pcm * 1.0e-6))
|
||||||
|
|
||||||
{
|
{
|
||||||
// nothing more to do
|
// nothing more to do
|
||||||
|
@ -314,8 +316,8 @@ void FmDecoder::process(const IQSampleVector& samples_in,
|
||||||
m_resample_mono.process(m_buf_baseband, m_buf_mono);
|
m_resample_mono.process(m_buf_baseband, m_buf_mono);
|
||||||
|
|
||||||
// DC blocking and de-emphasis.
|
// DC blocking and de-emphasis.
|
||||||
m_dcblock_mono.processInPlace(m_buf_mono);
|
m_dcblock_mono.process_inplace(m_buf_mono);
|
||||||
m_deemph_mono.processInPlace(m_buf_mono);
|
m_deemph_mono.process_inplace(m_buf_mono);
|
||||||
|
|
||||||
if (m_stereo_enabled) {
|
if (m_stereo_enabled) {
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,7 @@ public:
|
||||||
static constexpr double default_bandwidth_if = 100000;
|
static constexpr double default_bandwidth_if = 100000;
|
||||||
static constexpr double default_freq_dev = 75000;
|
static constexpr double default_freq_dev = 75000;
|
||||||
static constexpr double default_bandwidth_pcm = 15000;
|
static constexpr double default_bandwidth_pcm = 15000;
|
||||||
|
static constexpr double pilot_freq = 19000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct FM decoder.
|
* Construct FM decoder.
|
||||||
|
@ -169,6 +170,7 @@ private:
|
||||||
|
|
||||||
// Data members.
|
// Data members.
|
||||||
const double m_sample_rate_if;
|
const double m_sample_rate_if;
|
||||||
|
const double m_sample_rate_baseband;
|
||||||
const int m_tuning_table_size;
|
const int m_tuning_table_size;
|
||||||
const int m_tuning_shift;
|
const int m_tuning_shift;
|
||||||
const double m_freq_dev;
|
const double m_freq_dev;
|
||||||
|
|
Loading…
Reference in New Issue