Decimator.hpp¶
-
template<unsigned MIC_COUNT, unsigned S2_DEC_FACTOR, unsigned S2_TAP_COUNT>
class mic_array::TwoStageDecimator¶ First and Second Stage Decimator.
This class template represents a two stage decimator which converts a stream of PDM samples to a lower sample rate stream of PCM samples.
- Template Parameters
MIC_COUNT – Number of microphone channels.
S2_DEC_FACTOR – Stage 2 decimation factor.
S2_TAP_COUNT – Stage 2 tap count.git p
Public Functions
-
void Init(const uint32_t *s1_filter_coef, const int32_t *s2_filter_coef, const right_shift_t s2_filter_shr)¶
Initialize the decimator.
Sets the stage 1 and 2 filter coefficients. The decimator must be initialized before any calls to
ProcessBlock()
.s1_filter_coef
points to a block of coefficients for the first stage decimator. This library provides coefficients for the first stage decimator; seemic_array/etc/filters_default.h
. If you wish to provide your own filter coefficients, see- Todo:
.
s2_filter_coef
points to an array of coefficients for the second stage decimator. This library provides coefficients for the second stage decimator where the second stage decimation factor is 6; seemic_array/etc/filters_default.h
. If you wish to provide your own filter coefficients, see- Todo:
.
s2_filter_shr
is the final right-shift applied to the stage 2 filter’s accumulator prior to output. Seelib_xs3_math
’s documentation forxs3_filter_fir_s32_t
for more details.- Parameters
s1_filter_coef – Stage 1 filter coefficients.
s2_filter_coef – Stage 2 filter coefficients.
s2_filter_shr – Stage 2 filter right-shift.
-
void ProcessBlock(int32_t sample_out[MIC_COUNT], uint32_t pdm_block[BLOCK_SIZE])¶
Process one block of PDM data.
Processes a block of PDM data to produce an output sample from the second stage decimator.
pdm_block
contains exactly enough PDM samples to produce a single output sample from the second stage decimator. The layout ofpdm_block
should (effectively) be:struct { struct { // lower word indices are older samples. // less significant bits in a word are older samples. uint32_t samples[S2_DEC_FACTOR]; } microphone[MIC_COUNT]; // mic channels are in ascending order } pdm_block;
A single output sample from the second stage decimator is computed and written to
sample_out[]
.- Parameters
sample_out – Output sample vector.
pdm_block – PDM data to be processed.
Public Members
-
unsigned DecimationFactor = S2_DEC_FACTOR¶
Stage 2 decimator decimation factor.
-
unsigned TapCount = S2_TAP_COUNT¶
Stage 2 decimator tap count.
-
const uint32_t *filter_coef¶
Pointer to filter coefficients for Stage 1
-
xs3_filter_fir_s32_t filters[MIC_COUNT]¶
Stage 2 FIR filters
-
int32_t filter_state[MIC_COUNT][S2_TAP_COUNT] = {{0}}¶
Stage 2 filter stage.
Public Static Attributes
-
static constexpr unsigned BLOCK_SIZE = MIC_COUNT * S2_DEC_FACTOR¶
Size of a block of PDM data in words.
-
static const struct mic_array::TwoStageDecimator::[anonymous] Stage2¶
Stage 2 decimator parameters