Skip to contents

This function processes an sound 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_folder(
  folder = NULL,
  recursive = FALSE,
  list = NULL,
  start = 0,
  end = 1,
  unit = "minutes",
  channel = "each",
  hpf = 0,
  freq.res = 50,
  cutoff = -60,
  click.length = 10,
  difference = 10,
  gap.allowance = 2,
  spectrogram = FALSE,
  dark.plot = FALSE,
  plot.title = "",
  verbose = FALSE,
  output.csv = "bbai_results.csv",
  n.cores = -1
)

Arguments

folder

Character. The path to a folder with the wave files to analyze.

recursive

Logical. Whether to search in subfolders. Default is TRUE.

list

An optional list (subset) of files in the folder to analyze. If provided, files outside the list will be excluded.

start

numerical. Where to start reading the Wave.

end

numerical. Where to end reading the Wave.

unit

character. Unit of measurement for 'start' and 'end'. Options are 'samples', 'seconds', 'minutes', 'hours'. Default is 'minutes'.

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.

output.csv

Character. Name for the csv file. Default is "bbai_results.csv".

n.cores

Numeric. Number of cores to be used in parallel. Use -1 (Default) to use all but one.

click.height

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

Value

A tibble.

Examples

if (FALSE) { # \dontrun{
bbai_folder(path/to/folder)
} # }