| Mozzi version v1.1.0 sound synthesis library for Arduino |

Public Member Functions | List of all members
StateVariable< FILTER_TYPE > Class Template Reference

A State Variable filter which offers 12db resonant low, high, bandpass and notch modes. More...

`#include <StateVariable.h>`

## Public Member Functions
| StateVariable ()
| Constructor.
void | setResonance (Q0n8 resonance)
| Set how resonant the filter will be. More...
void | setCentreFreq (unsigned int centre_freq)
| Set the centre or corner frequency of the filter. More...
int | next (int input)
| Calculate the next sample, given an input signal. More...

## Detailed Description

### template<int8_t FILTER_TYPE>
class StateVariable< FILTER_TYPE >

A State Variable filter which offers 12db resonant low, high, bandpass and notch modes.

Template Parameters

  FILTER_TYPE | choose between LOWPASS, BANDPASS, HIGHPASS and NOTCH.

Note
  To save processing time, this version of the filter does not saturate internally, so any resonant peaks are unceremoniously truncated. It may be worth adding code to constrain the internal variables to enable resonant saturating effects.

Definition at line 65 of file StateVariable.h.

## Member Function Documentation

## ◆ next()

template<int8_t FILTER_TYPE>

int StateVariable< FILTER_TYPE >::next | ( | int | input | ) |
| inline

Calculate the next sample, given an input signal.

Parameters

  input | the signal input.

Returns
  the signal output.

Note
  Timing: 16 - 20 us

Definition at line 112 of file StateVariable.h.

## ◆ setCentreFreq()

template<int8_t FILTER_TYPE>

void StateVariable< FILTER_TYPE >::setCentreFreq | ( | unsigned int | centre_freq | ) |
| inline

Set the centre or corner frequency of the filter.

Parameters

  centre_freq | 20 - 4096 Hz (AUDIO_RATE/4). This will be the cut-off frequency for LOWPASS and HIGHPASS, and the centre frequency to pass or reduce for BANDPASS and NOTCH.

Note
  Timing 25-30us
  The frequency calculation is VERY "approximate". This really needs to be fixed.

Definition at line 94 of file StateVariable.h.

## ◆ setResonance()

template<int8_t FILTER_TYPE>

void StateVariable< FILTER_TYPE >::setResonance | ( | Q0n8 | resonance | ) |
| inline

Set how resonant the filter will be.

Parameters

  resonance | a byte value between 1 and 255. The lower this value is, the more resonant the filter. At very low values, the filter can output loud peaks which can exceed Mozzi's output range, so you may need to attenuate the output in your sketch.

Note
  Timing < 500 ns

Definition at line 79 of file StateVariable.h.