FMOD Label parameter plays previous and current value?

When I try to play audio type 1 in unity, type 0 is also played, and type 1. So you hear both play at the same time through one event emitter.
This is my fmod.

This is my code

How do I get it so that only the correct weapon shoots instead of the ones before in the array range?
So instead of sound 0 and 1 playing, just play sound 1 and ignore sound 0 because the value is on sound 1?

P.S In the inspector everything works fine, if I play 1 I only hear the rifle, but in the game again I hear the Rifle and the faint sound of the pistol.

First, check if you don’t have a timeline or action sheet playing at the same time with a wrong instrument. There’s a known bug where there can be some pasted elements on another sheet without knowing it…

I have no action or timeline added to this event. Only a parameter and 2 rilfles to test it out.

In the editor everyting works well, When I play the rifle audio in editor, it all does what it needs to do, but only in game you can hear both. My version is before 2021 though, maybe I should update the plugin and program??

Maybe try “hold value during playback” in the parameter settings. Did you check API calls with liveupdate?

Added the “hold value during playback” on the parameters. Where can I check these API calls? They should all work if I’m correct.

You have to put the flag STUDIO_INIT_LIVEUPDATE when doing Studio::System::initialize to activate liveupdate (but maybe there’s another method for Unity, which I’m not aware of). Then you’ll be able to connect FMOD to the game during the runtime (there’s a button at the bottom). Then, you should open Window/Profiler and record a session while playing and triggering the sounds. Then you can examine the session to find values passed to the parameter, or other problems. You can visualise the events by clicking on them on the overview. Or check the API calls (it’s the 3d button at the center/top of the window).

“hold value during playback” makes sense for that kind of event, but it shouldn’t be necessary. It was only to verify if the code tries to change the value during the playback, hence the double sound. But the API calls should be more informative in that regard.

Thanks for your info! I’ll try and see if I can figure things out!

Hmm… Your code snippet appears to be correct: The parameter value is being set before the event instance is started, so the event instance should only play the instruments at the set parameter value.

Is it possible that your code is creating two instances of the event instead of one, and setting the parameter value of only one of them? You should be able to determine whether one or multiple event instances are being created by closely examining your code or by profiling your game. You could also test it by adding a multi instrument with random playlist item selection and multiple playlist entries to your event; if multiple instances are being created, you should hear multiple playlist entries from the multi instrument playing simultaneously.

I’ve just done some further research, and the only instance is played every time. Though I do see (2) channels everytime I shoot. Is this correct?

Could it be due to me being on Unity 2019.4.15 LTS?? Or Should I be on 2020.3 LTS??

EDIT: because I assume I don’t have to lower the volume of the 1st audio clip right when I choose the “rifle” right?? I’d imagine it would just play the rifle part

EDIT2: I just tested this in another project and setting, full plain and empty. When I play the audio, it first plays the code with the pistol, then it plays the rifle and the pistol at the same time.



These are my audio settings

@joseph @Alcibiade

These are my API calls

“Hold value during playback” prevents the value of a parameter from being changed while the event instance is playing, but since you’re getting two instruments playing at the same time event with the hold value during playback setting enabled, it’s safe to say that the parameter value is not being incorrectly changed.

Are you re-using the same event instance each time you play this event? Or are you creating a new instance each time? If you’re creating a new instance each time, how does your code release the old instances?

The code snippet you posted contains the line shootSOurce.Play();. Exactly what does Play() do?

Shootsource just launches this scripts Play() function on the Studio Event Emitter


This is my test project, full script, same thing still happens

I’m not sure why the parameter is launching the pistol as well, the inspector audio play works fine through the Fmod Event Browser, yet ingame it goes wrong. Could this be an Fmod Issue or is this Unity Related?

EDIT: So I assume I"m reusing the event instance and just changing parameters.

EDIT2: When setting the parameter in the start function of Unity. Fmod doesn’t get the function call or something because it still plays the gun sound, or it does not hold it.

EDIT3: I’ve done some more tests where I update the parameter in the update, and play the sound. This has resulted in the audio playing correct 70% of the time without the pistol, and the other 30% of the time, it just plays the pistol sound.

I’ve found a hack where it works. I am very sure this is the wrong way though. Using the following code, I’ve managed to get it to play the correct audio type. But I’m sure this is not the way it should be done.
Testparams = 1

Since it’s working correctly in FMOD Studio, and FMOD Studio uses the same code to play events as the FMOD engine, the issue must be caused by something in Unity or something in your code. We haven’t received any reports of this issue from other users, which suggests this issue is unique to your project.

Looking at the screenshots from your latest post, I see that you’re calling both start() and Play() on the same event instance. This seems redundant. Have you tried commenting out one or the other?

I think it’s a Unity Related bug. I have just created a brand new 2020.3 LTS project in unity, installed a fresh version of Fmod from the assetstore. And once again the SetParameter() function does not work for me. I would assume that this isn’t anything related to my coding due to the fact that it’s a brand new project without any other issues. Maybe it’s a bug?

Maybe does your keyboard send multiple input signals? Did you try with another kind of trigger?

Tried with keyboard as well, same results.

The API calls you gave aren’t very informative. You should look for “start” and “setParameterByName”, by clicking on previous frame and last frame buttons, around the sound, which you can locate on the wave form. It would be usefull to know how many times the event is started and when the parameters are set (and how many times).
It doesn’t seem setparameter doesn’t work, it rather seems the event is started several times (maybe several simultaneous instances), one with the parameter correctly set, one with the default parameter value. You should find what is triggering this other event start.

I will do more digging and find out whats wrong! Thanks for your feedback!