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