Skip to main content

butterworth-lowpass

Design a 2nd-order Butterworth low-pass biquad and run synthetic tones through the <alp/dsp.h> IIR chain stage.

The other DSP examples (rail-predictive-maintenance, acoustic-safety-events) show the spectral side of <alp/dsp>. This one shows the filter side: the same chain API carries a cascaded-biquad IIR stage (ALP_DSP_STAGE_IIR).

Source: examples/audio/butterworth-lowpass/.

What it does

  1. Designs a 2nd-order Butterworth low-pass biquad with alp_dsp_biquad_design() — a cookbook low-pass at Q = 1/√2. No hand-derived filter math in the app.
  2. Pushes two float test tones through the same filter with alp_dsp_chain_apply_samples_f32() (float in → float out, no int16 round-trip): one in the passband (10 Hz), one in the stopband (250 Hz).
  3. Measures each tone's RMS before and after with alp_dsp_stats_f32() and reports the gain.

The backend runs CMSIS-DSP arm_biquad_cascade_df1_f32 on the Cortex-M55 and a portable-C biquad under native_sim — the app never touches arm_* symbols; it designs the coefficients and hands them to the chain.

ParameterValue
Sample rate FS_HZ1000 Hz
Cutoff FC_HZ50 Hz (−3 dB)
Samples N_SAMPLE1024
Settle (skipped before RMS)128 samples
Passband probe tone10 Hz
Stopband probe tone250 Hz

The first 128 samples are dropped before the RMS reduction: a freshly-opened biquad starts from zero state, so its output ramps up over the first few time constants. Measuring only the steady-state region reports the filter's true gain.

250 Hz is 5× FC — about 2.3 octaves — so a 2nd-order (−12 dB/octave) roll-off predicts roughly −28 dB (~0.04×) there.

Acceptance

The app self-checks with generous margins, so the test is about the filter working rather than matching a design to the decimal:

bool ok = (pass_gain > 0.7f) && (stop_gain < 0.25f);

board.yaml

Pure compute — no peripherals, no chips — so the same source builds on any SoM. The E1M-AEN801 M55 is the reference target.

libraries:
- name: cmsis-dsp
cores: [m55_hp]

som:
sku: E1M-AEN801

preset: e1m-evk
supported_boards:
- e1m-evk
- e1m-x-evk

cores:
a32_cluster:
os: "off"
m55_hp:
app: ./src

diagnostics:
log_level: info

Build and run

The whole pipeline runs to completion on native_sim against synthetic tones — no hardware needed:

west build -b native_sim/native/64 examples/audio/butterworth-lowpass
west build -t run

On the E1M-AEN801 (M55) the identical source runs the CMSIS-DSP biquad.

Expected output

Every line is prefixed [bwlp]. The app prints the designed coefficients, then the measured gain per probe tone:

[bwlp] 2nd-order Butterworth low-pass via <alp/dsp> IIR chain
[bwlp] fs=1000 Hz fc=50 Hz
[bwlp] biquad {b0,b1,b2,a1,a2} = {...}
[bwlp] 10.0 Hz (passband): gain 1.00
[bwlp] 250.0 Hz (stopband): gain 0.04 (-28.0 dB)
[bwlp] PASS: passband preserved, stopband rejected
[bwlp] done

Coefficient and gain values are shown indicatively — the exact printed numbers come from the designer at runtime.

See also

Questions about this page? Discuss in Community Forum