onsets

maelzel.snd.features.onsets(samples, sr, winsize=2048, hopsize=512, threshold=0.07, mingap=0.05, backtrack=False)[source]

Detect onsets

This is based on rosita, a minimal version of librosa with some fixes and simplifications (it avoids having to add numba as a dependency)

The onset detection algorithm uses the variation in mel spectrum to calculate an onset strength in time. Peaks above the given threshold are detected as onsets.

Parameters:
  • samples (ndarray) – mono samples

  • sr (int) – sr

  • winsize – the size of the fft window

  • hopsize – samples to skip between windows

  • threshold – the delta needed to trigger an onset

  • mingap – min. time gap between onsets

  • backtrack – detected onsets are backtracked to the nearest energy minimum

Return type:

tuple[ndarray, BpfBase]

Returns:

a tuple (onset array, onset strength bpf)