Get VCA by ID C++

,

Hello FMOD Team,

I am attempting to build out the settings functionality in my game. My Audio team has done a great job setting up the VCAs and I am now wanting to manipulate them. Below is a snippet of code that I have been trying to flesh out. I was hoping for feedback on the following:

  • Does my syntax appear correct? Is there a more preferred method? Apologies, I am relatively new to C++.
  • The “Get VCA By ID” function is obviously much different than the simpler BP one. What am I supposed to pass through on the first and third parameter?
  • Am I supposed to pass the GUID id as a string (second parameter)?

thank you in advance for any help.

Hi!

It seems like you’re using the C API, which has full namespaces in function names and requires you to pass the Studio system to every function. If you’re using CPP, we’d recommend making use of the CPP API, in which FMOD_Studio_System_GetVCAByID becomes a function you call from a FMOD::Studio::System* object like so: studioSystem->getVCAByID().

As for passing a GUID to the function, the easiest way to do this is to export your project’s GUIDs to a header file from FMOD Studio using Scripts->Export GUIDs Header->C++ Header File, which you can then integrate into your project and simplify referencing specific Studio objects. You can also expose a member in the Unreal editor and assign the VCA you want to it. However, if you want to enter it directly, you’d need to take your string of characters, then break them into the appropriate layout like so:

bb98917e-d65b-41f0-a0ca-c50756da3f0e

becomes

{ 0xbb98917e, 0xd65b, 0x41f0, {0xa0, 0xca, 0xc5, 0x07, 0x56, 0xda, 0x3f, 0x0e} };

Your full function call would look something like this:

FMOD_GUID guid = { 0xbb98917e, 0xd65b, 0x41f0, {0xa0, 0xca, 0xc5, 0x07, 0x56, 0xda, 0x3f, 0x0e} };
FMOD::Studio::VCA* myVCA = NULL;
studioSystem->getVCAByID(guid, &myVCA);
myVCA->setVolume(Value);

Hi Leah,

Thanks for the direction!

However, “GetVCAByID” only accepts const pointer references. I tried exporting the GUIDs into a header successfully and tried to directly reference them but I cannot convert a “namespace” into a const pointer. To avoid having to type out all of the GUIDs into this new format manually, is there a way to manipulate the namespace reference into a more acceptable format for this function to work?

As you can see from the error, you need to pass in an argument of type const FMOD_GUID*, not const FMOD_GUID. To do this, you need to provide the pointer to the GUID instead of the GUID itself, like so: &FSPRO::VCA::Master.