So, basically, I created a tool that helps me place notes in songs for my game. When the song ends, FMOD deletes all its channels, and now I can’t scroll the song up/down, pause it, etc. I don’t have access to the FMOD Studio project—it’s on another person’s computer.
When I check the profiler, it’s clear that the channels are being deleted.
I tried to lock channel groups, but it seems I’m targeting the wrong bus. Here’s what I did:
FMOD::Studio::Bus* bus = nullptr;
ERRCHECK(fmodSys->getBus("bus:/", &bus));
if (bus)
ERRCHECK(bus->lockChannelGroup());
But it doesn’t work. I wanted to lock the channel group for the main bus, but the API doesn’t provide a direct way to get the correct bus. Is there another approach?
What are the errors that you are seeing? Would it be possible to share more code? Are you able to reproduce the issue in one of our example scripts: "C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\studio\examples\vs2019\examples.sln"
You’re current method is correct for locking the master bus, if you call fmodSys->flushCommands() after locking the bus, it will ensure the channel group is created in the next update call.
If you want to lock all the buses you could use:
FMOD::Studio::Bus* bus[256];
int busCount;
masterBank->getBusList(bus, 256, &busCount);
for (int BusIdx = 0; BusIdx < busCount; ++BusIdx)
{
bus[BusIdx]->lockChannelGroup();
fmodSys->flushCommands();
}
if (!m_PauseVector.empty())
{
FMOD::Studio::EventInstance* instance = m_PauseVector.back();
FMOD::Studio::EventDescription* envDesc = nullptr;
if (instance->getDescription(&envDesc) == FMOD_OK && envDesc)
{
FMOD_STUDIO_LOADING_STATE state = FMOD_STUDIO_LOADING_STATE_ERROR;
if (envDesc->getSampleLoadingState(&state) == FMOD_OK &&
state == FMOD_STUDIO_LOADING_STATE_LOADED)
{
Audio::SetPosition(realName, 0);
Audio::Pause(realName, true);
m_PauseVector.pop_back();
}
}
}
So when i write
FMOD::Studio::Bus* bus = nullptr;
ERRCHECK(fmodSys->getBus("bus:/", &bus));
if (bus)
ERRCHECK(bus->lockChannelGroup());
This code executes after the event is created but before it’s added to ResourceManager and m_PauseVector. The bus pointer is returned without errors, but the channel group remains unlocked - after playback ends, the channels still get deleted.
Thank you for the code and testing that. Maybe we could look into a different solution. Could you explain the desired behavior? What are you hoping to do with the channels once the event has finished playing? The more information the better. Thanks