be.hogent.tarsos.util.histogram
Class PitchHistogram

java.lang.Object
  extended by be.hogent.tarsos.util.histogram.Histogram
      extended by be.hogent.tarsos.util.histogram.PitchHistogram
All Implemented Interfaces:
java.lang.Cloneable

public final class PitchHistogram
extends Histogram

The PitchHistogram accepts values from 0 to 9600 cents or +- from 16Hz to 40000Hz: the human hearing range is completely covered.
The start and stop values can be configured.
Values outside the defined range are ignored!

Author:
Joren Six

Constructor Summary
PitchHistogram()
           
 
Method Summary
static double[] createAccumulator(java.util.List<Annotation> annotations, double width)
           
static PitchHistogram createPitchHistogram(java.util.List<Annotation> annotations, double width)
          Create a tone scale histogram using a kernel instead of an ordinary count.
 PitchClassHistogram mostEnergyRichOctaves(int numberOfOctaves)
           
 PitchClassHistogram mostEnergyRitchOctave()
           
 PitchClassHistogram pitchClassHistogram()
           
 void plot(java.lang.String fileName, java.lang.String title)
          Plots the histogram to a x y plot.
 void plotAmbitusHistogram(java.lang.String fileName)
          Plot the complete ambitus.
 void plotAmbitusHistogram(java.lang.String fileName, int start, int stop)
          Plot the ambitus but use only values between start and stop (cents).
 void plotToneScaleHistogram(java.lang.String fileName, boolean splitOctaves)
          Saves a tone scale histogram plot with each octave separately or just the total.
 void valueAddedHook(double value)
          A hook to intercept added values.
 
Methods inherited from class be.hogent.tarsos.util.histogram.Histogram
add, add, add, addToEachBin, baselineHistogram, clear, clone, correlation, correlation, correlationWithDisplacement, correlationWithDisplacement, displace, displacementForOptimalCorrelation, displacementForOptimalCorrelation, export, exportMatLab, gaussianSmooth, getAbsoluteSumFreq, getClassWidth, getCount, getCountForClass, getCumFreq, getCumPct, getEntropy, getKeyForClass, getMaxBinCount, getMean, getMedian, getNumberOfClasses, getPct, getStart, getStop, getSumFreq, invert, isWrapped, keySet, max, mean, multiply, normalize, plotCorrelation, raise, setCount, smooth, subtract, toString, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PitchHistogram

public PitchHistogram()
Method Detail

valueAddedHook

public void valueAddedHook(double value)
Description copied from class: Histogram
A hook to intercept added values.

Overrides:
valueAddedHook in class Histogram
Parameters:
value - The value added

mostEnergyRichOctaves

public PitchClassHistogram mostEnergyRichOctaves(int numberOfOctaves)
Parameters:
numberOfOctaves - The number of energy rich octaves
Returns:
a PitchClassHistogram containing only samples from the numberOfOctaves most energy rich octaves.

pitchClassHistogram

public PitchClassHistogram pitchClassHistogram()
Returns:
the ambitus folded to one octave (1200 cents)

plotAmbitusHistogram

public void plotAmbitusHistogram(java.lang.String fileName)
Plot the complete ambitus.

Parameters:
fileName -

plotAmbitusHistogram

public void plotAmbitusHistogram(java.lang.String fileName,
                                 int start,
                                 int stop)
Plot the ambitus but use only values between start and stop (cents).

Parameters:
fileName - the plot is saved to this location.
start - the starting value
stop - stopping value

mostEnergyRitchOctave

public PitchClassHistogram mostEnergyRitchOctave()

plotToneScaleHistogram

public void plotToneScaleHistogram(java.lang.String fileName,
                                   boolean splitOctaves)
Saves a tone scale histogram plot with each octave separately or just the total.

Parameters:
fileName - the plot is saved to this location.
splitOctaves - if true each octave is separated, otherwise only the total is shown.

plot

public void plot(java.lang.String fileName,
                 java.lang.String title)
Description copied from class: Histogram
Plots the histogram to a x y plot. The file is saved in PNG file format so the fileName should end on PNG.

Overrides:
plot in class Histogram
Parameters:
fileName - The file is saved in PNG file format so the fileName should end on PNG.
title - The title of the histogram. Use an empty string or null for an empty title.

createPitchHistogram

public static PitchHistogram createPitchHistogram(java.util.List<Annotation> annotations,
                                                  double width)
Create a tone scale histogram using a kernel instead of an ordinary count. This construction uses a paradigm described here: http://en.wikipedia.org/wiki/Kernel_density_estimation It uses Gaussian kernels of a defined width. The width should be around the just noticeable threshold of about 7 cents.

Parameters:
annotations - A list of annotations.s
width - The width of each kernel.
Returns:
A histogram build with Gaussian kernels.

createAccumulator

public static double[] createAccumulator(java.util.List<Annotation> annotations,
                                         double width)