marytts.signalproc.analysis
Class FrameBasedAnalyser<T>

java.lang.Object
  extended by marytts.signalproc.process.FrameProvider
      extended by marytts.signalproc.analysis.FrameBasedAnalyser<T>
Direct Known Subclasses:
EnergyAnalyser, F0Tracker.CandidateEstimator, LpcAnalyser, ShortTermAutocorrelationAnalyser, ShortTermCepstrumAnalyser, ShortTermSpectrumAnalyser

public abstract class FrameBasedAnalyser<T>
extends FrameProvider

Author:
Marc Schröder The base class for all frame-based signal analysis algorithms

Nested Class Summary
static class FrameBasedAnalyser.FrameAnalysisResult<T>
           
 
Field Summary
protected  FrameBasedAnalyser.FrameAnalysisResult<T>[] analysisResults
          Array containing the analysis results, filled by analyseAllFrames().
 
Fields inherited from class marytts.signalproc.process.FrameProvider
frame, frameLength, frameShift, frameStart, nextFrameStart, processor, samplingRate, signal, totalRead, validSamplesInFrame
 
Constructor Summary
FrameBasedAnalyser(DoubleDataSource signal, Window window, int frameShift, int samplingRate)
          Initialise a FrameBasedAnalyser.
 
Method Summary
abstract  T analyse(double[] frame)
          Apply this FrameBasedAnalyser to the given data.
 FrameBasedAnalyser.FrameAnalysisResult<T>[] analyseAllFrames()
          Analyse the entire signal as frames.
 FrameBasedAnalyser.FrameAnalysisResult<T>[] analyseAvailableFrames()
          Analyse the currently available input signal as frames.
 FrameBasedAnalyser.FrameAnalysisResult<T> analyseNextFrame()
          The public method to call in order to trigger the analysis of the next frame.
protected  FrameBasedAnalyser.FrameAnalysisResult<T> constructAnalysisResult(T analysisResult)
           
 
Methods inherited from class marytts.signalproc.process.FrameProvider
getCurrentFrame, getData, getFrameLengthSamples, getFrameLengthTime, getFrameShiftSamples, getFrameShiftTime, getFrameStartSamples, getFrameStartTime, getNextFrame, getSamplingRate, hasMoreData, main, resetInternalTimer, stopWhenTouchingEnd, validSamplesInFrame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

analysisResults

protected FrameBasedAnalyser.FrameAnalysisResult<T>[] analysisResults
Array containing the analysis results, filled by analyseAllFrames(). Can be used for future reference to the results.

Constructor Detail

FrameBasedAnalyser

public FrameBasedAnalyser(DoubleDataSource signal,
                          Window window,
                          int frameShift,
                          int samplingRate)
Initialise a FrameBasedAnalyser.

Parameters:
signal - the signal source to read from
window - the window function to apply to each frame
frameShift - the number of samples by which to shift the window from one frame analysis to the next; if this is smaller than window.getLength(), frames will overlap.
samplingRate - the number of samples in one second.
Method Detail

analyseNextFrame

public FrameBasedAnalyser.FrameAnalysisResult<T> analyseNextFrame()
The public method to call in order to trigger the analysis of the next frame.

Returns:
the analysis result, or null if no part of the signal is left to analyse.

analyseAllFrames

public FrameBasedAnalyser.FrameAnalysisResult<T>[] analyseAllFrames()
Analyse the entire signal as frames. Stop as soon as the first frame reaches or passes the end of the signal. Repeated access to this method returns a stored version of the results.

Returns:
an array containing all frame analysis results.

analyseAvailableFrames

public FrameBasedAnalyser.FrameAnalysisResult<T>[] analyseAvailableFrames()
Analyse the currently available input signal as frames. This method is intended for live signals such as microphone data. Stop when the amount of data available from the input is less than one frame length. Repeated access to this method will read new data if new data has become available in the meantime.

Returns:
an array containing the frame analysis results for the data that is currently available, or an empty array if no new data is available.

analyse

public abstract T analyse(double[] frame)
Apply this FrameBasedAnalyser to the given data.

Parameters:
frame - the data to analyse, which must be of the length prescribed by this FrameBasedAnalyser, i.e. by @see{#getFrameLengthSamples()}.
Returns:
An analysis result. The data type depends on the concrete analyser.
Throws:
java.lang.IllegalArgumentException - if frame does not have the prescribed length

constructAnalysisResult

protected FrameBasedAnalyser.FrameAnalysisResult<T> constructAnalysisResult(T analysisResult)