Skip to contents

This function generates a spectrogram from a wave object and applies a cutoff to filter out amplitude values below a specified threshold. The resulting spectrogram can be plotted using either ggplot2 or base R plotting functions.

Usage

spectrogram_cutoff(
  wave,
  cutoff = -60,
  freq.res = 100,
  plot = FALSE,
  plot.title = NULL,
  ggplot = TRUE,
  noise.red = NULL,
  verbose = FALSE
)

Arguments

wave

A Wave object containing the audio data.

cutoff

A numeric value specifying the dB cutoff threshold for the spectrogram. Values below this threshold will be clipped to NA.

plot

A logical value indicating whether to plot the resulting spectrogram. Defaults to FALSE.

plot.title

An optional string specifying the title of the plot. Defaults to NULL.

ggplot

A logical value indicating whether to use ggplot2 for plotting. If FALSE, base R plotting will be used to generate the plot. Defaults to TRUE.

noise.red

Character. Either NULL, 'rows' or 'cols'. Determins if and in which direction to apply noise reduction (mean subtraction).

verbose

Logical. If TRUE, ancillary messages are printed in the console.

Value

Returns the spectrogram matrix with the cutoff applied. If plot = TRUE, a plot of the spectrogram is displayed.

Examples

if (FALSE) { # \dontrun{
wave <- seewave::synth(d=1, f=8000, cf=1000)
spectrogram_cutoff(wave, cutoff = -40, plot = TRUE, plot.title = "Filtered Spectrogram")
} # }