Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Fft.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2014, The Cinder Project
3 
4  This code is intended to be used with the Cinder C++ library, http://libcinder.org
5 
6  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
7  the following conditions are met:
8 
9  * Redistributions of source code must retain the above copyright notice, this list of conditions and
10  the following disclaimer.
11  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
12  the following disclaimer in the documentation and/or other materials provided with the distribution.
13 
14  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
15  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
16  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
17  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
18  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
20  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
21  POSSIBILITY OF SUCH DAMAGE.
22 */
23 
24 #pragma once
25 
26 #include "cinder/audio/Buffer.h"
27 #include "cinder/audio/dsp/Dsp.h"
28 
29 #include "cinder/Cinder.h"
30 
31 #include <vector>
32 
33 #if defined( CINDER_AUDIO_VDSP )
34  #include <Accelerate/Accelerate.h>
35 #else
36  #define CINDER_AUDIO_FFT_OOURA
37 #endif
38 
39 namespace cinder { namespace audio { namespace dsp {
40 
42 class Fft {
43  public:
45  Fft( size_t fftSize );
46  ~Fft();
47 
49  void forward( const Buffer *waveform, BufferSpectral *spectral );
51  void inverse( const BufferSpectral *spectral, Buffer *waveform );
53  size_t getSize() const { return mSize; }
54 
55  protected:
56  void init();
57 
59 
60 #if defined( CINDER_AUDIO_VDSP )
61  size_t mLog2FftSize;
62  ::FFTSetup mFftSetup;
63  ::DSPSplitComplex mSplitComplexSignal, mSplitComplexResult;
64 #elif defined( CINDER_AUDIO_FFT_OOURA )
66  int *mOouraIp;
67  float *mOouraW;
68 #endif
69 };
70 
71 } } } // namespace cinder::audio::dsp
size_t mSize
Definition: Fft.h:58
Real Discrete Fourier Transform (DFT).
Definition: Fft.h:42
size_t mSizeOverTwo
Definition: Fft.h:58
Buffer mBufferCopy
Definition: Fft.h:65
size_t getSize() const
Returns the size of the FFT.
Definition: Fft.h:53
void forward(const Buffer *waveform, BufferSpectral *spectral)
Computes the Forward DFT of waveform, filling spectral with freqency-domain audio data...
Fft(size_t fftSize)
Constructs an Fft object. fftSize must be a power of two and greater than two.
Definition: Fft.cpp:35
int * mOouraIp
Definition: Fft.h:66
float * mOouraW
Definition: Fft.h:67
void inverse(const BufferSpectral *spectral, Buffer *waveform)
Computes the Inverse DFT of spectral, filling waveform with time-domain audio data.