Loading...
Searching...
No Matches
filter.h File Reference

Digital filter. More...

Go to the source code of this file.

## Typedefs

typedef struct _aubio_filter_t | aubio_filter_t
| Digital filter.

## Functions

void | aubio_filter_do (aubio_filter_t *f, fvec_t *in)
| filter input vector (in-place)
void | aubio_filter_do_outplace (aubio_filter_t *f, const fvec_t *in, fvec_t *out)
| filter input vector (out-of-place)
void | aubio_filter_do_filtfilt (aubio_filter_t *f, fvec_t *in, fvec_t *tmp)
| filter input vector forward and backward
lvec_t * | aubio_filter_get_feedback (const aubio_filter_t *f)
| returns a pointer to feedback coefficients \( a_i \)
lvec_t * | aubio_filter_get_feedforward (const aubio_filter_t *f)
| returns a pointer to feedforward coefficients \( b_i \)
uint_t | aubio_filter_get_order (const aubio_filter_t *f)
| get order of the filter
uint_t | aubio_filter_get_samplerate (const aubio_filter_t *f)
| get sampling rate of the filter
uint_t | aubio_filter_set_samplerate (aubio_filter_t *f, uint_t samplerate)
| get sampling rate of the filter
void | aubio_filter_do_reset (aubio_filter_t *f)
| reset filter memory
aubio_filter_t * | new_aubio_filter (uint_t order)
| create new filter object
void | del_aubio_filter (aubio_filter_t *f)
| delete a filter object

## Detailed Description

Digital filter.

This object stores a digital filter of order \(n\). It contains the following data:

- \( n*1 b_i \) feedforward coefficients
- \( n*1 a_i \) feedback coefficients
- \( n*c x_i \) input signal
- \( n*c y_i \) output signal

For convenience, the samplerate of the input signal is also stored in the object.

Feedforward and feedback parameters can be modified using aubio_filter_get_feedback() and aubio_filter_get_feedforward().

The function aubio_filter_do_outplace() computes the following output signal \( y[n] \) from the input signal \( x[n] \):

\begin{eqnarray*} y[n] = b_0 x[n] & + & b_1 x[n-1] + b_2 x[n-2] + ... + b_P x[n-P] \\ & - & a_1 y[n-1] - a_2 y[n-2] - ... - a_P y[n-P] \\ \end{eqnarray*}

The function aubio_filter_do() executes the same computation but modifies directly the input signal (in-place).

The function aubio_filter_do_filtfilt() version runs the filter twice, first forward then backward, to compensate with the phase shifting of the forward operation.

Some convenience functions are provided:

- new_aubio_filter_a_weighting() and aubio_filter_set_a_weighting(),
- new_aubio_filter_c_weighting() and aubio_filter_set_c_weighting().
- new_aubio_filter_biquad() and aubio_filter_set_biquad().

Definition in file filter.h.

## Typedef Documentation

## aubio_filter_t

typedef struct _aubio_filter_t aubio_filter_t

Digital filter.

Examples
  temporal/test-a_weighting.c, temporal/test-biquad.c, temporal/test-c_weighting.c, and temporal/test-filter.c.

Definition at line 72 of file filter.h.

## Function Documentation

## aubio_filter_do()

void aubio_filter_do | ( | aubio_filter_t * | f,
|  | fvec_t * | in )

filter input vector (in-place)

Parameters

  f | filter object as returned by new_aubio_filter()
  in | input vector to filter

Examples
  temporal/test-biquad.c, and temporal/test-filter.c.

## aubio_filter_do_filtfilt()

void aubio_filter_do_filtfilt | ( | aubio_filter_t * | f,
|  | fvec_t * | in,
|  | fvec_t * | tmp )

filter input vector forward and backward

Parameters

  f | aubio_filter_t object as returned by new_aubio_filter()
  in | fvec_t input vector to filter
  tmp | memory space to use for computation

Examples
  temporal/test-biquad.c, and temporal/test-filter.c.

## aubio_filter_do_outplace()

void aubio_filter_do_outplace | ( | aubio_filter_t * | f,
|  | const fvec_t * | in,
|  | fvec_t * | out )

filter input vector (out-of-place)

Parameters

  f | filter object as returned by new_aubio_filter()
  in | input vector to filter
  out | output vector to store filtered input

Examples
  temporal/test-biquad.c, and temporal/test-filter.c.

## aubio_filter_do_reset()

void aubio_filter_do_reset | ( | aubio_filter_t * | f | ) |

reset filter memory

Parameters

  f | filter object as returned by new_aubio_filter()

## aubio_filter_get_feedback()

lvec_t * aubio_filter_get_feedback | ( | const aubio_filter_t * | f | ) |

returns a pointer to feedback coefficients \( a_i \)

Parameters

  f | filter object to get parameters from

Returns
  a pointer to the \( a_0 ... a_i ... a_P \) coefficients

## aubio_filter_get_feedforward()

lvec_t * aubio_filter_get_feedforward | ( | const aubio_filter_t * | f | ) |

returns a pointer to feedforward coefficients \( b_i \)

Parameters

  f | filter object to get coefficients from

Returns
  a pointer to the \( b_0 ... b_i ... b_P \) coefficients

## aubio_filter_get_order()

uint_t aubio_filter_get_order | ( | const aubio_filter_t * | f | ) |

get order of the filter

Parameters

  f | filter to get order from

Returns
  the order of the filter

## aubio_filter_get_samplerate()

uint_t aubio_filter_get_samplerate | ( | const aubio_filter_t * | f | ) |

get sampling rate of the filter

Parameters

  f | filter to get sampling rate from

Returns
  the sampling rate of the filter, in Hz

Examples
  temporal/test-filter.c.

## aubio_filter_set_samplerate()

uint_t aubio_filter_set_samplerate | ( | aubio_filter_t * | f,
|  | uint_t | samplerate )

get sampling rate of the filter

Parameters

  f | filter to get sampling rate from
  samplerate | sample rate to set the filter to

Returns
  the sampling rate of the filter, in Hz

## del_aubio_filter()

void del_aubio_filter | ( | aubio_filter_t * | f | ) |

delete a filter object

Parameters

  f | filter object to delete

Examples
  temporal/test-a_weighting.c, temporal/test-biquad.c, temporal/test-c_weighting.c, and temporal/test-filter.c.

## new_aubio_filter()

aubio_filter_t * new_aubio_filter | ( | uint_t | order | ) |

create new filter object

This function creates a new aubio_filter_t object, given the order of the filter.

Parameters

  order | order of the filter (number of coefficients)

Returns
  the newly created filter object

Examples
  temporal/test-a_weighting.c, temporal/test-c_weighting.c, and temporal/test-filter.c.