Learn R Programming

phonTools (version 0.1-6)

powertrack: Waveform power track

Description

Display power as a function of time.

Usage

powertrack (sound, timestep = 2, windowlength = timestep, fs = 22050, 
smoothing = .03, show = TRUE, output = FALSE, ...)

Arguments

sound
A numeric vector representing a waveform, or a 'sound' object created with the loadsound() or makesound() functions.
timestep
Determines how far the window will be moved for each adjacent analysis, in milliseconds. The minimum permissible timestep is 0.1 milliseconds.
windowlength
Determines how much of the signal is included for each analysis step, in milliseconds. By default this is set to be equal to the timestep, resulting in no overlap.
fs
The sampling frequency of the sound. If a 'sound' object is passed, this does not need to be specified.
smoothing
This is passed to an internal call of lowess() and acts as the 'f' parameter for that function. A larger number will result in greater smoothing. For no smoothing set this to 0 or to a negative number.
show
If TRUE, the track is plotted.
output
If TRUE, a dataframe containing timesteps, and power at each timestep is returned.
...
Additional parameters are passed to the internal call of plot(), and used to create the figure.

Value

  • A dataframe with the following columns:
  • timethe time, in milliseconds, of each point of analysis.
  • powerthe power, in decibels, at each analysis point.

Details

First, a series of points spanning the signal, in steps equal to 'timestep', are determined. For each point, the average power within the analysis window is found. The window length is determined by the 'windowlength' parameter, and each window is centered about each analysis point. The output is expressed in decibels, where peak power is set to 0 dB. If smoothing is set to a value greater than 0, the power track is smoothed using lowess() to minimize pitch-synchronous variation in signal power.

References

Lyons, R. G. (2004). Understanding Digital Signal Processing (2nd ed.). Prentice Hall.

Examples

Run this code
## plot the waveform and power of a given sound.
data (sound)
# sound = loadsound()        ## run this line to use you own sound

## compare waveform and power
multiplot (2); par (mar = c(4,4,1,1));
plot (sound)
powertrack (sound)

Run the code above in your browser using DataLab