Mozzi  version 2015-05-11-20:23
sound synthesis library for Arduino
 All Classes Functions Typedefs Groups
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_TYPEchoose 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

template<int8_t FILTER_TYPE>
int StateVariable< FILTER_TYPE >::next ( int  input)
inline

Calculate the next sample, given an input signal.

Parameters
inputthe signal input.
Returns
the signal output.
Note
Timing: 16 - 20 us

Definition at line 122 of file StateVariable.h.

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_freq20 - 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 105 of file StateVariable.h.

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

Set how resonant the filter will be.

Parameters
resonancea uint8_t 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 86 of file StateVariable.h.