periodogram-methods {tuneR} | R Documentation |
Periodogram (Spectral Density) Estimation on Wave objects
Description
This function estimates one or more periodograms (spectral densities)
of the time series contained in an object of class Wave
or WaveMC
(or directly in a Wave file)
using a window running through the time series (possibly with overlapping).
It returns an object of class Wspec
.
Usage
periodogram(object, ...)
## S4 method for signature 'WaveGeneral'
periodogram(object, width = length(object), overlap = 0,
starts = NULL, ends = NULL, taper = 0, normalize = TRUE,
frqRange = c(-Inf, Inf), ...)
## S4 method for signature 'character'
periodogram(object, width, overlap = 0, from = 1, to = Inf,
units = c("samples", "seconds", "minutes", "hours"),
downsample = NA, channel = c("left", "right"), pieces = 1, ...)
Arguments
object |
An object of class |
width |
A window of width ‘ |
overlap |
The window can be applied by each overlapping |
starts |
Start number (in samples) for a window.
If not given, this value is derived from argument |
ends |
End number (in samples) for a window.
If not given, this value is derived from argument |
taper |
proportion of data to taper. See |
normalize |
Logical; if |
frqRange |
Numeric vector of two elements indicating minimum and maximum of the frequency range that is to be stored in the resulting object. This is useful to reduce memory consumption. |
from |
Where to start reading in the Wave file, in |
to |
Where to stop reading in the Wave file, in |
units |
Units in which |
downsample |
Sampling rate the object is to be downsampled to.
If |
channel |
Character, indicating whether the “left” or “right” channel should be extracted
(see |
pieces |
The Wave file will be read in in |
... |
Further arguments to be passed to the underlying function |
Value
An object of class Wspec
is returned containing the following slots.
freq |
Vector of frequencies at which the spectral density is estimated.
See |
spec |
List of vectors or matrices of the |
kernel |
The kernel argument, or the kernel constructed from spans returned by |
df |
The distribution of the spectral density estimate can be approximated by a chi square distribution with
|
taper |
The value of the |
width |
The value of the |
overlap |
The value of the |
normalize |
The value of the |
starts |
If the argument |
stereo |
Always |
samp.rate |
|
variance |
The variance of samples in each window, corresponding to amplitude / loudness of sound. |
energy |
The “energy”
where |
Those slots marked with “(1)” contain the information once, because it is unique for all periodograms of estimated by the function call.
Note
Support for processing more than one channel of Wave
or WaveMC
objects has not yet been implemented.
Author(s)
Uwe Ligges ligges@statistik.tu-dortmund.de
See Also
for the resulting objects' class:
Wspec
,for plotting:
plot-Wspec
,for the underlying periodogram calculations:
spec.pgram
,for the input data class: Wave-class,
Wave
, WaveMC-class,WaveMC
.
Examples
# constructing a Wave object (1 sec.) containing sinus sound with 440Hz:
Wobj <- sine(440)
Wobj
# Calculate periodograms in windows of 4096 samples each - without
# any overlap - resulting in an Wspec object that is printed:
Wspecobj <- periodogram(Wobj, width = 4096)
Wspecobj
# Plot the first periodogram from Wspecobj:
plot(Wspecobj)
# Plot the third one and choose a reasonable xlim:
plot(Wspecobj, which = 3, xlim = c(0, 1000))
# Mark frequency that has been generated before:
abline(v = 440, col="red")
# plot the spectrogram
image(Wspecobj, ylim=c(0, 2000))
# same again with normalize = FALSE and with logarithmic y-axis plotted:
Wspecobj2 <- periodogram(Wobj, width = 4096, normalize = FALSE)
Wspecobj2
plot(Wspecobj2, which = 3, xlim = c(0, 1000), log="y")
abline(v = 440, col="red")
image(Wspecobj2, ylim=c(0, 2000), log="z")
FF(Wspecobj) # all ~ 440 Hertz
noteFromFF(FF(Wspecobj)) # all diapason a