public class FFT extends FourierTransform
timeSize
that is not a power of two, an IllegalArgumentException will be
thrown.FourierTransform
,
The Fast Fourier Transformaverages, avgPerOctave, bandWidth, BARTLETT, BARTLETTHANN, BLACKMAN, COSINE, GAUSS, HAMMING, HANN, imag, LANCZOS, LINAVG, LOGAVG, NOAVG, NONE, octaves, real, sampleRate, spectrum, timeSize, TRIANGULAR, TWO_PI, whichAverage, windowFunction
Constructor and Description |
---|
FFT(int timeSize,
float sampleRate)
Constructs an FFT that will accept sample buffers that are
timeSize long and have been recorded with a sample rate of
sampleRate . |
Modifier and Type | Method and Description |
---|---|
protected void |
allocateArrays() |
void |
forward(float[] buffer)
Performs a forward transform on
buffer . |
void |
forward(float[] buffReal,
float[] buffImag)
Performs a forward transform on the passed buffers.
|
void |
forward(float[] buffer,
int startAt)
Performs a forward transform on values in
buffer . |
void |
inverse(float[] buffer)
Performs an inverse transform of the frequency spectrum and places the
result in
buffer . |
void |
scaleBand(int i,
float s)
Scales the amplitude of the
ith frequency band
by s . |
void |
setBand(int i,
float a)
Sets the amplitude of the
ith frequency band to
a . |
avgSize, calcAvg, doWindow, fillSpectrum, forward, forward, freqToIndex, getAverageCenterFrequency, getAvg, getBand, getBandWidth, getFreq, getSpectrumImaginary, getSpectrumReal, indexToFreq, inverse, inverse, linAverages, logAverages, noAverages, scaleFreq, setComplex, setFreq, specSize, timeSize, window
public FFT(int timeSize, float sampleRate)
timeSize
long and have been recorded with a sample rate of
sampleRate
. timeSize
must be a
power of two. This will throw an exception if it is not.timeSize
- the length of the sample buffers you will be analyzingsampleRate
- the sample rate of the audio you will be analyzingprotected void allocateArrays()
allocateArrays
in class FourierTransform
public void scaleBand(int i, float s)
FourierTransform
ith
frequency band
by s
. You can use this to shape the spectrum before using
inverse()
.scaleBand
in class FourierTransform
i
- the frequency band to modifys
- the scaling factorpublic void setBand(int i, float a)
FourierTransform
ith
frequency band to
a
. You can use this to shape the spectrum before using
inverse()
.setBand
in class FourierTransform
i
- the frequency band to modifya
- the new amplitudepublic void forward(float[] buffer)
FourierTransform
buffer
.forward
in class FourierTransform
buffer
- the buffer to analyzepublic void forward(float[] buffer, int startAt)
FourierTransform
buffer
.forward
in class FourierTransform
buffer
- the buffer of samplesstartAt
- the index to start at in the buffer. there must be at least timeSize() samples
between the starting index and the end of the buffer. If there aren't, an
error will be issued and the operation will not be performed.public void forward(float[] buffReal, float[] buffImag)
buffReal
- the real part of the time domain signal to transformbuffImag
- the imaginary part of the time domain signal to transformpublic void inverse(float[] buffer)
FourierTransform
buffer
.inverse
in class FourierTransform
buffer
- the buffer to place the result of the inverse transform in