public class BiquadFilter extends IIRFilter implements DataBeadReceiver
Filter parameters may be set with individual setter functions (
setFreq
, setQ
, and
setGain
), or by passing a DataBead with the
appropriate properties to setParams
. (Messaging
the filter with a DataBead is equivalent to calling setParams.) Setter
methods return the instance, so they may be strung together:
filt.setFreq(200).setQ(30).setGain(.4);
BiquadFilterMulti can be used with pre-programmed algorithms that calculate
coefficients for various filter types. (See setType(int)
for a list
of available types.)
BiquadFilterMulti can also implement a user-defined filter algorithm by
calling setCustomType(CustomCoeffCalculator)
.
Modifier and Type | Class and Description |
---|---|
class |
BiquadFilter.CustomCoeffCalculator
CustomCoeffCalculator provides a mechanism to define custom filter
coefficients for a biquad filter based on frequency and Q.
|
static class |
BiquadFilter.Type |
protected class |
BiquadFilter.ValCalculator |
IIRFilter.IIRFilterAnalysis
UGen.OutputInitializationRegime, UGen.OutputPauseRegime
Modifier and Type | Field and Description |
---|---|
protected float |
a0 |
protected float |
a1 |
protected float |
a2 |
protected double |
ampResponse |
static BiquadFilter.Type |
AP
Indicates an all-pass filter; coefficients are calculated from equations
given in "Cookbook formulae for audio EQ biquad filter coefficients" by
Robert Bristow-Johnson.
|
protected boolean |
areAllStatic |
protected float |
b0 |
protected float |
b1 |
protected float |
b2 |
static BiquadFilter.Type |
BESSEL_HP
Indicates a Bessel high-pass filter; only frequency is relevant.
|
static BiquadFilter.Type |
BESSEL_LP
Indicates a Bessel low-pass filter; only frequency is relevant.
|
protected float |
bi1 |
protected float[] |
bi1m |
protected float |
bi2 |
protected float[] |
bi2m |
protected float |
bo1 |
protected float[] |
bo1m |
protected float |
bo2 |
protected float[] |
bo2m |
static BiquadFilter.Type |
BP_PEAK
Indicates a band-pass filter with constant peak gain; coefficients are
calculated from equations given in "Cookbook formulae for audio EQ biquad
filter coefficients" by Robert Bristow-Johnson.
|
static BiquadFilter.Type |
BP_SKIRT
Indicates a band-pass filter with constant skirt gain; coefficients are
calculated from equations given in "Cookbook formulae for audio EQ biquad
filter coefficients" by Robert Bristow-Johnson.
|
static BiquadFilter.Type |
BUTTERWORTH_HP
Indicates a Butterworth high-pass filter; only the frequency parameter is
relevant.
|
static BiquadFilter.Type |
BUTTERWORTH_LP
Indicates a Butterworth low-pass filter; only the frequency parameter is
relevant.
|
protected float |
cbi1 |
protected float[] |
cbi1m |
protected float |
cbi2 |
protected float[] |
cbi2m |
protected float |
cbo1 |
protected float[] |
cbo1m |
protected float |
cbo2 |
protected float[] |
cbo2m |
protected int |
channels |
protected boolean |
cuedInputMemory |
protected boolean |
cuedOutputMemory |
static BiquadFilter.Type |
CUSTOM_FILTER
Indicates a user-defined filter; see
setCustomType . |
protected float |
freq |
protected UGen |
freqUGen |
protected double |
frImag |
protected double |
frReal |
protected float |
gain |
protected UGen |
gainUGen |
static BiquadFilter.Type |
HIGH_SHELF
Indicates a high-shelf filter; coefficients are calculated from equations
given in "Cookbook formulae for audio EQ biquad filter coefficients" by
Robert Bristow-Johnson.
|
static BiquadFilter.Type |
HP
Indicates a high-pass filter; coefficients are calculated from equations
given in "Cookbook formulae for audio EQ biquad filter coefficients" by
Robert Bristow-Johnson.
|
protected boolean |
isFreqStatic |
protected boolean |
isGainStatic |
protected boolean |
isQStatic |
static BiquadFilter.Type |
LOW_SHELF
Indicates a low-shelf filter; coefficients are calculated from equations
given in "Cookbook formulae for audio EQ biquad filter coefficients" by
Robert Bristow-Johnson.
|
static BiquadFilter.Type |
LP
Indicates a low-pass filter; coefficients are calculated from equations
given in "Cookbook formulae for audio EQ biquad filter coefficients" by
Robert Bristow-Johnson.
|
static BiquadFilter.Type |
NOTCH
Indicates a notch (band-reject) filter; coefficients are calculated from
equations given in
"Cookbook formulae for audio EQ biquad filter coefficients" by Robert
Bristow-Johnson.
|
static BiquadFilter.Type |
PEAKING_EQ
Indicates a peaking-EQ filter; coefficients are calculated from equations
given in "Cookbook formulae for audio EQ biquad filter coefficients" by
Robert Bristow-Johnson.
|
protected double |
phaseDelay |
protected double |
phaseResponse |
protected float |
pi_over_sf |
protected float |
q |
protected UGen |
qUGen |
protected float |
samplingfreq |
static float |
SQRT2 |
protected float |
two_pi_over_sf |
protected BiquadFilter.Type |
type |
protected BiquadFilter.ValCalculator |
vc |
protected double |
w |
bufferSize, bufIn, bufOut, context, ins, outputInitializationRegime, outputPauseRegime, outs
Constructor and Description |
---|
BiquadFilter(AudioContext context,
BiquadFilter.Type itype,
float ifreq,
float iqval)
Constructor for frequency and Q as floats.
|
BiquadFilter(AudioContext context,
BiquadFilter.Type itype,
float ifreq,
UGen iqval)
Constructor for frequency as a float and Q as a UGen.
|
BiquadFilter(AudioContext context,
BiquadFilter.Type itype,
UGen ifreq,
float iqval)
Constructor for frequency as a UGen and Q as a float.
|
BiquadFilter(AudioContext context,
BiquadFilter.Type itype,
UGen ifreq,
UGen iqval)
Constructor for frequency and Q as UGens.
|
BiquadFilter(AudioContext context,
int channels)
Constructor for a multi-channel low-pass biquad filter UGen with the
specified number of channels.
|
BiquadFilter(AudioContext context,
int channels,
BiquadFilter.Type itype)
Constructor for a multi-channel biquad filter UGen of specified type with
the specified number of channels.
|
BiquadFilter(AudioContext context,
int channels,
BiquadFilter.Type itype,
DataBead params)
Constructor for a multi-channel biquad filter UGen of specified type,
with the specified number of channels, and with parameters specified by a
DataBead.
|
BiquadFilter(AudioContext context,
int channels,
DataBead params)
Constructor for a multi-channel biquad filter UGen with the specified
number of channels and parameters specified by a DataBead.
|
Modifier and Type | Method and Description |
---|---|
void |
calculateBuffer()
Called by the signal chain to update this UGen's ouput data.
|
float[] |
getCoefficients()
Gets an array of the current filter coefficients: {a0, a1, a2, b0, b1,
b2}.
|
IIRFilter.IIRFilterAnalysis |
getFilterResponse(float freq)
Gets an array filled with the filter response characteristics: {frequency
response (real), frequency response (imaginary), amplitude response,
phase response, phase delay, group delay}.
|
float |
getFreq()
Deprecated.
Use
getFrequency() . |
float |
getFrequency()
Gets the current filter frequency.
|
UGen |
getFrequencyUGen()
Gets the frequency UGen, if there is one.
|
UGen |
getFreqUGen()
Deprecated.
Use
getFrequencyUGen() . |
float |
getGain()
Gets the current gain in decibels for the filter.
|
UGen |
getGainUGen()
Gets the gain UGen, if there is one.
|
DataBead |
getParams()
Gets a DataBead with the filter's parameters (whether float or UGen),
stored in the keys "frequency", "q", "gain", and "filterType".
|
float |
getQ()
Gets the current Q-value for the filter.
|
UGen |
getQUGen()
Gets the Q UGen, if there is one.
|
DataBead |
getStaticParams()
Gets a DataBead with properties "frequency", "q", and "gain" set to their
current float values and "type" set appropriately.
|
BiquadFilter.Type |
getType()
Gets the type of the filter.
|
BiquadFilter |
loadInputMemory(float[] xm1,
float[] xm2) |
BiquadFilter |
loadInputMemory(float xm1,
float xm2) |
BiquadFilter |
loadMemory(float[] xm1,
float[] xm2,
float[] ym1,
float[] ym2) |
BiquadFilter |
loadMemory(float xm1,
float xm2,
float ym1,
float ym2) |
BiquadFilter |
loadOutputMemory(float[] ym1,
float[] ym2) |
BiquadFilter |
loadOutputMemory(float ym1,
float ym2) |
void |
messageReceived(Bead message)
Responds to an incoming message.
|
void |
reset()
Resets the filter in case it "explodes".
|
DataBeadReceiver |
sendData(DataBead db)
Equivalent to
setParams(DataBead) . |
BiquadFilter |
setCustomType(BiquadFilter.CustomCoeffCalculator cc)
Sets a user-defined coefficient calculation algorithm.
|
BiquadFilter |
setFreq(float freq)
Deprecated.
Use
setFrequency(float) . |
BiquadFilter |
setFreq(UGen freqUGen)
Deprecated.
Use
setFrequency(UGen) . |
BiquadFilter |
setFrequency(float freq)
Sets the filter frequency to a float value.
|
BiquadFilter |
setFrequency(UGen freqUGen)
Sets a UGen to determine the filter frequency.
|
BiquadFilter |
setGain(float ngain)
Sets the filter gain to a float.
|
BiquadFilter |
setGain(UGen ngain)
Sets a UGen to determine the filter Q-value.
|
BiquadFilter |
setParams(DataBead paramBead)
Sets the filter parameters with a DataBead.
|
BiquadFilter |
setQ(float nqval)
Sets the filter Q-value to a float.
|
BiquadFilter |
setQ(UGen nqval)
Sets a UGen to determine the filter Q-value.
|
BiquadFilter |
setType(BiquadFilter.Type ntype)
Sets the type of filter.
|
BiquadFilter |
setType(int ntype)
Deprecated.
Use
setType(Type) . |
analyzeFilter, calculateFilterResponse, calculateGroupDelay, getAmplitudeResponse, getGroupDelay, getPhaseDelay, getPhaseResponse
addDependent, addInput, addInput, clearDependents, clearInputConnections, containsInput, crossfadeInput, getConnectedInputs, getContext, getEnvelopes, getIns, getNumberOfConnectedUGens, getNumberOfDependents, getOutBuffer, getOuts, getTimeTakenLastUpdate, getValue, getValue, getValueDouble, getValueDouble, initializeOuts, isTimerMode, isUpdated, noInputs, pause, printInBuffers, printInputList, printOutBuffers, removeAllConnections, removeConnection, removeDependent, setOutsToPause, setTimerMode, setValue, update, zeroIns, zeroOuts
public static final BiquadFilter.Type LP
public static final BiquadFilter.Type HP
public static final BiquadFilter.Type BP_SKIRT
public static final BiquadFilter.Type BP_PEAK
public static final BiquadFilter.Type NOTCH
public static final BiquadFilter.Type AP
public static final BiquadFilter.Type PEAKING_EQ
public static final BiquadFilter.Type LOW_SHELF
public static final BiquadFilter.Type HIGH_SHELF
public static final BiquadFilter.Type BUTTERWORTH_LP
public static final BiquadFilter.Type BUTTERWORTH_HP
public static final BiquadFilter.Type BESSEL_LP
public static final BiquadFilter.Type BESSEL_HP
public static final BiquadFilter.Type CUSTOM_FILTER
setCustomType
. This
constant is not recognized by setType
.protected float a0
protected float a1
protected float a2
protected float b0
protected float b1
protected float b2
protected int channels
protected float freq
protected float q
protected float gain
protected BiquadFilter.Type type
protected float samplingfreq
protected float two_pi_over_sf
protected float pi_over_sf
public static final float SQRT2
protected double w
protected double ampResponse
protected double phaseResponse
protected double phaseDelay
protected double frReal
protected double frImag
protected float[] bo1m
protected float[] bo2m
protected float[] bi1m
protected float[] bi2m
protected float bo1
protected float bo2
protected float bi1
protected float bi2
protected boolean cuedInputMemory
protected boolean cuedOutputMemory
protected float[] cbo1m
protected float[] cbo2m
protected float[] cbi1m
protected float[] cbi2m
protected float cbo1
protected float cbo2
protected float cbi1
protected float cbi2
protected BiquadFilter.ValCalculator vc
protected UGen freqUGen
protected UGen qUGen
protected UGen gainUGen
protected boolean isFreqStatic
protected boolean isQStatic
protected boolean isGainStatic
protected boolean areAllStatic
public BiquadFilter(AudioContext context, int channels)
context
- The audio context.channels
- The number of channels.public BiquadFilter(AudioContext context, int channels, BiquadFilter.Type itype)
setType
for a
list of supported filter types.public BiquadFilter(AudioContext context, int channels, DataBead params)
context
- The audio context.channels
- The number of channels.params
- A DataBead specifying parameter values; see
setParams(DataBead)
.public BiquadFilter(AudioContext context, int channels, BiquadFilter.Type itype, DataBead params)
context
- The audio context.channels
- The number of channels.itype
- The initial filter type, e.g. LP
, HP
,
BP_SKIRT
, etc.params
- A DataBead specifying parameter values; see
setParams(DataBead)
.public BiquadFilter(AudioContext context, BiquadFilter.Type itype, float ifreq, float iqval)
setType
for a list of supported filter types.public BiquadFilter(AudioContext context, BiquadFilter.Type itype, UGen ifreq, float iqval)
setType
for a list of supported filter types.public BiquadFilter(AudioContext context, BiquadFilter.Type itype, float ifreq, UGen iqval)
setType
for a list of supported filter types.public BiquadFilter(AudioContext context, BiquadFilter.Type itype, UGen ifreq, UGen iqval)
setType
for a list of supported filter types.public void calculateBuffer()
UGen
UGen.bufIn
and putting data
into UGen.bufOut
in some way. UGen.bufIn
and UGen.bufOut
are 2D arrays of floats of the form float[numChannels][bufferSize]. The length of the buffers is given by
UGen.bufferSize
, and the number of channels of the input and output buffers are given by UGen.ins
and UGen.outs
respectively.calculateBuffer
in class UGen
public void reset()
public BiquadFilter setParams(DataBead paramBead)
Use the following properties to specify filter parameters:
paramBead
- The DataBead specifying parameters.public void messageReceived(Bead message)
Bead
messageReceived
in class Bead
message
- the messagepublic DataBeadReceiver sendData(DataBead db)
setParams(DataBead)
.sendData
in interface DataBeadReceiver
db
- The DataBead message.public DataBead getParams()
public DataBead getStaticParams()
public BiquadFilter setType(BiquadFilter.Type ntype)
setCustomType
. The
following types are recognized:
LP
- Low-pass filter.HP
- High-pass filter.BP_SKIRT
- Band-pass filter with constant skirt gain.BP_PEAK
- Band-pass filter with constant peak gain.NOTCH
- Notch (band-reject) filter.AP
- All-pass filter.PEAKING_EQ
- Peaking-EQ filter.LOW_SHELF
- Low-shelf filter.HIGH_SHELF
- High-shelf filter.BUTTERWORTH_LP
- Butterworth low-pass filter.BUTTERWORTH_HP
- Butterworth high-pass filter.BESSEL_LP
- Bessel low-pass filter.BESSEL_HP
- Bessel high-pass filter.ntype
- The type of filter.@Deprecated public BiquadFilter setType(int ntype)
setType(Type)
.setType(Type)
should be used.
ntype
- The type of filter.public BiquadFilter.Type getType()
setType(Type)
public float getFrequency()
public BiquadFilter setFrequency(float freq)
freq
- The frequency.public BiquadFilter setFrequency(UGen freqUGen)
freqUGen
- The frequency UGen.public UGen getFrequencyUGen()
@Deprecated public float getFreq()
getFrequency()
.@Deprecated public BiquadFilter setFreq(float freq)
setFrequency(float)
.freq
- The frequency.@Deprecated public BiquadFilter setFreq(UGen freqUGen)
setFrequency(UGen)
.freqUGen
- The frequency UGen.@Deprecated public UGen getFreqUGen()
getFrequencyUGen()
.public BiquadFilter setQ(float nqval)
nqval
- The Q-value.public BiquadFilter setQ(UGen nqval)
nqval
- The Q-value UGen.public float getQ()
public UGen getQUGen()
public BiquadFilter setGain(float ngain)
PEAKING_EQ
, LOW_SHELF
, and
HIGH_SHELF
types.)ngain
- The gain in decibels (0 means no gain).public BiquadFilter setGain(UGen ngain)
PEAKING_EQ
, LOW_SHELF
, and HIGH_SHELF
types.)ngain
- The gain UGen, specifying the gain in decibels.public float getGain()
PEAKING_EQ
, LOW_SHELF
, and HIGH_SHELF
types.)public UGen getGainUGen()
public BiquadFilter loadMemory(float xm1, float xm2, float ym1, float ym2)
public BiquadFilter loadMemory(float[] xm1, float[] xm2, float[] ym1, float[] ym2)
public BiquadFilter loadInputMemory(float xm1, float xm2)
public BiquadFilter loadInputMemory(float[] xm1, float[] xm2)
public BiquadFilter loadOutputMemory(float ym1, float ym2)
public BiquadFilter loadOutputMemory(float[] ym1, float[] ym2)
public float[] getCoefficients()
public IIRFilter.IIRFilterAnalysis getFilterResponse(float freq)
getFilterResponse
in class IIRFilter
freq
- The frequency to test.public BiquadFilter setCustomType(BiquadFilter.CustomCoeffCalculator cc)
BiquadFilter.CustomCoeffCalculator
.cc
- The custom coefficient calculator.