Package com.badlogic.gdx.audio.analysis
Class FFT
java.lang.Object
com.badlogic.gdx.audio.analysis.FourierTransform
com.badlogic.gdx.audio.analysis.FFT
FFT stands for Fast Fourier Transform. It is an efficient way to calculate the Complex Discrete Fourier Transform. There is not
much to say about this class other than the fact that when you want to analyze the spectrum of an audio buffer you will almost
always use this class. One restriction of this class is that the audio buffers you want to analyze must have a length that is a
power of two. If you try to construct an FFT with a
timeSize that is not a power of two, an
IllegalArgumentException will be thrown.- See Also:
-
Field Summary
Fields inherited from class com.badlogic.gdx.audio.analysis.FourierTransform
HAMMING, NONE -
Constructor Summary
ConstructorsConstructorDescriptionFFT(int timeSize, float sampleRate) Constructs an FFT that will accept sample buffers that aretimeSizelong and have been recorded with a sample rate ofsampleRate. -
Method Summary
Modifier and TypeMethodDescriptionvoidforward(float[] buffer) Performs a forward transform onbuffer.voidforward(float[] buffReal, float[] buffImag) Performs a forward transform on the passed buffers.voidinverse(float[] buffer) Performs an inverse transform of the frequency spectrum and places the result inbuffer.voidscaleBand(int i, float s) Scales the amplitude of theithfrequency band bys.voidsetBand(int i, float a) Sets the amplitude of theithfrequency band toa.Methods inherited from class com.badlogic.gdx.audio.analysis.FourierTransform
avgSize, calcAvg, forward, freqToIndex, getAverageCenterFrequency, getAvg, getBand, getBandWidth, getFreq, getImaginaryPart, getRealPart, getSpectrum, getTimeSize, indexToFreq, inverse, linAverages, logAverages, noAverages, scaleFreq, setFreq, specSize, timeSize, window
-
Constructor Details
-
FFT
public FFT(int timeSize, float sampleRate) Constructs an FFT that will accept sample buffers that aretimeSizelong and have been recorded with a sample rate ofsampleRate.timeSizemust be a power of two. This will throw an exception if it is not.- Parameters:
timeSize- the length of the sample buffers you will be analyzingsampleRate- the sample rate of the audio you will be analyzing
-
-
Method Details
-
scaleBand
public void scaleBand(int i, float s) Description copied from class:FourierTransformScales the amplitude of theithfrequency band bys. You can use this to shape the spectrum before usinginverse().- Specified by:
scaleBandin classFourierTransform- Parameters:
i- the frequency band to modifys- the scaling factor
-
setBand
public void setBand(int i, float a) Description copied from class:FourierTransformSets the amplitude of theithfrequency band toa. You can use this to shape the spectrum before usinginverse().- Specified by:
setBandin classFourierTransform- Parameters:
i- the frequency band to modifya- the new amplitude
-
forward
public void forward(float[] buffer) Description copied from class:FourierTransformPerforms a forward transform onbuffer.- Specified by:
forwardin classFourierTransform- Parameters:
buffer- the buffer to analyze
-
forward
public void forward(float[] buffReal, float[] buffImag) Performs a forward transform on the passed buffers.- Parameters:
buffReal- the real part of the time domain signal to transformbuffImag- the imaginary part of the time domain signal to transform
-
inverse
public void inverse(float[] buffer) Description copied from class:FourierTransformPerforms an inverse transform of the frequency spectrum and places the result inbuffer.- Specified by:
inversein classFourierTransform- Parameters:
buffer- the buffer to place the result of the inverse transform in
-