Smooths x^2 with a energy_window_ms boxcar and flags samples
where the smoothed energy crosses threshold_factor * median(energy).
Hysteresis: returns to "off" only when energy drops below baseline.
Usage
morie_dsp_onset_detect(x, fs, energy_window_ms = 20, threshold_factor = 3)
Arguments
- x
Numeric vector.
- fs
Sampling frequency (Hz).
- energy_window_ms
Smoothing window (ms). Default 20.
- threshold_factor
Multiplier on baseline median. Default 3.
Value
Integer vector of onset indices.
References
Rangayyan & Krishnan (2015), Ch. 4, sec. 4.5.
Examples
set.seed(1L)
x <- c(0.01 * rnorm(200), 5 + 0.01 * rnorm(200))
morie_dsp_onset_detect(x, fs = 1000, energy_window_ms = 5, threshold_factor = 3)
#> [1] 12 26 54 68 93 108 141 177 196