41 #ifndef _SpectralProcesor_H_
42 #define _SpectralProcesor_H_
44 #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
45 #include <CoreAudio/CoreAudioTypes.h>
46 #include <CoreFoundation/CoreFoundation.h>
48 #include <CoreAudioTypes.h>
49 #include <CoreFoundation.h>
52 #include <Accelerate/Accelerate.h>
54 #include "CAAutoDisposer.h"
56 struct SpectralBufferList
58 UInt32 mNumberSpectra;
59 DSPSplitComplex mDSPSplitComplex[1];
62 class CASpectralProcessor
65 CASpectralProcessor(UInt32 inFFTSize, UInt32 inHopSize, UInt32 inNumChannels, UInt32 inMaxFrames);
66 virtual ~CASpectralProcessor();
70 void Process(UInt32 inNumFrames, AudioBufferList* inInput, AudioBufferList* outOutput);
72 typedef void (*SpectralFunction)(SpectralBufferList* inSpectra,
void* inUserData);
74 void SetSpectralFunction(SpectralFunction inFunction,
void* inUserData);
76 UInt32 FFTSize()
const {
return mFFTSize; }
77 UInt32 MaxFrames()
const {
return mMaxFrames; }
78 UInt32 NumChannels()
const {
return mNumChannels; }
79 UInt32 HopSize()
const {
return mHopSize; }
80 Float32* Window()
const {
return mWindow; }
86 void GetFrequencies(Float32* freqs, Float32 sampleRate);
87 void GetMagnitude(AudioBufferList* inCopy, Float32* min, Float32* max);
89 virtual bool ProcessForwards(UInt32 inNumFrames, AudioBufferList* inInput);
90 bool ProcessBackwards(UInt32 inNumFrames, AudioBufferList* outOutput);
93 void PrintSpectralBufferList();
96 void CopyInput(UInt32 inNumFrames, AudioBufferList* inInput);
97 void CopyInputToFFT();
101 void OverlapAddOutput();
102 void CopyOutput(UInt32 inNumFrames, AudioBufferList* inOutput);
103 void ProcessSpectrum(UInt32 inFFTSize, SpectralBufferList* inSpectra);
122 CAAutoFree<Float32> mWindow;
123 struct SpectralChannel
125 CAAutoFree<Float32> mInputBuf;
126 CAAutoFree<Float32> mOutputBuf;
127 CAAutoFree<Float32> mFFTBuf;
128 CAAutoFree<Float32> mSplitFFTBuf;
130 CAAutoArrayDelete<SpectralChannel> mChannels;
132 CAAutoFree<SpectralBufferList> mSpectralBufferList;
134 SpectralFunction mSpectralFunction;
This implements a window function as described @ http://local.wasp.uwa.edu.au/~pbourke/miscellaneous/...