CSL  6.0
csl::Biquad Class Reference

General-purpose Biquad IIR (2nd order recursive) filter. This is simplified and optimized, but doesn't support dynamic or scalable controls. It uses inst vars rather than arrays for the coefficients. NB: peak gain (dB) is used only for the peak and shelf types) More...

#include <Filters.h>

+ Inheritance diagram for csl::Biquad:

Public Member Functions

 Biquad ()
 
 Biquad (FilterType type, float freq, float Q, float dB=0.0f)
 
 Biquad (UnitGenerator &in, FilterType type, float freq, float Q, float dB=0.0f)
 
void nextBuffer (Buffer &outputBuffer, unsigned outBufNum) throw (CException)
 really compute the next buffer given an offset base channel; this is called by nextBuffer, possibly multiple times More...
 
void setQ (float q)
 
void setFrq (float f)
 
void incrFrq (float f)
 
void setBoost (float d)
 
void incrBoost (float d)
 
void clear (void)
 clears the input/output buffers More...
 
void setupCoeffs (SampleBuffer bCoeffs, SampleBuffer aCoeffs, unsigned num_b, unsigned num_a)
 to be overloaded by subclasses supply the coefficients directly More...
 
virtual void nextBuffer (Buffer &outputBuffer) throw (CException)
 get a buffer of Frames – this is the core CSL "pull" function; the given buffer can be written into, and a changed() message is sent. More...
 
void dump ()
 log information about myself More...
 
virtual bool isActive ()
 am I active? More...
 
void setInput (UnitGenerator &inp)
 set the receiver's input generator More...
 
void setInline ()
 set the Effect to be inline More...
 
virtual void trigger ()
 trigger passed on here More...
 
unsigned frameRate ()
 
void setFrameRate (unsigned rate)
 get/set the receiver's frame rate More...
 
virtual unsigned numChannels ()
 
void setNumChannels (unsigned ch)
 get/set the receiver's number of outputs More...
 
BufferCopyPolicy copyPolicy ()
 
void setCopyPolicy (BufferCopyPolicy ch)
 get/set the receiver's buffer copy policy More...
 
virtual bool isFixed ()
 query whether I'm fixed (StaticVariable overrides this) More...
 
void addOutput (UnitGenerator *ugen)
 add to or return the UGen vector of outputs More...
 
void removeOutput (UnitGenerator *ugen)
 
UGenVector outputs ()
 
virtual unsigned numOutputs ()
 
bool checkFanOut (Buffer &outputBuffer) throw (CException)
 check for fan-out and copy previous buffer; return true if fanning out More...
 
void handleFanOut (Buffer &outputBuffer) throw (CException)
 
virtual void setValue (sample theValue)
 set/get the value (not allowed in the abstract, useful for static values) More...
 
virtual sample value ()
 
void attachObserver (Observer *)
 (possibly notify obersvers on my death) More...
 
void detachObserver (Observer *)
 
void changed (void *argument)
 this is what I send to myself to notify my observers; It's not overridden in general. It results in the observers receiving update() calls < override evaluate to filter updates to the observer map More...
 
virtual int evaluate (void *argument)
 
PortgetPort (CSL_MAP_KEY name)
 
void setScale (UnitGenerator &scale)
 set the receiver's scale member to a UGen or a float More...
 
void setScale (float scale)
 
void setOffset (UnitGenerator &offset)
 set the receiver's offset member to a UGen or a float More...
 
void setOffset (float offset)
 
void isScaled ()
 answer whether scale = 1 & offset = 0 More...
 
void setFrequency (UnitGenerator &frequency)
 set the receiver's frequency to a UGen or a float More...
 
void setFrequency (float frequency)
 
float getFrequency ()
 
void setAmount (UnitGenerator &amount)
 set the receiver's amount to a UGen or a float More...
 
void setAmount (float amount)
 

Public Attributes

bool isInline
 whether to use input or buffer as source More...
 

Protected Member Functions

void setupCoeffs ()
 
void init (unsigned a, unsigned b)
 shared initialization function More...
 
void pullInput (Buffer &outputBuffer) throw (CException)
 
void pullInput (unsigned numFrames) throw (CException)
 trigger passed on here More...
 
void pullInput (Port *thePort, unsigned numFrames) throw (CException)
 method to read the control values (in case they're dynamic). this sends nextBuffer() to the input. More...
 
void pullInput (Port *thePort, Buffer &theBuffer) throw (CException)
 
virtual void trigger ()
 trigger passed on here get the input port More...
 
PortinPort ()
 
void zeroBuffer (Buffer &outputBuffer, unsigned outBufNum)
 utility method to zero out an outputBuffer More...
 
void addInput (CSL_MAP_KEY name, UnitGenerator &ugen)
 Plug in a unit generator to the named input slot. More...
 
void addInput (CSL_MAP_KEY name, float value)
 Plug in a float to the named input slot. More...
 

Protected Attributes

int mFilterType
 flag as to what kind of filter I am More...
 
float Fc
 
float dB
 
float Q
 ctr frq (Hz), peak (dB), Q(uality) factor More...
 
float a0
 
float a1
 
float a2
 
float b1
 
float b2
 coefficients More...
 
float z1
 
float z2
 past outputs More...
 
float mBCoeff [FILTER_MAX_COEFFICIENTS]
 array of numerator coeffs More...
 
float mACoeff [FILTER_MAX_COEFFICIENTS]
 array of denominator coeffs More...
 
unsigned mBNum
 number of coeffs in b More...
 
unsigned mANum
 number of coeffs in a More...
 
BuffermPrevInputs
 arrays of past input and output samples More...
 
BuffermPrevOutputs
 
float mFrame
 to keep hold of sample rate for calculating coeffs More...
 
SampleBuffer mInputPtr
 A pointer to my input's data. method to read the input value. More...
 
unsigned mFrameRate
 trigger ignored here More...
 
unsigned mNumChannels
 my "expected" number of output channels More...
 
BufferCopyPolicy mCopyPolicy
 the policy I use if asked for more or fewer channels More...
 
UGenVector mOutputs
 the vector of my output UGens More...
 
unsigned mNumOutputs
 the number of outputs More...
 
BuffermOutputCache
 my past output ring buffer (only used in case of fan-out) More...
 
unsigned mSequence
 the highest-seen buffer seq number More...
 
PortMap mInputs
 the map of my inputs or controls (used by the mix-in classes) More...
 

Detailed Description

General-purpose Biquad IIR (2nd order recursive) filter. This is simplified and optimized, but doesn't support dynamic or scalable controls. It uses inst vars rather than arrays for the coefficients. NB: peak gain (dB) is used only for the peak and shelf types)

Definition at line 161 of file Filters.h.

Constructor & Destructor Documentation

Biquad::Biquad ( )

Definition at line 295 of file Filters.cpp.

Biquad::Biquad ( FilterType  type,
float  freq,
float  Q,
float  dB = 0.0f 
)

Definition at line 297 of file Filters.cpp.

References csl::Filter::clear(), dB, Fc, csl::CGestalt::frameRateF(), mFilterType, Q, and setupCoeffs().

Biquad::Biquad ( UnitGenerator in,
FilterType  type,
float  freq,
float  Q,
float  dB = 0.0f 
)

Definition at line 308 of file Filters.cpp.

References csl::Filter::clear(), dB, Fc, csl::CGestalt::frameRateF(), mFilterType, Q, and setupCoeffs().

Member Function Documentation

void Biquad::nextBuffer ( Buffer outputBuffer,
unsigned  outBufNum 
)
throw (CException
)
virtual

really compute the next buffer given an offset base channel; this is called by nextBuffer, possibly multiple times

Reimplemented from csl::Filter.

Definition at line 521 of file Filters.cpp.

References csl::Effect::pullInput().

void Biquad::setQ ( float  q)

Definition at line 496 of file Filters.cpp.

References Q, and setupCoeffs().

void Biquad::setFrq ( float  f)

Definition at line 501 of file Filters.cpp.

References CSL_FILTER_FREQUENCY, csl::Controllable::mInputs, and setupCoeffs().

void Biquad::incrFrq ( float  f)

Definition at line 506 of file Filters.cpp.

References CSL_FILTER_FREQUENCY, csl::Controllable::mInputs, and setupCoeffs().

void Biquad::setBoost ( float  d)

Definition at line 511 of file Filters.cpp.

References CSL_FILTER_AMOUNT, csl::Controllable::mInputs, and setupCoeffs().

void Biquad::incrBoost ( float  d)

Definition at line 516 of file Filters.cpp.

References CSL_FILTER_AMOUNT, csl::Controllable::mInputs, and setupCoeffs().

void Biquad::setupCoeffs ( )
protectedvirtual

Reimplemented from csl::Filter.

Definition at line 402 of file Filters.cpp.

References a0, a1, a2, b1, b2, BW_BAND_PASS, BW_BAND_STOP, BW_HIGH_PASS, BW_HIGH_SHELF, BW_LOW_PASS, BW_LOW_SHELF, Fc, mFilterType, PEAKING, Q, z1, and z2.

Referenced by Biquad(), incrBoost(), incrFrq(), setBoost(), setFrq(), and setQ().

void Filter::clear ( void  )
inherited
void Filter::setupCoeffs ( SampleBuffer  bCoeffs,
SampleBuffer  aCoeffs,
unsigned  num_b,
unsigned  num_a 
)
inherited

to be overloaded by subclasses supply the coefficients directly

this version is to be inherited by the subclasses. provides a way to directly supply the filter info

Definition at line 156 of file Filters.cpp.

References csl::Filter::mACoeff, and csl::Filter::mBCoeff.

void Filter::dump ( void  )
virtualinherited
void Filter::init ( unsigned  a,
unsigned  b 
)
protectedinherited
bool Effect::isActive ( )
virtualinherited

am I active?

Reimplemented from csl::UnitGenerator.

Reimplemented in csl::Joiner, and csl::Stereoverb.

Definition at line 1105 of file CSL_Core.cpp.

References CSL_INPUT, csl::Port::isActive(), and csl::Controllable::mInputs.

Referenced by csl::Stereoverb::isActive().

void Effect::setInput ( UnitGenerator inp)
inherited

set the receiver's input generator

Definition at line 1112 of file CSL_Core.cpp.

References csl::Controllable::addInput(), CSL_INPUT, csl::Effect::isInline, and csl::logMsg().

void csl::Effect::setInline ( )
inlineinherited

set the Effect to be inline

Definition at line 476 of file CSL_Core.h.

void Effect::pullInput ( unsigned  numFrames)
throw (CException
)
protectedinherited

trigger passed on here

Definition at line 1137 of file CSL_Core.cpp.

References csl::Buffer::buffer(), CSL_INPUT, csl::logMsg(), csl::Port::mBuffer, and csl::Controllable::pullInput().

void Controllable::pullInput ( Port thePort,
unsigned  numFrames 
)
throw (CException
)
protectedinherited

method to read the control values (in case they're dynamic). this sends nextBuffer() to the input.

Definition at line 847 of file CSL_Core.cpp.

References csl::kSamples, csl::logMsg(), csl::Buffer::mIsPopulated, csl::Buffer::mNumFrames, csl::Buffer::mType, csl::UnitGenerator::nextBuffer(), and csl::Buffer::zeroBuffers().

Referenced by csl::Panner::nextBuffer(), csl::NtoMPanner::nextBuffer(), and csl::Effect::pullInput().

void Controllable::pullInput ( Port thePort,
Buffer theBuffer 
)
throw (CException
)
protectedinherited

Definition at line 879 of file CSL_Core.cpp.

References csl::UnitGenerator::nextBuffer().

void Effect::trigger ( void  )
protectedvirtualinherited

trigger passed on here get the input port

Reimplemented from csl::UnitGenerator.

Reimplemented in csl::Joiner.

Definition at line 1148 of file CSL_Core.cpp.

References CSL_INPUT, and csl::Controllable::mInputs.

void Scalable::trigger ( void  )
virtualinherited

trigger passed on here

Reimplemented in csl::RandEnvelope, csl::Abst_SoundFile, csl::Envelope, and csl::KarplusString.

Definition at line 1069 of file CSL_Core.cpp.

References CSL_OFFSET, CSL_SCALE, and csl::Controllable::mInputs.

Port* csl::Effect::inPort ( )
inlineprotectedinherited

Definition at line 485 of file CSL_Core.h.

References CSL_INPUT.

Referenced by csl::BinaryOp::dump(), and csl::BinaryOp::inputIsFixed().

unsigned csl::UnitGenerator::frameRate ( )
inlineinherited
void csl::UnitGenerator::setFrameRate ( unsigned  rate)
inlineinherited

get/set the receiver's frame rate

Definition at line 250 of file CSL_Core.h.

References csl::UnitGenerator::mFrameRate.

void csl::UnitGenerator::setNumChannels ( unsigned  ch)
inlineinherited

get/set the receiver's number of outputs

Definition at line 253 of file CSL_Core.h.

References csl::UnitGenerator::mNumChannels.

Referenced by csl::BinauralPanner::BinauralPanner(), csl::Spatializer::Spatializer(), csl::VBAP::speakerLayoutChanged(), and csl::VBAP::VBAP().

BufferCopyPolicy csl::UnitGenerator::copyPolicy ( )
inlineinherited

Definition at line 255 of file CSL_Core.h.

References csl::UnitGenerator::mCopyPolicy.

void csl::UnitGenerator::setCopyPolicy ( BufferCopyPolicy  ch)
inlineinherited
virtual bool csl::UnitGenerator::isFixed ( )
inlinevirtualinherited

query whether I'm fixed (StaticVariable overrides this)

Reimplemented in csl::StaticVariable, and csl::BinaryOp.

Definition at line 271 of file CSL_Core.h.

UGenVector csl::UnitGenerator::outputs ( )
inlineinherited

Definition at line 277 of file CSL_Core.h.

References csl::UnitGenerator::mOutputs.

virtual unsigned csl::UnitGenerator::numOutputs ( )
inlinevirtualinherited

Definition at line 278 of file CSL_Core.h.

References csl::UnitGenerator::mNumOutputs.

bool UnitGenerator::checkFanOut ( Buffer outputBuffer)
throw (CException
)
inherited

check for fan-out and copy previous buffer; return true if fanning out

Definition at line 699 of file CSL_Core.cpp.

void UnitGenerator::handleFanOut ( Buffer outputBuffer)
throw (CException
)
inherited

Definition at line 713 of file CSL_Core.cpp.

References csl_max.

virtual void csl::UnitGenerator::setValue ( sample  theValue)
inlinevirtualinherited

set/get the value (not allowed in the abstract, useful for static values)

Reimplemented in csl::DynamicVariable, and csl::StaticVariable.

Definition at line 284 of file CSL_Core.h.

virtual sample csl::UnitGenerator::value ( )
inlinevirtualinherited

Reimplemented in csl::StaticVariable.

Definition at line 285 of file CSL_Core.h.

void UnitGenerator::zeroBuffer ( Buffer outputBuffer,
unsigned  outBufNum 
)
protectedinherited

utility method to zero out an outputBuffer

Definition at line 663 of file CSL_Core.cpp.

References csl::Buffer::buffer(), and csl::Buffer::mMonoBufferByteSize.

void Model::attachObserver ( Observer o)
inherited

(possibly notify obersvers on my death)

register/remove observers

Definition at line 502 of file CGestalt.cpp.

References csl::logMsg(), csl::Observer::mKey, and csl::Observer::mPeriod.

Referenced by CSLMIDIComponent::CSLMIDIComponent(), and csl::SpatialPanner::setSpeakerLayout().

void Model::detachObserver ( Observer o)
inherited
void Model::changed ( void *  argument)
inherited

this is what I send to myself to notify my observers; It's not overridden in general. It results in the observers receiving update() calls < override evaluate to filter updates to the observer map

Definition at line 540 of file CGestalt.cpp.

References csl::logMsg().

Referenced by csl::SpeakerLayout::addSpeaker(), csl::MIDIIn::handleIncomingMidiMessage(), and csl::SpeakerLayout::setDefaultSpeakerLayout().

virtual int csl::Model::evaluate ( void *  argument)
inlinevirtualinherited

Reimplemented in csl::MIDIIn.

Definition at line 270 of file CGestalt.h.

Port * Controllable::getPort ( CSL_MAP_KEY  name)
inherited
void Controllable::addInput ( CSL_MAP_KEY  name,
float  value 
)
protectedinherited

Plug in a float to the named input slot.

Definition at line 906 of file CSL_Core.cpp.

References csl::logMsg(), csl::Controllable::mInputs, and csl::Port::mValue.

void Scalable::setScale ( float  scale)
inherited

Definition at line 1046 of file CSL_Core.cpp.

References csl::Controllable::addInput(), CSL_SCALE, and csl::logMsg().

void Scalable::setOffset ( UnitGenerator offset)
inherited

set the receiver's offset member to a UGen or a float

Definition at line 1053 of file CSL_Core.cpp.

References csl::Controllable::addInput(), CSL_OFFSET, and csl::logMsg().

void Scalable::setOffset ( float  offset)
inherited

Definition at line 1060 of file CSL_Core.cpp.

References csl::Controllable::addInput(), CSL_OFFSET, and csl::logMsg().

void csl::Scalable::isScaled ( )
inherited

answer whether scale = 1 & offset = 0

void FrequencyAmount::setFrequency ( UnitGenerator frequency)
inherited
void FrequencyAmount::setFrequency ( float  frequency)
inherited

Definition at line 34 of file Filters.cpp.

References csl::Controllable::addInput(), CSL_FILTER_FREQUENCY, and csl::logMsg().

float FrequencyAmount::getFrequency ( )
inherited

Definition at line 41 of file Filters.cpp.

References CSL_FILTER_FREQUENCY, and csl::Controllable::getPort().

void FrequencyAmount::setAmount ( UnitGenerator amount)
inherited

set the receiver's amount to a UGen or a float

Definition at line 45 of file Filters.cpp.

References csl::Controllable::addInput(), CSL_FILTER_AMOUNT, and csl::logMsg().

Referenced by csl::Allpass::Allpass(), csl::Butter::Butter(), csl::Formant::Formant(), csl::Moog::Moog(), and csl::Notch::Notch().

void FrequencyAmount::setAmount ( float  amount)
inherited

Definition at line 52 of file Filters.cpp.

References csl::Controllable::addInput(), CSL_FILTER_AMOUNT, and csl::logMsg().

Member Data Documentation

int csl::Biquad::mFilterType
protected

flag as to what kind of filter I am

Definition at line 176 of file Filters.h.

Referenced by Biquad(), and setupCoeffs().

float csl::Biquad::Fc
protected

Definition at line 177 of file Filters.h.

Referenced by Biquad(), and setupCoeffs().

float csl::Biquad::dB
protected

Definition at line 177 of file Filters.h.

Referenced by Biquad().

float csl::Biquad::Q
protected

ctr frq (Hz), peak (dB), Q(uality) factor

Definition at line 177 of file Filters.h.

Referenced by Biquad(), setQ(), and setupCoeffs().

float csl::Biquad::a0
protected

Definition at line 178 of file Filters.h.

Referenced by setupCoeffs().

float csl::Biquad::a1
protected

Definition at line 178 of file Filters.h.

Referenced by setupCoeffs().

float csl::Biquad::a2
protected

Definition at line 178 of file Filters.h.

Referenced by setupCoeffs().

float csl::Biquad::b1
protected

Definition at line 178 of file Filters.h.

Referenced by setupCoeffs().

float csl::Biquad::b2
protected

coefficients

Definition at line 178 of file Filters.h.

Referenced by setupCoeffs().

float csl::Biquad::z1
protected

Definition at line 179 of file Filters.h.

Referenced by setupCoeffs().

float csl::Biquad::z2
protected

past outputs

Definition at line 179 of file Filters.h.

Referenced by setupCoeffs().

float csl::Filter::mBCoeff[FILTER_MAX_COEFFICIENTS]
protectedinherited

array of numerator coeffs

Definition at line 120 of file Filters.h.

Referenced by csl::Filter::dump(), csl::Filter::init(), csl::Filter::setupCoeffs(), and csl::Butter::setupCoeffs().

float csl::Filter::mACoeff[FILTER_MAX_COEFFICIENTS]
protectedinherited

array of denominator coeffs

Definition at line 121 of file Filters.h.

Referenced by csl::Filter::dump(), csl::Filter::init(), csl::Filter::setupCoeffs(), and csl::Butter::setupCoeffs().

unsigned csl::Filter::mBNum
protectedinherited

number of coeffs in b

Definition at line 122 of file Filters.h.

Referenced by csl::Filter::dump(), and csl::Filter::init().

unsigned csl::Filter::mANum
protectedinherited

number of coeffs in a

Definition at line 123 of file Filters.h.

Referenced by csl::Filter::dump(), and csl::Filter::init().

Buffer* csl::Filter::mPrevInputs
protectedinherited

arrays of past input and output samples

Definition at line 124 of file Filters.h.

Referenced by csl::Filter::clear(), csl::Filter::init(), and csl::Filter::~Filter().

Buffer* csl::Filter::mPrevOutputs
protectedinherited

Definition at line 125 of file Filters.h.

Referenced by csl::Filter::clear(), csl::Filter::init(), and csl::Filter::~Filter().

float csl::Filter::mFrame
protectedinherited

to keep hold of sample rate for calculating coeffs

Definition at line 126 of file Filters.h.

bool csl::Effect::isInline
inherited

whether to use input or buffer as source

Definition at line 475 of file CSL_Core.h.

Referenced by csl::Effect::Effect(), and csl::Effect::setInput().

SampleBuffer csl::Effect::mInputPtr
protectedinherited

A pointer to my input's data. method to read the input value.

Definition at line 479 of file CSL_Core.h.

BufferCopyPolicy csl::UnitGenerator::mCopyPolicy
protectedinherited

the policy I use if asked for more or fewer channels

Definition at line 293 of file CSL_Core.h.

Referenced by csl::UnitGenerator::copyPolicy(), and csl::UnitGenerator::setCopyPolicy().

UGenVector csl::UnitGenerator::mOutputs
protectedinherited
unsigned csl::UnitGenerator::mNumOutputs
protectedinherited

the number of outputs

Definition at line 295 of file CSL_Core.h.

Referenced by csl::UnitGenerator::addOutput(), csl::UnitGenerator::numOutputs(), and csl::UnitGenerator::removeOutput().

Buffer* csl::UnitGenerator::mOutputCache
protectedinherited

my past output ring buffer (only used in case of fan-out)

Definition at line 296 of file CSL_Core.h.

Referenced by csl::UnitGenerator::addOutput().

unsigned csl::UnitGenerator::mSequence
protectedinherited

the highest-seen buffer seq number

Definition at line 297 of file CSL_Core.h.


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