CSL  6.0
SpatialAudio.h
Go to the documentation of this file.
1 //
2 // SpatialAudio.h -- Spatializer
3 //
4 // See the copyright notice and acknowledgment of authors in the file COPYRIGHT
5 // Created by Jorge Castellanos on 7/23/06. Hacked 8/09 by STP.
6 //
7 
8 #ifndef CSL_SPATIAL_AUDIO_H
9 #define CSL_SPATIAL_AUDIO_H
10 
11 #include "SpatialPanner.h"
12 #include "DistanceSimulator.h"
13 
14 namespace csl {
15 
16 /// Panner types
17 
18 typedef enum {
20  kBinaural, ///< HRTF 2-channel panning
21  kVBAP, ///< Vector Base Amplitude Panning
22  kAmbisonic, ///< Full 3D Ambisonics
23  kSimple, ///< Simple panning/filtering spatializer
24  kWFS ///< Wave Field Synthesis
25 } PannerType;
26 
27 /// Container class that simplifies the spatial audio interface.
28 /// This layer hides most of the inner-working of audio spatialization,
29 /// providing a simple interface for sound placement in a space.
30 
31 class Spatializer : public UnitGenerator, public Observer {
32 public:
34  ~Spatializer();
35 
36  void addSource(SpatialSource &s); ///< Add a sound souce to the list of inputs to be processed.
37  void removeSource(SpatialSource &s); ///< Remove a Sound Source.
38 
39  unsigned numSources() { return mPanner->numSources(); }; ///< number of active inputs.
40 
41  void setPanningMode(PannerType panType);
42 
43  virtual void update(void *arg); ///< called when the speaker layout changes, so panners update precalculated data.
44 
45  virtual void nextBuffer(Buffer &outputBuffer /*, unsigned outBufNum */) throw (CException); ///< fill the buffer with data :-)
46 
47 private:
49  /// a map between a source passed/key and a the corresponding distance
50  /// simulator (used for removing sources)
51  map <SpatialSource *, DistanceSimulator *> mInputsHashMap;
52  /// If null, it will use the default layout by calling
53  /// SpeakerLayout::defaultSpeakerLayout();
56 };
57 
58 
59 class Auralizer : public Spatializer {
60 public:
61  Auralizer() { };
62  ~Auralizer() { };
63 
64 
65 private:
66 
67 // SHOULD REVERB BE PART OF THE AURALIZER? OR THE SPATIALIZER?
68 // TO AN EXTENT, ADDING REVERB IS ALREADY A VERY COARSE ATTEMPT TO SIMULATE A SPACE, MAKING IT PART OF AURALIZER
69 // BUT A SPATIALIZER IS ALSO SUPPOSED TO PLACE A SOUND IN A SPACE, THUS THE NAME.
70 // ADDING ROOM SIZE TO A SPAIZALIZER TO CONTROL REVERB AMOUNT WOULD GET INTO THE INTERFAXE OF AURALIZER
71 // UNLESS NOT SPECIFIED? NAHH!
72 
73 /*
74 For now use Freeverb as the reverberator. In the future, a base reverb class should exist,
75 allowing to specify the type of reverb. Although this would call for a subclass of Auralizer,
76 rather than using setter functions, where by default it gets constructed to use Freverb, but
77 A subclass could just place any other reverb.
78 */
79 
80 // Freeverb *mGlobalReverb
81 
82 /*
83 The reverb settings would be set depending on the room specified.
84 The "Room" Class should have a method for returning volume, as well as average absorption
85 (in order to set the tail properties, as well as calculating reflections.
86 
87 The calculation of early reflections should also share a common base class, so that subclasses
88 can initialize the "geometer" to any desired one."
89 */
90 
91 
92 };
93 
94 ///*
95 //I GUESS I'VE FOUND A SOLUTION TO THE SPATIALIZER "CONTAINER".
96 //FIRST, IT WONT BE A SPATIALIZER, BUT THE AURALIZER WILL COME A LEVEL DOWN, AND BE ITSELF THE SPATIALIZER.
97 //THE DIFFERENCE IS THAT BY DEFAULT IT WON'T DEAL WITH ROOM MODELS. (IT COULD POSSIBLY BE A SUBCLASS OF SPATIALIZER IF THE "ECHO" INFO
98 //BECOMES TO COMPLICATED TO HAVE FOR EVERY SPATIALIZER.
99 //
100 //HERE IT GOES:
101 //WHEN ADDING A SOURCE TO THE SPATIALIZER, THIS WILL MAKE A DISTANCE_SIMULATOR AND PASS IT THE ADDED SOURCE. THEN, IT'LL CALL "ADD SOURCE" OF THE
102 //PANNER AND WILL PASS IT THE NEW CREATED DISTANCE SIMULATOR.
103 //IN THE NEXT BUFFER OF THE SPATIALIZER, THIS WILL CALL NEXT BUFFER OF THE PANNER, WHICH IN TURN WILL CALL NEXT BUFFER OF EACH SOURCE, MEANING EACH DISTANCE SIMULATOR
104 //WHICH IN TURN IT'LL CAL THE NEXT BUFFER OF EACH PASSED SOURCE.
105 //
106 //
107 //
108 //
109 //*/
110 
112 public:
115 
117 
118 };
119 
120 } // end of nameespace
121 
122 #endif
Simple panning/filtering spatializer.
Definition: SpatialAudio.h:23
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
void addSource(SpatialSource &s)
Add a sound souce to the list of inputs to be processed.
void setPanningMode(PannerType panType)
number of active inputs.
unsigned numSources()
Definition: SpatialPanner.h:32
static PannerType findPannerFromLayout(SpeakerLayout *layout=SpeakerLayout::defaultSpeakerLayout())
Wave Field Synthesis.
Definition: SpatialAudio.h:24
Vector Base Amplitude Panning.
Definition: SpatialAudio.h:21
PannerType mType
Definition: SpatialAudio.h:55
Base class for all panners. Handles source management and holds a speaker layout. ...
Definition: SpatialPanner.h:22
PannerType
Panner types.
Definition: SpatialAudio.h:18
Temp Spatial Sound Source.
Definition: SpatialSource.h:29
void removeSource(SpatialSource &s)
Remove a Sound Source.
Spatializer(PannerType panMode=kAutomatic, SpeakerLayout *speakerLayout=SpeakerLayout::defaultSpeakerLayout())
SpeakerLayout * mSpeakerLayout
If null, it will use the default layout by calling SpeakerLayout::defaultSpeakerLayout();.
Definition: SpatialAudio.h:54
map< SpatialSource *, DistanceSimulator * > mInputsHashMap
a map between a source passed/key and a the corresponding distance simulator (used for removing sourc...
Definition: SpatialAudio.h:51
Buffer – the multi-channel sample buffer class (passed around between generators and IO guys)...
Definition: CSL_Core.h:106
virtual void nextBuffer(Buffer &outputBuffer)
fill the buffer with data :-)
unsigned numSources()
Definition: SpatialAudio.h:39
forward declaration
Definition: CSL_Core.h:241
static SpeakerLayout * defaultSpeakerLayout()
Returns a pointer to the default layout. If no default exists, it creates one.
Container class that simplifies the spatial audio interface. This layer hides most of the inner-worki...
Definition: SpatialAudio.h:31
SpatialPanner * mPanner
Definition: SpatialAudio.h:48
Full 3D Ambisonics.
Definition: SpatialAudio.h:22
virtual void update(void *arg)
called when the speaker layout changes, so panners update precalculated data.
Base class of CSL exceptions (written upper-case). Has a string message.
HRTF 2-channel panning.
Definition: SpatialAudio.h:20