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 #ifndef CSL_BINAURAL_H 00026 #define CSL_BINAURAL_H 00027 00028 #include "BinauralDB.h" 00029 00030 #ifdef IPHONE 00031 #define SUM_DOWNS 1 // scale # blocks to sum (16 / SUM_DOWNS) 00032 #define FFT_DOWNS 2 // scale IFFT len (FFT_DOWNS * blockSize) 00033 #define LEN_DOWNS 1 // scale sum len (513 / LEN_DOWNS) 00034 #else 00035 #define SUM_DOWNS 1 // scale # blocks to sum (16 / SUM_DOWNS) 00036 #define FFT_DOWNS 2 // scale IFFT len (FFT_DOWNS * blockSize) 00037 #define LEN_DOWNS 1 // scale sum len (513 / LEN_DOWNS) 00038 #endif 00039 00040 namespace csl { 00041 00042 class BinauralSourceCache; 00043 00048 00049 class BinauralPanner : public SpatialPanner { 00050 00051 public: 00052 BinauralPanner(unsigned blockSize = HRTF_BLOCK_SIZE); 00053 ~BinauralPanner(); 00057 virtual void nextBuffer(Buffer &outputBuffer, unsigned outBufNum) throw (CException); 00058 00059 unsigned mNumBlocks; 00060 unsigned mNumBlocksToSum; 00061 unsigned mFramesPerBlock; 00062 00063 protected: 00064 FFTWrapper mInFFT; 00065 FFTWrapper mOutFFT; 00066 00067 Buffer mInBuf, mTmpBuf, mOutBuf; 00068 00069 SampleComplexVector mHOutL, mHOutR; 00070 SampleBuffer mIFFTOutL, mIFFTOutR; 00071 00072 unsigned mBlockInd; 00073 BinauralSourceCache * cache(); 00074 }; 00075 00076 00079 00080 class BinauralSourceCache { 00081 public: 00082 BinauralSourceCache(BinauralPanner *parent); 00083 ~BinauralSourceCache(); 00084 00085 SampleComplexVector *mInSpect; 00086 SampleBuffer mPrevOutL, mPrevOutR; 00087 unsigned *mHRTF; 00088 unsigned mNumBlocks; 00089 }; 00090 00091 } // end namespace 00092 00093 #endif
1.4.5-20051010