Document toolboxDocument toolbox

FIRSparse

Overview

Sparse FIR filter in which most coefficients equal zero

Discussion

This module implements a sparse FIR filter in which most coefficients are equal to zero. The filter is implemented using a tap delay line rather than a traditional FIR filter. The number of output taps (NUMTAPS) is specified at instantiation time. For each tap, you specify the delay time (tapDelay array) and the weighting coefficient (tapCoeffs array). Delays are specified in units of samples.

At construction time, you specify the maximum delay (maxDelay) of the module. maxDelay determines the size of the internal state buffer. To be precise, the size of the internal state buffer equals maxDelay+blockSize samples. The delay time per tap must be in the range [0 MAXDELAY]. Delay times and coefficients can be adjusted at run-time. However, the module is not smoothly updating and you may get audible clicks when adjusting the tapDelay at run-time. The module uses one scratch buffer whose size equals the size of the input pin.

The module gives you some control over where the state buffer is allocated in memory. By default, the memory heap AWE_FAST2SLOW is used and thus the state buffer is first allocated in internal DM memory. If this fails, then internal PM memory is used. And finally, if this fails, then external memory is used. The 4th input argument MEMHEAP provide control over the allocation process. See the fir_sparse_module.m function header for more details.

The tapCoeffs and tapDelay array are always allocated in internal DM memory.

Type Definition

typedef struct _ModuleFIRSparse { ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure INT32 numTaps; // Number of non-zero coefficients (taps) in the filter INT32 maxDelay; // Maximum delay that can be realized, in samples INT32 stateHeap; // Heap in which to allocate memory INT32 stateIndex; // Index of the oldest state variable in the array of state variables INT32* tapDelay; // Current delay per channel FLOAT32* tapCoeffs; // Coefficient applied to each tap output FLOAT32* state; // State variable array } ModuleFIRSparseClass;

Variables

Properties

Name

Type

Usage

isHidden

Default value

Range

Units

numTaps

int

const

0

5

Unrestricted

 

maxDelay

int

const

0

100

1:100000

samples

stateHeap

int

const

1

2

Unrestricted

 

stateIndex

int

state

1

0

Unrestricted

 

tapDelay

int*

parameter

0

[5 x 1]

0:1:100

samples

tapCoeffs

float*

parameter

0

[5 x 1]

Unrestricted

 

state

float*

state

1

[132 x 1]

Unrestricted

 

Pins

Input Pins

Name: in

Description: audio input

Data type: float

Channel range: 1

Block size range: Unrestricted

Sample rate range: Unrestricted

Complex support: Real

Output Pins

Name: out

Description: audio output

Data type: float

Scratch Pins

Channel count: 1

Block size: 32

Sample rate: 48000

MATLAB Usage

File Name: fir_sparse_module.m

M=fir_sparse_module(NAME, NUMTAPS, MAXDELAY, MEMHEAP) Creates a sparse FIR filter which is equivalent to a multi-tap time delay in which the outputs are weighted and summed. The module has a single mono input pin and a single mono output pin. Arguments: NAME - name of the module. NUMTAPS - number of taps MAXDELAY - Maximum delay, in samples. This is the largest delay which will be supported and determines the length of the internal state buffer. MEMHEAP - specifies the memory heap to use to allocate the main state buffer. This is a string and follows the memory allocation enumeration in Framework.h. Allowable values are: 'AWE_HEAP_FAST' - always use internal DM memory. 'AWE_HEAP_FASTB' - always use internal PM memory. 'AWE_HEAP_SLOW' - always use external memory. (the default) 'AWE_HEAP_FAST2SLOW' - use internal memory. If this fails then use external memory (the default).

Â