|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.beadsproject.beads.core.Bead
net.beadsproject.beads.core.UGen
net.beadsproject.beads.ugens.IIRFilter
net.beadsproject.beads.ugens.BiquadFilter
public class BiquadFilter
A simple implementation of a multi-channel biquad filter. It calculates coefficients based on three parameters (frequency, Q, and gain - the latter only relevant for EQ and shelving filters), each of which may be specified by a static float or by the output of a UGen.
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)
.
Nested Class Summary | |
---|---|
class |
BiquadFilter.CustomCoeffCalculator
CustomCoeffCalculator provides a mechanism to define custom filter coefficients for a biquad filter based on frequency and Q. |
protected class |
BiquadFilter.ValCalculator
|
Nested classes/interfaces inherited from class net.beadsproject.beads.ugens.IIRFilter |
---|
IIRFilter.IIRFilterAnalysis |
Nested classes/interfaces inherited from class net.beadsproject.beads.core.UGen |
---|
UGen.OutputInitializationRegime, UGen.OutputPauseRegime |
Field Summary | |
---|---|
protected float |
a0
|
protected float |
a1
|
protected float |
a2
|
protected double |
ampResponse
|
static int |
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 int |
BESSEL_HP
Indicates a Bessel high-pass filter; only frequency is relevant. |
static int |
BESSEL_LP
Indicates a Bessel low-pass filter; only frequency is relevant. |
static int |
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 int |
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 int |
BUTTERWORTH_HP
Indicates a Butterworth high-pass filter; only the frequency parameter is relevant. |
static int |
BUTTERWORTH_LP
Indicates a Butterworth low-pass filter; only the frequency parameter is relevant. |
static int |
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 int |
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 int |
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 int |
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 int |
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 int |
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 int |
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.ValCalculator |
vc
|
protected double |
w
|
Fields inherited from class net.beadsproject.beads.core.UGen |
---|
bufferSize, bufIn, bufOut, context, ins, outputInitializationRegime, outputPauseRegime, outs |
Constructor Summary | |
---|---|
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,
DataBead params)
Constructor for a multi-channel biquad filter UGen with the specified number of channels and parameters specified by a DataBead. |
|
BiquadFilter(AudioContext context,
int itype,
float ifreq,
float iqval)
Constructor for frequency and Q as floats. |
|
BiquadFilter(AudioContext context,
int itype,
float ifreq,
UGen iqval)
Constructor for frequency as a float and Q as a UGen. |
|
BiquadFilter(AudioContext context,
int channels,
int itype)
Constructor for a multi-channel biquad filter UGen of specified type with the specified number of channels. |
|
BiquadFilter(AudioContext context,
int channels,
int 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 itype,
UGen ifreq,
float iqval)
Constructor for frequency as a UGen and Q as a float. |
|
BiquadFilter(AudioContext context,
int itype,
UGen ifreq,
UGen iqval)
Constructor for frequency and Q as UGens. |
Method Summary | |
---|---|
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. |
int |
getType()
Gets the type of the filter. |
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(int ntype)
Sets the type of filter. |
Methods inherited from class net.beadsproject.beads.ugens.IIRFilter |
---|
analyzeFilter, calculateFilterResponse, calculateGroupDelay, getAmplitudeResponse, getGroupDelay, getPhaseDelay, getPhaseResponse |
Methods inherited from class net.beadsproject.beads.core.UGen |
---|
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 |
Methods inherited from class net.beadsproject.beads.core.Bead |
---|
getKillListener, getName, isDeleted, isPaused, kill, message, setKillListener, setName, start, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int LP
public static final int HP
public static final int BP_SKIRT
public static final int BP_PEAK
public static final int NOTCH
public static final int AP
public static final int PEAKING_EQ
public static final int LOW_SHELF
public static final int HIGH_SHELF
public static final int BUTTERWORTH_LP
public static final int BUTTERWORTH_HP
public static final int BESSEL_LP
public static final int BESSEL_HP
public static final int 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 float freq
protected float q
protected float gain
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 BiquadFilter.ValCalculator vc
protected UGen freqUGen
protected UGen qUGen
protected UGen gainUGen
protected boolean isFreqStatic
protected boolean isQStatic
protected boolean isGainStatic
protected boolean areAllStatic
Constructor Detail |
---|
public BiquadFilter(AudioContext context, int channels)
context
- The audio context.channels
- The number of channels.public BiquadFilter(AudioContext context, int channels, int itype)
setType
for a
list of supported filter types.
context
- The AudioContext.channels
- The number of channels.itype
- The initial filter type, e.g. LP
, HP
,
BP_SKIRT
, etc.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, int 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, int itype, float ifreq, float iqval)
setType
for a list of supported filter types.
context
- The AudioContext.itype
- The initial filter type, e.g. LP
, HP
,
BP_SKIRT
, etc.ifreq
- The initial frequency.iqval
- The initial Q-value.public BiquadFilter(AudioContext context, int itype, UGen ifreq, float iqval)
setType
for a list of supported filter types.
context
- The AudioContext.itype
- The initial filter type, LP
, HP
,
BP_SKIRT
, etc.ifreq
- The frequency UGen.iqval
- The initial Q-value.public BiquadFilter(AudioContext context, int itype, float ifreq, UGen iqval)
setType
for a list of supported filter types.
context
- The AudioContext.itype
- The initial filter type, e.g. LP
, HP
,
BP_SKIRT
, etc.ifreq
- The initial frequency.iqval
- The Q-value UGen.public BiquadFilter(AudioContext context, int itype, UGen ifreq, UGen iqval)
setType
for a list of supported filter types.
context
- The AudioContext.itype
- The initial filter type, e.g. LP
, HP
,
BP_SKIRT
, etc.ifreq
- The frequency UGen.iqval
- The Q-value UGen.Method Detail |
---|
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(int 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.
ntype
- The type of filter.public int getType()
setType(int)
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 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.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |