MotionScript

@motion-script/core


@motion-script/core / AudioDevice

Abstract Class: AudioDevice

Defined in: platform/audio-device.ts:12

Stackable audio player driven by the AssetManager.

The AssetManager decides which audio data is needed within the current look-ahead window and pushes it in via append; the device caches the decoded form, schedules the matching AudioRequests via schedule, and drives playback through syncTo on each tick.

Constructors

Constructor

new AudioDevice(): AudioDevice

Returns

AudioDevice

Accessors

schedulesAudio

Get Signature

get schedulesAudio(): boolean

Defined in: platform/audio-device.ts:22

Whether pushing the audio working set to this device does anything at all.

False for a sink that discards everything — an export, whose audio is mixed offline in a single pass at the end. AssetManager.syncAudio runs on every frame and rebuilds a Set, a per-request id string and a sorted signature each time; against such a device every one of those calls lands on a no-op, so the work is skipped rather than done and thrown away.

Returns

boolean

Methods

append()

abstract append(src, data): Promise<void>

Defined in: platform/audio-device.ts:33

Decode and stack data under src. Idempotent — repeat calls for an already-cached src are no-ops.

Parameters

src

string

data

ArrayBuffer

Returns

Promise<void>


dispose()

dispose(): void

Defined in: platform/audio-device.ts:70

Returns

void


has()

abstract has(src): boolean

Defined in: platform/audio-device.ts:27

True if decoded data for src is already cached on the device.

Parameters

src

string

Returns

boolean


play()

abstract play(time, speed, reverse): void | Promise<void>

Defined in: platform/audio-device.ts:51

Parameters

time

number

speed

number

reverse

boolean

Returns

void | Promise<void>


retain()

abstract retain(keep): void

Defined in: platform/audio-device.ts:36

Drop cached audio data (and any active sources) for srcs not in keep.

Parameters

keep

ReadonlySet<string>

Returns

void


schedule()

abstract schedule(requests): void

Defined in: platform/audio-device.ts:43

Set the working set of audio requests for the current look-ahead window. Requests no longer present are stopped; new ones become eligible for playback via syncTo as soon as their data is appended.

Parameters

requests

readonly AudioRequest[]

Returns

void


setMuted()

setMuted(_muted): void

Defined in: platform/audio-device.ts:58

Mute or unmute all output. Default is a no-op for devices that produce no sound (e.g. export/noop sinks).

Parameters

_muted

boolean

Returns

void


setVolume()

setVolume(_volume): void

Defined in: platform/audio-device.ts:68

Set the linear gain applied to all output, on top of each request's own volume. Independent of setMuted — unmuting restores this level rather than resetting to 1, so a host can hold a volume slider and a mute button without the two clobbering each other.

Default is a no-op, as for setMuted.

Parameters

_volume

number

Returns

void


stop()

abstract stop(): void

Defined in: platform/audio-device.ts:52

Returns

void


syncTo()

abstract syncTo(sceneTime): void

Defined in: platform/audio-device.ts:49

Start/stop scheduled sources to match sceneTime. Called every tick. Sources whose data has not yet been appended are skipped until it is.

Parameters

sceneTime

number

Returns

void