This function calculates various spectral statistics for a complete Wave object, including peak frequency, bandwidth, spectral entropy, spectral flatness, spectral excursion, and spectral energy. It generates an interactive plot with frequency and amplitude traces and includes options to visualize key statistics with lines on the plot.
Usage
spectral_stats(
wave,
specimen_id = "",
locality = "",
sound_type = "",
total_range = FALSE,
robust = TRUE,
db = FALSE,
cutoff = 0.5,
lines = TRUE,
temp = NULL,
hpf = 0
)
Arguments
- wave
A
Wave
object representing the sound data.- specimen_id
Character string for the specimen identifier.
- locality
Character. The locality where the specimen was found.
- sound_type
Character string for the type of sound analyzed.
- total_range
Logical, whether to calculate the full frequency range.
- robust
Logical, whether to use a robust frequency resolution (244 Hz).
- db
Logical. If TRUE, a decibel scale is used. If FALSE (default), a linear scale is used. Both are relative to the peak amplitude in the Wave.
- cutoff
Numeric, threshold for bandwidth calculation. If db = FALSE, set between 0 and 1. If db = TRUE, set to a negative dB value.
- lines
Logical, whether to add lines for min, max, and peak frequencies.
- temp
Numeric, optional, temperature in degrees Celsius.
- hpf
Numeric, optional, high-pass filter cutoff frequency in kHz. Defaults to 0.
Value
A list containing:
data
: A tibble with calculated statistics.plot
: An interactiveplotly
plot with frequency and amplitude traces.
Examples
if (FALSE) { # \dontrun{
wave <- readWave("example.wav")
result <- spectral_stats(wave)
result$plot
} # }