marytts.signalproc.process
Class PitchFrameProvider

java.lang.Object
  extended by marytts.signalproc.process.FrameProvider
      extended by marytts.signalproc.process.PitchFrameProvider
Direct Known Subclasses:
PitchFrameAnalyser

public class PitchFrameProvider
extends FrameProvider

Author:
Marc Schröder Cut frames out of a given signal, and provide them one by one, optionally applying a processor to the frame. This implementation provides non-overlapping frames of varying length, delimited by a series of markers (e.g., pitchmarks).

Field Summary
protected  long currPitchmark
           
protected  double[] cutFrame
           
protected  int[] periodLengths
           
protected  int periodsInMemory
           
protected  DoubleDataSource pitchmarks
           
protected  int shiftPeriods
           
protected  DynamicTwoHalvesWindow twoHalvesWindow
           
 
Fields inherited from class marytts.signalproc.process.FrameProvider
frame, frameLength, frameShift, frameStart, nextFrameStart, processor, samplingRate, signal, totalRead, validSamplesInFrame
 
Constructor Summary
PitchFrameProvider(DoubleDataSource signal, DoubleDataSource pitchmarks, InlineDataProcessor processor, int samplingRate)
          Create a new PitchFrameProvider providing one period at a time.
PitchFrameProvider(DoubleDataSource signal, DoubleDataSource pitchmarks, InlineDataProcessor processor, int samplingRate, int framePeriods, int shiftPeriods)
          Create a new PitchFrameProvider with a configurable number of pitch periods per frame and pitch periods to shift by.
 
Method Summary
 double[] getCurrentFrame()
           
protected  int getData(int nPrefilled)
          Read data from input signal into current frame.
 int getFramePeriods()
          The number of periods provided in one frame.
 double[] getNextFrame()
          Provide the next frame of data.
 int getShiftPeriods()
          The number of periods by which the analysis window is shifted.
 boolean hasMoreData()
          Whether or not this frameprovider can provide another frame.
static void main(java.lang.String[] args)
          Test this pitch frame provider, by printing information about the pitch frames of an audio file.
 
Methods inherited from class marytts.signalproc.process.FrameProvider
getFrameLengthSamples, getFrameLengthTime, getFrameShiftSamples, getFrameShiftTime, getFrameStartSamples, getFrameStartTime, getSamplingRate, resetInternalTimer, stopWhenTouchingEnd, validSamplesInFrame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pitchmarks

protected DoubleDataSource pitchmarks

periodLengths

protected int[] periodLengths

shiftPeriods

protected int shiftPeriods

periodsInMemory

protected int periodsInMemory

currPitchmark

protected long currPitchmark

twoHalvesWindow

protected DynamicTwoHalvesWindow twoHalvesWindow

cutFrame

protected double[] cutFrame
Constructor Detail

PitchFrameProvider

public PitchFrameProvider(DoubleDataSource signal,
                          DoubleDataSource pitchmarks,
                          InlineDataProcessor processor,
                          int samplingRate)
Create a new PitchFrameProvider providing one period at a time.

Parameters:
signal - audio signal
pitchmarks - an array of pitchmarks; each pitch mark is in seconds from signal start
processor - an optional processor to apply to each input frame (e.g., a DynamicWindow)
samplingRate - number of samples per second in signal

PitchFrameProvider

public PitchFrameProvider(DoubleDataSource signal,
                          DoubleDataSource pitchmarks,
                          InlineDataProcessor processor,
                          int samplingRate,
                          int framePeriods,
                          int shiftPeriods)
Create a new PitchFrameProvider with a configurable number of pitch periods per frame and pitch periods to shift by.

Parameters:
signal - audio signal
pitchmarks - an array of pitchmarks; each pitch mark is in seconds from signal start
processor - an optional processor to apply to each input frame (e.g., a DynamicWindow)
samplingRate - number of samples per second in signal
framePeriods - number of periods that each frame should contain
shiftPeriods - number of periods that frames should be shifted by
Method Detail

getData

protected int getData(int nPrefilled)
Read data from input signal into current frame. This implementation will attempt to read up to the next pitch mark, filling the frame from the position given in nPrefilled onwards and extending the size of frame if necessary.
Note that this implementation will perform zero-padding of periods at the beginning and end of the signal: when the first shiftPeriods periods are read, (framePeriods-shiftPeriods) empty periods (zero signal), equal in length to the first period, will be added to the left; after the end of the signal, (framePeriods-shiftPeriods) empty periods (zero signal), equal in length to the last period, will be added to the right.

Overrides:
getData in class FrameProvider
Parameters:
frame - the frame to read into
nPrefilled - number of valid values at the beginning of frame. These should not be lost or overwritten.
Returns:
the number of new values read into frame at position nPrefilled. 0 signals that no further data can be read.

getNextFrame

public double[] getNextFrame()
Provide the next frame of data.

Overrides:
getNextFrame in class FrameProvider
Returns:
the next frame on success, null on failure.

getCurrentFrame

public double[] getCurrentFrame()
Overrides:
getCurrentFrame in class FrameProvider

getFramePeriods

public int getFramePeriods()
The number of periods provided in one frame.

Returns:

getShiftPeriods

public int getShiftPeriods()
The number of periods by which the analysis window is shifted.

Returns:

hasMoreData

public boolean hasMoreData()
Whether or not this frameprovider can provide another frame.

Overrides:
hasMoreData in class FrameProvider

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Test this pitch frame provider, by printing information about the pitch frames of an audio file.

Parameters:
args - two args are expected: the name of an audio file, and the name of the corresponding pitch mark file.
Throws:
java.lang.Exception