public abstract class IIRFilter extends UGen implements AudioEffect
calcCoeff()
function. When filling the
coefficient arrays, be aware that b[0]
corresponds to
b1
.UGen.InputType, UGen.UGenInput
Modifier and Type | Field and Description |
---|---|
protected float[] |
a
The a coefficients.
|
UGen.UGenInput |
audio |
protected float[] |
b
The b coefficients.
|
UGen.UGenInput |
cutoff |
Constructor and Description |
---|
IIRFilter(float freq,
float sampleRate)
Constructs an IIRFilter with the given cutoff frequency that will be used
to filter audio recorded at
sampleRate . |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
calcCoeff()
Calculates the coefficients of the filter using the current cutoff
frequency.
|
float |
frequency()
Returns the cutoff frequency (in Hz).
|
void |
printCoeff()
Prints the current values of the coefficients to the console.
|
void |
process(float[] signal)
Processes
signal in some way. |
void |
process(float[] sigLeft,
float[] sigRight)
Processes
sigLeft and sigRight in some way. |
void |
setFreq(float f)
Sets the cutoff/center frequency of the filter.
|
void |
uGenerate(float[] channels)
Implement this method when you extend UGen.
|
boolean |
validFreq(float f)
Returns true if the frequency is valid for this filter.
|
addInput, getLastValues, patch, patch, patch, printInputs, removeInput, sampleRate, sampleRateChanged, setAudioChannelCount, setSampleRate, tick, unpatch, unpatch
public final UGen.UGenInput audio
public final UGen.UGenInput cutoff
protected float[] a
protected float[] b
public IIRFilter(float freq, float sampleRate)
sampleRate
.freq
- the cutoff frequencysampleRate
- the sample rate of audio to be filteredpublic final void uGenerate(float[] channels)
UGen
getLastValues
method of your audio UGenInput to
retrieve the audio you want to modify, which you will then modify however
you need to, assigning the result to the values in channels
.public final void process(float[] signal)
AudioEffect
signal
in some way.process
in interface AudioEffect
signal
- an array of audio samples, representing a mono sound stream.public final void process(float[] sigLeft, float[] sigRight)
AudioEffect
sigLeft
and sigRight
in some way.process
in interface AudioEffect
sigLeft
- an array of audio samples, representing the left channel of a
stereo sound streamsigRight
- an array of audio samples, representing the right channel of a
stereo sound streampublic final void setFreq(float f)
f
- the new cutoff/center frequency (in Hz).public boolean validFreq(float f)
f
is positive.f
- the frequency (in Hz) to validatef
is a valid frequency for this filterpublic final float frequency()
protected abstract void calcCoeff()
b[0]
corresponds to the coefficient b1
.public final void printCoeff()