Interrupted sounds when using Probability setting and Max Instances = 1 / Stealing = Oldest

Greetings! I faced the problem with interrupted sounds when using Probability setting and Max Instances = 1 with Stealing = Oldest in Group Macros.

Details. There is an “Event 1” - a character voice sample in idle (idle-voice), which plays with a probability of 100%. “Event 2” is a character voice sample when taking damage (damage-voice), which plays with a probability of 50%. The main goal is to make so that character never plays more than one voice sound simultaneously. To do this, I combined these two events into one mixer group, and in the Group Macros settings I set Max Instances to 1 and Stealing to Oldest, so that new voices could interrupt old ones.

With these settings, the following happens inside the game: when an idle-voice is played and at that moment character takes damage, the damage-voice (which, I remind, plays with a probability of 50%) ALWAYS interrupts the idle-voice, regardless of whether the damage-voice was played or not. That is, in those 50% when the damage-voice is not playing, the idle-voice is interrupted anyway, which is wrong.

Expected behavior: the idle-voice interrupts only when a damage-voice plays, which plays with a 50% chance. If the damage-voice was not played, the idle-voice should NOT be interrupted. Is it possible to make such behavior in FMOD?

Thank you.

Hi,

The issue is, the 50% trigger is on the Single Instrument (FMOD Studio | Instrument Reference - Single Instrument) rather than the Event (FMOD Studio | FMOD Studio Concepts - Event) resulting in the event being started 100% of the time and the instrument only being triggered 50% of the time which is not the behavior you are expecting.

There are a few solutions:

  1. Using a Command Instrument (FMOD Studio | Instrument Reference - Command Instrument) with a 50% trigger probability that is on a different bus. Now the event containing the command instrument (Trigger Event) can be triggered multiple times and not stop Event 1 incorrectly. Here you can see that the Trigger Event being started without interrupting the Idle Event unless the Damage Event is played:
    image
    which hopefully is the behavior you are looking for.

  2. Triggering Event 2 via code that works with a random number range. This way you avoid any events being started till they are needed.

float random = Random.Range(0.0f, 1.0f);
if (random >= 0.5)
{
    emitter1.Play();
}

Let me know if either of these options will work for your situation.

Hi, thanks for the reply! I did the following and it worked:

  1. I created new event called “Damage”, on a new audio track inside this event I created a Command Instrument, Command Type chose “Start Event”, Target chose “Event 2” (damage-voice), Conditions → Probability set to On, Chance set to 50%. Event 2 became #referenced.
  2. In the “Voice” mixer group bus, where all the voice events are placed - both “Event 1” (with the idle sound) and “Event 2” (with the damage sound), I set Max Instances = 1 and Stealing = Oldest. The “Damage” event (with the Command Instrument) is placed outside of the “Voice” mixer group bus.
  3. In Unity, when character takes damage, I call the “Damage” event, which contains only one Command Instrument.

About item 2 - triggering Event 2 via code. I didn’t quite understand what exactly should be done, I’m not a programmer. Do I need to configure something in FMOD Studio additionally? Do I understand correctly that the emitter1.Play() function in your example will have a 50% chance of starting the event (but not the instrument inside the event, as I had at first), which will solve the issue and idle will only be interrupted when Event 2 is actually played?

However, another issue arose. If there are two identical monsters in the scene, they begin to steal voice sounds from each other causing sound interruptions. Is it possible in FMOD Studio to make the “only one voice sound from one monster simultaneously” rule apply to each monster individually, but not to all the monsters in the scene at once? Do I need to code additional logic for this?

Thanks.

Hi,

The only changes would have to be removing the probability triggers so that the instruments will play every time the event is started. Other than that, nothing would have to change and/or be added to the project.

Correct, we have moved the probability away from the instrument and to the event instead.

Correct, idle will always be played and only be interrupted by event 2 being triggered.

Unfortunately not. The instance limit is set on the bus and every event played on it rather than each monster with a voice.

Yes, that would depend on the behavior of the event. Correct me if I am wrong. There is a level with multiple monsters that have an idle event that can be played, while that event is playing and the monster receives damage there is a 50% chance that a damage event can be triggered. Each monster should never play both the idle and damage events at the same time.

  1. Can the damage event be played without the idle event being played?
  2. Is the idle event playing all the time or is this triggered by an event in the game?

There are certainly ways to achieve this behavior depending on your situation. With this information we will hopefully find something that works for you!

Thanks for the detailed answer! In my first post, I intentionally simplified the task for better understanding. I will now describe in more detail.

Our 2D platformer has a main character and mobs in different levels. There can be quite a lot of identical mobs on the same level, for instance, small spiders. Each mob has a set of animations with sound: several types of attacks, charge, damage, run, turn, cast, idle, etc. To avoid voice chaos, we need the following:

  1. Mobs play their voice sounds sometimes, with some probability.
  2. Each mob can’t play more than one voice sound simultaneously. For instance, the spider plays the idle animation+sound and after a few milliseconds it takes damage and plays the damage voice sound, as a result one voice sound will overlap with another.
  3. Multiple mobs CAN play their voice sounds simultaneously (but not too many).

I have already done items 1 and 2 with your help. Now the problem with item 3. Here’s an example: there are 2 monsters on the level, one is not far from the player (its sounds are audible), the second monster is far away, at the other end of the level (its sounds are not audible). When I set Max Instances to 1 and Stealing to Oldest, then, if the monster that is close to the player plays any animation with a voice sound, and right after that at the other end of the level the second monster (which can’t be heard) plays its animation with a voice sound (for instance, idle or turn), the nearby monster’s voice will simply be interrupted as the oldest one, and nothing else will happen.

I could use the Stealing = Furthest setting, but then if 2 monsters are close to the player within earshot, they will interrupt each other’s voice sounds.

Also, there is a checkbox “Stop Events Outside Max Distance” in the Unity FMOD settings, which could solve the issue, but for some reason it doesn’t work. With this checkbox enabled, the far not audible monster still interrupts the voice sounds of the near monster.

So, I’m a little bit confused what should we do. As far as I understand, the only solution to this issue is that our programmers will need to code quite complex logic to prioritize voice sounds.

Answering your questions:

  1. Yes, the damage event can be played independently.
  2. Idle event is triggered by an corresponding animation and not playing all the time.

Thank you and excuse me for the long post.

1 Like

Hi,

Thank you for the explanation, the detail is perfect.

There are ways you can have this behavior without using the limiting system. Rather than having each sound in its own event, rather have them all in a single event and use parameters to control which instruments are triggered. Here is an example:

  1. Here I am using FMOD Studio | Glossary - Transition Region’s to control what instruments are played. When the event is started Idle will always play (this can be changed if it is not the behavior you are after), while is it playing if either TriggerAttack or TriggerDamage are set then it will transition to the desired instrument. This will allow for multiple instances of this event to be played while never allowing a mob to have overlapping sounds.
  2. The parameters can easily be set in code via a random number:
emitter.setParameterByName("TriggerDamage", Random.Range(0.0f, 1.0f))
  • this will set the parameter every time but as you can see here:
    image
  • it will not transition unless the value is above 0.50, which will provide the change you were hoping for.
  1. I am using transition markers at the end of each instrument to stop the event.
    image
    This is so only the desired instruments are played rather than the whole timeline.

Let me know if this is the behavior you are after.