Convolver.h

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 #ifndef INCLUDE_CONVOLUTION_H
00012 #define INCLUDE_CONVOLUTION_H
00013 
00014 #include "CSL_Core.h"
00015 #include "Spectral.h"           // fftw includes and types
00016 
00018 
00019 #define CHECK_PTR(ptr)                              \
00020     if (!ptr)    throw MemoryError("Can't allocate buffer")
00021 
00022 #define initvec( name, size, type )                 \
00023     if ((name = (type *) calloc(size, sizeof(type))) == NULL)  \
00024         throw MemoryError("Can't allocate buffer");
00025 
00026 #define cmac(in1, in2, out)                         \
00027     out[0] += in1[0] * in2[0] - in1[1] * in2[1];    \
00028     out[1] += in1[0] * in2[1] + in1[1] * in2[0];
00029 
00030 #define cbinc(buf, size)    if (++buf > size-1)     buf = 0;
00031 #define cbdec(buf, size)    if (--buf < 0)          buf = size - 1;
00032 
00033 #define cbarb(buf, size, amt)                       \
00034     buf += amt;                                     \
00035     if (buf >= size) buf -= size;                   \
00036     else if (buf < 0) buf += size;
00037 
00038 namespace csl {
00039 
00043 
00044 class Convolver : public Effect {
00045 
00046 public:                                     
00047     Convolver() : Effect() { };
00048     Convolver(char *IRfilename);            
00049     Convolver(unsigned len, Buffer & impulseResp);
00050     Convolver(unsigned len, char * IRfilename);
00051     Convolver(Buffer & inbuf);
00052     ~Convolver();
00054     void initialize(Buffer & buf) throw (CException);       
00055     void setFilters(fftwf_complex ** filterFFTs);           
00056     void setInputf(fftwf_complex * inFFT);                  
00057     CSL_FFTW_sample * mSampleBuffer;                        
00058 
00060     void nextBuffer(Buffer &outputBuffer, unsigned outBufNum) throw (CException);
00061 
00062 protected:  
00063     CSL_FFTW_cmplx ** mFilterFFTs;                          
00064     CSL_FFTW_cmplx ** mInputFFTs;                           
00065     CSL_FFTW_cmplx * mSpectrumBuffer;                       
00066     CSL_FFTW_plan mForwardPlan, mInversePlan;               
00067     unsigned mFFTSize, mWindowCount, mNumBufs;              
00068     bool mMyBuffers;                                        
00069     bool mMyInput;                                          
00070     
00071     void initialize (const char *filename) throw (CException);  
00072     
00074     void complex_multiply_accumulate(fftwf_complex* left, fftwf_complex* right, fftwf_complex * output);
00075 
00076 };
00077 
00078 }
00079 
00080 #endif

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