XCORE SDK
XCORE Software Development Kit
Public Member Functions | Static Public Attributes | List of all members
mic_array::TwoStageDecimator< MIC_COUNT, S2_DEC_FACTOR, S2_TAP_COUNT > Class Template Reference

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
 

Detailed Description

template<unsigned MIC_COUNT, unsigned S2_DEC_FACTOR, unsigned S2_TAP_COUNT>
class mic_array::TwoStageDecimator< MIC_COUNT, S2_DEC_FACTOR, S2_TAP_COUNT >

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_COUNTNumber of microphone channels.
S2_DEC_FACTORStage 2 decimation factor.
S2_TAP_COUNTStage 2 tap count.git p

Member Function Documentation

◆ Init()

template<unsigned MIC_COUNT, unsigned S2_DEC_FACTOR, unsigned S2_TAP_COUNT>
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

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; see mic_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. See lib_xs3_math's documentation for xs3_filter_fir_s32_t for more details.

Parameters
s1_filter_coefStage 1 filter coefficients.
s2_filter_coefStage 2 filter coefficients.
s2_filter_shrStage 2 filter right-shift.

◆ ProcessBlock()

template<unsigned MIC_COUNT, unsigned S2_DEC_FACTOR, unsigned S2_TAP_COUNT>
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:

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_outOutput sample vector.
pdm_blockPDM data to be processed.

Member Data Documentation

◆ BLOCK_SIZE

template<unsigned MIC_COUNT, unsigned S2_DEC_FACTOR, unsigned S2_TAP_COUNT>
constexpr unsigned mic_array::TwoStageDecimator< MIC_COUNT, S2_DEC_FACTOR, S2_TAP_COUNT >::BLOCK_SIZE = MIC_COUNT * S2_DEC_FACTOR
staticconstexpr

Size of a block of PDM data in words.

◆ DecimationFactor

template<unsigned MIC_COUNT, unsigned S2_DEC_FACTOR, unsigned S2_TAP_COUNT>
unsigned mic_array::TwoStageDecimator< MIC_COUNT, S2_DEC_FACTOR, S2_TAP_COUNT >::DecimationFactor = S2_DEC_FACTOR

Stage 2 decimator decimation factor.

◆ filter_coef

template<unsigned MIC_COUNT, unsigned S2_DEC_FACTOR, unsigned S2_TAP_COUNT>
const uint32_t* mic_array::TwoStageDecimator< MIC_COUNT, S2_DEC_FACTOR, S2_TAP_COUNT >::filter_coef

Pointer to filter coefficients for Stage 1

◆ filter_state

template<unsigned MIC_COUNT, unsigned S2_DEC_FACTOR, unsigned S2_TAP_COUNT>
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.

◆ filters

template<unsigned MIC_COUNT, unsigned S2_DEC_FACTOR, unsigned S2_TAP_COUNT>
xs3_filter_fir_s32_t mic_array::TwoStageDecimator< MIC_COUNT, S2_DEC_FACTOR, S2_TAP_COUNT >::filters[MIC_COUNT]

Stage 2 FIR filters

◆ MicCount

template<unsigned MIC_COUNT, unsigned S2_DEC_FACTOR, unsigned S2_TAP_COUNT>
constexpr unsigned mic_array::TwoStageDecimator< MIC_COUNT, S2_DEC_FACTOR, S2_TAP_COUNT >::MicCount = MIC_COUNT
staticconstexpr

Number of microphone channels.

◆ pdm_history

template<unsigned MIC_COUNT, unsigned S2_DEC_FACTOR, unsigned S2_TAP_COUNT>
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

◆ TapCount

template<unsigned MIC_COUNT, unsigned S2_DEC_FACTOR, unsigned S2_TAP_COUNT>
unsigned mic_array::TwoStageDecimator< MIC_COUNT, S2_DEC_FACTOR, S2_TAP_COUNT >::TapCount = S2_TAP_COUNT

Stage 2 decimator tap count.


The documentation for this class was generated from the following file: