Package toxi.audio
Class IIRFilter
java.lang.Object
toxi.audio.IIRFilter
This class provides a simple IIR filter implementation with one of lowpass,
highpass or bandpass characteristics. The class can filter individual samples
or entire signal buffers. The filter function always has this form:
y = 1 / a0 * (b0 * x0 + b1 * x1 + b2 * x2 - a1 * q1 - a2 * q2)http://en.wikipedia.org/wiki/Infinite_impulse_response
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfloat
calculateAmplitude
(float[] in) Just calculates the amplitude of the filtered signal, but doesn't actually apply the filter.clear()
float
filter
(float in) Applies filter to a single sample value.float
filter
(float[] in) Destructively filters a the given signal buffer.float
getDecay()
init
(float freq, float q) Initializes the filter to the given cutoff frequency and Q (resonance) settings.setDecay
(float decay)
-
Constructor Details
-
IIRFilter
- Parameters:
type
-sampleRate
-
-
-
Method Details
-
calculateAmplitude
public float calculateAmplitude(float[] in) Just calculates the amplitude of the filtered signal, but doesn't actually apply the filter.- Parameters:
in
-- Returns:
- amplitude
-
clear
-
filter
public float filter(float in) Applies filter to a single sample value.- Parameters:
in
-- Returns:
- filtered sample
-
filter
public float filter(float[] in) Destructively filters a the given signal buffer. The original samples are overwritten.- Parameters:
in
-- Returns:
- amplitude of filtered signal
-
getDecay
public float getDecay()- Returns:
- the decay
-
init
Initializes the filter to the given cutoff frequency and Q (resonance) settings. This function needs to be called at least once before the filter can be used.- Parameters:
freq
-q
-- Returns:
- itself
-
setDecay
- Parameters:
decay
- the decay to set- Returns:
- itself
-