20 :
Effect(in), mFFTSize(size),
21 mWrapper(size, type,
CSL_FFT_FORWARD), mInBuf(1, size), mWindowBuffer(0) {
37 unsigned numFrames = outputBuffer.mNumFrames;
41 memcpy(mInBuf.buffer(0), mInputPtr, numFrames *
sizeof(
sample));
45 for (
int i = 0; i < mFFTSize; i++)
46 *bufPtr++ *= *winPtr++;
48 mWrapper.nextBuffer(mInBuf, outputBuffer);
51 this->changed((
void *) & outputBuffer);
69 void IFFT::binValue(
int binNumber,
float * outRealPart,
float * outImagPart) {
75 float myReal, myComplex;
76 binValue(binNumber, &myReal, &myComplex);
77 *outMag = hypot(myReal, myComplex);
78 *outPhase = (0.0 == myReal) ? 0 : atan(myComplex/myReal);
83 logMsg(
"\t\tset [%d] = %5.3f @ %5.3f", binNumber, realPart, imagPart);
104 for (
int i = 0; i <
mFFTSize; i += 2) {
111 if (lower <0 || lower >=
mFFTSize ) {
return; }
112 if (upper <0 || upper >=
mFFTSize ) {
return; }
113 if (upper <lower ) {
return; }
115 for (
int i = lower; i < upper; i++) {
122 float myReal, myComplex;
123 myReal = mag*cos(phase);
124 myComplex = mag*sin(phase);
125 setBin(binNumber, myReal, myComplex);
129 for (
int i = 0; i <
mFFTSize; i++) {
138 if (outputBuffer.mNumFrames != mWrapper.mSize) {
140 "IFFT::nextBuffer # frames %d wrong for FFT size %d (use a block resizer).",
141 outputBuffer.mNumFrames, mWrapper.mSize);
144 mInBuf.setSize(1, outputBuffer.mNumFrames);
147 mWrapper.nextBuffer(mInBuf, outputBuffer);
sample * SampleBuffer
1-channel buffer data type, vector of (sample)
void setBin(int binNumber, float realPart, float imagPart)
void logMsg(const char *format,...)
These are the public logging messages.
SampleComplex * SampleComplexVector
complex vector
void binValueMagPhase(int binNumber, float *outMag, float *outPhase)
void nextBuffer(Buffer &outputBuffer)
get a buffer of Frames – this is the core CSL "pull" function; the given buffer can be written into...
SampleBuffer mWindowBuffer
Buffer to store window.
CSL_FFTType
real/complex flag (determines results from forward FFT)
AdditiveInstrument.h – Sum-of-sines synthesis instrument class.
Effect – mix-in for classes that have unit generators as inputs (like filters).
FFT(UnitGenerator &in, int size=CGestalt::blockSize(), CSL_FFTType type=CSL_FFT_COMPLEX)
Default size to the buffer size and flags to measure.
void setBinsMagPhase(float *mags, float *phases)
void binValue(int binNumber, float *outRealPart, float *outComplexPart)
getter methods
void setBinMagPhase(int binNumber, float mag, float phase)
HammingWindow: Belongs to the familly of cosine window functions.
#define cx_r(val)
complex # accesor macros
float sample
(could be changed to int, or double)
void nextBuffer(Buffer &outputBuffer)
we override the general-case version because this needs a mono input
int mFFTSize
This should be unsigned, but is signed for compatability with FFTW.
void setBins(float *real, float *imag)
IFFT(int size=CGestalt::blockSize(), CSL_FFTType type=CSL_FFT_COMPLEX)
Default size to the buffer size and flags to measure.
int mFFTSize
This should be unsigned, but is signed for compatability with FFTW.
FFT complex spectral frames.
Buffer – the multi-channel sample buffer class (passed around between generators and IO guys)...
Buffer mInBuf
input buffer
bool mOverwriteOutput
no setter – create a new FFT to change size
void allocateBuffers()
fcn to malloc storage buffers
SampleComplexPtr mSpectrum
spectral data I accumulate
sample SampleComplex[2]
array-of-2 complex # type (like FFTW)
#define SAFE_MALLOC(ptr, type, len)
Useful Macros.
Base class of CSL exceptions (written upper-case). Has a string message.