Skip to contents

This function generates a spectrogram plot using Plotly, allowing for customization of frequency resolution, amplitude normalization, and plot appearance. It can display the spectrogram in decibels (dBFS) or linear scale, apply a minimum amplitude threshold, and customize the plot with dark themes and grid settings.

Usage

spectrogram_plotly(
  wave,
  norm = FALSE,
  freq.res = 100,
  overlap = 50,
  zp = 0,
  min.amp = -60,
  dark.plot = FALSE,
  grid = TRUE,
  plot.title = NULL
)

Arguments

wave

A Wave object representing the audio signal to be analyzed.

norm

Logical. If TRUE, the amplitude values are normalized. Defaults to FALSE.

freq.res

Numeric. The frequency resolution in Hz, which determines the window length for the spectrogram. Defaults to 100.

overlap

Numeric. The percentage overlap between successive windows in the spectrogram. Defaults to 50.

min.amp

Numeric. The minimum amplitude threshold in decibels (dB) for the spectrogram. Values below this will be clipped. Defaults to -60 dB.

dark.plot

Logical. If TRUE, applies a dark theme to the plot. Defaults to FALSE.

grid

Logical. If TRUE, grid lines are shown in the plot. Defaults to TRUE.

plot.title

Character. Optional. A title for the plot. If NULL, no title is displayed. Defaults to NULL.

Value

A Plotly object containing the spectrogram heatmap.

Examples

# Load a Wave object
data(orni)
#> Warning: data set 'orni' not found
# Generate a Plotly spectrogram
p <- spectrogram_plotly(orni, norm = TRUE, freq.res = 200, min.amp = -50, dark.plot = TRUE, plot.title = "Spectrogram")
#> Error: object 'orni' not found
p
#> Error: object 'p' not found