Skip to main content

OnsetDetector

Detects the onsets (note attacks / transients) in an audio stream in real time.

TypeNameInterface Description
Functionsconstructor()

FunctionsgetResult(): number

Function: Gets the current onset detection result. The value represents the onset energy of the current audio frame. A higher value indicates a stronger note attack or transient.

Returns The onset energy value in the range [0, 1024], or -1 when no result is available.

Examples

constructor()

let obj = new APJS.OnsetDetector();

Use Case

@component()
export class NewBehaviourScript extends APJS.BasicScriptComponent {
onStart() {
// TODO: instantiate / use OnsetDetector here
}
onUpdate(deltaTime: number) {
}
}
Copyright © 2026 TikTok. All rights reserved.
About TikTokHelp CenterCareersContactLegalTerms of ServicePrivacy PolicyCookies