AudioPlugin class final

The audio model in the engine loop: the mix worked out once a frame, in the loop's audio phase.

A view plugin. It reads the scene's nodes through the listener and the emitters that follow them and touches nothing of the simulation, so a replay, a rollback and a server never run it twice or at all. The sounds a step decided to make reach it the way they always did — a SoundtrackPlugin playing a cue sheet off the frame channel, which is delivered before the frame's phases, or a game's own system earlier in this phase — and this mixes whatever is in the scene by then.

Real seconds, not simulated ones. Snapshots blend and ducks move by the frame's wall-clock seconds, so a "paused" snapshot blends in while the simulation is stopped, and velocities are measured over the same seconds the nodes were seen to move in.

final listener = AudioListener()..follow(() => camera.worldMatrix);
final loop = EngineLoop(
  input: input,
  plugins: [genre, AudioPlugin(scene: () => speakers.scene, listener: listener)],
);

The camera phase runs after this one, so a listener following the camera hears from where the camera was placed the frame before. A game whose camera moves fast enough for that to be heard passes phase as LoopPhase.render.

Constructors

AudioPlugin({required AudioScene scene(), required AudioListener listener, String id = 'flutter3d_audio_core', LoopPhase phase = LoopPhase.audio, Iterable<DuckRule> ducking = const <DuckRule>[]})

Properties

ducking → List<DuckRule>
Ducking rules added to the mixer of each scene this mixes, once.
final
hashCode → int
The hash code for this object.
no setterinherited
id → String
The plugin's id. Two mixes in one engine need two.
final
listener → AudioListener
Where the ears are: placed by hand, or following a node.
final
manifest → PluginManifest
no setter
phase → LoopPhase
The frame phase the mix runs in: audio unless a game says otherwise.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
scene → AudioScene Function()
The scene to mix, asked once a frame, because a game swaps its silent scene for the speakers' once they open.
final

Methods

install(PluginHost host) → void
Registers this plugin's phases, systems, subscriptions and the rest.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
uninstall(PluginHost host) → void
Takes this plugin's ducking rules back out of the mixer it put them in, so switching it off and on again does not duck twice.

Operators

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