Setting global pitch via code/script

We’re just switching over to fmodStudio from fmod Ex/Designer.
One thing we used to do was set a pitch on an entire Category ie when going into “slow motion” mode pitch the Voice and Foley categories down.
Is there a Studio equivalent ie is this possible via group buses etc?

1 Like

The Studio::Bus class does not expose a setPitch() function. This is something we will be adding in the near future.

In the meantime, you should be able to achieve what you want by retrieving the Bus’s low level ChannelGroup and calling setPitch() on that. Something like this…

FMOD::Studio::Bus* bus = NULL;
if (system->getBus(“bus:/Voice”, &bus) == FMOD_OK)
FMOD::ChannelGroup* group = NULL;
if (bus->getChannelGroup(&group) == FMOD_OK)

There are some complexities involved with obtaining the ChannelGroup of a Studio Bus. You need to check the result of each function call, as I did above, because they may fail under some circumstances. Please read the API docs for all the details:

Another complexity is the lifetime of the bus’s ChannelGroup. By default Studio creates and destroys the ChannelGroup on demand. This means it only exists if at least one event instance routes into the bus. If it doesn’t exist, getChannelGroup() will return FMOD_ERR_STUDIO_NOT_LOADED.

I highly recommend that you call lockChannelGroup() on these two buses, in order to force their channel groups to be created and to persist for the duration. You can just do this once after loading your master bank, like so…

// After master bank has loaded

FMOD::Studio::Bus* voiceBus = NULL;
system->getBus(“bus:/Voice”, &voiceBus);

FMOD::Studio::Bus* foleyBus = NULL;
system->getBus(“bus:/Foley”, &foleyBus);

Please read the API docs for this function:

Hope that helps. It will be a lot nicer when we finally have a Studio::bus::setPitch() function you can simply call.

1 Like