Skip to main content

<alp/dsp.h> — Signal Processing Chains

FIR / IIR / window / FFT chain composition over CMSIS-DSP, with a portable-C fallback when CMSIS-DSP isn't available.

#include <alp/dsp.h>

Build a chain

alp_dsp_chain_t chain;
alp_dsp_chain_init(&chain);

alp_dsp_fir_t fir = { .taps = my_fir_taps, .num_taps = 64 };
alp_dsp_chain_add(&chain, ALP_DSP_FIR, &fir);

alp_dsp_iir_t iir = { /* ... */ };
alp_dsp_chain_add(&chain, ALP_DSP_IIR, &iir);

alp_dsp_window_t win = { .type = ALP_DSP_WINDOW_HANN, .size = 256 };
alp_dsp_chain_add(&chain, ALP_DSP_WINDOW, &win);

alp_dsp_fft_t fft = { .size = 256, .complex = false };
alp_dsp_chain_add(&chain, ALP_DSP_FFT, &fft);

int16_t input[256], output[256];
alp_dsp_chain_run(&chain, input, output, 256);

Plug into ADC streaming

The same chain composes with <alp/adc.h>:

alp_adc_filter_t filter = { .chain = &chain };
alp_adc_stream_t *stream = alp_adc_stream_open(&(alp_adc_stream_config_t){
.sample_rate_hz = 16000,
.filter = &filter,
});

CMSIS-DSP integration

When cmsis-dsp is listed in board.yaml's libraries:, <alp/dsp.h> uses CMSIS-DSP kernels under the hood. Otherwise a portable-C fallback is used (slower but functionally equivalent).

See also

Questions about this page? Discuss in Community Forum