Skip to content

File syn_filter.c

FileList > dsp > syn_filter.c

Go to the source code of this file

Digital filter implementations.

  • #include "../util/syn_assert.h"
  • #include "syn_filter.h"
  • #include <string.h>

Public Functions

Type Name
void syn_filter_ema_init (SYN_FilterEMA * f, uint8_t alpha)
Initialize an EMA filter.
void syn_filter_ema_reset (SYN_FilterEMA * f)
Reset the filter to its initial state.
int16_t syn_filter_ema_update (SYN_FilterEMA * f, int16_t sample)
Feed a new sample and get the filtered output.
void syn_filter_fir_init (SYN_FilterFIR * f, const q16_t * taps, q16_t * history, uint16_t num_taps)
Initialize an FIR filter.
void syn_filter_fir_reset (SYN_FilterFIR * f)
Reset FIR filter sample history to 0.
q16_t syn_filter_fir_update (SYN_FilterFIR * f, q16_t sample)
Feed a new Q16 sample and get the FIR filtered output.
void syn_filter_ma_init (SYN_FilterMA * f, uint8_t window)
Initialize a moving average filter.
void syn_filter_ma_reset (SYN_FilterMA * f)
Reset the filter to its initial state.
int16_t syn_filter_ma_update (SYN_FilterMA * f, int16_t sample)
Feed a new sample and get the filtered output.
void syn_filter_median_init (SYN_FilterMedian * f, uint8_t window)
Initialize a median filter.
void syn_filter_median_reset (SYN_FilterMedian * f)
Reset the filter to its initial state.
int16_t syn_filter_median_update (SYN_FilterMedian * f, int16_t sample)
Feed a new sample and get the filtered output.

Public Functions Documentation

function syn_filter_ema_init

Initialize an EMA filter.

void syn_filter_ema_init (
    SYN_FilterEMA * f,
    uint8_t alpha
) 

Parameters:

  • f Filter instance.
  • alpha Smoothing factor (0–255). Higher = more responsive. Equivalent to alpha = value/256. Example: 64 ≈ 0.25 (slow), 192 ≈ 0.75 (fast).

function syn_filter_ema_reset

Reset the filter to its initial state.

void syn_filter_ema_reset (
    SYN_FilterEMA * f
) 

Parameters:

  • f Filter instance.

function syn_filter_ema_update

Feed a new sample and get the filtered output.

int16_t syn_filter_ema_update (
    SYN_FilterEMA * f,
    int16_t sample
) 

Parameters:

  • f Filter instance.
  • sample New raw sample.

Returns:

Filtered value.


function syn_filter_fir_init

Initialize an FIR filter.

void syn_filter_fir_init (
    SYN_FilterFIR * f,
    const q16_t * taps,
    q16_t * history,
    uint16_t num_taps
) 

Parameters:

  • f Filter instance.
  • taps Array of Q16 filter coefficients.
  • history Caller-provided Q16 history buffer of size num_taps.
  • num_taps Number of filter taps.

function syn_filter_fir_reset

Reset FIR filter sample history to 0.

void syn_filter_fir_reset (
    SYN_FilterFIR * f
) 

Parameters:

  • f Filter instance.

function syn_filter_fir_update

Feed a new Q16 sample and get the FIR filtered output.

q16_t syn_filter_fir_update (
    SYN_FilterFIR * f,
    q16_t sample
) 

Parameters:

  • f Filter instance.
  • sample New Q16 sample.

Returns:

Filtered output in Q16.


function syn_filter_ma_init

Initialize a moving average filter.

void syn_filter_ma_init (
    SYN_FilterMA * f,
    uint8_t window
) 

Parameters:

  • f Filter instance.
  • window Window size (must be <= SYN_FILTER_MAX_WINDOW).

function syn_filter_ma_reset

Reset the filter to its initial state.

void syn_filter_ma_reset (
    SYN_FilterMA * f
) 

Parameters:

  • f Filter instance.

function syn_filter_ma_update

Feed a new sample and get the filtered output.

int16_t syn_filter_ma_update (
    SYN_FilterMA * f,
    int16_t sample
) 

Parameters:

  • f Filter instance.
  • sample New raw sample.

Returns:

Filtered value (average of the last window samples).


function syn_filter_median_init

Initialize a median filter.

void syn_filter_median_init (
    SYN_FilterMedian * f,
    uint8_t window
) 

Parameters:

  • f Filter instance.
  • window Window size (should be odd for a true median; must be <= SYN_FILTER_MAX_WINDOW).

function syn_filter_median_reset

Reset the filter to its initial state.

void syn_filter_median_reset (
    SYN_FilterMedian * f
) 

Parameters:

  • f Filter instance.

function syn_filter_median_update

Feed a new sample and get the filtered output.

int16_t syn_filter_median_update (
    SYN_FilterMedian * f,
    int16_t sample
) 

Parameters:

  • f Filter instance.
  • sample New raw sample.

Returns:

Median of the last window samples.



The documentation for this class was generated from the following file src/syntropic/dsp/syn_filter.c