音频素材,为创建、编辑音视频功能提供音频数据

Example

new AudioClip((await fetch('<mp3 url>')).body, {
loop: true,
}),

Implements

Constructors

Properties

#chan0Buf: Float32Array = ...
#chan1Buf: Float32Array = ...
#frameOffset: number = 0
#meta: {
    duration: number;
    height: number;
    width: number;
} = ...

Type declaration

  • duration: number
  • height: number
  • width: number
#opts: {
    loop: boolean;
    volume: number;
}

Type declaration

  • loop: boolean
  • volume: number
#ts: number = 0
ready: Promise<IClipMeta>

当素材准备完成,ready 会切换到 resolved 状态

ctx: null | AudioContext = null

Accessors

  • get meta(): {
        chanCount: number;
        duration: number;
        height: number;
        sampleRate: 48000;
        width: number;
    }
  • 音频元信息

    ⚠️ 注意,这里是转换后(标准化)的元信息,非原始音频元信息

    Returns {
        chanCount: number;
        duration: number;
        height: number;
        sampleRate: 48000;
        width: number;
    }

    • chanCount: number
    • duration: number
    • height: number
    • sampleRate: 48000
    • width: number

Methods

  • 返回上次与当前时刻差对应的音频 PCM 数据;

    若差值超过 3s 或当前时间小于上次时间,则重置状态

    Parameters

    • time: number

    Returns Promise<{
        audio: Float32Array[];
        state: "done" | "success";
    }>

    Example

    tick(0) // => []
    tick(1e6) // => [leftChanPCM(1s), rightChanPCM(1s)]