CSL  6.0
csl::UnitGenerator Class Reference

forward declaration More...

#include <CSL_Core.h>

+ Inheritance diagram for csl::UnitGenerator:

Public Member Functions

 UnitGenerator (unsigned rate=CGestalt::frameRate(), unsigned chans=1)
 Constructors (UGens are mono by default) defaults to mono and maxBlockSize if not specified. More...
 
virtual ~UnitGenerator ()
 Destructor. 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 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...
 
virtual 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...
 
virtual bool isFixed ()
 query whether I'm fixed (StaticVariable overrides this) More...
 
virtual bool isActive ()
 query whether I'm currently active (Envelopes can go inactive) 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 ()
 
virtual void dump ()
 pretty-print the receiver More...
 
virtual void trigger ()
 
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)
 

Protected Member Functions

void zeroBuffer (Buffer &outputBuffer, unsigned outBufNum)
 utility method to zero out an outputBuffer More...
 

Protected Attributes

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...
 

Detailed Description

forward declaration

UnitGenerator – the core of CSL; all unit generators inherit from this class.

These have members for their sample rate and number of channels, and know their outputs. The main operation is the nextBuffer() method, which is overridden in many of the subclasses.

If more than 1 output is used, these can handle fan-out automatically, either synchronous (as in loops in a graph) or async (as in separate call-back threads). The mOutputCache RingBuffer may hold some large number of past samples, and can use nextBuffer() to do n-way fan-out either synchronously or with differing buffer sizes or callback rates.

UnitGenerator inherits from Model, meaning that it has to send this->changed((void *) dataBuffer) from within its nextBuffer method so that dependent objects (like signal views) can get notification when it computes samples. This mechanism could also be used for signal flow.

Definition at line 241 of file CSL_Core.h.

Constructor & Destructor Documentation

UnitGenerator::UnitGenerator ( unsigned  rate = CGestalt::frameRate(),
unsigned  chans = 1 
)

Constructors (UGens are mono by default) defaults to mono and maxBlockSize if not specified.

Destructor.

Definition at line 647 of file CSL_Core.cpp.

UnitGenerator::~UnitGenerator ( )
virtual

Destructor.

Definition at line 659 of file CSL_Core.cpp.

Member Function Documentation

unsigned csl::UnitGenerator::frameRate ( )
inline

Definition at line 249 of file CSL_Core.h.

References mFrameRate.

Referenced by csl::CASoundFile::dump(), csl::Abst_SoundFile::dump(), and csl::SoundCue::dump().

void csl::UnitGenerator::setFrameRate ( unsigned  rate)
inline

get/set the receiver's frame rate

Definition at line 250 of file CSL_Core.h.

References mFrameRate.

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

get/set the receiver's number of outputs

Definition at line 253 of file CSL_Core.h.

References mNumChannels.

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

BufferCopyPolicy csl::UnitGenerator::copyPolicy ( )
inline

Definition at line 255 of file CSL_Core.h.

References mCopyPolicy.

void csl::UnitGenerator::setCopyPolicy ( BufferCopyPolicy  ch)
inline
virtual bool csl::UnitGenerator::isFixed ( )
inlinevirtual

query whether I'm fixed (StaticVariable overrides this)

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

Definition at line 271 of file CSL_Core.h.

virtual bool csl::UnitGenerator::isActive ( )
inlinevirtual
UGenVector csl::UnitGenerator::outputs ( )
inline

Definition at line 277 of file CSL_Core.h.

References mOutputs.

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

Definition at line 278 of file CSL_Core.h.

References mNumOutputs.

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

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
)

Definition at line 713 of file CSL_Core.cpp.

References csl_max.

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

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 ( )
inlinevirtual

Reimplemented in csl::StaticVariable.

Definition at line 285 of file CSL_Core.h.

virtual void csl::UnitGenerator::trigger ( void  )
inlinevirtual
void UnitGenerator::zeroBuffer ( Buffer outputBuffer,
unsigned  outBufNum 
)
protected

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.

Member Data Documentation

BufferCopyPolicy csl::UnitGenerator::mCopyPolicy
protected

the policy I use if asked for more or fewer channels

Definition at line 293 of file CSL_Core.h.

Referenced by copyPolicy(), and setCopyPolicy().

UGenVector csl::UnitGenerator::mOutputs
protected

the vector of my output UGens

Definition at line 294 of file CSL_Core.h.

Referenced by addOutput(), dump(), outputs(), and removeOutput().

unsigned csl::UnitGenerator::mNumOutputs
protected

the number of outputs

Definition at line 295 of file CSL_Core.h.

Referenced by addOutput(), numOutputs(), and removeOutput().

Buffer* csl::UnitGenerator::mOutputCache
protected

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

Definition at line 296 of file CSL_Core.h.

Referenced by addOutput().

unsigned csl::UnitGenerator::mSequence
protected

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: