periodogram: Periodogram (Spectral Density) Estimation on Wave objects

Description Usage Arguments Value Note Author(s) See Also Examples

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

1
2
3
4
5
6
7
8
9
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 Wave, WaveMC, or a character string pointing to a Wave file.

width

A window of width ‘width’ running through the time series selects the samples from which the periodograms are to be calculated.

overlap

The window can be applied by each overlapping overlap samples.

starts

Start number (in samples) for a window. If not given, this value is derived from argument ends, or will be derived width and overlap.

ends

End number (in samples) for a window. If not given, this value is derived from argument starts, or will be derived from width and overlap.

taper

proportion of data to taper. See spec.pgram for details.

normalize

Logical; if TRUE (default), two steps will be applied: (i) the input signal will be normalized to amplitude max(abs(amplitude)) == 1, (ii) the resulting spec values will be normalized to sum up to one for each periodogram.

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 units.

to

Where to stop reading in the Wave file, in units.

units

Units in which from and to is given, the default is “samples”, but can be set to time intervals such as “seconds”, see the Usage Section above.

downsample

Sampling rate the object is to be downsampled to. If NA, the default, no changes are applied. Otherwise downsample must be in [2000, 192000]; typical values are 11025, 22050, and 44100 for CD quality. See also downsample.

channel

Character, indicating whether the “left” or “right” channel should be extracted (see mono for details) - stereo processing is not yet implemented.

pieces

The Wave file will be read in in pieces steps in order to reduce the amount of required memory.

...

Further arguments to be passed to the underlying function spec.pgram.

Value

An object of class Wspec is returned containing the following slots.

freq

Vector of frequencies at which the spectral density is estimated. See spectrum for details. (1)

spec

List of vectors or matrices of the spec values returned by spec.pgram at frequencies corresponding to freq. Each element of the list corresponds to one periodogram estimated from samples of the window beginning at start of the Wave or WaveMC object.

kernel

The kernel argument, or the kernel constructed from spans returned by spec.pgram. (1)

df

The distribution of the spectral density estimate can be approximated by a chi square distribution with df degrees of freedom. (1)

taper

The value of the taper argument. (1)

width

The value of the width argument. (1)

overlap

The value of the overlap argument. (1)

normalize

The value of the normalize argument. (1)

starts

If the argument starts was given in the call, its value. If the argument ends was given in the call, ‘ends - width’. If neither starts nor ends was given, the start points of all periodograms. In the latter case the start points are calculated from the arguments width and overlap.

stereo

Always FALSE (for back compatibility). (1)

samp.rate

Sampling rate of the underlying Wave or WaveMC object. (1)

variance

The variance of samples in each window, corresponding to amplitude / loudness of sound.

energy

The “energy” E, also an indicator for the amplitude / loudness of sound:

E(x_I) := 20 * log_{10} sum_{j in I} |x_j|,

where I indicates the interval I:= start[i]:end[i] for all 1:=1,..., length(starts).

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 [email protected]

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# 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")

FF(Wspecobj)              # all ~ 440 Hertz
noteFromFF(FF(Wspecobj))  # all diapason a

tuneR documentation built on May 31, 2017, 4:48 a.m.

Related to periodogram in tuneR...