# Parameter Event Instance always plays sound set as initial value together with (correctly selected) sound from parameter

**URL:** https://qa.fmod.com/t/parameter-event-instance-always-plays-sound-set-as-initial-value-together-with-correctly-selected-sound-from-parameter/22418
**Category:** Unity
**Created:** [December 17, 2024, 12:11am UTC](https://qa.fmod.com/t/parameter-event-instance-always-plays-sound-set-as-initial-value-together-with-correctly-selected-sound-from-parameter/22418 "2024-12-17T00:11:54Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![AxelAntediluvianInte](https://avatars.discourse-cdn.com/v4/letter/a/cab0a1/32.png) [@AxelAntediluvianInte](https://qa.fmod.com/u/AxelAntediluvianInte)
#### Post date: [December 17, 2024, 12:11am UTC](https://qa.fmod.com/t/parameter-event-instance-always-plays-sound-set-as-initial-value-together-with-correctly-selected-sound-from-parameter/22418/1 "2024-12-17T00:11:54Z")

</div>

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.

```auto
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.

 ![bild](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/a/a795124fc4ff3b09de81fed07faf4b3f379e6a64.png)

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?

---

<div class="post-metadata">

### Author: ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)
#### Post date: [December 18, 2024, 11:14pm UTC](https://qa.fmod.com/t/parameter-event-instance-always-plays-sound-set-as-initial-value-together-with-correctly-selected-sound-from-parameter/22418/2 "2024-12-18T23:14:48Z")

</div>

Hi,

Can I please grab your integration version?

Can you please try starting the instance before setting the parameter:

```auto
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.

---

<div class="post-metadata">

### Author: ![AxelAntediluvianInte](https://avatars.discourse-cdn.com/v4/letter/a/cab0a1/32.png) [@AxelAntediluvianInte](https://qa.fmod.com/u/AxelAntediluvianInte)
#### Post date: [December 21, 2024, 7:29pm UTC](https://qa.fmod.com/t/parameter-event-instance-always-plays-sound-set-as-initial-value-together-with-correctly-selected-sound-from-parameter/22418/3 "2024-12-21T19:29:38Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)
#### Post date: [December 23, 2024, 3:41am UTC](https://qa.fmod.com/t/parameter-event-instance-always-plays-sound-set-as-initial-value-together-with-correctly-selected-sound-from-parameter/22418/4 "2024-12-23T03:41:31Z")

</div>

Thank you for sharing the workaround.

I have set up a simple test:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/f/f423ba39f24d8b8daca385dbaf343346dd41e22d.png)  
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?
