Sound Group Variations

A Sound Group has 1 or more Variations. They can be used for random subtle differences in a sound or for a progression of often triggered sounds such as 1-2-3-repeat. A Variation appears as a child game object of its Sound Group.

 

Note: A Variation game object also contains an Audio Source component, but for the most part you should never need to touch the Audio Source as Master Audio handles this for you with its Inspectors, with one notable exception of needing to change its 3D sound settings (and if you're doing that, you should consider making an Audio Source template to import into the Group Creation section for bulk use). Also, do not use Play on Awake! This is not supported and an error is logged to Console if you use it. If you want to play a sound when the Scene begins, use Event Sounds with either a Start or Enabled event for a no coding solution for ambient sounds, or better yet our Ambient Sound so voices are never playing when out of audible range.

 

Top Section

A Variation has the following options:

  1. Status / Command Bar: contains a few buttons showing you the status and allowing previews.
       
    • Back to Group: Clicking this button navigates you to the parent Game Object, the Sound Group containing this Variation.
    •  
    • Variation status bar: Appears only at runtime. Shows either "Not playing", "Paused" or "Playing (X%)". If it's the latter, it tells you how much of the clip has already played.
    •  
    • Select Caller: Appears only at runtime, if this Variation is playing and the sound is following a Game Object or played at the position of a Game Object. Clicking the button will select the Game Object so you can see what it is.
    •  
    • Preview / Stop Preview: These icons preview and stop previewing the Variation.
  2.  
  3. Audio Origin: This lets you choose between the different Audio Origins, which affect memory usage and latency. Read about the options on that page.
  4.  
  5. Probability to Play (%): Defaults to 1. If any value less than 1, this represents the % chance of this Variation to play the actual audio or not when this Variation is selected to play. This can be used to play an effect X% of the time and silence otherwise. Range is from 0-1 with 0 meaning never play and 1 meaning always play.
  6.  
  7. Volume / Pitch / Loop Clip: These are properties of the Audio Source the Variation will use.
  8. Voices (Weight): This is the maximum number of this Variation that can be played at once. Since it defaults to 1, if you have a single Variation with Voices of 1, you can only play 1 of this Sound Group at once. It is also used for weight: you can also make each Variation trigger more or less often than the other Variations by changing this value. For example, if you have 2 Variations, and Variation A has Voices = 4 and Variation B has Voices = 1, then Variation A will be triggered 4 times as often, and you can play a maximum of 5 of this Sound Group at once. This saves you from having to create more Variations than you would need otherwise for duplicates. A value of zero for Voices can be specified to not use the Variation without deleting it.

Collapsible Sections

  1. Use Random Pitch: When this section is enabled, the following controls appear:
       
    • Pitch Compute Mode: This has 3 modes:
         
      • Add to clip pitch: The random pitch will be added to the clip's pitch when played.
      •  
      • Ignore clip pitch: The random pitch will be the clip's pitch when played.
    •  
    • Random Pitch Min / Max: The min and max pitch to randomize between. It will either be added or used directly based on your Pitch Compute Mode.
  2.  
  3. Use Random Volume: Same field types as Random Pitch, but operates on volume instead.
  4.  
  5. Use Random Delay: If you enable this, whenever this Variation plays, it will delay before playing for an additional X seconds. X is random between the min and max you specify. This is in addition to any delay you specified in the MasterAudio.PlaySound method parameters, Event Sounds or Looped Chain random delay (set at the Sound Group level).
  6.  
  7. Use Custom Start/End Position: If you enable this, whenever this Variation plays, you can pick a starting and/or ending part of the clip. Looping of the clip is disabled if you choose this option, since it wouldn't be possible to loop just a portion of the clip accurately.
       
    • Start Min/Max (%): Instead of starting at the beginning, it will start at a random position between the Start % Min and Start % Max numbers. The min and max are percentages of the clip's play time.
    •  
    • End (%): Instead of stopping at the end of a clip, it will end at the percentage you specify here.
  8.  
  9. Use Finite Loops: Only visible if you have turned on Loop Clip for your Variation. Turning on this section will allow you to specify how many loops to play instead of unlimited.
       
    • Min / Max Loops: Choose the minimum and maximum number of times the loop should happen. A random number between the two will be chosen each time (inclusive).
  10.  
  11. Use Custom Fading: If you enable this, whenever this Variation plays, it will use any Fade In and Fade Out Time you've specified. Fade Out Time is applied at the last portion of the clip.

 

Further Explanation of Voice Limiting

 

Voices vs. Variations: Master Audio will create additional Variation children for each Voices (Weight) value greater than one once you press Play.

  • If you need the ability to play up to 5 of the SAME sound in a polyphonic manner, use a single Variation with Voices = 5.
  • If you need the ability to play different sounds in the same group, use more than one Variation. Each Variation can have its own Voices (weight) value, which will also have clones created at runtime for polyphonic purposes.

 

Setting up a Group for a max number of voices: Master Audio never uses Unity's AudioSource.PlayOneShot. This is because that method allows multiple overlapping samples to play on the same Audio Source. This would make the voice-limiting and Retrigger Percentage code not work. However, the combination of Voices + Retrigger Percentage gives you a "controllable" PlayOneShot in effect. By default a single Variation in a Sound Group will have Voices = 1. Therefore you can only play one of that sound at the same time. If you want to allow 5 simultaneously, up the Voices of that Variation to 5. Four additional clones of the Variation will be created at runtime. If you have 3 different Variations of the sound, but only want to allow 2 to play at the same time, keep the Voices of all 3 at just 1, then set the Polyphony Voice Limit to 2. Master Audio will play the Variations in random order (or Top To Bottom) until all have been played, then "refill the pool" and start over the next time that Sound Group is requested. When all Variation are "busy" per the Retrigger Percentage, nothing will be heard for this trigger. When the first random Variation is busy, the rest will be tried from least recently played to most recently played. This way usually the 2nd choice will succeed.