AudioSource class abstract Audio

A sound emitter attached to a node.

The abstract base owns what every backend can honor, transport, gain, pitch, and the per-frame world-transform sync for positional playback. Concrete sources add their content model, ClipAudioSource plays an AudioClip on any backend, and backend packages may add event-style sources with their own surface.

A source resolves the nearest ancestor AudioEngine on mount and is inert without one, so mount the engine before the sources.

Inheritance
Implementers

Constructors

AudioSource()

Properties

attenuation AudioAttenuation
Spatialization parameters, re-applied every frame while playing positionally. Sources whose attenuation is authored externally (event middleware) treat this as an override hint at most.
getter/setter pair
enabled bool
Whether this component's update hook runs each frame.
getter/setter pairinherited
engine AudioEngine?
The nearest ancestor engine, resolved while mounted.
no setter
hashCode int
The hash code for this object.
no setterinherited
isAttached bool
Whether this component is currently attached to a node.
no setterinherited
isLoaded bool
Whether onLoad has completed.
no setterinherited
isMounted bool
Whether the owning node is part of a live scene graph.
no setterinherited
isPlaying bool
Whether the source is currently playing (not paused or stopped).
no setter
node Node
The node this component is attached to.
no setterinherited
pitch double
Playback rate multiplier. 1.0 is natural rate.
getter/setter pair
positional bool
Whether playback is spatialized at the node's world position. When false the source plays flat (music, UI). Changing it while playing takes effect on the next play.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
volume double
Gain for this source. 1.0 is unity.
getter/setter pair

Methods

cloneFor(Node cloneOwner) Component?
Returns a copy of this component for cloneOwner, the Node.clone counterpart of the owning node, or null to not carry the component to clones (the default).
inherited
fixedUpdate(double fixedDt) → void
Called once per fixed physics step while the component is mounted, enabled, and loaded. fixedDt is the fixed timestep of the surrounding PhysicsWorld, not the frame interval.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onAttach() → void
Called when this component is added to a node.
inherited
onDetach() → void
Called when this component is removed from a node.
inherited
onLoad() Future<void>
Optional asynchronous setup, such as loading an asset.
inherited
onMount() → void
Called when the owning node enters a live scene graph.
override
onTransformSync(Vector3 position, Vector3 velocity) → void
Concrete-source hook receiving this frame's world position and velocity while the source is positional and mounted under an engine. Subclasses overriding update must call super.update to keep receiving it.
onUnmount() → void
Called when the owning node leaves a live scene graph.
override
pause() → void
Pauses playback, keeping the position; play resumes.
play() → void
Begins (or restarts) playback.
stop() → void
Stops playback and rewinds.
toString() String
A string representation of this object.
inherited
update(double deltaSeconds) → void
Called once per frame while the component is mounted, enabled, and loaded. deltaSeconds is the elapsed time since the previous tick.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited