The Audio Random Container - 23.2 alpha feature release

Hello from the Unity Audio team! We know there has been a long silence from us here, so we wanted to take this opportunity to kick off some better ongoing communications with our community. A few years back, the audio team released the experimental DSPGraph package. As with many elements in our strategy to enable more ambitious games with DOTS, we learned a lot in the process. Many of these learnings will directly benefit other upcoming DOTS-powered offerings, such as Unity’s new animation system. While the idea is very much alive to also bring these benefits to audio in Unity, we have paused it in order to focus on providing some immediate value for all users of audio in Unity.

During our numerous user interviews these past few years, it became clear that users are looking for better audio workflows that provide them with the ability to create and iterate over more advanced soundscapes faster and easier. Building immersive soundscapes that underscores all important moments in your game and ensuring that every impact, footstep or gunshot is as realistic and randomized as in the real world… seems to be the everlasting challenge for audio designers. At Unity Audio we have spent quite some time in discovering what exactly audio designers and implementer needs, in order to accomplish great sound work. Now we are ready with our first feature, within a roadmap focusing on supporting codeless flows within Unity: the Audio Random Container. As the name implies the feature is all about randomizing audio and ensuring that volume, pitch, time and triggers can be set to non-repetitive intervals, so your game never sounds the same twice.

It is useful for almost any sound use case (footsteps, impacts, weapons, props, Crowds and dialogue, etc), especially when it is integrated in Unity Visual Scripting and other state and trigger mechanisms.

And last but not least. The audio team here would like to give a big shout out to all of those who participated in the user research. Your input has been invaluable in helping us understand what you want and need from Unity Audio.

We look forward to engaging more in the future and continue building Unity Audio together with you!

Keep rocking the audio world!

Resources

Requirements

  • The minimum required Unity version is 2023.2.0a10

Getting started

  • Download Unity 2023.2a10 or newer through the Alpha Releases site or directly from the Hub using the “Install Editor” button and navigating to the “Pre-releases” tab.

  • Open your project in Unity and create the Audio Random Container through the various options:

  • From the menu:

  • The Unity Editor contains a working menu item Asset → Create → Audio → Audio Random Container that creates an empty Audio Random Container asset.

  • The project view:

  • Right clicking in the Project window brings up the asset menu containing a working menu item Create → Audio → Audio Random Container that creates an empty Audio Random Container asset.

Current state
The Audio Random Container is in an alpha state which means that bugs can appear and that the feature is missing minor UI elements or functionality. It is tested for all platforms for the Editor and StandAlone builds.

What’s next
The immediate next thing that we are working on is to provide you with some visual feedback such as a VU meter and visualization of what is currently playing in the audio random container. Please watch out for more updates in this space!

As part of this early alpha release, we are also looking to get as much feedback as we can from you all to improve the overall experience of working with the Audio random container and make it more robust. We would like to invite you to try it out and give us your feedback here in this thread and also please feel free to report any unexpected behaviour or bugs that you encounter through our bug-reporter.

Feedback
We’re especially looking for feedback on the functionality and bugs as you come across.

  • Are there any workflows that are unclear or missing?

  • Are there any issues or unclear parts in the documentation?

  • Do you face any difficulties integrating with other game domains and triggers?

Please share your feedback about the Audio Random Container in this thread. Any other feedback should be submitted via our official Roadmap page. This thread should remain focused on the original topic and we reserve the right to remove unrelated posts.

How to report bugs
Bugs need to be reported via the built-in bug reporter tool, as that will automatically provide us with some relevant context. When reporting bugs, please:

  • Attach a (stripped) project when there are issues with the Audio Random Container.

  • Please provide us with the steps to reproduce the issue.

Have a look at this page for more information and best practices around bug reporting.

Once you have submitted a bug report through the bug reporter, please feel free to start a discussion about it in this thread.

Thank you for your interest, we’re looking forward to your feedback!

18 Likes

This is pretty cool! We have always created a wrapper like this in all of our games, so if this one covers the things we need, and cut the requirement for an extra MonoBehaviour next to every AudioSource, that would be nice.

Here’s the wrapper we use in Teslagrad 2, called “Foley”, for reference. It’s strikingly similar in many aspects;
8956899--1230039--Unity_ojDbGKHP43.gif
(Feel free to take any inspiration you want!)

First impressions, high level:

  • It’s pretty neat! Most of the interface is intuitive, and it’s a feature that we do need. It’s a big, big improvement to have the package of clips and setting be a thing we can feed to an AudioSource!

  • The name is a bit meh? This isn’t only useful for randomness, although that is a big part of it. What’s also useful is to just wrap sound+volume+pitch in a single asset without any randomness. So I think the name is selling it a bit short. Then again, naming is really hard!

  • I miss some extensibility. Audio is one of Unity’s most black-boxy and least scriptable corners, and this is still there. I’d love to be able to add additional data to a RandomContainer subclass, or be able to make our own kinds of AudioResource to play on AudioSources. While this is neat, different games have different requirements, and if you put in the effort to let us make custom versions of things, you’re doing us a much larger favor.

  • The current documentation is just real bad. I assume you’re planning on improving it, but it’s a confusing mess right now that needs fixing,

First impressions, nitty-gritty

  • Why do I have to open the RandomContainer instead of just editing it in the inspector like any other asset ever? Is that a bug? If I just select it, the inspector is empty. I have to double-click it to get a custom editor window of some sort.

  • The for the AudioRandomContainer doesn’t imply in any way that it does audio, so you probably want another pass on it!

  • While most things are intuitive, I don’t understand the Automatic Trigger mode, or all the things under it at all from looking at the UI and the tooltips, or the docs. Like, what is a pulse? How do I make one, how do I send one?

  • “Avoid Repeating Last X” is a cool feature, for avoiding the randomization playing the same sound many times in a row. We achieve the same thing now by instead using a “Gamblers Fallacy” random distribution, where the chance of a clip getting selected falls whenever it’s selected. It’s a bit easier to set up, as you don’t have to do a different thing based on the number of clips in the container, and it can be on by default since it doesn’t have to be clamped to the number of clips - 1.

  • What does the checkbox next to the audio clips do? Deactivate them? This is currently not intuitive. If it does deactivate them, you should show that either by graying out the clip entry, or doing the same thing as Timeline does when you mute a track

  • What does the volume value next to the audio clips do? Is it added to the volume of the entire container? It can only be 0 dB and down, so you can’t make the volume of a clip be louder than other clips.

  • In general, decibels are stupid and strange. We much prefer to present volume as 0-1, and then do the maths in the background to turn that into something that sounds like a linear range from no sound to “normal”.

  • If you look at the gif I posted above, you can see that we show which clip is currently being previewed when we press the play button. That’s a neat little extra that helps us confirm that things are working as intended.

  • Similarly, it’d be neat when previewing to see what was selected for the random value for pitch and volume

  • Another feature that’s been very useful for us is what’s called “Next” in the Foley I posted. Essentially, it allows the sound designer to set up a different sound to be played automatically after a sound has been played - for example, play a cloth sound after a footstep, or a grunt after a jump. Since both can have random selections, it allows the sound designer to set up pretty nice audio sequences without interaction with the code.

  • I really want to be able to assign a Mixer to the AudioRandomContainer, and have the AudioSource play the sound through that container. We do that for our system (though it’s not visible on the gif I posted as the mixer is assigned to a parent asset), and it helped a lot. Sound designers should be responsible for what sounds go through what mixers, but forcing them to go through the nitty-gritties of prefabs and scenes makes that hard to do. So we find that mixers doesn’t belong on audio sources, they belong on sounds.

15 Likes

Hi and thanks for all the great comments and questions:). Really great to get some feedback at this stage. I will see if I can answer all of them.

Naming… A hard one and we probably can’t nail it - In all of our research we didn’t see any clear naming that would explain the feature behind. I guess we need to do more on the documentation side.
The main reason for having a new window is that it opens up for a workflow where the user can preview and choose audio clips and always have the Audio Random Container present in another window.
And thanks for pointing out that disable/enable + volume in the audio clip list is not totally clear. Good idea with graying out the clip entry or reuse Timeline UX. And likewise for showing what is currently playing. It is definitely something we would like to look more into. The more visual and easy and understandable the interface can be, the better. Also extensions to audio mixer groups are on our radar.
I really like your idea for “Next”. We are looking into having public API’s from where you can get the signal when a clip is done and when to play a “Next” sound. Currently we are looking for having that kind of codeless flow in Visual scripting, but having it directly in the interface might make a lot of sense. It really extends the use cases.
Once again thanks for all the great comments. I hope that the Audio Random Container will be useful for you, so you can save the trouble of creating it yourself over and over again. That has been a main driver for adding it to the Audio tooling:)

3 Likes

I would change the default settings of the Audio Random Container to the following:

  • Trigger = Manual (Currently Automatic)
  • Playback Mode = Random (Currently Sequential)
  • Avoid Repeating Last = 1 (Currently 0)

For most use-cases, I would play a random AudioClip from the list instead of playing all the AudioClips in the list automatically one after the other.

My recommended default settings would, for my standard use-case, involve fewer clicks.

3 Likes

Hey, Peter I agree with you for the default settings. In most cases I was able to start using it for my Metroidvania test project with those settings and they are honestly what I used 90% of the time.

The only main one I ended up thinking about creating a Unity preset for was a preset for Tigger = Automatic in some cases. But in most cases I used manual for all of them.

For anyone wondering how I used the new feature it is with weather SFX for the most part. Randomizing the sound of thunder/rain in part’s of the game. Also used it to easily switch between how they sound outdoors vs indoors in different environments. Think outdoors in a forest vs indoors in a castle hallway.

Also used it to test some use cases for enemies that are injured vs uninjured. I have different animations for disabled/ low health enemies. Wanted to try using the audio container to make their footsteps sounds heavier when they are low hp and dragging their weapons on the ground as they move.

I do think my first thought is a rename of the component. It is selling itself way too short for what it can do. It can be used way more than for randomized audio. So far I found several cool use cases for it. More than the mention above.

2 Likes

Hi Peter. Thanks for the feedback. We are currently collecting data for the most used default settings, so it is definitely something we want make sure is correct, so great with the feedback:-)

Hi. Great to see your feedback:-). We are currently looking at learning material, so if you can share more about which use cases you are thinking of, we can get inspired by that:-)
Kind regards Mikkel

Just as a fast UX thing: I didn’t know what to do with the asset. I though information would show up in the inspector. It was later when i discovered you have to double click and open a window. Why doesnt the inspector display anything?

This is what Alt+P is for, no?

1 Like

How to play OneShot audio when using the new AudioResource? We can assign the resource to the AudioSource and call play but PlayOneshot method requires clip as a parameter

1 Like

We have since added a bigger Edit Audio Random Container button in the inspector that will also open the window.

PlayOneshot is currently only supported for AudioClip, but not yet AudioResource/AudioRandomContainer.

I still don’t quite understand why it’s not just the same workflow as most other assets, where you interact with it in the inspector. All the assets where you can’t do that are things like AnimatorControllers and VFX Graphs and other assets that require large UIs in order to interact with them. That’s not the case for the Audio Random Container!

There’s this answer for it from earlier:

But you already have a tool for that - the property window. I guess older users might not be really aware of that yet as it’s newer, but you should train users to use the tools you have instead of implementing a new special case that does exactly the same thing.

1 Like

By “currently”, does that mean that it’s on the roadmap to support it?

1 Like

Yes, I implemented AudioRandomContainer Now I am confused whether to stick to it or go back to AudioClips. I need OneShot Audio for my game. Any Hack I can follow for now using pooling AudioSource May be?

Yeah a pooling audio source solution isn’t very hard to set up. Just keep a list of sources and whenever you play a “one shot sound”, you move the source, Play, and spawn a coroutine that returns it when the sound is done.

You’ll probably want a different solution for looping music, but that’s not relevant to OneShot anyway.

1 Like

Getting the length of the clip is a problem to despawn once its done playing.

TLDR: Don’t use the Audio Random Container, unstable. Play random audio the old fashion way.

I tried out the Random Audio Container this morning and it is buggy as hell. I am not using a beta version of Unity, this is released in 2023.2.12f1. Just a few simple footsteps and it couldn’t handle it during a run cycle. Unity, please for the love of all things, test your stuff and stick to standard workflows. The data is not even using the inspector and opens it’s open window to edit. I cannot believe Unity would release such a buggy asset into a production version. My prediction for this is it will be yet another abandoned and useless feature.

Yeah, I would go one step further and say don’t use any Unity audio stuff in general. Learn FMOD Studio or Wwise.

2 Likes

I wonder if some of the fixes for Audio container will be backported to 2023.2. In 2023.3 beta, several fixes landed for that stuff. With 2023.3 Audio container really got less issues and some of them seem like they could be backported to 2023.2. Maybe they could even backport the QOL commands that were added. There were some short cuts and new commands that make working with audio container a lot easier. They maybe be also able to be backported.