com.meapsoft
Class STFT

java.lang.Object
  extended bycom.meapsoft.STFT

public class STFT
extends java.lang.Object

A class to extract and hold STFT info from an AudioInputStream. Calls listeners when a new frame is added. Calculates the log magnitude spectrogram.


Field Summary
 int nhop
           
 float samplingRate
           
 
Constructor Summary
STFT(javax.sound.sampled.AudioInputStream input, int frameLen, int history)
           
STFT(javax.sound.sampled.AudioInputStream input, int frameLen, int hopsize, int history)
           
 
Method Summary
 void addFrameListener(FrameListener fl)
           
 void bytes2doubles(byte[] audioBytes, double[] audioData)
           
 long fr2Samp(long frAddr)
           
 double fr2Seconds(long frAddr)
           
 int getColumns()
           
 double[] getFrame(long frAddr)
           
 long getLastFrameAddress()
          Get the frame address of the last frame read into this object.
 int getRows()
           
 double[] getSamples(long frStart, long frEnd)
           
static RingMatrix getSTFT(double[] samples, int nfft)
          Get the STFT of samples, with no overlap between frames
static RingMatrix getSTFT(double[] samples, int nfft, int nhop)
          Get the STFT of samples
 void notifyListeners(long frAddr)
           
 int readFrames(long nframes)
          Fill this STFT object with up to the next nframes frames of data.
 void removeFrameListener(FrameListener fl)
           
 long samp2fr(long sampAddr)
           
 long seconds2fr(double sec)
           
 void setFrame(long frAddr, double[] dat)
           
 long start()
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

samplingRate

public float samplingRate

nhop

public int nhop
Constructor Detail

STFT

public STFT(javax.sound.sampled.AudioInputStream input,
            int frameLen,
            int hopsize,
            int history)

STFT

public STFT(javax.sound.sampled.AudioInputStream input,
            int frameLen,
            int history)
Method Detail

start

public long start()

getSamples

public double[] getSamples(long frStart,
                           long frEnd)

fr2Samp

public long fr2Samp(long frAddr)

samp2fr

public long samp2fr(long sampAddr)

getFrame

public double[] getFrame(long frAddr)

setFrame

public void setFrame(long frAddr,
                     double[] dat)

getColumns

public int getColumns()

getRows

public int getRows()

addFrameListener

public void addFrameListener(FrameListener fl)

removeFrameListener

public void removeFrameListener(FrameListener fl)

notifyListeners

public void notifyListeners(long frAddr)

bytes2doubles

public void bytes2doubles(byte[] audioBytes,
                          double[] audioData)

fr2Seconds

public double fr2Seconds(long frAddr)

seconds2fr

public long seconds2fr(double sec)

getSTFT

public static RingMatrix getSTFT(double[] samples,
                                 int nfft)
Get the STFT of samples, with no overlap between frames


getSTFT

public static RingMatrix getSTFT(double[] samples,
                                 int nfft,
                                 int nhop)
Get the STFT of samples


readFrames

public int readFrames(long nframes)
Fill this STFT object with up to the next nframes frames of data.

Parameters:
nframes - number of audio frames to read
Returns:
the number of frames actually read (will be less than nframes if the end of the audio data is reached first.

getLastFrameAddress

public long getLastFrameAddress()
Get the frame address of the last frame read into this object.


stop

public void stop()
          throws java.io.IOException
Throws:
java.io.IOException