CSL  5.2
csl::UnitGenerator Class Reference

forward declaration More...

#include <CSL_Core.h>

+ Inheritance diagram for csl::UnitGenerator:

List of all members.

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.
virtual ~UnitGenerator ()
 Destructor.
unsigned frameRate ()
void setFrameRate (unsigned rate)
 get/set the receiver's frame rate
virtual unsigned numChannels ()
void setNumChannels (unsigned ch)
 get/set the receiver's number of outputs
BufferCopyPolicy copyPolicy ()
void setCopyPolicy (BufferCopyPolicy ch)
 get/set the receiver's buffer copy policy
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.
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
virtual bool isFixed ()
 query whether I'm fixed (StaticVariable overrides this)
virtual bool isActive ()
 query whether I'm currently active (Envelopes can go inactive)
void addOutput (UnitGenerator *ugen)
 add to or return the UGen vector of outputs
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
void handleFanOut (Buffer &outputBuffer) throw (CException)
virtual void setValue (sample theValue)
 set/get the value (not allowed in the abstract, useful for static values)
virtual sample value ()
virtual void dump ()
 pretty-print the receiver
virtual void trigger ()
void attachObserver (Observer *)
 (possibly notify obersvers on my death)
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
virtual int evaluate (void *argument)

Protected Member Functions

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

Protected Attributes

unsigned mFrameRate
 trigger ignored here
unsigned mNumChannels
 my "expected" number of output channels
BufferCopyPolicy mCopyPolicy
 the policy I use if asked for more or fewer channels
UGenVector mOutputs
 the vector of my output UGens
unsigned mNumOutputs
 the number of outputs
BuffermOutputCache
 my past output ring buffer (only used in case of fan-out)
unsigned mSequence
 the highest-seen buffer seq number

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 217 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 497 of file CSL_Core.cpp.

UnitGenerator::~UnitGenerator ( )
virtual

Destructor.

Definition at line 509 of file CSL_Core.cpp.


Member Function Documentation

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

get/set the receiver's frame rate

Definition at line 226 of file CSL_Core.h.

References mFrameRate.

Referenced by m3_header().

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

get/set the receiver's number of outputs

Definition at line 229 of file CSL_Core.h.

References mNumChannels.

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

BufferCopyPolicy csl::UnitGenerator::copyPolicy ( )
inline

Definition at line 231 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 247 of file CSL_Core.h.

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

Definition at line 253 of file CSL_Core.h.

References mOutputs.

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

Definition at line 254 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 549 of file CSL_Core.cpp.

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

Definition at line 563 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 260 of file CSL_Core.h.

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

Reimplemented in csl::StaticVariable.

Definition at line 261 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 513 of file CSL_Core.cpp.

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

void Model::attachObserver ( Observer o)
inherited

(possibly notify obersvers on my death)

register/remove observers

Definition at line 491 of file CGestalt.cpp.

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

Referenced by 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 529 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 259 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 269 of file CSL_Core.h.

Referenced by copyPolicy(), and setCopyPolicy().

UGenVector csl::UnitGenerator::mOutputs
protected

the vector of my output UGens

Definition at line 270 of file CSL_Core.h.

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

unsigned csl::UnitGenerator::mNumOutputs
protected

the number of outputs

Definition at line 271 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 272 of file CSL_Core.h.

Referenced by addOutput().

unsigned csl::UnitGenerator::mSequence
protected

the highest-seen buffer seq number

Definition at line 273 of file CSL_Core.h.


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