Bus class

A mixing bus to have control over a group of audio sources.

A mixing bus is a special audio source that plays other audio sources through it. It is particularly useful for grouped volume control, per-bus filtering, and routing of multiple sounds. You can play multiple sounds on a single bus and apply effects or adjust the volume of the entire bus at once.

Refer to the official SoLoud documentation for more information on mixing buses: https://solhsa.com/soloud/mixbus.html

Workflow example:

// 1. Create a new mixing bus
final myBus = SoLoud.instance.createMixingBus();

// 2. Play the bus on the SoLoud engine so its output becomes audible
myBus.playOnEngine();

// 3. Play sounds through the bus
final sound = await SoLoud.instance.loadAsset('audio.mp3');
myBus.play(sound);

// 4. Apply filters or change volume to affect all sounds on the bus
SoLoud.instance.setVolume(myBus.soundHandle!, 0.5);
myBus.filters.echoFilter.activate();

See also:

Constructors

Bus({String name = ''})
Creates a new bus.

Properties

busId int
The ID of this bus. Internally managed on native side. The first bus has ID 1.
latefinal
filters ↔ FiltersSingle
The filters for this bus.
getter/setter pair
hashCode int
The hash code for this object.
no setteroverride
isActive bool
Whether this bus is active (playOnEngine alredy called successfully).
no setter
name String
The name of this bus.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
soundHandle SoundHandle?
The sound handle of the bus itself once it's playing on the engine.
getter/setter pair

Methods

annexSound(SoundHandle handle) → void
Move a live voice (identified by its handle) into this bus. The voice will be reparented so it plays through the bus. Useful for dynamically routing sounds in/out of filtered busses.
dispose() → void
Destroys this bus.
getActiveVoiceCount() int
Get the number of voices currently playing through this bus.
getChannelVolume(int channel) double
Get the approximate output volume for a specific channel of this bus. Useful for VU meters or level indicators. Visualization must be enabled first.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
play(AudioSource sound, {double volume = 1, double pan = 0, bool paused = false, bool looping = false, Duration loopingStartAt = Duration.zero, Duration? loopingEndAt, int? loopingStartOffsetAt, int? loopingEndOffsetAt, double scale = 1}) SoundHandle
Play an audio source through a mixing bus.
play3d(AudioSource sound, double posX, double posY, double posZ, {double velX = 0, double velY = 0, double velZ = 0, double volume = 1, bool paused = false, bool looping = false, Duration loopingStartAt = Duration.zero, Duration? loopingEndAt, int? loopingStartOffsetAt, int? loopingEndOffsetAt, double scale = 1}) SoundHandle
This function is the 3D version of the play call.
play3dClocked(AudioSource sound, Duration soundTime, double posX, double posY, double posZ, {double velX = 0, double velY = 0, double velZ = 0, double volume = 1, double scale = 1, bool looping = false, Duration loopingStartAt = Duration.zero, Duration? loopingEndAt, int? loopingStartOffsetAt, int? loopingEndOffsetAt}) SoundHandle
This function is the 3D version of the playClocked call.
play3dScheduled(AudioSource sound, Duration atTime, double posX, double posY, double posZ, {Duration? duration, double velX = 0, double velY = 0, double velZ = 0, double volume = 1, double scale = 1, bool looping = false, Duration loopingStartAt = Duration.zero, Duration? loopingEndAt, int? loopingStartOffsetAt, int? loopingEndOffsetAt}) SoundHandle
Start playing sound through this bus in 3D space at an absolute engine time (see SoLoud.getEngineTime), with sample accuracy.
playClocked(AudioSource sound, Duration soundTime, {double volume = 1, double pan = 0, double scale = 1, bool looping = false, Duration loopingStartAt = Duration.zero, Duration? loopingEndAt, int? loopingStartOffsetAt, int? loopingEndOffsetAt}) SoundHandle
Variant of play that takes an additional parameter, the time offset for the sound.
playOnEngine({double volume = 1.0, bool paused = false}) SoundHandle
Play the bus itself on the main SoLoud engine so it becomes audible. You must call this before sounds routed through the bus can be heard.
playScheduled(AudioSource sound, Duration atTime, {Duration? duration, double volume = 1, double pan = 0, double scale = 1, bool looping = false, Duration loopingStartAt = Duration.zero, Duration? loopingEndAt, int? loopingStartOffsetAt, int? loopingEndOffsetAt}) SoundHandle
Start playing sound through this bus at an absolute engine time (see SoLoud.getEngineTime), with sample accuracy.
setChannels({Channels channels = Channels.stereo}) → void
Set the number of output channels for the bus (default is 2 = stereo).
toString() String
A string representation of this object.
inherited

Operators

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