1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
5 An audio time-stretching and pitch-shifting library.
6 Copyright 2007-2008 Chris Cannam.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version. See the file
12 COPYING included with this distribution for more information.
15 #ifndef _RUBBERBAND_FFT_H_
16 #define _RUBBERBAND_FFT_H_
20 namespace RubberBand
{
25 * Provide the basic FFT computations we need, using one of a set of
26 * candidate FFT implementations (depending on compile flags).
28 * Implements real->complex FFTs of power-of-two sizes only. Note
29 * that only the first half of the output signal is returned (the
30 * complex conjugates half is omitted), so the "complex" arrays need
31 * room for size/2+1 elements.
33 * Not thread safe: use a separate instance per thread.
39 enum Exception
{ InvalidSize
};
41 FFT(int size
, int debugLevel
= 0); // may throw InvalidSize
44 void forward(const double *R__ realIn
, double *R__ realOut
, double *R__ imagOut
);
45 void forwardPolar(const double *R__ realIn
, double *R__ magOut
, double *R__ phaseOut
);
46 void forwardMagnitude(const double *R__ realIn
, double *R__ magOut
);
48 void forward(const float *R__ realIn
, float *R__ realOut
, float *R__ imagOut
);
49 void forwardPolar(const float *R__ realIn
, float *R__ magOut
, float *R__ phaseOut
);
50 void forwardMagnitude(const float *R__ realIn
, float *R__ magOut
);
52 void inverse(const double *R__ realIn
, const double *R__ imagIn
, double *R__ realOut
);
53 void inversePolar(const double *R__ magIn
, const double *R__ phaseIn
, double *R__ realOut
);
54 void inverseCepstral(const double *R__ magIn
, double *R__ cepOut
);
56 void inverse(const float *R__ realIn
, const float *R__ imagIn
, float *R__ realOut
);
57 void inversePolar(const float *R__ magIn
, const float *R__ phaseIn
, float *R__ realOut
);
58 void inverseCepstral(const float *R__ magIn
, float *R__ cepOut
);
60 // Calling one or both of these is optional -- if neither is
61 // called, the first call to a forward or inverse method will call
62 // init(). You only need call these if you don't want to risk
63 // expensive allocations etc happening in forward or inverse.
67 float *getFloatTimeBuffer();
68 double *getDoubleTimeBuffer();