Skip to main content

OnsetDetectorBuilder

A builder for onset detector to set the source of the detector and build the detector.

TypeNameInterface Description
Functionsconstructor()

Functionsbuild(): OnsetDetector | null

• Function: Build the onset detector. Note that the detector should be built in onInit, otherwise it will return null.

FunctionssetDetectorSource(type: AudioSourceType, audioComponent: IAudioComponent | null): this

• Function: Set the source of the detector.

Parameters

• type: - The type of audio source. Default is None. When the type is ExternalFile, the audioComponent must be provided.

• audioComponent: - The audio component which plays the external audio file.

Returns Builder instance for chaining.

FunctionssetThreshold(threshold: number): this

• Function: Set the threshold of the onset detection.

Parameters

• threshold: - The threshold of the onset detection. value range [0, 160]. default value is 10.

Examples​

constructor()​

let obj = new APJS.OnsetDetectorBuilder();

setDetectorSource(type: AudioSourceType, audioComponent: IAudioComponent | null): this​

audioDetectorBuilder
.setDetectorSource(APJS.AudioSourceType.ExternalFile, audioComponent)
.build();

Use Case​

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