Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  3. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Official The Audio Random Container - 23.2 alpha feature release

Discussion in '2023.2 Beta' started by harini, Apr 18, 2023.

  1. harini

    harini

    Unity Technologies

    Joined:
    May 28, 2015
    Posts:
    45
    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
    1. 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.

    2. Open your project in Unity and create the Audio Random Container through the various options:
      1. From the menu:
        1. The Unity Editor contains a working menu item Asset -> Create -> Audio -> Audio Random Container that creates an empty Audio Random Container asset.
      2. The project view:
        1. 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!
     
  2. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,342
    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;
    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.
     
  3. Mikkel_Munch-Christiansen

    Mikkel_Munch-Christiansen

    Unity Technologies

    Joined:
    Sep 23, 2021
    Posts:
    6
    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:)
     
    Last edited: Apr 19, 2023
    MrDizzle26 and mariandev like this.
  4. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,625
    I would change the default settings of the Audio Random Container to the following:
    1. Trigger = Manual (Currently Automatic)
    2. Playback Mode = Random (Currently Sequential)
    3. 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.
     
  5. Jonathan-Westfall-8Bits

    Jonathan-Westfall-8Bits

    Joined:
    Sep 17, 2013
    Posts:
    289

    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.
     
  6. Mikkel_Munch-Christiansen

    Mikkel_Munch-Christiansen

    Unity Technologies

    Joined:
    Sep 23, 2021
    Posts:
    6
    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:)
     
  7. Mikkel_Munch-Christiansen

    Mikkel_Munch-Christiansen

    Unity Technologies

    Joined:
    Sep 23, 2021
    Posts:
    6
    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
     
  8. joan_stark

    joan_stark

    Joined:
    Jul 24, 2018
    Posts:
    52
    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?
     
  9. Saniell

    Saniell

    Joined:
    Oct 24, 2015
    Posts:
    205
    This is what Alt+P is for, no?
     
    mariandev likes this.
  10. sathya

    sathya

    Joined:
    Jul 30, 2012
    Posts:
    298
    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
     
  11. zollenz

    zollenz

    Unity Technologies

    Joined:
    Jun 4, 2019
    Posts:
    27
    We have since added a bigger Edit Audio Random Container button in the inspector that will also open the window.
     
  12. zollenz

    zollenz

    Unity Technologies

    Joined:
    Jun 4, 2019
    Posts:
    27
    PlayOneshot is currently only supported for AudioClip, but not yet AudioResource/AudioRandomContainer.
     
  13. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,342
    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.
     
    Peter77 likes this.
  14. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,342
    By "currently", does that mean that it's on the roadmap to support it?
     
    sathya likes this.
  15. sathya

    sathya

    Joined:
    Jul 30, 2012
    Posts:
    298
    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?
     
  16. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,342
    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.
     
    sathya likes this.
  17. sathya

    sathya

    Joined:
    Jul 30, 2012
    Posts:
    298
    Getting the length of the clip is a problem to despawn once its done playing.
     
  18. s4lt3d

    s4lt3d

    Joined:
    Nov 21, 2014
    Posts:
    14
    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.

    upload_2024-3-10_9-8-54.png
     
  19. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,958
    Yeah, I would go one step further and say don't use any Unity audio stuff in general. Learn FMOD Studio or Wwise.
     
    Lurking-Ninja and s4lt3d like this.
  20. Jonathan-Westfall-8Bits

    Jonathan-Westfall-8Bits

    Joined:
    Sep 17, 2013
    Posts:
    289
    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.
     
  21. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,958
    Why would you stick with 2023.2? I know people say take one Unity version and stick with it, but you shouldn't do that with TECH releases, you should ride the wave towards LTS if you start using TECH.
     
    Peter77 likes this.
  22. zollenz

    zollenz

    Unity Technologies

    Joined:
    Jun 4, 2019
    Posts:
    27
    Hi there. I'm sorry you are hitting these issues when using the Audio Random Container. We have definitely not abandoned it. As @Jonathan-Westfall-8Bits noted, there are are many fixes in 2023.3 that should improve the experience greatly and there are more coming. Any of these fixes that have not been backported to 2023.2 yet will be ASAP. We want the feature to be as stable as possible.

    As for the job temp alloc warnings you posted a screenshot of: are you getting these when working with prefabs? If yes, it's a known issue and it's on our radar. Though admittedly annoying, these warnings should not affect the functionality of the ARC. Can you elaborate on the issues you're having with your run cycle?

    As for why the UI is in a separate editor window rather than the inspector, as @Mikkel_Munch-Christiansen posted earlier in the thread, that was a design choice. The feedback has been noted (we know it's a recurring one), but this will not change in 2023.2 or 2023.3.
     
    Last edited: Mar 11, 2024
  23. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,342
    Those temp alloc warnings are pretty bad, and it's something that comes up in a lot of different instances. There's no guarantee that @s4lt3d is getting these warnings from the ARC, it could be some change in the editor UI or whatever that just happens to be triggered by this version.

    You really need to improve what information is in there, as "something is wrong somewhere lol" is not helpful information. Unity is riddled with these kinds of errors and warnings with no stack trace, no information about which subsystem sends them, or no information about which asset/object the error relates to.

    I'm talking about things like
    "[worker(0)] can't create a directory out of process"
    "Some mesh has some bones with no weights"
    "There is some allocation that's long-lived!"
    "SerializedObject target has been destroyed."

    You should really just sit down with the entire code-base, search through every single call that outputs information to the console, and ask the question "is this information actionable in a real project?" If the answer is "no", add whatever information's required, or delete the output.
     
    Last edited: Mar 11, 2024
  24. zollenz

    zollenz

    Unity Technologies

    Joined:
    Jun 4, 2019
    Posts:
    27
    No disagreement here, warning and error logs should provide useful information. And you are absolutely right, the root cause for that warning could be something else.

    ARC issue tracked here.
    Other issue that results in the same warning, but different cause.
     
  25. Jonathan-Westfall-8Bits

    Jonathan-Westfall-8Bits

    Joined:
    Sep 17, 2013
    Posts:
    289
    Sorry I somehow skipped over this question. My apologies.
    For the current moment on our teams commercial project we are working on updating to 2023.3 because of the render graph. We have a branch on both 2023.2 and 2023.3. I agree with you on riding the tech release wave. We just have to convert more stuff over to render graph (been super easy and simple so far), do some checks on a WebGPU build, and lastly finish up some updates for certain UI Toolkit stuff.

    But so far the audio container is a lot better in 2023.3 in every way possible. I don't have any bugs and we have not noticed console logs, visual bugs in inspector for the audio container, or audio issues in build except on for WebGPU builds. The WebGPU builds bug is honestly more related to the core audio than just audio containers, but I think I saw a notification saying the bug was found and a fix is already being done.
     
    AcidArrow likes this.
  26. Jonathan-Westfall-8Bits

    Jonathan-Westfall-8Bits

    Joined:
    Sep 17, 2013
    Posts:
    289
    Hey, just thought I would let people know in the patches notes today for the newest version of Unity 6 had some of the previous mention fixes that were coming down the pipeline. Uploaded an attached image with three of the ones that some people asked about.

    Not sure when or if they are already coming down, but they might be being backported already to Unity 2023.2. Not sure yet on that timeline or if the work for backporting is already started, but thought people might be happy to see the bugs mentioned are fixed in some areas.

    Main ones that were fixed in the Unity 6 version for some are probably the console spams and the null reference error spamming.
     

    Attached Files:

  27. s4lt3d

    s4lt3d

    Joined:
    Nov 21, 2014
    Posts:
    14
    I just want to clarify that the scene I was working in had very few items in it and nothing that used jobs. The errors came up only when using ARC and the sounds overlapped as the footsteps would repeat quicker than the length of each track. This warning was spammed to the console which is a no go for any project. I was playing around with the new system for making footsteps for a player controller in a grey boxed scene. The warnings came up only when using ARC. It's not great to see warnings every time the game is played as it will cause warning fatigue and developers will start ignoring issues in the editor.
     
  28. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,491
    The "opens in a separate window unlike almost everything else in Unity" is just like the Audio Mixer Groups window. Very confusing for newcomers. If you're going to lean into this "audio is a system, not an asset" mindset, then get rid of the stupid singleton "Audio Listener" component which also trips up newcomers, and just mix all active listeners.
     
    s4lt3d likes this.
  29. zollenz

    zollenz

    Unity Technologies

    Joined:
    Jun 4, 2019
    Posts:
    27
    Agreed, and if this is indeed the issue, a fix is in progress.

    Were the sounds overlapping when the automatic trigger mode was set to offset or pulse? If it's the former, there should be no overlap and it's a bug. If it's the latter, then it's intended.

    Or were the overlaps you were experiencing more a "bunching up" where many clips would suddenly be playing all at once?
     
  30. zollenz

    zollenz

    Unity Technologies

    Joined:
    Jun 4, 2019
    Posts:
    27
  31. Buzzrick

    Buzzrick

    Joined:
    Aug 2, 2013
    Posts:
    3
    Is this Audio Random Container feature going to be available in Unity v2022.3.x?
     
  32. zollenz

    zollenz

    Unity Technologies

    Joined:
    Jun 4, 2019
    Posts:
    27
    No, it is only available from 2023.2 and on.