Package org.jamdev.jpamutils.spectrogram
Class Spectrogram
java.lang.Object
org.jamdev.jpamutils.spectrogram.Spectrogram
public class Spectrogram extends Object
Class which converts raw wave data into a spectrgram and can perform some
basic transforms.
- Author:
- Jamie Macaulay
-
Constructor Summary
Constructors Constructor Description Spectrogram(AudioData wave, int fftLength, int fftHop)Create the spectrogram from a clip of sound data -
Method Summary
Modifier and Type Method Description static double[][]buildAbsoluteSpectram(ComplexArray[] complexSpectrogram)Builds the absolute spectrogram from the complex arraydouble[][]getAbsoluteSpectrogram()Calculates the absolute spectrogram.ComplexArray[]getComplexSpectrogram()Get the spectrogram with both magnitude and phase information.ComplexArray[]getFFTData()Get the raw spectrogram data.intgetFFTHop()Get the FFT hop in samples.intgetFFTLength()Get the FFT length in samples.intgetFramesPerSecond()Get the number of FFT units per seconddoublegetFrequencyBinSize()Get the frequency width of frequency binsintgetNumFrames()Get the total number of FFT binsfloatgetSampleRate()Get the sample rate in samples per second.voidsetComplexSpectrogram(ComplexArray[] complexSpectrogram)Set the spectrogram with both magnitude and phase information.
-
Constructor Details
-
Spectrogram
Create the spectrogram from a clip of sound data- Parameters:
wave- - the clip of sound datafftLength- - the FFT length in samplesfftHop- - the spectrogram hop size to use in samples.
-
-
Method Details
-
getAbsoluteSpectrogram
public double[][] getAbsoluteSpectrogram()Calculates the absolute spectrogram. Note this is not saved within the Spectrogram object and so is recalculated every time this function is called.- Returns:
- the absolute spectrogram
-
buildAbsoluteSpectram
Builds the absolute spectrogram from the complex array- Returns:
- the absolute spectrogram.
-
getNumFrames
public int getNumFrames()Get the total number of FFT bins- Returns:
- the number of FFT bins
-
getFramesPerSecond
public int getFramesPerSecond()Get the number of FFT units per second- Returns:
- the number of FFT units per second
-
getFrequencyBinSize
public double getFrequencyBinSize()Get the frequency width of frequency bins- Returns:
- the bin size in Hz
-
getFFTData
Get the raw spectrogram data. This is a complex array containing both the phase and amplitude information- Returns:
- complex array with each array one FFT slice of the spectrogram.
-
getSampleRate
public float getSampleRate()Get the sample rate in samples per second.- Returns:
- the sample rate.
-
getFFTLength
public int getFFTLength()Get the FFT length in samples.- Returns:
- the FFT length in samples
-
getFFTHop
public int getFFTHop()Get the FFT hop in samples.- Returns:
- the FFT hop in samples.
-
getComplexSpectrogram
Get the spectrogram with both magnitude and phase information.- Returns:
- array of ComplaxArray where each ComplexArray is an FFT.
-
setComplexSpectrogram
Set the spectrogram with both magnitude and phase information.- Parameters:
array- of ComplaxArray where each ComplexArray is an FFT.
-