be.hogent.tarsos.dsp
Class AudioEvent

java.lang.Object
  extended by be.hogent.tarsos.dsp.AudioEvent

public class AudioEvent
extends java.lang.Object

An audio event flows through the processing pipeline. The object is reused for performance reasons. The arrays with audio information are also reused, so watch out when using the buffer getter and setters.

Author:
Joren Six

Constructor Summary
AudioEvent(javax.sound.sampled.AudioFormat format, long frameLength)
           
 
Method Summary
static double calculateRMS(float[] floatBuffer)
          Calculates and returns the root mean square of the signal.
 void clearFloatBuffer()
           
 int getBufferSize()
           
 byte[] getByteBuffer()
          Return a byte array with the audio data in bytes.
 float[] getFloatBuffer()
           
 int getOverlap()
           
 double getProgress()
          Calculate the progress in percentage of the total number of frames.
 double getRMS()
          Calculates and returns the root mean square of the signal.
 float getSampleRate()
           
 long getSamplesProcessed()
           
 double getTimeStamp()
          Calculates and returns the time stamp at the beginning of this audio event.
 boolean isSilence(double silenceThreshold)
           
 void setBytesProcessed(long bytesProcessed)
           
 void setFloatBuffer(float[] floatBuffer)
           
 void setOverlap(int newOverlap)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AudioEvent

public AudioEvent(javax.sound.sampled.AudioFormat format,
                  long frameLength)
Method Detail

getSampleRate

public float getSampleRate()

getBufferSize

public int getBufferSize()

getOverlap

public int getOverlap()

setOverlap

public void setOverlap(int newOverlap)

setBytesProcessed

public void setBytesProcessed(long bytesProcessed)

getTimeStamp

public double getTimeStamp()
Calculates and returns the time stamp at the beginning of this audio event.

Returns:
The time stamp at the beginning of the event in seconds.

getSamplesProcessed

public long getSamplesProcessed()

getProgress

public double getProgress()
Calculate the progress in percentage of the total number of frames.

Returns:
a percentage of processed frames or a negative number if the number of frames is not known beforehand.

getByteBuffer

public byte[] getByteBuffer()
Return a byte array with the audio data in bytes. A conversion is done from float, cache accordingly on the other side...

Returns:
a byte array with the audio data in bytes.

setFloatBuffer

public void setFloatBuffer(float[] floatBuffer)

getFloatBuffer

public float[] getFloatBuffer()

getRMS

public double getRMS()
Calculates and returns the root mean square of the signal. Please cache the result since it is calculated every time.

Returns:
The RMS of the signal present in the current buffer.

calculateRMS

public static double calculateRMS(float[] floatBuffer)
Calculates and returns the root mean square of the signal. Please cache the result since it is calculated every time.

Parameters:
floatBuffer - The audio buffer to calculate the RMS for.
Returns:
The RMS of the signal present in the current buffer.

clearFloatBuffer

public void clearFloatBuffer()

isSilence

public boolean isSilence(double silenceThreshold)