Learn R Programming

phonTools (version 0.2-2.2)

powertrack: Power tracking

Description

Create a power track for a sound.

Usage

powertrack (sound, timestep = 5, windowlength = 30, 
            fs = 22050, show = TRUE, zeromax = TRUE, ...)

Value

A dataframe with the following columns:

time

The time, in milliseconds, of each point of analysis.

power

The power, in decibels, at each analysis point.

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.

windowlength

Determines how much of the signal is included for each analysis step, in milliseconds. If this is too small, pitch-synchronous ripples will be seen in the track.

fs

The sampling frequency of the sound. If a 'sound' or 'ts' object is passed, this does not need to be specified.

show

If TRUE, the track is plotted.

zeromax

If TRUE, the maximum dB value is set to zero.

...

Additional parameters are passed to the internal call of plot(), and used to create the figure.

Author

Santiago Barreda <sbarreda@ucdavis.edu>

Details

Returns the average power in the signal in a section as determined by the parameters of the function. A Hann window is applied to each section prior to analysis. Sections with zero power are ignored and not returned.

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
#par (mfrow = c(2,1), mar = c(4,4,1,1));
#plot (sound)
#powertrack (sound)

Run the code above in your browser using DataLab