AudioMixer

Namespace:

namespace Lenga\Engine\Audio;

class AudioMixer

AudioMixer is a script-facing reference to an audio mixer asset.

Use mixer references when a Behaviour needs to route an AudioSource into a specific mix channel. Prefer assigning the mixer and output channel in the Inspector when the routing is static.

Properties

name

public string $name

Display name derived from the assigned mixer asset.

assetPath

public string $assetPath

Project-relative path to the mixer asset.

Methods

matches

public function matches(?AudioMixer $other): bool

Returns true when both mixer handles point to the same asset.

Example

use Lenga\Engine\Audio\AudioMixer;
use Lenga\Engine\Audio\AudioSource;
use Lenga\Engine\Core\Behaviour;

final class MenuAudio extends Behaviour
{
    public ?AudioMixer $mixer = null;

    private ?AudioSource $source = null;

    public function start(): void
    {
        $this->source = $this->gameObject->getComponent(AudioSource::class);
        $this->source?->setOutput($this->mixer, 'channel-1');
    }
}

Assign the mixer in the Inspector, then route the source to the channel that matches the sound's role.

Notes

  • AudioMixer values are asset references. Assign them in the Inspector instead of typing file paths in gameplay code.
  • New mixer assets start with a Master channel. Add more channels in the Audio Mixer window as your project needs them.
  • If an AudioSource has no mixer assigned, it plays through the default output.