Skip to content

Guide: Routing sound through buses & applying filters

Alan Stagner edited this page Jun 10, 2020 · 1 revision

BNA supports routing sound through audio buses, routing audio buses through each other, and attaching up to 8 filters to each bus. By default all sound plays through a single default Master bus, but you can create new buses at will:

using BNA.Audio;

// ...

let musicBus = new AudioBus(Audio);
let soundBus = new AudioBus(Audio);
let uiBus = new AudioBus(Audio, soundBus);
let voBus = new AudioBus(Audio, soundBus);
let sfxBus = new AudioBus(Audio, soundBus);

To attach filters to buses, just construct a filter and then call AttachFilter, passing the slot to attach to (valid values are 0 .. 7)

using BNA.Audio.Filters;

// ...

let reverbFilter = new ReverbFilter();
sfxBus.AttachFilter( reverbFilter, 0 );

Note that a filter can only be attached to one bus at a time. You can call DetachFilter to remove a filter from a bus:

sfxBus.DetachFilter( 0 );

To play sounds through buses, just pass the bus to the Audio.Play methods:

let sfxInstance = Audio.Play( mySoundEffect, sfxBus );