Bus::getChannelGroup returned ERR_STUDIO_NOT_LOADED for STUDIO_BUS

Hi there I am currently having issue with a getMeterInfo script, for the part of getting the bus channel group suddenly stopped working even though it was working perfectly fine before.

Below is the warning It showed. “Only Level” is the metering script which I will attach. It is detecting a group which a programmer instrument of player talking live is sending into.

This is the script.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using FMOD;
using FMODUnity;
using FMOD.Studio;

public class OnlyLevel : MonoBehaviour
{
    FMOD.ChannelGroup playerGroup;
    FMOD.DSP playerdsp;
    FMOD.DSP_METERING_INFO playerLevel = new FMOD.DSP_METERING_INFO();
    public float onlyLevel;
    public float whisperLevel;


    void Start()
    {
        FMOD.Studio.Bus playerBus = FMODUnity.RuntimeManager.GetBus("bus:/ONLY");
        playerBus.getChannelGroup(out playerGroup);
        playerGroup.getDSP(0, out playerdsp);
        playerdsp.setMeteringEnabled(true, true);

    }

    void Update()
    {
        playerdsp.getMeteringInfo(new IntPtr(), out playerLevel);
        onlyLevel = playerLevel.rmslevel[0] + playerLevel.rmslevel[1];
    }
}

I have found some forums about the channel group not being created yet, and to use method such as flushCommands() or lockChannelGroup(). However, I have a hard time understanding the concepts as well as how to implement them. Would love to have some insight!

Hi,

I will outline how to use some of these commands.
lockChannelGroup: we will want to call this immediately after retrieving the bus, in this case playerBus.
flushCommands: called straight after our lock command. Work through the command thread to make sure our lockChannelGroup is called before the next Studio::System::update is triggered.
unlockChannelGroup: called either before or at the end of the game to make sure the FMOD system can shut down correctly.

It would look something like this:

playerBus
playerGroup

start()
{
    1. retrieve the bus from the FMOD system 
    2. Lock the bus 
    3. Flush commands to make sure we have locked the bus
    4. Continue working the channel group
}

OnDestroy()
{
    1. Make sure we unlock the bus so that FMOD can clean up correctly
}

I have also updated your code here:
OnlyLevel.cs.txt (1.5 KB)
I have added some debug logging using our FMOD_RESULT which greatly aids in working through issues with FMOD.

Hope this helps!

It worked!! Thank you Connor you are a life saver!

Out of curiosity, what could be the possible cause of this issue if it was working fine before and no major change was made either to the metering script, the programmer instrument, nor the FMOD session itself?

1 Like

I am not sure, it could have been a range of things. This is the suggested workflow when wanting to interact with a Bus for the duration of playtime rather than relying on having an event playing or signal present.