BinauralDB.h

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

Generated on Sat Oct 17 14:12:30 2009 for CSL by  doxygen 1.4.5-20051010