Skip to contents

A serializable description of a spectrogram. Build one with setup_SpectrogramConfig() rather than calling this constructor directly.

Usage

SpectrogramConfig(
  dat_path = NULL,
  title = NULL,
  origin = NULL,
  writer = NULL,
  legend_position = "right",
  legend_placement = "outside",
  sample_rate = NULL,
  n_fft = 256L,
  window = "hanning",
  overlap = NULL,
  power = TRUE,
  db = TRUE,
  db_range = 80,
  freq_scale = "linear",
  freq_range = NULL,
  time_range = NULL,
  freq_unit = "Hz",
  time_unit = "s",
  colormap = "magma",
  colormap_reverse = FALSE,
  n_colors = 256L,
  zlim = NULL,
  show_colorbar = TRUE,
  colorbar_title = NULL,
  xlab = NULL,
  ylab = NULL,
  margin_top = NULL,
  margin_right = NULL,
  margin_bottom = NULL,
  margin_left = NULL
)

Arguments

dat_path

Optional Character: Path to the data, read at draw time. The serializable alternative to passing data to draw().

title

Optional Character: Chart title. Declared here because it is the one property every chart type has; palette is not (four take a colormap instead), and axis labels and margins are cartesian-only.

origin

Optional Named character {"user", "default", "derived"}: Where each value came from, one entry per settable property. Absent on an authored config; written by the interface that resolved it.

writer

Optional Named character: Which interface wrote the config, as name and version. Absent on an authored config.

legend_position

Character {"top", "bottom", "left", "right", "top-left", "top-right", "bottom-left", "bottom-right"}: Legend anchor. Top/bottom anchors use horizontal rows; left/right anchors use a vertical column. Corner anchors align within the top or bottom row.

legend_placement

Character {"outside", "inside"}: Relation to the plotting area. Outside placement reserves space for the complete legend; inside placement overlays the data. Neither setting adds a missing legend.

sample_rate

Optional Numeric [0, Inf): Signal sample rate in Hz.

n_fft

Integer [2, Inf): FFT window length.

window

Character: Window function.

overlap

Optional Numeric [0, 1): Fractional window overlap.

power

Logical: Use the power spectrum rather than magnitude.

db

Logical: Convert to decibels.

db_range

Numeric [0, Inf): Dynamic range in dB below the peak.

freq_scale

Character {"linear", "log", "mel"}: Frequency axis scale.

freq_range, time_range

Optional Numeric: Axis limits, length 2.

freq_unit, time_unit

Character: Axis units, for the labels.

colormap

Character: Continuous color scheme, or two or more hex colors defining one.

colormap_reverse

Logical: Reverse the color scheme.

n_colors

Integer [2, Inf): Number of discrete colors.

zlim

Optional Numeric: Color-scale limits, length 2.

show_colorbar

Logical: Draw the color bar.

colorbar_title

Optional Character: Color bar title.

xlab, ylab

Optional Character: Axis labels.

margin_top, margin_right, margin_bottom, margin_left

Optional Integer [0, Inf): Override the auto-computed margins, per side.

Value

SpectrogramConfig object.

Details

The bound data is either a numeric signal vector, which is transformed with a short-time Fourier transform, or a precomputed frequency-by-time matrix.

Author

EDG

Examples

setup_SpectrogramConfig(n_fft = 512L)@type
#> [1] "spectrogram"