spectralslice {phonTools}R Documentation

Spectral Slice

Description

A function to plot the power spectrum of a vector representing a sound wave.

Usage

spectralslice (sound, padding = length(sound) * 2, fs = 1,  
show = TRUE, add = FALSE, window = "kaiser", 
windowparameter = 3, zeromax = TRUE, preemphasisf = 0, type, 
line = FALSE, removeDC = TRUE, ...)

Arguments

sound

A vector representing a sound wave, or a 'sound' object.

padding

The amount of zero-padding desired for the analysis, in number of samples.

fs

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

show

If FALSE, no plot is created.

add

If TRUE, the spectrum is added to an existing plot. If FALSE a new one is created.

window

The window to be applied to the signal, applied by windowfunc(), provided in this package.

windowparameter

The parameter for the window to be applied to the signal, if appropriate. Passed to windowfunc().

zeromax

If TRUE, the maximum dB is set to 0.

type

The line type to be used for plotting, passes its value to the 'lty' parameter.

preemphasisf

Preemphasis of 3 dB per octave is added to frequencies above the specified frequency.

line

If TRUE, a line spectrum is created.

removeDC

If TRUE, the DC component is removed.

...

any additional arguments will be passed to the internal calls of 'plot' or 'lines'.

Value

A dataframe with the following elements is returned:

hz

The center frequency of the analysis bins.

dB

The dB magnitude/power for the analysis bin.

Author(s)

Santiago Barreda <sbarreda@ucdavis.edu>

Examples


## synthesize schwa-like vowel 
#vowel = vowelsynth (ffs = c(500,1500,2500,3500,4500))$sound
    
## compare window lengths
#par (mfrow = c(3,1))
#spectralslice (vowel[500:550], fs = 10000)
#spectralslice (vowel[500:1000], fs = 10000)
     
## line spectrum
#spectralslice (vowel[500:600], padding = 0, line = TRUE, fs = 10000)


[Package phonTools version 0.2-2.2 Index]