@motion-script/core / Sound
Class: Sound
Defined in: attributes/audio/sound.ts:49
A playable audio clip. Deliberately not a Node — audio lives on a parallel timeline, not in the visual scene graph.
Wire it up by calling tick from your node or scene's tick(), then call prepare from prepare() to register requests with the asset tracker. Use start/stop imperatively or play in a generator.
Constructors
Constructor
new Sound(
props):Sound
Defined in: attributes/audio/sound.ts:61
Parameters
props
Returns
Sound
Properties
filters
filters:
AudioFilterItem[]
Defined in: attributes/audio/sound.ts:55
loop
loop:
boolean
Defined in: attributes/audio/sound.ts:52
src
readonlysrc:string
Defined in: attributes/audio/sound.ts:50
trimEnd
trimEnd:
number
Defined in: attributes/audio/sound.ts:54
trimStart
trimStart:
number
Defined in: attributes/audio/sound.ts:53
volume
volume:
number
Defined in: attributes/audio/sound.ts:51
Accessors
playRanges
Get Signature
get playRanges():
object[]
Defined in: attributes/audio/sound.ts:127
The scene-time ranges this sound has been scheduled to play, derived from
its accumulated requests. endAt is null while a clip is still open
(started but not yet stopped, or an unbounded loop).
Returns
object[]
Methods
dispose()
dispose():
void
Defined in: attributes/audio/sound.ts:227
Returns
void
effectiveSpeed()
effectiveSpeed():
number
Defined in: attributes/audio/sound.ts:83
Net constant playback-rate multiplier from any scalar speed filters
(product of all), defaulting to 1. Curve-valued speed filters contribute 1
here — they're handled by sceneDurationFor via integration, not a
simple division. A clip of source length L occupies L / effectiveSpeed
seconds of scene time when every speed is scalar.
Returns
number
play()
play(
duration?):FrameGenerator
Defined in: attributes/audio/sound.ts:177
Generator form: start, yield for the clip's duration, then stop.
Pass duration to override — required for looping clips unless trimEnd
is set (the catalog-resolved full length counts as set).
Parameters
duration?
number
Returns
prepare()
prepare(
tracker):void
Defined in: attributes/audio/sound.ts:194
Register this sound's requests with the asset tracker. Call from your node's prepare(tracker). Handles file-load registration and pushes new playback requests — safe to call every frame (deduplicated internally).
Parameters
tracker
Returns
void
sceneDurationFor()
sceneDurationFor(
trimmedSourceLength):number
Defined in: attributes/audio/sound.ts:108
Scene-time length consumed by playing trimmedSourceLength seconds of source.
- All speeds scalar →
trimmedSourceLength / effectiveSpeed()(fast path, unchanged behavior). - A speed curve is present → numerically integrate
∫ 1/speed(τ) dτover the trimmed source length. Scalar speed filters are folded in by dividing the integral by their product (they scale the rate uniformly).
This is the single source of truth for how much scene time a clip occupies and
must match the renderer's playbackRate schedule.
Parameters
trimmedSourceLength
number
Returns
number
start()
start():
void
Defined in: attributes/audio/sound.ts:135
Start playback. No-op if already playing.
Returns
void
stop()
stop():
void
Defined in: attributes/audio/sound.ts:157
Stop playback. No-op if not playing.
Returns
void
tick()
tick(
time):void
Defined in: attributes/audio/sound.ts:72
Update the sound's current time. Call from your node's tick(time).
Parameters
time
number
Returns
void