Skip to contents

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. The function also classifies whether the signal contains noise or insect based on the variance and centroid frequencies of the clicks.

Usage

bbai(
  wave,
  channel = "left",
  hpf = 0,
  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.

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.

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 is TRUE. Default is NULL.

verbose

Logical. If TRUE, details of dynamic range will be printed on the console.

click.height

Numeric. The minimum height (in frequency bins) for a detected click to be kept. Default is 10.

Value

A tibble and optional spectrogram.

Examples

bbai(wave)
#> Error: object 'wave' not found