00001 /* 00002 * SpatialAudio.h 00003 * CSL 00004 * 00005 * Created by Jorge Castellanos on 7/23/06. 00006 * Copyright 2006 Jorge Castellanos. All rights reserved. 00007 * 00008 */ 00009 00010 #ifndef CSL_SPATIAL_AUDIO_H 00011 #define CSL_SPATIAL_AUDIO_H 00012 00013 #include "Panner.h" 00014 #include "DistanceSimulator.h" 00015 00016 namespace csl { 00017 00019 typedef enum { 00020 kAutomatic = 0, 00021 kBinaural, 00022 kVBAP, 00023 kAmbisonic 00024 00025 } PannerType; 00026 00027 00028 00031 class Spatializer : public UnitGenerator, public Observer { 00032 public: 00033 Spatializer(PannerType panMode = kAutomatic, SpeakerLayout *speakerLayout = SpeakerLayout::defaultSpeakerLayout()); 00034 ~Spatializer(); 00035 00036 void addSource(SpatSource &s); 00037 void removeSource(SpatSource &s); 00038 00039 unsigned numSources() { return mPanner->numSources(); }; 00040 00041 void setPanningMode(PannerType panType); 00042 00043 virtual void update(void *arg); 00044 00045 virtual void nextBuffer(Buffer &outputBuffer, unsigned outBufNum) throw (CException); 00046 00047 private: 00048 00049 Panner *mPanner; 00051 map<SpatSource *, DistanceSimulator *> mInputsHashMap; 00052 SpeakerLayout *mSpeakerLayout; 00053 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 00119 } // end of nameespace 00120 00121 #endif
1.4.5-20051010