XCORE SDK
XCORE Software Development Kit
|
First and Second Stage Decimator. More...
#include <Decimator.hpp>
Public Member 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. More... | |
void | ProcessBlock (int32_t sample_out[MIC_COUNT], uint32_t pdm_block[BLOCK_SIZE]) |
Process one block of PDM data. More... | |
Static Public Attributes | |
static constexpr unsigned | BLOCK_SIZE = MIC_COUNT * S2_DEC_FACTOR |
static constexpr unsigned | MicCount = MIC_COUNT |
struct { | |
unsigned DecimationFactor = S2_DEC_FACTOR | |
unsigned TapCount = S2_TAP_COUNT | |
} | Stage2 |
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.
MIC_COUNT | Number of microphone channels. |
S2_DEC_FACTOR | Stage 2 decimation factor. |
S2_TAP_COUNT | Stage 2 tap count.git p |
void mic_array::TwoStageDecimator< MIC_COUNT, S2_DEC_FACTOR, S2_TAP_COUNT >::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; see mic_array/etc/filters_default.h
. If you wish to provide your own filter coefficients, see
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; see mic_array/etc/filters_default.h
. If you wish to provide your own filter coefficients, see
s2_filter_shr
is the final right-shift applied to the stage 2 filter's accumulator prior to output. See lib_xs3_math
's documentation for xs3_filter_fir_s32_t
for more details.
s1_filter_coef | Stage 1 filter coefficients. |
s2_filter_coef | Stage 2 filter coefficients. |
s2_filter_shr | Stage 2 filter right-shift. |
void mic_array::TwoStageDecimator< MIC_COUNT, S2_DEC_FACTOR, S2_TAP_COUNT >::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 of pdm_block
should (effectively) be:
A single output sample from the second stage decimator is computed and written to sample_out[]
.
sample_out | Output sample vector. |
pdm_block | PDM data to be processed. |
|
staticconstexpr |
Size of a block of PDM data in words.
unsigned mic_array::TwoStageDecimator< MIC_COUNT, S2_DEC_FACTOR, S2_TAP_COUNT >::DecimationFactor = S2_DEC_FACTOR |
Stage 2 decimator decimation factor.
const uint32_t* mic_array::TwoStageDecimator< MIC_COUNT, S2_DEC_FACTOR, S2_TAP_COUNT >::filter_coef |
Pointer to filter coefficients for Stage 1
int32_t mic_array::TwoStageDecimator< MIC_COUNT, S2_DEC_FACTOR, S2_TAP_COUNT >::filter_state[MIC_COUNT][S2_TAP_COUNT] = {{0}} |
Stage 2 filter stage.
xs3_filter_fir_s32_t mic_array::TwoStageDecimator< MIC_COUNT, S2_DEC_FACTOR, S2_TAP_COUNT >::filters[MIC_COUNT] |
Stage 2 FIR filters
|
staticconstexpr |
Number of microphone channels.
uint32_t mic_array::TwoStageDecimator< MIC_COUNT, S2_DEC_FACTOR, S2_TAP_COUNT >::pdm_history[MIC_COUNT][8] |
Filter state (PDM history) for stage 1 filters.
const { ... } mic_array::TwoStageDecimator< MIC_COUNT, S2_DEC_FACTOR, S2_TAP_COUNT >::Stage2 |
Stage 2 decimator parameters
unsigned mic_array::TwoStageDecimator< MIC_COUNT, S2_DEC_FACTOR, S2_TAP_COUNT >::TapCount = S2_TAP_COUNT |
Stage 2 decimator tap count.