be.hogent.tarsos.dsp
Class SilenceDetector

java.lang.Object
  extended by be.hogent.tarsos.dsp.SilenceDetector
All Implemented Interfaces:
AudioProcessor

public class SilenceDetector
extends java.lang.Object
implements AudioProcessor

The continuing silence detector does not break the audio processing pipeline when silence is detected.


Field Summary
static double DEFAULT_SILENCE_THRESHOLD
           
 
Constructor Summary
SilenceDetector()
          Create a new silence detector with a default threshold.
SilenceDetector(double silenceThreshold, boolean breakProcessingQueueOnSilence)
          Create a new silence detector with a defined threshold.
 
Method Summary
 double currentSPL()
           
 boolean isSilence(float[] buffer)
           
 boolean isSilence(float[] buffer, double silenceThreshold)
          Checks if the dBSPL level in the buffer falls below a certain threshold.
 boolean process(AudioEvent audioEvent)
          Process the audio event.
 void processingFinished()
          Notify the AudioProcessor that no more data is available and processing has finished.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SILENCE_THRESHOLD

public static final double DEFAULT_SILENCE_THRESHOLD
See Also:
Constant Field Values
Constructor Detail

SilenceDetector

public SilenceDetector()
Create a new silence detector with a default threshold.


SilenceDetector

public SilenceDetector(double silenceThreshold,
                       boolean breakProcessingQueueOnSilence)
Create a new silence detector with a defined threshold.

Parameters:
silenceThreshold - The threshold which defines when a buffer is silent (in dB). Normal values are [-70.0,-30.0] dB SPL.
breakProcessingQueueOnSilence -
Method Detail

currentSPL

public double currentSPL()

isSilence

public boolean isSilence(float[] buffer,
                         double silenceThreshold)
Checks if the dBSPL level in the buffer falls below a certain threshold.

Parameters:
buffer - The buffer with audio information.
silenceThreshold - The threshold in dBSPL
Returns:
True if the audio information in buffer corresponds with silence, false otherwise.

isSilence

public boolean isSilence(float[] buffer)

process

public boolean process(AudioEvent audioEvent)
Description copied from interface: AudioProcessor
Process the audio event. Do the actual signal processing on an (optionally) overlapping buffer.

Specified by:
process in interface AudioProcessor
Parameters:
audioEvent - The audio event that contains audio data.
Returns:
False if the chain needs to stop here, true otherwise. This can be used to implement e.g. a silence detector.

processingFinished

public void processingFinished()
Description copied from interface: AudioProcessor
Notify the AudioProcessor that no more data is available and processing has finished. Can be used to deallocate resources or cleanup.

Specified by:
processingFinished in interface AudioProcessor