This function processes an audio signal to detect broadband activity by identifying 'clicks' based on time-frame-wise (i.e., column-wise) amplitude changes in the spectrogram. It computes statistics related to click height, variance, and centroid frequency, and can plot a spectrogram with detected clicks highlighted. Included in this package to explore its potential for monitoring the activity of non-stridulating pests in stored food or wood. The function obtains a non-normalized spectrogram with seewave's spectro() using a row-wise noise reduction procedure and transforms the amplitude values to decibels full-scale (dBFS).
Usage
broadband_activity(
wave,
channel = "left",
hpf = 0,
rm.offset = TRUE,
freq.res = 50,
cutoff = -60,
click.length = 10,
difference = 10,
gap.allowance = 2,
spectrogram = FALSE,
dark.plot = FALSE,
plot.title = NULL,
verbose = TRUE
)
Arguments
- wave
A
Wave
object containing the audio signal to be analyzed.- channel
Character. If Wave is stereo and you want to use only one channel, pass either "left" or "right" to this argument. If you want to analyze a mix of both channels, select "mix". If NULL (default), results are returned for each channel.
- hpf
Numeric. High-pass filter. The default (500 Hz) should be used always for consistency unless signals of interest are below that threshold.
- rm.offset
Logical. Should the DC offset be removed from the audio signal? Defaults to
TRUE
.- freq.res
Numeric. Frequency resolution in Hz. This value determines the "height" of each frequency bin and, therefore, the window length to be used (sampling rate / frequency resolution).
- cutoff
Numeric. The amplitude threshold (in dBFS) for removing low-amplitude values in the spectrogram. Default is
-50
.- click.length
Numeric. The minimum length (in frequency bins) for a detected click to be kept. Default is
10
.- difference
Numeric. The maximum difference in amplitude between adjacent frequency bins to be considered part of a single 'click'. Default is
20
.- gap.allowance
Numeric. The size of gaps (in frequency bins) allowed between contiguous parts of a click. Default is
2
. Gaps larger than this value will split clicks.- spectrogram
Logical. Should a spectrogram with highlighted clicks be plotted? Default is
TRUE
.- dark.plot
Logical. Should the plot use a dark theme (black background)? Default is
FALSE
.- plot.title
Character. The title for the plot, if
plot
isTRUE
. Default isNULL
.- verbose
Logical. If TRUE, details of dynamic range will be printed on the console.
Value
A tibble containing the following columns:
index
: The name of the index. Useful later when merging data with other indices.value
: The number of clicks detected in the recording.mean
: The mean click height (in frequency bins).variance
: The variance of the click height.sd
: The standard deviation of the click height.