I’m using FMOD to play an event, the event has multiple parameters and a sound for every event.
When playing from code, the initial value always plays along with the correct value selected by the parameter, the initial value sound is a long loop which is why it’s so noticeable.
This is the code that sets the parameters, it’s called once, parameters are correct, all the set-calls returns “OK” results.
private void PlayLooping(Source source, List<(string, string)> parameters)
{
StopLooping(source);
if (sources[source] == null)
return;
EventInstance instance = RuntimeManager.CreateInstance(master);
RuntimeManager.AttachInstanceToGameObject(instance, sources[source].transform);
if (instances.ContainsKey(source))
instances[source] = instance;
else
instances.Add(source, instance);
for (int i = 0; i < parameters.Count; i++)
{
FMOD.RESULT result = instance.setParameterByNameWithLabel(parameters[i].Item1, parameters[i].Item2);
Debug.Log($"{parameters[i].Item1} set to {parameters[i].Item2}, result: {result}");
}
Debug.Log($"Playing: {source}");
instance.start();
}
This is my event setup.
What happens is that the idle-loop ALWAYS play, regardless if the parameters is set before/after start, or if the parameters change.
The correct sound also plays.
Setting the parameter initial value to an empty slot, such as “Death” or “Hurt” stops the Idle-loop from playing.
What am I doing wrong?
Hi,
Can I please grab your integration version?
Can you please try starting the instance before setting the parameter:
private void PlayLooping(Source source, List<(string, string)> parameters)
{
StopLooping(source);
if (sources[source] == null)
return;
EventInstance instance = RuntimeManager.CreateInstance(master);
Debug.Log($"Playing: {source}");
instance.start();
RuntimeManager.AttachInstanceToGameObject(instance, sources[source].transform);
if (instances.ContainsKey(source))
instances[source] = instance;
else
instances.Add(source, instance);
for (int i = 0; i < parameters.Count; i++)
{
FMOD.RESULT result = instance.setParameterByNameWithLabel(parameters[i].Item1, parameters[i].Item2);
Debug.Log($"{parameters[i].Item1} set to {parameters[i].Item2}, result: {result}");
}
}
The issue may be that the instance is not valid yet which is confusing why it is returning FMOD_OK
. You can confirm that an instance is valid with instance.isValid()
.
Hope this helps.
Thank you for the rapid response!
Our integration version is 2.02.20, running in Unity 2022.3.25f1.
All instances are valid, changing parameters to be set before/after starting an event does not change anything at all.
If it helps, some context: We are setting up a system where animation event can trigger audio events, with parameters specified by the animation event string parameter, if that changes anything.
Having an empty initial value is a work-around, but it’s very odd the issue happens.
1 Like
Thank you for sharing the workaround.
I have set up a simple test:
Unfortunately, I cannot reproduce the issue. It is playing
Value B
without issue.
Would it be possible to try a simple reproduction of the issue and let me know if it continues?