CSL  6.0
Convolver2.h
Go to the documentation of this file.
1 ///
2 /// Convolver2.h -- The simplified convolution class.
3 /// This is an FFT-based convolver that uses the FFT wrapper.
4 /// stephen@heaveneverywhere.com - 1905
5 // Copyright(C) 2019 Stephen T. Pope. All rights reserved.
6 // THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE.
7 // The copyright notice above does not evidence any actual or intended
8 // publication of such source code.
9 ///
10 
11 #ifndef INCLUDE_CONVOLUTION2_H
12 #define INCLUDE_CONVOLUTION2_H
13 
14 #include "CSL_Core.h"
15 #define USE_FFTW // use FFTW (faster but complicated to build)
16 #include "FFT_Wrapper.h"
17 
18 namespace csl {
19 
20 ///
21 /// The Convolver2 is a CSL Effect
22 ///
23 
24 class Convolver2 : public Effect {
25 public: /// Constructors
26  Convolver2(UnitGenerator & in, char * inFName, unsigned chan = 0, unsigned len = 512, bool norm = false);
27  Convolver2(UnitGenerator & in, float * irData, unsigned nTaps, unsigned len = 512, bool norm = false);
28  ~Convolver2();
29  ///< set the IR file name; runs the analysis ffts
30  void setIRFile(char * inFName, unsigned chan = 0);
31  void setIRData(float * irData, unsigned nTaps);
32  /// main nextBuffer call does the fft/ifft
33  void nextBuffer(Buffer &outputBuffer) throw (CException);
34 protected:
36  bool mNormOut; // whether to normalize the output (scale by 1 / fft-len)
37 
38  SampleComplexMatrix mInputFFT; ///< A list of past input spectra
39  SampleComplexMatrix mFilterFFT; ///< list of IR ffts
40  SampleComplexVector mSpectrumBuffer; ///< temp summing complex vector
41  SampleBuffer mLastOutput; ///< most-recent output (1/2 window)
42 
43  FFT_Wrapper mFFTAnalyzer; ///< FFT analysis/synthesis wrappers
44  FFT_Wrapper mFFTSynthesizer;
45  Buffer mFFTBuffer; ///< buffer used for FFTs, no storage
46 
47  void checkBuffers(unsigned newNumBufs); ///< alloc buffers
48  void free_buffers();
49  /// fast complex MAC using non-interleaved complex arrays
51  SampleComplexVector output);
52 };
53 
54 }
55 
56 #endif
sample * SampleBuffer
1-channel buffer data type, vector of (sample)
Definition: CSL_Types.h:194
SampleComplex * SampleComplexVector
complex vector
Definition: CSL_Types.h:202
AdditiveInstrument.h – Sum-of-sines synthesis instrument class.
Definition: Accessor.h:17
Effect – mix-in for classes that have unit generators as inputs (like filters).
Definition: CSL_Core.h:466
unsigned mFlSize
Definition: Convolver2.h:35
Convolver2(UnitGenerator &in, char *inFName, unsigned chan=0, unsigned len=512, bool norm=false)
Constructors.
Definition: Convolver2.cpp:22
unsigned mNumTaps
Definition: Convolver2.h:35
void free_buffers()
Definition: Convolver2.cpp:54
void nextBuffer(Buffer &outputBuffer)
main nextBuffer call does the fft/ifft
Definition: Convolver2.cpp:136
SampleComplexPtr * SampleComplexMatrix
complex 2D matrix
Definition: CSL_Types.h:204
SampleComplexMatrix mInputFFT
A list of past input spectra.
Definition: Convolver2.h:38
unsigned mChan
Definition: Convolver2.h:35
SampleComplexVector mSpectrumBuffer
temp summing complex vector
Definition: Convolver2.h:40
FFT_Wrapper mFFTAnalyzer
FFT analysis/synthesis wrappers.
Definition: Convolver2.h:43
static unsigned len
Definition: fft_N.c:39
SampleComplexMatrix mFilterFFT
list of IR ffts
Definition: Convolver2.h:39
void setIRFile(char *inFName, unsigned chan=0)
Definition: Convolver2.cpp:93
SampleBuffer mLastOutput
most-recent output (1/2 window)
Definition: Convolver2.h:41
void checkBuffers(unsigned newNumBufs)
alloc buffers
Definition: Convolver2.cpp:70
void setIRData(float *irData, unsigned nTaps)
Definition: Convolver2.cpp:110
Buffer – the multi-channel sample buffer class (passed around between generators and IO guys)...
Definition: CSL_Core.h:106
The Convolver2 is a CSL Effect.
Definition: Convolver2.h:24
unsigned mWindowCount
Definition: Convolver2.h:35
forward declaration
Definition: CSL_Core.h:241
~Convolver2()
set the IR file name; runs the analysis ffts
Definition: Convolver2.cpp:48
FFT_Wrapper mFFTSynthesizer
Definition: Convolver2.h:44
void complex_multiply_accumulate(SampleComplexVector left, SampleComplexVector right, SampleComplexVector output)
fast complex MAC using non-interleaved complex arrays
Definition: Convolver2.cpp:211
unsigned mFFTSize
Definition: Convolver2.h:35
Buffer mFFTBuffer
buffer used for FFTs, no storage
Definition: Convolver2.h:45
unsigned mNumBufs
Definition: Convolver2.h:35
Base class of CSL exceptions (written upper-case). Has a string message.