mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
De-std::vector MatchedFilter, was chewing up far too much memory.
This commit is contained in:
parent
3e9f0971e1
commit
fe94cfa45a
@ -24,24 +24,5 @@
|
||||
namespace dsp {
|
||||
namespace matched_filter {
|
||||
|
||||
bool MatchedFilter::execute_once(
|
||||
const sample_t input
|
||||
) {
|
||||
samples[samples.size() - decimation_factor + decimation_phase] = input;
|
||||
|
||||
advance_decimation_phase();
|
||||
if( is_new_decimation_cycle() ) {
|
||||
output = std::inner_product(samples.cbegin(), samples.cend(), taps.cbegin(), sample_t { 0.0f, 0.0f });
|
||||
shift_by_decimation_factor();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void MatchedFilter::shift_by_decimation_factor() {
|
||||
std::rotate(samples.begin(), samples.begin() + decimation_factor, samples.end());
|
||||
}
|
||||
|
||||
} /* namespace matched_filter */
|
||||
} /* namespace dsp */
|
||||
|
@ -22,11 +22,12 @@
|
||||
#ifndef __MATCHED_FILTER_H__
|
||||
#define __MATCHED_FILTER_H__
|
||||
|
||||
#include "baseband_ais.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <complex>
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#include <algorithm>
|
||||
@ -35,46 +36,53 @@
|
||||
namespace dsp {
|
||||
namespace matched_filter {
|
||||
|
||||
template<size_t N>
|
||||
class MatchedFilter {
|
||||
public:
|
||||
using sample_t = std::complex<float>;
|
||||
using tap_t = std::complex<float>;
|
||||
|
||||
using taps_t = std::vector<tap_t>;
|
||||
using taps_t = std::array<tap_t, N>;
|
||||
|
||||
MatchedFilter(
|
||||
const taps_t& taps,
|
||||
size_t decimation_factor = 1
|
||||
) : decimation_factor { decimation_factor }
|
||||
) : taps(taps),
|
||||
decimation_factor { decimation_factor }
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void set_taps(const T& new_taps) {
|
||||
taps.assign(new_taps.cbegin(), new_taps.cend());
|
||||
taps.shrink_to_fit();
|
||||
|
||||
samples.assign(new_taps.size(), 0);
|
||||
samples.shrink_to_fit();
|
||||
}
|
||||
|
||||
bool execute_once(
|
||||
const sample_t input
|
||||
);
|
||||
) {
|
||||
samples[samples.size() - decimation_factor + decimation_phase] = input;
|
||||
|
||||
advance_decimation_phase();
|
||||
if( is_new_decimation_cycle() ) {
|
||||
output = std::inner_product(samples.cbegin(), samples.cend(), taps.cbegin(), sample_t { 0.0f, 0.0f });
|
||||
shift_by_decimation_factor();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
sample_t get_output() const {
|
||||
return output;
|
||||
}
|
||||
|
||||
private:
|
||||
using samples_t = std::vector<sample_t>;
|
||||
using samples_t = std::array<sample_t, N>;
|
||||
|
||||
samples_t samples;
|
||||
taps_t taps;
|
||||
const taps_t taps;
|
||||
size_t decimation_factor { 1 };
|
||||
size_t decimation_phase { 0 };
|
||||
sample_t output;
|
||||
|
||||
void shift_by_decimation_factor();
|
||||
void shift_by_decimation_factor() {
|
||||
std::rotate(samples.begin(), samples.begin() + decimation_factor, samples.end());
|
||||
}
|
||||
|
||||
void advance_decimation_phase() {
|
||||
decimation_phase = (decimation_phase + 1) % decimation_factor;
|
||||
|
@ -30,9 +30,6 @@ FSKProcessor::FSKProcessor(
|
||||
MessageHandlerMap& message_handlers
|
||||
) : message_handlers(message_handlers)
|
||||
{
|
||||
mf_0.set_taps(baseband::ais::rrc_taps_8_n);
|
||||
mf_1.set_taps(baseband::ais::rrc_taps_8_p);
|
||||
|
||||
message_handlers.register_handler(Message::ID::FSKConfiguration,
|
||||
[this](const Message* const p) {
|
||||
auto m = reinterpret_cast<const FSKConfigurationMessage*>(p);
|
||||
|
@ -57,8 +57,8 @@ private:
|
||||
const fir_taps_real<64>& channel_filter_taps = taps_64_lp_031_070_tfilter;
|
||||
dsp::decimate::FIRAndDecimateBy2Complex<64> channel_filter { channel_filter_taps.taps };
|
||||
|
||||
dsp::matched_filter::MatchedFilter mf_0 { 1 };
|
||||
dsp::matched_filter::MatchedFilter mf_1 { 1 };
|
||||
dsp::matched_filter::MatchedFilter<8> mf_0 { baseband::ais::rrc_taps_8_n, 1 };
|
||||
dsp::matched_filter::MatchedFilter<8> mf_1 { baseband::ais::rrc_taps_8_p, 1 };
|
||||
|
||||
clock_recovery::ClockRecovery<clock_recovery::FixedErrorFilter> clock_recovery {
|
||||
static_cast<float>(sampling_rate / 4),
|
||||
|
Loading…
Reference in New Issue
Block a user