public class FourierTransform extends AudioProcessor
getLastFFT()
to get the
last generated frequency domain calculation.
The class also includes an inverse transform function that takes a
frequency domain array (such as that delivered by getLastFFT()
)
and returns a SampleChunk
. The format of the output sample chunk
is determined by the given audio format.
Constructor and Description |
---|
FourierTransform()
Default constructor for ad-hoc processing.
|
FourierTransform(AudioStream as)
Constructor for chaining.
|
Modifier and Type | Method and Description |
---|---|
float[][] |
getLastFFT()
Get the last processed FFT frequency data.
|
float[][] |
getMagnitudes()
Returns the magnitudes of the last FFT data.
|
float[][] |
getNormalisedMagnitudes(float scalar)
Scales the real and imaginary parts by the scalar prior to
calculating the (square) magnitude for normalising the outputs.
|
float[][] |
getPowerMagnitudes()
Returns the power magnitudes of the last FFT data.
|
float[][] |
getReals()
Returns just the real numbers from the last FFT.
|
float |
getScalingFactor()
Get the scaling factor in use.
|
static SampleChunk |
inverseTransform(AudioFormat format,
float[][] transformedData)
Given some transformed audio data, will convert it back into
a sample chunk.
|
boolean |
isPadToNextPowerOf2()
Returns whether the input will be padded to be the length
of the next higher power of 2.
|
SampleBuffer |
process(SampleBuffer sb)
Process the given sample buffer
|
SampleChunk |
process(SampleChunk sample)
Function that takes a sample chunk and processes the chunk.
|
void |
setPadToNextPowerOf2(boolean padToNextPowerOf2)
Set whether to pad the input to the next power of 2.
|
void |
setScalingFactor(float scalingFactor)
Set the scaling factor to use.
|
getLength, getUnderlyingStream, nextSampleChunk, process, processingComplete, reset, setUnderlyingStream
iterator, seek
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public FourierTransform()
public FourierTransform(AudioStream as)
as
- The stream to chain topublic SampleChunk process(SampleChunk sample)
process
in class AudioProcessor
sample
- The sample chunk to process.AudioProcessor.process(org.openimaj.audio.SampleChunk)
public SampleBuffer process(SampleBuffer sb)
sb
- The sample bufferpublic static SampleChunk inverseTransform(AudioFormat format, float[][] transformedData)
format
- The required format for the outputtransformedData
- The frequency domain dataSampleChunk
public float[][] getLastFFT()
public float[][] getMagnitudes()
public float[][] getPowerMagnitudes()
10log10( real^2 + imaginary^2 )
public float[][] getNormalisedMagnitudes(float scalar)
scalar
- The scalarpublic float[][] getReals()
public float getScalingFactor()
public void setScalingFactor(float scalingFactor)
scalingFactor
- The scaling factor to use.public boolean isPadToNextPowerOf2()
public void setPadToNextPowerOf2(boolean padToNextPowerOf2)
padToNextPowerOf2
- TRUE to pad the input, FALSE otherwise