Added onset detection functions