inpro.pitch
Class PitchTracker

java.lang.Object
  extended by edu.cmu.sphinx.util.props.ConfigurableAdapter
      extended by edu.cmu.sphinx.frontend.BaseDataProcessor
          extended by inpro.pitch.PitchTracker
All Implemented Interfaces:
edu.cmu.sphinx.frontend.DataProcessor, edu.cmu.sphinx.util.props.Configurable
Direct Known Subclasses:
LookAheadPitchTracker

public class PitchTracker
extends edu.cmu.sphinx.frontend.BaseDataProcessor

Data Processor for voicing-decision and pitch tracking. pitch tracking usually consists of several steps: - preprocessing (e. g. low pass filtering) - period candidate generation (score, auto-correlation, cross-correlation, normalized cross-correlation) - candidate refinement (e. g. thresholding of candidates) - voicing decision and final path determination (dynamic programming, ...)


Field Summary
private  double candidateScoreThreshold
          TODO: IS THIS CORRECT?
protected static boolean debug
           
private  double energyThreshold
          the silence threshold below which we don't do any pitch extraction (this avoids division by zero, and especially reduces processing overhead)
private  double lastBestPitch
          for tracking, we have to keep track of the previously selected lag
private  java.util.List<SignalFeatureListener> listeners
           
private  int maxLag
           
private  int minLag
           
private static double NO_LAST_BEST_PITCH
           
private  java.util.concurrent.ArrayBlockingQueue<PitchedDoubleData> pitchAssignmentQueue
          pitch can only be assigned to a PitchedDoubleData object a little later, when this data is in the center of the signalBuffer (not the newest data on the right of the buffer) but we don't want to buffer the objects before we output them; we therefore output the PDD objects immediately, keep reference to them in this queue and fill in the pitch values once they have been calculated.
static java.lang.String PROP_CAND_SCORE_THRESHOLD
           
static java.lang.String PROP_LISTENERS
           
static java.lang.String PROP_MAX_PITCH_HZ
           
static java.lang.String PROP_MIN_PITCH_HZ
           
private static float SAMPLING_FREQUENCY
           
private  double[] signalBuffer
           
 
Fields inherited from class edu.cmu.sphinx.util.props.ConfigurableAdapter
logger
 
Constructor Summary
PitchTracker()
           
 
Method Summary
 double[] amdf(double[] signal)
          calculate score of a given signalBuffer and downsample the signalBuffer on the way.
(package private) static PitchCandidate bestCandidateSelection(java.util.List<PitchCandidate> candidates)
          select the candidate with the highest quality (deepest minimum in the lagScoreTrajectory
 double[] cmn(double[] smdsf)
          cumulative mean normalization
static void functionalTest(java.lang.String[] args, edu.cmu.sphinx.util.props.ConfigurationManager cm)
           
 edu.cmu.sphinx.frontend.Data getData()
           
private static java.util.Queue<java.lang.Double> getReferencePitch(java.lang.String filename)
           
static void main(java.lang.String[] args)
           
 void newProperties(edu.cmu.sphinx.util.props.PropertySheet ps)
           
(package private)  double parabolicInterpolation(double alpha, double beta, double gamma)
           
private  java.util.List<PitchCandidate> qualityThresheldCandidates(double[] lagScoreTrajectory)
          pick global minima in the lagScoreFunction that are smaller than candidateScoreThreshold as candidates and return the least lag.
private  void signalListeners(PitchCandidate selectedCandidate, java.util.List<PitchCandidate> candidates)
          signal listeners, and apply values to first element of queue
private static PitchCandidate simplisticCandidateSelection(java.util.List<PitchCandidate> candidates)
          select the first candidate (with the highest f0)
 double[] smdsf(double[] signal)
          calculate the sum magnitude difference square function of a signal.
static void speedTest(edu.cmu.sphinx.frontend.BaseDataProcessor fe)
           
(package private)  PitchCandidate trackingCandidateSelection(java.util.List<PitchCandidate> candidates)
          select lag of the candidate that is closest to the most recently selected lag (which is recorded in lastBestPitch)
 
Methods inherited from class edu.cmu.sphinx.frontend.BaseDataProcessor
getPredecessor, getTimer, initialize, setPredecessor
 
Methods inherited from class edu.cmu.sphinx.util.props.ConfigurableAdapter
getName, initLogger, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SAMPLING_FREQUENCY

private static final float SAMPLING_FREQUENCY
See Also:
Constant Field Values

PROP_CAND_SCORE_THRESHOLD

@S4Double(defaultValue=0.15)
public static final java.lang.String PROP_CAND_SCORE_THRESHOLD
See Also:
Constant Field Values

candidateScoreThreshold

private double candidateScoreThreshold
TODO: IS THIS CORRECT? a lower threshold will lead to more (potentially less reliable) candidates


PROP_MIN_PITCH_HZ

@S4Double(defaultValue=66.66666666)
public static final java.lang.String PROP_MIN_PITCH_HZ
See Also:
Constant Field Values

maxLag

private int maxLag

PROP_MAX_PITCH_HZ

@S4Double(defaultValue=500.0)
public static final java.lang.String PROP_MAX_PITCH_HZ
See Also:
Constant Field Values

minLag

private int minLag

energyThreshold

private double energyThreshold
the silence threshold below which we don't do any pitch extraction (this avoids division by zero, and especially reduces processing overhead)


signalBuffer

private double[] signalBuffer

pitchAssignmentQueue

private java.util.concurrent.ArrayBlockingQueue<PitchedDoubleData> pitchAssignmentQueue
pitch can only be assigned to a PitchedDoubleData object a little later, when this data is in the center of the signalBuffer (not the newest data on the right of the buffer) but we don't want to buffer the objects before we output them; we therefore output the PDD objects immediately, keep reference to them in this queue and fill in the pitch values once they have been calculated. The size of the queue (and hence the lag with which pitch becomes available) depends on the size of the signalBuffer, which in turn depends on PROP_MIN_PITCH_HZ.


PROP_LISTENERS

@S4ComponentList(type=SignalFeatureListener.class)
public static final java.lang.String PROP_LISTENERS
See Also:
Constant Field Values

listeners

private java.util.List<SignalFeatureListener> listeners

debug

protected static final boolean debug
See Also:
Constant Field Values

NO_LAST_BEST_PITCH

private static final double NO_LAST_BEST_PITCH
See Also:
Constant Field Values

lastBestPitch

private double lastBestPitch
for tracking, we have to keep track of the previously selected lag

Constructor Detail

PitchTracker

public PitchTracker()
Method Detail

amdf

public double[] amdf(double[] signal)
calculate score of a given signalBuffer and downsample the signalBuffer on the way. NOTE: this is currently not used in the algorithm implemented below.


smdsf

public double[] smdsf(double[] signal)
calculate the sum magnitude difference square function of a signal.


cmn

public double[] cmn(double[] smdsf)
cumulative mean normalization


qualityThresheldCandidates

private java.util.List<PitchCandidate> qualityThresheldCandidates(double[] lagScoreTrajectory)
pick global minima in the lagScoreFunction that are smaller than candidateScoreThreshold as candidates and return the least lag.

Returns:
the least lag of all the candidates considered

trackingCandidateSelection

PitchCandidate trackingCandidateSelection(java.util.List<PitchCandidate> candidates)
select lag of the candidate that is closest to the most recently selected lag (which is recorded in lastBestPitch)

Parameters:
candidates -
Returns:
the selected candidate

simplisticCandidateSelection

private static PitchCandidate simplisticCandidateSelection(java.util.List<PitchCandidate> candidates)
select the first candidate (with the highest f0)


bestCandidateSelection

static PitchCandidate bestCandidateSelection(java.util.List<PitchCandidate> candidates)
select the candidate with the highest quality (deepest minimum in the lagScoreTrajectory


parabolicInterpolation

double parabolicInterpolation(double alpha,
                              double beta,
                              double gamma)

getData

public edu.cmu.sphinx.frontend.Data getData()
                                     throws edu.cmu.sphinx.frontend.DataProcessingException
Specified by:
getData in interface edu.cmu.sphinx.frontend.DataProcessor
Specified by:
getData in class edu.cmu.sphinx.frontend.BaseDataProcessor
Throws:
edu.cmu.sphinx.frontend.DataProcessingException

signalListeners

private void signalListeners(PitchCandidate selectedCandidate,
                             java.util.List<PitchCandidate> candidates)
signal listeners, and apply values to first element of queue

Parameters:
selectedCandidate - or null if no candidate/voiceless

newProperties

public void newProperties(edu.cmu.sphinx.util.props.PropertySheet ps)
                   throws edu.cmu.sphinx.util.props.PropertyException
Specified by:
newProperties in interface edu.cmu.sphinx.util.props.Configurable
Overrides:
newProperties in class edu.cmu.sphinx.util.props.ConfigurableAdapter
Throws:
edu.cmu.sphinx.util.props.PropertyException

getReferencePitch

private static java.util.Queue<java.lang.Double> getReferencePitch(java.lang.String filename)

functionalTest

public static void functionalTest(java.lang.String[] args,
                                  edu.cmu.sphinx.util.props.ConfigurationManager cm)
                           throws edu.cmu.sphinx.util.props.PropertyException,
                                  edu.cmu.sphinx.frontend.DataProcessingException
Throws:
edu.cmu.sphinx.util.props.PropertyException
edu.cmu.sphinx.frontend.DataProcessingException

speedTest

public static void speedTest(edu.cmu.sphinx.frontend.BaseDataProcessor fe)
                      throws edu.cmu.sphinx.frontend.DataProcessingException
Throws:
edu.cmu.sphinx.frontend.DataProcessingException

main

public static void main(java.lang.String[] args)