Learn R Programming

phonTools (version 0.2-2.0)

pitchtrack: Pitch Tracking

Description

Create a pitch track for a sound.

Usage

pitchtrack (sound, f0range = c(60,400), timestep = 2, fs = 22050, minacf = .5,
correction = TRUE, show = TRUE, windowlength = 50, addtospect = FALSE)

Arguments

sound
A numeric vector representing a waveform, or a 'sound' object created with the loadsound() or makesound() functions.
f0range
A numeric vector of length two where the first value corresponds to the minimum f0 Hz to be considered, and the second represents the maximum to be considered.
timestep
How far the analysis window will advance, in milliseconds. If this value is set to zero, the function is applied to the entire signal.
fs
The sampling frequency of the sound. If a 'sound' or 'ts' object is passed, this does not need to be specified.
minacf
Autocorrelation values below this are ignored.
correction
If TRUE, ACF values are corrected for lag value.
show
If TRUE, a plot displaying the pitch track is created.
windowlength
The length of the analysis window, in milliseconds. This should be approximately three-times longer than the wavelength of the lowest pitch. The default value is appropriate for a floor of 60 Hz.
addtospect
If TRUE, the pitch track is added to a spectrogram created with the spectrogram() function included in this package. The track is scaled up by a factor of 10 (e.g., 100 Hz will be plotted at 1000 Hz on the spectrogram) so that it will fit nicely in the ty

Value

  • A dataframe with the following columns:
  • timeThe analysis window centre point, in milliseconds.
  • f0The calculated f0 (pitch).
  • acfThe value of the autocorrelation function corresponding to the winning f0.

Details

Pitch tracking is carried out using a simplified version of the algorithm described in Boersma (1993), including corrections for lag value and window function. When plotting pitch tracks, the points sizes are proportional to autocorrelation values.

References

Boersma, P., (1993). Accurate short-term analysis of the fundamental frequency and the harmonics-to-noise ratio of a sampled sound. Proc. Instit. Phon. Sci. 17: 97-110.

Examples

Run this code
data (sound)               ## use the example 'sound' object provided
#sound = loadsound()       ## or run this line to use you own sound

## to generate a pitch track
output = pitchtrack (sound)

## to add a pitch to a spectrogram
#spectrogram (sound)
#pitchtrack (sound, addtospect = TRUE)

Run the code above in your browser using DataLab