00001 // 00002 // SpatialAudio.h -- Spatializer 00003 // See the copyright notice and acknowledgment of authors in the file COPYRIGHT 00004 // Created by Jorge Castellanos on 7/23/06. Hacked 8/09 by STP. 00005 // 00006 00007 #ifndef CSL_SPATIAL_AUDIO_H 00008 #define CSL_SPATIAL_AUDIO_H 00009 00010 #include "SpatialPanner.h" 00011 #include "DistanceSimulator.h" 00012 00013 namespace csl { 00014 00016 00017 typedef enum { 00018 kAutomatic = 0, 00019 kBinaural, 00020 kVBAP, 00021 kAmbisonic, 00022 kWFS 00023 } PannerType; 00024 00028 00029 class Spatializer : public UnitGenerator, public Observer { 00030 public: 00031 Spatializer(PannerType panMode = kAutomatic, SpeakerLayout *speakerLayout = SpeakerLayout::defaultSpeakerLayout()); 00032 ~Spatializer(); 00033 00034 void addSource(SpatialSource &s); 00035 void removeSource(SpatialSource &s); 00036 00037 unsigned numSources() { return mPanner->numSources(); }; 00038 00039 void setPanningMode(PannerType panType); 00040 00041 virtual void update(void *arg); 00042 00043 virtual void nextBuffer(Buffer &outputBuffer, unsigned outBufNum) throw (CException); 00044 00045 private: 00046 SpatialPanner *mPanner; 00049 map <SpatialSource *, DistanceSimulator *> mInputsHashMap; 00052 SpeakerLayout *mSpeakerLayout; 00053 }; 00054 00055 00056 class Auralizer : public Spatializer { 00057 public: 00058 Auralizer() { }; 00059 ~Auralizer() { }; 00060 00061 00062 private: 00063 00064 // SHOULD REVERB BE PART OF THE AURALIZER? OR THE SPATIALIZER? 00065 // TO AN EXTENT, ADDING REVERB IS ALREADY A VERY COARSE ATTEMPT TO SIMULATE A SPACE, MAKING IT PART OF AURALIZER 00066 // BUT A SPATIALIZER IS ALSO SUPPOSED TO PLACE A SOUND IN A SPACE, THUS THE NAME. 00067 // ADDING ROOM SIZE TO A SPAIZALIZER TO CONTROL REVERB AMOUNT WOULD GET INTO THE INTERFAXE OF AURALIZER 00068 // UNLESS NOT SPECIFIED? NAHH! 00069 00070 /* 00071 For now use Freeverb as the reverberator. In the future, a base reverb class should exist, 00072 allowing to specify the type of reverb. Although this would call for a subclass of Auralizer, 00073 rather than using setter functions, where by default it gets constructed to use Freverb, but 00074 A subclass could just place any other reverb. 00075 */ 00076 00077 // Freeverb *mGlobalReverb 00078 00079 /* 00080 The reverb settings would be set depending on the room specified. 00081 The "Room" Class should have a method for returning volume, as well as average absorption 00082 (in order to set the tail properties, as well as calculating reflections. 00083 00084 The calculation of early reflections should also share a common base class, so that subclasses 00085 can initialize the "geometer" to any desired one." 00086 */ 00087 00088 00089 }; 00090 00092 //I GUESS I'VE FOUND A SOLUTION TO THE SPATIALIZER "CONTAINER". 00093 //FIRST, IT WONT BE A SPATIALIZER, BUT THE AURALIZER WILL COME A LEVEL DOWN, AND BE ITSELF THE SPATIALIZER. 00094 //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 00095 //BECOMES TO COMPLICATED TO HAVE FOR EVERY SPATIALIZER. 00096 // 00097 //HERE IT GOES: 00098 //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 00099 //PANNER AND WILL PASS IT THE NEW CREATED DISTANCE SIMULATOR. 00100 //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 00101 //WHICH IN TURN IT'LL CAL THE NEXT BUFFER OF EACH PASSED SOURCE. 00102 // 00103 // 00104 // 00105 // 00106 //*/ 00107 00108 class SpeakerLayoutExpert { 00109 public: 00110 SpeakerLayoutExpert() { }; 00111 ~SpeakerLayoutExpert() { }; 00112 00113 static PannerType findPannerFromLayout(SpeakerLayout *layout = SpeakerLayout::defaultSpeakerLayout()); 00114 00115 }; 00116 00117 } // end of nameespace 00118 00119 #endif
1.5.8