# Get a bus list from a bank

**URL:** <https://qa.fmod.com/t/get-a-bus-list-from-a-bank/19434>\
**Category:** Unity\
**Created:** [October 20, 2022, 2:48pm UTC](https://qa.fmod.com/t/get-a-bus-list-from-a-bank/19434 "2022-10-20T14:48:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafzael](https://avatars.discourse-cdn.com/v4/letter/r/aeb1de/32.png) [@Rafzael](https://qa.fmod.com/u/Rafzael)\
**Post date:** [October 20, 2022, 2:48pm UTC](https://qa.fmod.com/t/get-a-bus-list-from-a-bank/19434/1 "2022-10-20T14:48:58Z")

</div>

Hello, I am trying a create a mixer in unity allowing to set he volume of the buses of the project.  
To make it, I’m trying to get the list of buses in the fmod bank.

The problem is that I get an ERR\_INVALID\_HANDLE error. This probably seem that he way I’m referring to the current fmod system isn’t OK.

Here is the code

> Blockquote  
> [FMODUnity.BankRef]  
> public List Banks;

```
private FMOD.Studio.Bus[] myBuses = new FMOD.Studio.Bus[12];
private string busesList;
private string buf;
private FMOD.Studio.Bank myBank;

private string BusPath;
public FMOD.RESULT busListOk;
public FMOD.RESULT sysemIsOk;

void Start()
{
    foreach (var bank in Banks)
    {
        FMODUnity.RuntimeManager.StudioSystem.getBank(bank, out myBank);
        busListOk = myBank.getBusList(out myBuses);
        if (myBuses.Length > 0 )
        {
            foreach (var bus in myBuses)
            {
                bus.getPath(out buf);
            }
        } 
    }
}

```

> Blockquote

If not OK does somebody can explain me how to declare properly the system?

Thanks

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [October 23, 2022, 10:53pm UTC](https://qa.fmod.com/t/get-a-bus-list-from-a-bank/19434/2 "2022-10-23T22:53:40Z")

</div>

Hi,

You are using the right FMOD System to get the buses.

I would recommend getting an array of all the banks, to get the array use:

```auto
FMODUnity.RuntimeManager.StudioSystem.getBankList(out bankList);

```

`bankList` being an array of `FMOD.Studio.Bank[]`. Then looping through this array checking the `bankList[i].getBusCount()` to make sure it has any buses. This way you are sure that you are checking all the banks and getting all their buses.

I will link the [Bank API](https://fmod.com/docs/2.02/api/studio-api-bank.html) and the [Bus API](https://fmod.com/docs/2.02/api/studio-api-bank.html) for explanations of the functions I am using.

Getting the FMOD.RESULT from each FMOD function might give more insight to which function is failing rather than having a public variable.

If you are still having issues I can share more code.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![Rafzael](https://avatars.discourse-cdn.com/v4/letter/r/aeb1de/32.png) [@Rafzael](https://qa.fmod.com/u/Rafzael)\
**Post date:** [October 24, 2022, 6:46am UTC](https://qa.fmod.com/t/get-a-bus-list-from-a-bank/19434/3 "2022-10-24T06:46:19Z")

</div>

Hi,

Thanks for the answers,

OK and this also avoid to try to load bank that are already loaded.

For those interested, here is the fixed code:

```auto
void Start()
{
        FMODUnity.RuntimeManager.StudioSystem.getBankList(out FMOD.Studio.Bank[] loadedBanks);
        foreach (FMOD.Studio.Bank bank in loadedBanks)
        {
            bank.getPath(out string path);
            busListOk = bank.getBusList(out myBuses);
            bank.getBusCount(out busCount);
            if (busCount > 0)
            {
                foreach (var bus in myBuses)
                {
                    bus.getPath(out busPath);
                }
            }
        }
    }

```
