View Source NxAudio.Transforms.SpectrogramConfig (nx_audio v0.2.0)

Configuration options for spectrogram transformation.

Summary

Types

t()
  • :n_fft (non_neg_integer/0) - Size of FFT, creates n_fft // 2 + 1 bins. The default value is 400.

Types

t()

@type t() :: [
  n_fft: non_neg_integer(),
  win_length: non_neg_integer(),
  hop_length: non_neg_integer(),
  pad: non_neg_integer(),
  window_fn: term(),
  power: float(),
  normalized: term(),
  wkwargs: keyword(),
  center: boolean(),
  pad_mode: atom(),
  onesided: boolean()
]
  • :n_fft (non_neg_integer/0) - Size of FFT, creates n_fft // 2 + 1 bins. The default value is 400.

  • :win_length (non_neg_integer/0) - Number of samples in each frame. By default its half of the n_fft

  • :hop_length (non_neg_integer/0) - Number of samples between successive frames., By default its half of the n_fft

  • :pad (non_neg_integer/0) - Two sided padding of signal. The default value is 0.

  • :window_fn (term/0) - Window function to apply to each frame. The default value is &NxAudio.Commons.Windows.haan/1.

  • :power (float/0) - Exponent for the magnitude spectrogram, (must be > 0) e.g., 1 for magnitude, 2 for power, etc. If None, then the complex spectrum is returned instead. The default value is 2.

  • :normalized - Whether to normalize by magnitude after stft. choices are "window" and "frame_length", if specific normalization type is desirable.

  • :wkwargs (keyword/0) - Arguments for window function. The default value is [].

  • :center (boolean/0) - Whether to pad waveform on both sides so that the t-th frame is centered at time t * hop_length. The default value is true.

  • :pad_mode (atom/0) - Controls the padding method used when center is true. The default value is :reflect.

  • :onesided (boolean/0) - Controls whether to return half of results to avoid redundancy. The default value is true.

Functions

maybe_calculate_hop_length(hop_length, win_length)

maybe_calculate_win_length(win_length, n_fft)

validate(config)

Parses and validate a keyword list into a valid spectrogram config