The following example is taken from hpf.cfg(<SDK>\examples\audio\appi_fir\data). All the values in cfg file are specified in little endian format.
To Enable FIR module, a flag called ENABLE needs to be set to 1. This can be done as shown below
# Set FIR Enable
SetParamInband
PayloadSizeInBytes 24
00 00 00 00 # Data Payload address
10 00 00 00 # Size of Payload
02 2D 01 00 # MODULE_ID_FIR_FILTER 0x00012D02
03 2D 01 00 # PARAM_ID_FIR_FILTER_ENABLE 0x00012D03
04 00 00 00 # Param Size and Padding
01 00 00 00 # Enable flag
1) Setting these paramters is done using "SetParamInBand" variable. Other identifiers based on usage are : "ProcessData", "SetMediaFormat", "GetParamInband"
2) The next identifier is "PayloadSizeInBytes". This is the size in bytes in Decimal and not Hexadecimal. This is understood and used by the configuration fileparser.
3) Data Payload Address is not used by module.
4) The next parameter "Size of Payload" tells the size of the payload. This is used by audio unit test framework. This has to be specified in Hexadecimal number system.
5) Next value in payload "MODULE_ID_FIR_FILTER" is the module ID in little endian format. 32 bit value
6) Next value in payload "PARAM_ID_FIR_FILTER_ENABLE" corresponds to parameter ID in little endian. 32 bit value
7) Next value in payload "ParamSize and Padding". These are 16 bit values each. First 16 bits are reserved for padding followed by next 16 bits containing the actual param size in bytes.
8) Next value in payload is the actual parameter value. In the above example it's 0x00000001.
Let's consider another example from the same configuration file to set the coefficients for FIR filter.
The FIR filter is a 13 tap filter with the following coefficients {0xffe9, 0xfff4, 0x00a8 ...}.
The example below shows setting 13 coefficients of FIR example
# Set FIR coefficients
SetParamInband
PayloadSizeInBytes 52
00 00 00 00 # Data Payload address
2C 00 00 00 # Size of Payload
02 2D 01 00 # MODULE_ID_FIR_FILTER 0x00012D02
05 2D 01 00 # PARAM_ID_FIR_FILTER_PARAMS 0x00012D05
20 00 00 00 # Param Size and Padding
0D 00 00 00 # Numtaps=13 and reserved fields
f4 ff e9 ff # Coefficients
ce ff a8 ff
82 ff 66 ff
5b 3f 66 ff
82 ff a8 ff
ce ff e9 ff
f4 ff 00 00
FAQ: Configuration file for Audio Unit Testframework
Posted: Thu, 2013-10-10 18:56
Hello,
Could somebody explain why in the FIR example below, the PayloadSizeInBytes is 52?
The original example from Qualcomm is for a stereo audio file with sampling rate of 48kHz.
If I want to apply some modifications (use a FIR with only 5 taps, mono audio files, 16kHz) which fields should be modified in the hpf configuration file and the source code also.
Thanks for any answer in advance.
# Configuration file for OpenDSP Example FIR unit test
# What this config file does:
# - Resets algorithm
# - Enables FIR
# - Sets shift factor
# - Sets HPF coefficients to use
# - Processes buffers as specified by NumBuffers
# - Sets another set of HPF coefficients to use
# - Processes buffers as specified by NumBuffers
# - As a sanity check, gets delay introduced by algorithm (refer APPI document)
# Reset algorithm
SetParamInband
PayloadSizeInBytes 24
00 00 00 00 # Data Payload address
10 00 00 00 # Size of Payload
02 2D 01 00 # MODULE_ID_FIR_FILTER 0x00012D02
07 07 01 00 # APPI_PARAM_ID_ALGORITHMIC_RESET 0x00010707
04 00 00 00 # Param Size and Padding
00 00 00 00 # Dummy payload
# Set FIR Enable
SetParamInband
PayloadSizeInBytes 24
00 00 00 00 # Data Payload address
10 00 00 00 # Size of Payload
02 2D 01 00 # MODULE_ID_FIR_FILTER 0x00012D02
03 2D 01 00 # PARAM_ID_FIR_FILTER_ENABLE 0x00012D03
04 00 00 00 # Param Size and Padding
01 00 00 00 # Enable flag
# Set FIR Shift factor
SetParamInband
PayloadSizeInBytes 24
00 00 00 00 # Data Payload address
10 00 00 00 # Size of Payload
02 2D 01 00 # MODULE_ID_FIR_FILTER 0x00012D02
04 2D 01 00 # PARAM_ID_FIR_FILTER_SHIFT 0x00012D04
04 00 00 00 # Param Size and Padding
04 00 00 00 # Shift factor = 1
# Set FIR coefficients
# High pass, Fc=-3dB=100Hz
SetParamInband
PayloadSizeInBytes 52
00 00 00 00 # Data Payload address
2C 00 00 00 # Size of Payload
02 2D 01 00 # MODULE_ID_FIR_FILTER 0x00012D02
05 2D 01 00 # PARAM_ID_FIR_FILTER_PARAMS 0x00012D05
20 00 00 00 # Param Size and Padding
0D 00 00 00 # Numtaps=13 and reserved fields
f4 ff e9 ff # Coefficients
ce ff a8 ff
82 ff 66 ff
5b 3f 66 ff
82 ff a8 ff
ce ff e9 ff
f4 ff 00 00
ProcessData
NumBuffers 100
# Set FIR coefficients
# High pass, Fc=-3dB=300Hz
SetParamInband
PayloadSizeInBytes 64
00 00 00 00 # Data Payload address
38 00 00 00 # Size of Payload
02 2D 01 00 # MODULE_ID_FIR_FILTER 0x00012D02
05 2D 01 00 # PARAM_ID_FIR_FILTER_PARAMS 0x00012D05
20 00 00 00 # Param Size and Padding
13 00 00 00 # Numtaps=19 and reserved fields
a0 fc a5 fb
a9 fa b5 f9
d2 f8 0a f8
64 f7 e8 f6
9c f6 9c 73
9c f6 e8 f6
64 f7 0a f8
d2 f8 b5 f9
a9 fa a5 fb
a0 fc 00 00
ProcessData
NumBuffers 100
# Get IIR algorithm Delay
GetParamInband
PayloadSizeInBytes 16
00 00 00 00 # Data Payload address
02 2D 01 00 # MODULE_ID_FIR_FILTER 0x00012D02
08 07 01 00 # APPI_PARAM_ID_ALGORITHMIC_DELAY 0x00010708
04 00 00 00 # Param Size and Padding
RefPayloadSizeInBytes 4
12 00 00 00 #Filter delay = Numtaps-1