Search Unity

Ambient Sounds

Discussion in 'Assets and Asset Store' started by AdamGoodrich, Mar 16, 2019.

  1. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    Hi, I have a game outside loops playing (wind, birds etc), when I enter a building I'd like to lower the volume of the those sounds but not other sounds, is this possible?
     
  2. PWPeter

    PWPeter

    Joined:
    Dec 16, 2018
    Posts:
    555
    Hi, yes, this should be possible as long as these sounds that you want to turn down are contained within different sequences than the "other sounds" that should still play at full volume.
    If that is given, you can set up a modifier that lowers the volume of the sequence and that modifier becomes active when you enter the building.
    You can take a closer look at the Ambient Sounds Demo scene: If you start the demo scene, there is a path that takes you down to a village, in the village there are multiple gazebos to demonstrate modifiers for sequences. One of the gazebos is set up to lower the background music when you enter it, you could apply the same logic to your sequence as well.
     
    derkoi likes this.
  3. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    Thanks for the reply. Looking at the gazebo mute modifier you suggested seems to lower the volume, but I'm not sure how to select the sequences I'd like to lower the volume of? I get the impression it's lowering the master volume of the plugin?
     
  4. PWPeter

    PWPeter

    Joined:
    Dec 16, 2018
    Posts:
    555
    It is the other way round - You can attach a modifier to a sequence to determine which sequence the modifier should apply to. Check the Sequence: Town BGM in the demo scene, you can find it in the folder
    Assets\Procedural Worlds\Ambient Sounds\Demo\Sequences
    In this sequence you can see that it has multiple modifiers attached to it, including the mute modifier:

    upload_2019-9-10_14-13-37.png

    So what you would need to do is:
    1. Create a mute modifier with an event to control whether it is active or not
    2. Assign the mute modifier the sequences which should be muted
    3. Trigger the event for the modifier from within your game when your player is inside the building (See the Trigger game object on the Gazebo in the demo scene, it has a script with example code for triggering an event, you could probably even use the same script 1:1)

    upload_2019-9-10_14-18-50.png
     
  5. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    This looks like a great new asset. I have a question regarding the 1D audio area as demonstrated in the video for the ocean area. Is this meant to play the audio whenever the player is close to the Y plane of the audio area? No matter where in the scene the player is? If so, I'm wondering how it works where you have an island and the water is in the entire scene, but you only see it around the perimeter. What happens if you are in the middle of the island and there is a really low point, say 1 meter from sea level, but you are still on land. Will I hear the water audio in that case?
     
  6. PWJonathanW

    PWJonathanW

    Joined:
    Jul 23, 2018
    Posts:
    1
    yes, the 1D AudioArea just checks player position along a single local axis of your choosing. The initial ideas for adding it were things like wind sounds when above a certain height. If you have an area that dips into the activation range but you don't want it to be active, you can disable the 1D area by having it's sequence check for a Value or Event then having an AudioArea in that position that has a Sequence with that Value in it's "Values While Playing" or Event in "Events While Playing" lists (it can have no tracks if you only want to set the value). An option to set Values in AudioAreas without having to use a Sequence is planned for future updates

    upload_2019-10-23_15-4-26.png

    upload_2019-10-23_15-1-15.png

    Alternatively, you can just use a few 2D or 3D areas that overlap. as long as they use the same Sequence, only one instance of the Sequence will play at any time.
     

    Attached Files:

    AdamGoodrich and PWPeter like this.
  7. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Thanks. This gives me some other idea son solutions as well.
     
  8. Michal_Stangel

    Michal_Stangel

    Joined:
    Apr 17, 2017
    Posts:
    151
    Hello,

    First of all, your asset is absolutely stellar. I expected something much less complex, which I will only use to do my own ambient sound system with lot of randomization. But as it turned out it can do everything out of the box. So I happily decided to stick with it.

    There is one thing i struggle with though. In my game player controls several characters and camera can rotate and zoom freely around active one. So as an Player object in Manager settings I set character which is currently selected (in runtime). All ambient sounds Sequences use Player Position and Output Prefab where my Sound Effect mixer is set. This setup makes animal sounds being spawned correctly around character and not around camera, which can be anywhere at that moment.

    But now I've run into this problem. I have an island surrounded by water. And best setup I found is using long 3D areas around island with like 30 meters falloffs. But I need sound source to being placed on camera and follow it in this case, so Sea loop volume is always the same and only decrease due to moving through falloff area. This works perfectly when I change Player object from active character object to main camera. But it mess up spawning animal sounds effects of course. Make them being spawned around camera and not around played character.

    Would it be possible in some future update to add secondary Player Object to Manager settings and possibility in Sequence Output option to choose between primary or secondary one? Or maybe there is some elegant solution in current version I am missing.

    Michal
     
  9. PWPeter

    PWPeter

    Joined:
    Dec 16, 2018
    Posts:
    555
    Hi Michael, great to hear that you are liking Ambient Sounds! In theory we could add another transform and call that the second Player or something and then allow all sounds etc. to be directed at the second player, but it would create a technical problem: Ambient Sounds uses the Audio Listener component of unity, to maintain compatibility with the existing audio infrastructure so that custom audio sources and spatializer plugins still work with it, you can use the unity mixer as usual, etc.
    You can only have one of these Audio listener in a scene at the same time, if you create another one it produces a warning and the component will be disabled.
    There is also a logical part in this problem: Usually you want the 3D sound in the game to be played back at the camera position so it feels and sounds right for the player. Some games decide to map the listening position to the character instead so the player "can hear the same as the game character would". But as soon as you add another listener in the mix it gets problematic: When a 3D sound is played that both listener can hear - how should it be played back then? For the direction of Listener A, or B, or both? If you would separate some sounds only to be heard by listener A, and some only by listener B it would be an inconsistent experience. How would you apply reverb zones when both listeners are in different zones? etc.
    Could you maybe describe your problem a bit more, because I think there must be another way to solve this. If I understand you correctly, you want the player character to be the listener, and not the camera. But if that is the case, wouldn't the player then pick up the sound of the waves correctly as well? (As long as the player character stays in the audio area) Can you maybe post a screenshot to illustrate the problem?
     
  10. Michal_Stangel

    Michal_Stangel

    Joined:
    Apr 17, 2017
    Posts:
    151
    Hi Peter,

    Thanks for an answer. I probably explained it a bit vaguely.
    There would be still only 1 Audio listener, which is on camera in my case. But most of the Sequences (animal sounds) would be placed around active player character and some specific Sequences would be placed around camera (sound of sea loop), which would be set as secondary "Player object" in Manager settings. For this sound of sea Sequence I would set distance to 0 and check follow. Meaning player would hear same sound (same volume) when orbiting and zooming camera above water, decreasing in volume only if leaving 2D sea area due to falloff, which is perfect. But meantime, all other animal sounds would be placed around active player which is not moving (primary "Player Object"), with audio listener still on camera, which is correct.

    It would just add possibility for Sequence to select from two "Player" objects instead of one, so Audio Sources could be placed around object 1 (active player in my case) or object 2 (camera in my case).

    If it's still confusing, I can try to start my cameraman career and create short video :)
     
    Last edited: Nov 25, 2019
  11. PWPeter

    PWPeter

    Joined:
    Dec 16, 2018
    Posts:
    555
    Not required, I think I got it now, I was missing the information that the animal sounds should still be picked up by the camera even though they are generated around the player character. I think you can do this in Ambient Sounds already, with a bit of extra scripting:
    Try to create an extra Audio Area dedicated for those animal sounds. Use the existing animal sounds sequence in it. Set both the output type in the audio area and in the sequence in the exact same way as you have it for your currently animal sound spawning, but set the output type to "Local Position" instead.
    Now you should have an Audio Area that does the exact same animal sound random spawning, but the sounds should be spawned at the local position of the Audio Area instead of the player position.
    Next you would need to write a script that makes the Audio Area follow the player character, and you should have it already: Since the sounds are created around the local position of the Audio Area, and the Audio Area follows the player, you should have random generation of sounds around the player while the camera stays the listener.

    What you would need to fine-tune is the distance of that Audio Area: Since the Audio Area only plays when the listener (=camera) is inside it, you would need to make sure that the area is large enough that the playback starts again when the camera is near to the player character.

    Another thing you would need to control is when you want to restrict the entire animal sound generation to a distinct area, then you would either need to extend the logic of the follow script a bit to deactivate the audio area, or tie the sequence used in there to a condition in Ambient Sounds.
     
  12. Michal_Stangel

    Michal_Stangel

    Joined:
    Apr 17, 2017
    Posts:
    151
    Using Local Position for areas is an interesting idea. Because sometimes character stands at the edge of area, e.g. Forest, and because horizontal angle in Sequence Output is set to -180 to 180, sounds in Sequence can be spawned outside area. Using Local Position and set max Distance in Output of area as an area length / 2 would solve it. At least for Sphere areas and partially for square ones. Or maybe add some option to Output settings, that sound source cannot be spawned outside area boundaries, no matter if Player Position or Local Position is used? Other than this, I am really ok with using character position for animal sounds spawning.

    But my original problem is how to play sounds which should have same volume accross whole area, like mentioned Sea sound loop. And found out that it's easy to do by spawning Audio Source on same object as where Audio Listener sits (camera in my case) and check Follow in Output settings in Sequence. Only problem is, it requires change Player object in main Manager Settings from active player to camera (in my scenario), so I would not be able to use this object for normal positional spawning of animal sounds in many game areas, as camera can be flying in all angles all the time.

    Anyway, as I mentioned at the beginning, your asset is awesome as it is and I know you have a lot of work with Gaia, not to mention Black Friday :) I will work on my game for several years, so I don't ask for some quick solution. If you will have some time in future and it will makes sense for you, you can add some additional option for Audio source spawning reference point maybe. Or I will probably be able to add it myself, as most of the users will not have this problem.
     
  13. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    All the soundtrack along with Ambient Sounds - Interactive Soundscapes is free to use like for game that will be selling?
     
  14. PWPeter

    PWPeter

    Joined:
    Dec 16, 2018
    Posts:
    555
    Yes, the sound files are cleared for this usage, they can be used in commercial and non-commercial game projects that you create.
     
  15. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    In this tutorial
    . Is it necessary to place water sounds more then one time? I mean, this only occur if you run on the special height near to the point isn't it? so you have to set up multiple point around an island correct?
     
  16. Pourya-MDP

    Pourya-MDP

    Joined:
    May 18, 2017
    Posts:
    145
    Hey there every one i have a simple question isn't there any loop bool to uncheck so the sequence will play one shot??
    I have so many sequences in my scene and want to play them through events individually only once
    But right now if you start a sequence it will keep playing it as long as game running
    Any help will appreciated
     
  17. PWPeter

    PWPeter

    Joined:
    Dec 16, 2018
    Posts:
    555
    This is necessary when you have a water shape that can't be represented well with a single sphere or box volume. If you have a (mostly) round lake you should be fine with a single sphere audio area. If you have a (mostly) straight coast line, then a large box volume should be able to cover it well. If you have an oddly shaped body of water, or an island, then you can create multiple volumes to make sure the water sound is played everywhere at the right position.
     
    Sam512 likes this.
  18. Michal_Stangel

    Michal_Stangel

    Joined:
    Apr 17, 2017
    Posts:
    151
    This works best for me. Place thin 3D area on water, with falloff representing volume increase/decrease caused by distance from water. As an Output in Sequence use camera (Player Position) and set distance in Output to 0 and check Follow Position.

    Only problem I have with that is that I need to place ambient animal sounds around player characters and not around camera. And because you can currently have only one Player Object defined in Manager Settings I cannot set water like that. But I hope guys will add secondary Player Object option in some future update. Or ideally add option to Sequence for specific Player Object, meaning object which is reference point for audio source spawning.
     
    Sam512 likes this.
  19. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    Okay, thanks! I have another issue
    How can I add global ambient sound like.. in town I have specific town music right... so when I leave the town area the global ambient music will play and when I enter town area or other area with specific music the global ambient music will be blocked and play that specific music instead.. how can I do this?
     
  20. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    Can this be achieved like the event system shown in the video? I hope it's okay to put too many audio areas over each other
     
    Last edited: Dec 3, 2019
  21. Michal_Stangel

    Michal_Stangel

    Joined:
    Apr 17, 2017
    Posts:
    151
    Is it correct that all loaded audio clips remain in memory, referenced in loadedAudioClips dictionary? I have huge amount of high quality clips, so I am a bit concerned about memory usage. Even if Preload Audio in Manager is unchecked, audio clip sits in memory once played for the first time, right?
     
  22. PWPeter

    PWPeter

    Joined:
    Dec 16, 2018
    Posts:
    555
    Yes, you can use the event system to block one sequence and play the other instead. You can check the gazebos in the town in the demo scene for an example for this - when you enter the gazebos a modifier is activated by an event, but you could use the same mechanism to block the global ambient music instead.
     
  23. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    I decided to pick this up and will be using extensively in my game. I love what you've done so far with this asset. It will definitely save a lot of time and effort.
     
    AdamGoodrich and PWPeter like this.
  24. HenryChinaski

    HenryChinaski

    Joined:
    Jul 9, 2013
    Posts:
    108
    Hi!

    First of all, thanks for the asset. It works perfectly in our use case.

    Unfortunately, I think I stumbled upon a bug or I am missing something. I want to assign all the audio from the Ambience Manager to a mixer group, so I can fade the sounds in when the game starts. I checked the "use audio source" at the Ambience Manager component and assigned a prefab with a simple audio source component on it. As soon as the game starts, the Ambience Manager is recreated on my player object where the audio listener is located, but the "use audio source" bool is unchecked and the assigned prefab is missing - so the audio is not assigned to a mixer. I can manually change the bool and prefab at startup, but since it is an already implemented feature, I just wanted to ask if you have an idea what's going wrong. There is no error message and I am running on Unity 2018.1.1.

    Best regards,
    Daniel
     
  25. BryanPW

    BryanPW

    Joined:
    Apr 20, 2017
    Posts:
    232
    Ok to help fix this issue you need to move the AmbienceManager itself to the camera on startup (it has to be attached to the camera to work properly) and not copying that setting to the new instance,
     
    HenryChinaski likes this.
  26. chris_schubert

    chris_schubert

    Joined:
    Jan 8, 2019
    Posts:
    28
    How can I get the current level (not the clip volume) of a sequence? So that I can have the actual audio level drive other events.
     
  27. BryanPW

    BryanPW

    Joined:
    Apr 20, 2017
    Posts:
    232
    The AmbienceManager has an overall "m_volume" value
    To get the volume level of any specific Sequence there are several properties of Sequence that give information.
    Volume (volume this sequence will try to output at 1.0 fade), FadeValue (0-1 for this track fading in/out), PlaybackSpeed, TotalLength (length of all tracks in sequence), TrackDelayTime (time system is waiting before this track will be buffered), RandomizePlaybackSpeed, MinMaxPlaybackSpeed, RandomizeVolume, MinMaxVolume.
    the Volume property takes the random volume into account and is multiplied by the FadeValue and the overall m_volume of the Manager to get the final value
     
  28. chris_schubert

    chris_schubert

    Joined:
    Jan 8, 2019
    Posts:
    28
    Thanks for the info Bryan. I'm actually looking for the audio level, not the volume setting. If we were talking about an audio mixer, I believe the values you shared would be controlling the position of the sequence "fader" knob. I'm looking for the sound level that would be displayed on a VU meter. So, higher value when the clip is in louder section, lower when the clip is in a quiet section.

    Sorry if the question is confusing. Is that level information available?
     
  29. chris_schubert

    chris_schubert

    Joined:
    Jan 8, 2019
    Posts:
    28
  30. chris_schubert

    chris_schubert

    Joined:
    Jan 8, 2019
    Posts:
    28
    Is it possible to get the info I'm requesting, Bryan or Peter?
     
  31. BryanPW

    BryanPW

    Joined:
    Apr 20, 2017
    Posts:
    232
    "Is there a way to get the audio level, not the volume setting"
    Currently, no there is not. We are looking into possibly adding this.
     
  32. chris_schubert

    chris_schubert

    Joined:
    Jan 8, 2019
    Posts:
    28
    Thanks. Exposing some of the realtime audio properties like level (or level per area) could enable audio-reactive gameplay elements. A simple example would be modifying the amplitude of tree-wind animations to match the volume of a wind track. Weather alone offers a lot of possibilities that I think fall into the Ambient Sounds arena - thunder, lighting, wind, etc.

    This tool offers a lot in the way of how/when to cue sounds, but I would take advantage of more options in how to react to sounds (not just them starting, but their content). Events could be triggered like noise gates - when the level of a certain sequence or "channel" (like mixer channel, or group of sequences) exceeds a threshold, an event is triggered. This could enable something like animal reaction to sounds based on proximity.

    Please let me know if you see any kind of value in exposing these types of settings, either in the short or long term. For me, it will be a determining factor in my use. Thanks!
     
    BryanPW likes this.
  33. Pandur1982

    Pandur1982

    Joined:
    Jun 16, 2015
    Posts:
    275
    Hello, i have a Problem, when i start my Game in Playmode in Unity i hear Sound and that works with no Problems and errors, when i build my Game i hear no Sound more.Any Ideas what do i wrong?
     
  34. Pandur1982

    Pandur1982

    Joined:
    Jun 16, 2015
    Posts:
    275
    Ok found the Problem, my Player have the AudioListner and not my Camera, i have change that and no that works with no Porblems.
     
  35. BryanPW

    BryanPW

    Joined:
    Apr 20, 2017
    Posts:
    232

    I will look into the possibility, and see what we can come up with!
     
  36. Michal_Stangel

    Michal_Stangel

    Joined:
    Apr 17, 2017
    Posts:
    151
    I wonder how to prevent memory from being flooded with audio clips I currently don't need.
    Audio Sequences use direct references for it's audio clips. So once I use AmbienceManager.AddSequence(), all audio clips inside it are loaded into memory. When I don't need Sequence anymore and use AmbienceManager.RemoveSequence(), it's audio clips remain in memory.
    I realized I cannot use it to play music as I have too many music clips for different game scenarios and it would consume all the memory at some point.

    Could you please consider using AssetReferences instead of direct references and add option for unloading finished audio clips from memory, through Addressables.Release(audioClip)?
     
    EnigmaFactory likes this.
  37. BryanPW

    BryanPW

    Joined:
    Apr 20, 2017
    Posts:
    232


    I will look into this!!
     
    EnigmaFactory likes this.
  38. IEdge

    IEdge

    Joined:
    Mar 25, 2017
    Posts:
    51
    Hello.
    It is possible to play sounds from A to B? For example I want to play "Game Intro" from 0:30 to 1:20 only.
     
  39. BryanPW

    BryanPW

    Joined:
    Apr 20, 2017
    Posts:
    232
    I would just change the clip to that in your audio application, for example, I use Fruity Loops. Then just use that clip.
     
  40. JeffG

    JeffG

    Joined:
    Oct 21, 2013
    Posts:
    85
    I have a strange issue. May be due to Unity 2020 though. I add Global sequences, but when I run the game, those Global sequences are deleted from the list.

    Edit: Figured it out. (Kinda) If I added it to AM Global list that was attached to my camera (ie Audio Listener) it saved and worked as expected. Adding it to the Main Project window didn't. Probably has to do with how I use my camera's
     
    Last edited: Aug 9, 2020
  41. BryanPW

    BryanPW

    Joined:
    Apr 20, 2017
    Posts:
    232
    I am glad you have figured it out if you need help please let me know!
     
  42. Michal_Stangel

    Michal_Stangel

    Joined:
    Apr 17, 2017
    Posts:
    151
    Hello, did you guys look into Addressables and using AssetReferences already?
     
  43. BryanPW

    BryanPW

    Joined:
    Apr 20, 2017
    Posts:
    232


    AmbienceManager.AddSequence(Sequence) and AmbienceManager.RemoveSequence(Sequence) to add or remove a sequence at runtime. If the sequences have requirements, those will still be enforced so you will need to make sure the "requirements" setting is set to "none"
     
  44. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    455
    Ambience Manager creates a lot of garbage when there's a good number of audio zones in level. Is there a way to combat this?



    Even when there's only 5 zones, it generates 0.5 kb of garbage. Which is a lot.
     
    Last edited: Dec 14, 2020
  45. BryanPW

    BryanPW

    Joined:
    Apr 20, 2017
    Posts:
    232

    We are looking into this!
     
    Gua likes this.
  46. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    455
    Can you tell a rough release date for the patch with the fix?
     
  47. BryanPW

    BryanPW

    Joined:
    Apr 20, 2017
    Posts:
    232

    I will check into this and post here!
     
  48. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    455
    Any news on this matter?
     
  49. BryanPW

    BryanPW

    Joined:
    Apr 20, 2017
    Posts:
    232
    We are working on a patch now hopefully not much longer!
     
  50. BryanPW

    BryanPW

    Joined:
    Apr 20, 2017
    Posts:
    232

    An update has been published!!!