be.hogent.tarsos.dsp
Class PercussionOnsetDetector

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

public class PercussionOnsetDetector
extends java.lang.Object
implements AudioProcessor

Estimates the locations of percussive onsets using a simple method described in "Drum Source Separation using Percussive Feature Detection and Spectral Modulation" by Dan Barry, Derry Fitzgerald, Eugene Coyle and Bob Lawlor, ISSC 2005.

Implementation based on a VAMP plugin example by Chris Cannam at Queen Mary, London:

  Centre for Digital Music, Queen Mary, University of London.
  Copyright 2006 Chris Cannam.
    
  Permission is hereby granted, free of charge, to any person
  obtaining a copy of this software and associated documentation
  files (the "Software"), to deal in the Software without
  restriction, including without limitation the rights to use, copy,
  modify, merge, publish, distribute, sublicense, and/or sell copies
  of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:
  
  The above copyright notice and this permission notice shall be
  included in all copies or substantial portions of the Software.
  
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
  ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  
  Except as contained in this notice, the names of the Centre for
  Digital Music; Queen Mary, University of London; and Chris Cannam
  shall not be used in advertising or otherwise to promote the sale,
  use or other dealings in this Software without prior written
  authorization.
 

Author:
Joren Six, Chris Cannam

Nested Class Summary
static interface PercussionOnsetDetector.PercussionHandler
          Describes a simple interface to handle percussion onsets: a time stamp (in seconds) signifies the onset.
 
Field Summary
static double DEFAULT_SENSITIVITY
           
static double DEFAULT_THRESHOLD
           
 
Constructor Summary
PercussionOnsetDetector(float sampleRate, int bufferSize, int bufferOverlap, PercussionOnsetDetector.PercussionHandler handler)
          Create a new percussion onset detector.
PercussionOnsetDetector(float sampleRate, int bufferSize, PercussionOnsetDetector.PercussionHandler handler, double sensitivity, double threshold)
          Create a new percussion onset detector.
 
Method Summary
 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_THRESHOLD

public static final double DEFAULT_THRESHOLD
See Also:
Constant Field Values

DEFAULT_SENSITIVITY

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

PercussionOnsetDetector

public PercussionOnsetDetector(float sampleRate,
                               int bufferSize,
                               int bufferOverlap,
                               PercussionOnsetDetector.PercussionHandler handler)
Create a new percussion onset detector. With a default sensitivity and threshold.

Parameters:
sampleRate - The sample rate in Hz (used to calculate timestamps)
bufferSize - The size of the buffer in samples.
bufferOverlap - The overlap of buffers in samples.
handler - An interface implementor to handle percussion onset events.

PercussionOnsetDetector

public PercussionOnsetDetector(float sampleRate,
                               int bufferSize,
                               PercussionOnsetDetector.PercussionHandler handler,
                               double sensitivity,
                               double threshold)
Create a new percussion onset detector.

Parameters:
sampleRate - The sample rate in Hz (used to calculate timestamps)
bufferSize - The size of the buffer in samples.
handler - An interface implementor to handle percussion onset events.
sensitivity - Sensitivity of the peak detector applied to broadband detection function (%). In [0-100].
threshold - Energy rise within a frequency bin necessary to count toward broadband total (dB). In [0-20].
Method Detail

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