CSL 5.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
25 SpatialPanner(SpeakerLayout *layout = SpeakerLayout::defaultSpeakerLayout());
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