pl-nk v0.4.5
Plonk|Plink|Plank are a set of cross-platform C/C++ frameworks for audio software development
Typedefs | Functions
Plank FFTF class
Plank classes

A simple, cross-platform FFT processor for audio signals. More...

Typedefs

typedef struct PlankFFTF * PlankFFTFRef
 An opaque reference to the Plank FFTF object.

Functions

PlankFFTFRef pl_FFTF_CreateAndInit ()
 Create and initialise a Plank FFTF object and return an oqaque reference to it.
PlankFFTFRef pl_FFTF_Create ()
 Create a Plank FFTF object and return an oqaque reference to it.
PlankResult pl_FFTF_Init (PlankFFTFRef p)
 Initialise a Plank FFTF object with a default length (PLANKFFTF_DEFAULTLENGTH).
PlankResult pl_FFTF_InitWithLength (PlankFFTFRef p, const PlankL length)
 Initialise a Plank FFTF object.
PlankResult pl_FFTF_DeInit (PlankFFTFRef p)
 Deinitialise a Plank FFTF object.
PlankResult pl_FFTF_Destroy (PlankFFTFRef p)
 Destroy a Plank FFTF object.
void pl_FFTF_Forward (PlankFFTFRef p, float *output, const float *input)
 Apply the FFT to the input and place the result in output.
void pl_FFTF_Inverse (PlankFFTFRef p, float *output, const float *input)
 Apply the inverse-FFT to the input and place the result in output.
PlankL pl_FFTF_Length (PlankFFTFRef p)
 Get the FFT size.
PlankL pl_FFTF_HalfLength (PlankFFTFRef p)
 Get half FFT size.
float * pl_FFTF_Temp (PlankFFTFRef p)
 Get a pointer to the internal temporary buffer.

Detailed Description

A simple, cross-platform FFT processor for audio signals.

This must be allocated/deallocated using pl_FFTF_Create() and pl_FFTF_Destroy(), a statically alloacted version is not currently available.

This makes use of other underlying libraries on request. By default it uses FFTReal (via the Plank FFTRealInternal class). To use vDSP on Mac OS X or iOS define the preprocessor macro PLANK_FFT_VDSP.

 PlankFFTFRef fft;
 float input[128];
 float output[128];
 int i;
 fft = pl_FFTF_Create (128); // create with FFT size 128
 
 // fill the buffer
 for (i = 0; i < 128; i++)
 {
    input[i] = i / 127.f;
 }
 
 pl_FFTF_Forward (fft, output, input); // perform the forward FFT, the result will be in output
 pl_FFTF_Destroy (fft); // destroy the FFT object

The layout of the resulting FFT bins is in a "packed" format which omits the imaginary components of the DC and Nyquist bins (as these are always zero anyway). This means that the size of the data input and output fits in the same memory size.

For the FFT size of 128 illustrated by the code snippet:


Typedef Documentation

typedef struct PlankFFTF* PlankFFTFRef

An opaque reference to the Plank FFTF object.


Function Documentation

PlankFFTFRef pl_FFTF_Create ( )

Create a Plank FFTF object and return an oqaque reference to it.

Returns:
A Plank FFTF object as an opaque reference.
PlankFFTFRef pl_FFTF_CreateAndInit ( )

Create and initialise a Plank FFTF object and return an oqaque reference to it.

Returns:
A Plank FFTF object as an opaque reference.
PlankResult pl_FFTF_DeInit ( PlankFFTFRef  p)

Deinitialise a Plank FFTF object.

Parameters:
pThe Plank FFTF object.
Returns:
A result code which will be PlankResult_OK if the operation was completely successful.
PlankResult pl_FFTF_Destroy ( PlankFFTFRef  p)

Destroy a Plank FFTF object.

Parameters:
pThe Plank FFTF object.
Returns:
A result code which will be PlankResult_OK if the operation was completely successful.
void pl_FFTF_Forward ( PlankFFTFRef  p,
float *  output,
const float *  input 
)

Apply the FFT to the input and place the result in output.

This may be performed in-place (i.e., input and output can point to the same data).

Parameters:
pThe Plank FFTF object.
outputA pointer to an array of floats to store the result.
inputA pointer to an array of floats holding the input data.
PlankL pl_FFTF_HalfLength ( PlankFFTFRef  p)

Get half FFT size.

This is just as a convenience as it is already cached for efficiency.

Parameters:
pThe Plank FFTF object.
Returns:
The half FFT size.
PlankResult pl_FFTF_Init ( PlankFFTFRef  p)

Initialise a Plank FFTF object with a default length (PLANKFFTF_DEFAULTLENGTH).

Parameters:
pThe Plank FFTF object.
Returns:
A result code which will be PlankResult_OK if the operation was completely successful.
PlankResult pl_FFTF_InitWithLength ( PlankFFTFRef  p,
const PlankL  length 
)

Initialise a Plank FFTF object.

Parameters:
pThe Plank FFTF object.
lengthThe FFT size - this must be a power of 2 or less than 16 (where it will specify the log2 FFT size e.g., length 8 = pow(2,8) = 256
Returns:
A result code which will be PlankResult_OK if the operation was completely successful.
void pl_FFTF_Inverse ( PlankFFTFRef  p,
float *  output,
const float *  input 
)

Apply the inverse-FFT to the input and place the result in output.

This may be performed in-place (i.e., input and output can point to the same data).

Parameters:
pThe Plank FFTF object.
outputA pointer to an array of floats to store the result.
inputA pointer to an array of floats holding the input data.
PlankL pl_FFTF_Length ( PlankFFTFRef  p)

Get the FFT size.

Parameters:
pThe Plank FFTF object.
Returns:
The FFT size.
float* pl_FFTF_Temp ( PlankFFTFRef  p)

Get a pointer to the internal temporary buffer.

This is an array of floats the size of the FFT. This could be useful as a scratch space to save allocating more memory. Of course its contents may be invalidated by any other Plank FFTF calls.

Parameters:
pThe Plank FFTF object.
Returns:
A pointer to the temporary float buffer.
 All Classes Functions Typedefs Enumerations Enumerator Properties