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 Details

    • Spectrogram

      public Spectrogram​(AudioData wave, int fftLength, int fftHop)
      Create the spectrogram from a clip of sound data
      Parameters:
      wave - - the clip of sound data
      fftLength - - the FFT length in samples
      fftHop - - 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

      public static double[][] buildAbsoluteSpectram​(ComplexArray[] complexSpectrogram)
      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

      public ComplexArray[] 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

      public ComplexArray[] getComplexSpectrogram()
      Get the spectrogram with both magnitude and phase information.
      Returns:
      array of ComplaxArray where each ComplexArray is an FFT.
    • setComplexSpectrogram

      public void setComplexSpectrogram​(ComplexArray[] complexSpectrogram)
      Set the spectrogram with both magnitude and phase information.
      Parameters:
      array - of ComplaxArray where each ComplexArray is an FFT.