BinauralDB.h

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 //      2 channels * 16 blocks * 512-complex-float arrays
00045 
00046 #ifndef CSL_BINAURALDB_H
00047 #define CSL_BINAURALDB_H
00048 
00049 #include "CSL_Core.h"
00050 #include "SpatialPanner.h"
00051 #include "FFT_Wrapper.h"
00052 
00053 #ifdef USE_JSND
00054     #include "SoundFileJ.h"
00055 #endif
00056 #ifdef USE_LSND
00057     #include "SoundFileL.h"
00058 #endif
00059 #ifdef USE_CASND
00060     #include "SoundFileCA.h"
00061 #endif 
00062 
00063 #ifndef IPHONE                              
00064     #define HRTF_BLOCK_SIZE CGestalt::blockSize()
00065     #define HRIR_SIZE 1024                  
00066 #else 
00067     #define HRTF_BLOCK_SIZE 256             
00068     #define HRIR_SIZE 1024                  
00069 #endif 
00070 
00071 #define FLIST_NAME "files.txt"              
00072 #define DEFAULT_HRTF_FOLDER "IRCAM_HRTF/"   
00073 
00074 #ifdef USE_CASND
00075     #define HRTF_RESOURCE "1047"            
00076 #else
00077     #define HRTF_RESOURCE "IRC_1047_R"      
00078 #endif
00079 
00080 // complex multiply-accumulate macro; uses cx_r/i marcos
00081 
00082 //#define cmac(in1, in2, out)                                           \
00083 //  cx_r(out) += (cx_r(in1) * cx_r(in2)) - (cx_i(in1) * cx_i(in2));     \
00084 //  cx_i(out) += (cx_r(in1) * cx_i(in2)) + (cx_i(in1) * cx_r(in2))
00085 
00086 // this way assumes SampleComplex is sample[2]
00087 
00088 #define cmac(in1, in2, out)                         \
00089     out[0] += in1[0] * in2[0] - in1[1] * in2[1];    \
00090     out[1] += in1[0] * in2[1] + in1[1] * in2[0];
00091 
00092 namespace csl {
00093 
00099 
00100 class HRTF {
00101 public:                                     
00102 
00103     HRTF();                                 
00104     HRTF(char * fname, FFTWrapper & fft);   
00105     ~HRTF();
00106     
00107     void dump();                            
00108     unsigned size();                        
00109     
00110     CPoint mPosition;                       
00111     SampleComplexVector *mHrtfL, *mHrtfR;   
00112 
00113     unsigned mNumFFTBlocks;                 
00114 };
00115 
00116 typedef vector <HRTF *> HRTFVector;
00117 
00118 
00126 
00127 class HRTFDatabase {
00128 public:
00129     ~HRTFDatabase() { };
00130     
00131     static HRTFDatabase * Database();       
00132     static void Destroy();                  
00133     static void Reload(char * folder);      
00134     static void convertDB(const char *listname) throw (CException);     
00135 
00136     unsigned numHRTFs();                    
00137     unsigned windowSize();                  
00138     unsigned hrtfLength();                  
00139     unsigned hrirLength();                  
00140     unsigned numBlocks();                   
00141 
00142     unsigned hrtfAt(CPoint srcPos);         
00143     HRTF * hrtfAt(unsigned index);          
00144     
00145     void dump(bool verbose = false);        
00146     unsigned size();                        
00147 
00149     void storeToDB(const char *filename,const char *same) throw (CException);
00150     
00151 protected:
00152     HRTFDatabase(const char * folder);      
00153 //  HRTFDatabase(HRTFVector hrtfs);
00155     void loadFromFolder (const char *folder) throw (CException);
00156     void loadFromFile(const char *filename) throw (CException);
00157     void loadFromDB (const char *dbName) throw (CException);
00158     
00159     HRTFVector mHRTFVector;                 
00160     
00161     unsigned mWindowSize;                   
00162     unsigned mHRTFLength;                   
00163     unsigned mHRIRLength;                   
00164 
00165     static HRTFDatabase* mDatabase;         
00166 };
00167 
00168 } // end namespace
00169 
00170 #endif

Generated on Thu Sep 17 23:14:16 2009 for CSL by  doxygen 1.5.8