# periodogram-methods

##### Periodogram (Spectral Density) Estimation on Wave objects

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`

.

- Keywords
- ts

##### Usage

```
periodogram(object, ...)
# S4 method for WaveGeneral
periodogram(object, width = length(object), overlap = 0,
starts = NULL, ends = NULL, taper = 0, normalize = TRUE,
frqRange = c(-Inf, Inf), ...)
# S4 method for 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.

Vector of frequencies at which the spectral density is estimated.
See `spectrum`

for details. (1)

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.

The kernel argument, or the kernel constructed from spans returned by `spec.pgram`

. (1)

The distribution of the spectral density estimate can be approximated by a chi square distribution with
`df`

degrees of freedom. (1)

The value of the `taper`

argument. (1)

The value of the `width`

argument. (1)

The value of the `overlap`

argument. (1)

The value of the `normalize`

argument. (1)

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`

.

Always `FALSE`

(for back compatibility). (1)

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

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
\(i:=1,\dots,\) `length(starts)`

.

##### Note

Support for processing more than one channel of `Wave`

or `WaveMC`

objects has not yet been implemented.

##### 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

```
# NOT RUN {
# 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
# }
```

*Documentation reproduced from package tuneR, version 1.3.3, License: GPL-2 | GPL-3*