Default constructors and configure methods for baseband classes.

This commit is contained in:
Jared Boone 2015-11-05 10:19:05 -08:00
parent 5236a858d0
commit ddd34793a6
10 changed files with 65 additions and 77 deletions

View file

@ -38,12 +38,6 @@ public:
By32, By32,
}; };
ChannelDecimator(
DecimationFactor f
) : decimation_factor { f }
{
}
void set_decimation_factor(const DecimationFactor f) { void set_decimation_factor(const DecimationFactor f) {
decimation_factor = f; decimation_factor = f;
} }
@ -75,7 +69,7 @@ private:
dsp::decimate::DecimateBy2CIC3 cic_3; dsp::decimate::DecimateBy2CIC3 cic_3;
dsp::decimate::DecimateBy2CIC3 cic_4; dsp::decimate::DecimateBy2CIC3 cic_4;
DecimationFactor decimation_factor { DecimationFactor::By32 }; DecimationFactor decimation_factor = DecimationFactor::By32;
buffer_c16_t execute_decimation(buffer_c8_t buffer); buffer_c16_t execute_decimation(buffer_c8_t buffer);
}; };

View file

@ -90,7 +90,11 @@ private:
class FixedErrorFilter { class FixedErrorFilter {
public: public:
FixedErrorFilter( FixedErrorFilter(
const float weight = (1.0f / 16.0f) ) {
}
FixedErrorFilter(
const float weight
) : weight_ { weight } ) : weight_ { weight }
{ {
} }
@ -106,28 +110,25 @@ public:
} }
private: private:
const float weight_; float weight_ { 1.0f / 16.0f };
}; };
template<typename ErrorFilter> template<typename ErrorFilter>
class ClockRecovery { class ClockRecovery {
public: public:
ClockRecovery( ClockRecovery(
const float sampling_rate,
const float symbol_rate,
const ErrorFilter error_filter,
std::function<void(const float)> symbol_handler std::function<void(const float)> symbol_handler
) : resampler(sampling_rate, symbol_rate * timing_error_detector.samples_per_symbol), ) : symbol_handler { symbol_handler }
error_filter { error_filter },
symbol_handler { symbol_handler }
{ {
} }
void configure( void configure(
const float sampling_rate, const float sampling_rate,
const float symbol_rate const float symbol_rate,
ErrorFilter error_filter
) { ) {
resampler.configure(sampling_rate, symbol_rate * timing_error_detector.samples_per_symbol); resampler.configure(sampling_rate, symbol_rate * timing_error_detector.samples_per_symbol);
error_filter = error_filter;
} }
void operator()( void operator()(

View file

@ -89,21 +89,20 @@ public:
* processed will be a multiple of the taps_count. * processed will be a multiple of the taps_count.
*/ */
FIRAndDecimateComplex( FIRAndDecimateComplex(
const size_t taps_count, ) : taps_count_ { 0 },
const size_t decimation_factor decimation_factor_ { 1 }
) : samples_ { std::make_unique<samples_t>(taps_count) },
taps_reversed_ { std::make_unique<taps_t>(taps_count) },
taps_count_ { taps_count },
decimation_factor_ { decimation_factor }
{ {
} }
template<typename T> template<typename T>
FIRAndDecimateComplex( void configure(
const T& taps, const T& taps,
const size_t decimation_factor const size_t decimation_factor
) : FIRAndDecimateComplex(taps.size(), decimation_factor) ) {
{ samples_ = std::make_unique<samples_t>(taps.size());
taps_reversed_ = std::make_unique<taps_t>(taps.size());
taps_count_ = taps.size();
decimation_factor_ = decimation_factor;
std::reverse_copy(taps.cbegin(), taps.cend(), &taps_reversed_[0]); std::reverse_copy(taps.cbegin(), taps.cend(), &taps_reversed_[0]);
} }
@ -115,10 +114,10 @@ public:
private: private:
using samples_t = sample_t[]; using samples_t = sample_t[];
const std::unique_ptr<samples_t> samples_; std::unique_ptr<samples_t> samples_;
const std::unique_ptr<taps_t> taps_reversed_; std::unique_ptr<taps_t> taps_reversed_;
const size_t taps_count_; size_t taps_count_;
const size_t decimation_factor_; size_t decimation_factor_;
}; };
class DecimateBy2CIC4Real { class DecimateBy2CIC4Real {

View file

@ -27,15 +27,6 @@ namespace interpolation {
class LinearResampler { class LinearResampler {
public: public:
constexpr LinearResampler(
const float input_rate,
const float output_rate
) : last_sample { 0.0f },
phase { 0.0f },
phase_increment { calculate_increment(input_rate, output_rate) }
{
}
void configure( void configure(
const float input_rate, const float input_rate,
const float output_rate const float output_rate
@ -63,9 +54,9 @@ public:
} }
private: private:
float last_sample; float last_sample { 0.0f };
float phase; float phase { 0.0f };
float phase_increment; float phase_increment { 0.0f };
static constexpr float calculate_increment(const float input_rate, const float output_rate) { static constexpr float calculate_increment(const float input_rate, const float output_rate) {
return input_rate / output_rate; return input_rate / output_rate;

View file

@ -43,24 +43,16 @@ public:
using taps_t = tap_t[]; using taps_t = tap_t[];
MatchedFilter( template<class T>
const tap_t* const taps, void configure(
const size_t taps_count,
size_t decimation_factor = 1
) : samples_ { std::make_unique<samples_t>(taps_count) },
taps_reversed_ { std::make_unique<taps_t>(taps_count) },
taps_count_ { taps_count },
decimation_factor { decimation_factor }
{
std::reverse_copy(&taps[0], &taps[taps_count], &taps_reversed_[0]);
}
template<typename T>
MatchedFilter(
const T& taps, const T& taps,
size_t decimation_factor = 1 size_t decimation_factor = 1
) : MatchedFilter(taps.data(), taps.size(), decimation_factor) ) {
{ samples_ = std::make_unique<samples_t>(taps.size());
taps_reversed_ = std::make_unique<taps_t>(taps.size());
taps_count_ = taps.size();
decimation_factor = decimation_factor;
std::reverse_copy(taps.cbegin(), taps.cend(), &taps_reversed_[0]);
} }
bool execute_once(const sample_t input); bool execute_once(const sample_t input);
@ -72,9 +64,9 @@ public:
private: private:
using samples_t = sample_t[]; using samples_t = sample_t[];
const std::unique_ptr<samples_t> samples_; std::unique_ptr<samples_t> samples_;
const std::unique_ptr<taps_t> taps_reversed_; std::unique_ptr<taps_t> taps_reversed_;
const size_t taps_count_; size_t taps_count_ { 0 };
size_t decimation_factor { 1 }; size_t decimation_factor { 1 };
size_t decimation_phase { 0 }; size_t decimation_phase { 0 };
float output; float output;

View file

@ -33,12 +33,17 @@
class NarrowbandAMAudio : public BasebandProcessor { class NarrowbandAMAudio : public BasebandProcessor {
public: public:
NarrowbandAMAudio() {
decimator.set_decimation_factor(ChannelDecimator::DecimationFactor::By32);
channel_filter.configure(channel_filter_taps.taps, 2);
}
void execute(buffer_c8_t buffer) override; void execute(buffer_c8_t buffer) override;
private: private:
ChannelDecimator decimator { ChannelDecimator::DecimationFactor::By32 }; ChannelDecimator decimator;
const fir_taps_real<64>& channel_filter_taps = taps_64_lp_031_070_tfilter; const fir_taps_real<64>& channel_filter_taps = taps_64_lp_031_070_tfilter;
dsp::decimate::FIRAndDecimateComplex channel_filter { channel_filter_taps.taps, 2 }; dsp::decimate::FIRAndDecimateComplex channel_filter;
dsp::demodulate::AM demod; dsp::demodulate::AM demod;
IIRBiquadFilter audio_hpf { audio_hpf_config }; IIRBiquadFilter audio_hpf { audio_hpf_config };
}; };

View file

@ -44,7 +44,10 @@ FSKProcessor::~FSKProcessor() {
void FSKProcessor::configure(const FSKConfiguration new_configuration) { void FSKProcessor::configure(const FSKConfiguration new_configuration) {
// TODO: Matched filter characteristics are hard-coded for the moment. YUCK! // TODO: Matched filter characteristics are hard-coded for the moment. YUCK!
clock_recovery.configure(sampling_rate / 4, new_configuration.symbol_rate); decimator.set_decimation_factor(ChannelDecimator::DecimationFactor::By16);
channel_filter.configure(channel_filter_taps.taps, 8);
mf.configure(baseband::ais::rrc_taps_128_decim_4_p, 1);
clock_recovery.configure(new_configuration.symbol_rate * 2, new_configuration.symbol_rate, { 0.0555f });
packet_builder.configure( packet_builder.configure(
{ new_configuration.access_code, new_configuration.access_code_length, new_configuration.access_code_tolerance }, { new_configuration.access_code, new_configuration.access_code_length, new_configuration.access_code_tolerance },
{ new_configuration.unstuffing_pattern, new_configuration.unstuffing_length } { new_configuration.unstuffing_pattern, new_configuration.unstuffing_length }

View file

@ -53,18 +53,12 @@ public:
void execute(buffer_c8_t buffer) override; void execute(buffer_c8_t buffer) override;
private: private:
const size_t sampling_rate = 76800; ChannelDecimator decimator;
const fir_taps_real<64>& channel_filter_taps = taps_64_lp_042_078_tfilter;
ChannelDecimator decimator { ChannelDecimator::DecimationFactor::By16 }; dsp::decimate::FIRAndDecimateComplex channel_filter;
const fir_taps_real<64>& channel_filter_taps = taps_64_lp_031_070_tfilter; dsp::matched_filter::MatchedFilter mf;
dsp::decimate::FIRAndDecimateComplex channel_filter { channel_filter_taps.taps, 8 };
dsp::matched_filter::MatchedFilter mf { baseband::ais::rrc_taps_128_decim_4_p, 1 };
clock_recovery::ClockRecovery<clock_recovery::FixedErrorFilter> clock_recovery { clock_recovery::ClockRecovery<clock_recovery::FixedErrorFilter> clock_recovery {
static_cast<float>(sampling_rate / 4),
9600,
{ 0.0555f },
[this](const float symbol) { this->consume_symbol(symbol); } [this](const float symbol) { this->consume_symbol(symbol); }
}; };
symbol_coding::NRZIDecoder nrzi_decode; symbol_coding::NRZIDecoder nrzi_decode;

View file

@ -34,12 +34,17 @@
class NarrowbandFMAudio : public BasebandProcessor { class NarrowbandFMAudio : public BasebandProcessor {
public: public:
NarrowbandFMAudio() {
decimator.set_decimation_factor(ChannelDecimator::DecimationFactor::By32);
channel_filter.configure(channel_filter_taps.taps, 2);
}
void execute(buffer_c8_t buffer) override; void execute(buffer_c8_t buffer) override;
private: private:
ChannelDecimator decimator { ChannelDecimator::DecimationFactor::By32 }; ChannelDecimator decimator;
const fir_taps_real<64>& channel_filter_taps = taps_64_lp_042_078_tfilter; const fir_taps_real<64>& channel_filter_taps = taps_64_lp_042_078_tfilter;
dsp::decimate::FIRAndDecimateComplex channel_filter { channel_filter_taps.taps, 2 }; dsp::decimate::FIRAndDecimateComplex channel_filter;
dsp::demodulate::FM demod { 48000, 7500 }; dsp::demodulate::FM demod { 48000, 7500 };
IIRBiquadFilter audio_hpf { audio_hpf_config }; IIRBiquadFilter audio_hpf { audio_hpf_config };

View file

@ -33,10 +33,14 @@
class WidebandFMAudio : public BasebandProcessor { class WidebandFMAudio : public BasebandProcessor {
public: public:
WidebandFMAudio() {
decimator.set_decimation_factor(ChannelDecimator::DecimationFactor::By4);
}
void execute(buffer_c8_t buffer) override; void execute(buffer_c8_t buffer) override;
private: private:
ChannelDecimator decimator { ChannelDecimator::DecimationFactor::By4 }; ChannelDecimator decimator;
dsp::demodulate::FM demod { 768000, 75000 }; dsp::demodulate::FM demod { 768000, 75000 };
dsp::decimate::DecimateBy2CIC4Real audio_dec_1; dsp::decimate::DecimateBy2CIC4Real audio_dec_1;