Skip to contents

This function generates a data frame containing the frequency and amplitude of a wave object using the mean spectrum method. The function leverages the meanspec function from the seewave package to compute the spectrum.

Usage

spectrum_df(
  wave,
  freq_res = 10,
  fun = "mean",
  wn = "hanning",
  verbose = FALSE,
  ...
)

Arguments

wave

An object of class Wave containing the audio data to be analyzed.

freq_res

The frequency resolution to be used for the frequency spectrum analysis. Use this argument consistently for standardized measurements across recordings with different sampling rate. Default is 10 Hz per frequency bin.

fun

Character string indicating the summary function to be applied for computing the mean spectrum. Default is 'mean'. Other options include 'median', 'sd' (standard deviation), or 'var' (variance).

wn

Window filtering function. Choices are: bartlett, blackman, flattop, hamming, hanning, or rectangle. Default is hanning.

verbose

Logical. If TRUE, parameter info is printed in the console.

...

Other arguments passed to meanspec() from the seewave package.

Value

A list with two tibbles. The first tibble "spec_df" with two columns: frequency and amplitude, and the second tibble "params_df" contains all the relevant parameters used to create the spectrum. The frequency column contains the frequencies in Hertz (Hz), and the amplitude column contains the corresponding amplitude values.

Examples

 if (FALSE) { # \dontrun{
spec_df <- meanspec_df(wave, from = 0, to = 5, wl = 1024, fun = 'mean')
} # }