Mozzi  alpha 0.01.1t
sound synthesis library for Arduino
 All Classes Functions Typedefs
Public Member Functions
Smooth< T > Class Template Reference

A simple low pass filter for smoothing control signals. More...

List of all members.

Public Member Functions

 Smooth (float smoothness)
 Constructor.
next (T in)
 Filters the input and returns the filtered value.
void setSmoothness (float smoothness)
 Sets how much smoothing the filter will apply to its input.

Detailed Description

template<class T>
class Smooth< T >

A simple low pass filter for smoothing control signals.

This algorithm comes from http://en.wikipedia.org/wiki/Low-pass_filter: y[i] := y[i-1] + α * (x[i] - y[i-1]), translated as out = last_out + a * (in - last_out). It's not calibrated to any real-world update rate, so if you use it at CONTROL_RATE and you change CONTROL_RATE, you'll need to adjust the smoothness value to suit.

Template Parameters:
Tthe type of numbers being smoothed. Watch out for numbers overflowing the internal calculations. Some experimentation is recommended. If this can't be overcome using different settings or values, LowPass1stOrder may be another option.
Note:
Timing: ~5us for 16 bit types, ~1us for 8 bit types.
Todo:
Check if 8 bit templates can work efficiently with a higher res smoothness - as is they don't have enough resolution to work well at audio rate. See if Line might be more useful in most cases.

Definition at line 44 of file Smooth.h.


Constructor & Destructor Documentation

template<class T >
Smooth< T >::Smooth ( float  smoothness) [inline]

Constructor.

Parameters:
smoothnesssets how much smoothing the filter will apply to its input. Use a float in the range 0~1, where 0 is not very smooth and 0.99 is very smooth.

Definition at line 56 of file Smooth.h.


Member Function Documentation

template<class T >
T Smooth< T >::next ( in) [inline]

Filters the input and returns the filtered value.

Parameters:
inthe signal to be smoothed.
Returns:
the filtered signal.

Definition at line 66 of file Smooth.h.

template<class T >
void Smooth< T >::setSmoothness ( float  smoothness) [inline]

Sets how much smoothing the filter will apply to its input.

Parameters:
smoothnesssets how much smoothing the filter will apply to its input. Use a float in the range 0~1, where 0 is not very smooth and 0.99 is very smooth.

Definition at line 79 of file Smooth.h.


The documentation for this class was generated from the following file: