CSL  6.0
SpatialPanner.h
Go to the documentation of this file.
1 //
2 // SpatialPanner.h -- Specification of the abstract framework for panner/spatializers
3 // See the copyright notice and acknowledgment of authors in the file COPYRIGHT
4 // Created by Jorge Castellanos on 3/29/06. Hacked 8/09 by STP.
5 //
6 
7 #ifndef SPATIAL_PANNER_H
8 #define SPATIAL_PANNER_H
9 
10 #include "SpeakerLayout.h"
11 #include "SpatialSource.h"
12 
13 #include "CSL_Core.h"
14 #include "CPoint.h"
15 
16 namespace csl {
17 
18 /// Base class for all panners.
19 /// Handles source management and holds a speaker layout.
20 /// @todo Update all Panners so that they rebuild their caches when changing the speaker layout.
21 
22 class SpatialPanner : public UnitGenerator, public Observer {
23 public:
24  /// Constructor - a SpeakerLayout can be specified
26  virtual ~SpatialPanner();
27 
28  /// Set the speaker layout to be used by this panner.
29  /// The panner will request the default layout if not set.
30  void setSpeakerLayout(SpeakerLayout *aLayout);
31 
32  unsigned numSources() { return mSources.size(); }; ///< number of active inputs.
33 
34  virtual void addSource(SpatialSource &s); ///< Add a souce to the list of inputs to be
35  /// processed and create a cache object
36 
37  virtual void removeSource(SpatialSource &s); ///< Remove a Sound Source.
38 
39  virtual void update(void *arg); ///< Called when the speaker layout changes
40 
41  virtual void nextBuffer(Buffer & outputBuffer) throw (CException) = 0;
42  virtual void nextBuffer(Buffer & outputBuffer, unsigned outBufNum) throw (CException) {
43  throw LogicError("Asking for mono nextBuffer of a SpatialPanner");
44  }
45 
46 protected:
47  /// SpatialSource... refers to its input UGen,
48  /// but with the knowledge of its position within a space.
49  UGenVector mSources; ///< Vector of pointers to the inputs
50  vector <void *> mCache; ///< Vector of pointers to the prior I/O data.
51 
52  SpeakerLayout *mSpeakerLayout; ///< If null, it will use the default layout by calling
53  /// SpeakerLayout::defaultSpeakerLayout();
54  Buffer mTempBuffer; ///< Buffer used to temporarily hold input source data.
55 
56  virtual void *cache(); ///< create the cache
57  virtual void speakerLayoutChanged() { }; ///< Called when the speaker layout changes.
58 };
59 
60 }
61 
62 #endif
virtual ~SpatialPanner()
virtual void nextBuffer(Buffer &outputBuffer)=0
get a buffer of Frames – this is the core CSL "pull" function; the given buffer can be written into...
AdditiveInstrument.h – Sum-of-sines synthesis instrument class.
Definition: Accessor.h:17
CSL Observer/Dependent/Monitor class – instances receive update() messages from "models" and handle ...
Definition: CGestalt.h:296
UGenVector mSources
SpatialSource... refers to its input UGen, but with the knowledge of its position within a space...
Definition: SpatialPanner.h:49
unsigned numSources()
Definition: SpatialPanner.h:32
Buffer mTempBuffer
Buffer used to temporarily hold input source data.
Definition: SpatialPanner.h:54
virtual void * cache()
create the cache
Impossible operation.
vector< void * > mCache
Vector of pointers to the prior I/O data.
Definition: SpatialPanner.h:50
Base class for all panners. Handles source management and holds a speaker layout. ...
Definition: SpatialPanner.h:22
Temp Spatial Sound Source.
Definition: SpatialSource.h:29
SpeakerLayout * mSpeakerLayout
If null, it will use the default layout by calling SpeakerLayout::defaultSpeakerLayout();.
Definition: SpatialPanner.h:52
virtual void removeSource(SpatialSource &s)
Remove a Sound Source.
virtual void addSource(SpatialSource &s)
number of active inputs.
virtual void nextBuffer(Buffer &outputBuffer, unsigned outBufNum)
really compute the next buffer given an offset base channel; this is called by nextBuffer, possibly multiple times
Definition: SpatialPanner.h:42
std::vector< UnitGenerator * > UGenVector
Definition: CSL_Types.h:241
virtual void speakerLayoutChanged()
Definition: SpatialPanner.h:57
virtual void update(void *arg)
Called when the speaker layout changes.
SpatialPanner(SpeakerLayout *layout=SpeakerLayout::defaultSpeakerLayout())
Constructor - a SpeakerLayout can be specified.
Buffer – the multi-channel sample buffer class (passed around between generators and IO guys)...
Definition: CSL_Core.h:106
forward declaration
Definition: CSL_Core.h:241
static SpeakerLayout * defaultSpeakerLayout()
Returns a pointer to the default layout. If no default exists, it creates one.
void setSpeakerLayout(SpeakerLayout *aLayout)
Set the speaker layout to be used by this panner. The panner will request the default layout if not s...
Base class of CSL exceptions (written upper-case). Has a string message.