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,
};
ChannelDecimator(
DecimationFactor f
) : decimation_factor { f }
{
}
void set_decimation_factor(const DecimationFactor f) {
decimation_factor = f;
}
@ -75,7 +69,7 @@ private:
dsp::decimate::DecimateBy2CIC3 cic_3;
dsp::decimate::DecimateBy2CIC3 cic_4;
DecimationFactor decimation_factor { DecimationFactor::By32 };
DecimationFactor decimation_factor = DecimationFactor::By32;
buffer_c16_t execute_decimation(buffer_c8_t buffer);
};

View File

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

View File

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

View File

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

View File

@ -43,25 +43,17 @@ public:
using taps_t = tap_t[];
MatchedFilter(
const tap_t* const taps,
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(
template<class T>
void configure(
const T& taps,
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);
@ -72,9 +64,9 @@ public:
private:
using samples_t = sample_t[];
const std::unique_ptr<samples_t> samples_;
const std::unique_ptr<taps_t> taps_reversed_;
const size_t taps_count_;
std::unique_ptr<samples_t> samples_;
std::unique_ptr<taps_t> taps_reversed_;
size_t taps_count_ { 0 };
size_t decimation_factor { 1 };
size_t decimation_phase { 0 };
float output;

View File

@ -33,12 +33,17 @@
class NarrowbandAMAudio : public BasebandProcessor {
public:
NarrowbandAMAudio() {
decimator.set_decimation_factor(ChannelDecimator::DecimationFactor::By32);
channel_filter.configure(channel_filter_taps.taps, 2);
}
void execute(buffer_c8_t buffer) override;
private:
ChannelDecimator decimator { ChannelDecimator::DecimationFactor::By32 };
ChannelDecimator decimator;
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;
IIRBiquadFilter audio_hpf { audio_hpf_config };
};

View File

@ -44,7 +44,10 @@ FSKProcessor::~FSKProcessor() {
void FSKProcessor::configure(const FSKConfiguration new_configuration) {
// 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(
{ new_configuration.access_code, new_configuration.access_code_length, new_configuration.access_code_tolerance },
{ new_configuration.unstuffing_pattern, new_configuration.unstuffing_length }

View File

@ -53,18 +53,12 @@ public:
void execute(buffer_c8_t buffer) override;
private:
const size_t sampling_rate = 76800;
ChannelDecimator decimator { ChannelDecimator::DecimationFactor::By16 };
const fir_taps_real<64>& channel_filter_taps = taps_64_lp_031_070_tfilter;
dsp::decimate::FIRAndDecimateComplex channel_filter { channel_filter_taps.taps, 8 };
dsp::matched_filter::MatchedFilter mf { baseband::ais::rrc_taps_128_decim_4_p, 1 };
ChannelDecimator decimator;
const fir_taps_real<64>& channel_filter_taps = taps_64_lp_042_078_tfilter;
dsp::decimate::FIRAndDecimateComplex channel_filter;
dsp::matched_filter::MatchedFilter mf;
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); }
};
symbol_coding::NRZIDecoder nrzi_decode;

View File

@ -34,12 +34,17 @@
class NarrowbandFMAudio : public BasebandProcessor {
public:
NarrowbandFMAudio() {
decimator.set_decimation_factor(ChannelDecimator::DecimationFactor::By32);
channel_filter.configure(channel_filter_taps.taps, 2);
}
void execute(buffer_c8_t buffer) override;
private:
ChannelDecimator decimator { ChannelDecimator::DecimationFactor::By32 };
ChannelDecimator decimator;
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 };
IIRBiquadFilter audio_hpf { audio_hpf_config };

View File

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