Search Unity

Master Audio - AAA Sound Solution. #1 audio plugin on Asset Store!

Discussion in 'Assets and Asset Store' started by dark_tonic, Jan 28, 2013.

  1. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I mean you can always access the Audio Source of things Master Audio is playing for sound effects (via code). Then you could do whatever to it. Simply don't add that Sound Group to Ducking. It won't affect anything. It can be as lightweight as you like. If you don't need extras, then you don't turn them on. I can show you code how to get to the Audio Source here.

    Code (csharp):
    1.  
    2. private AudioSource audSrc;
    3.  
    4. private void AwakeOrWhateverMethod() {
    5.   var playResult = MasterAudio.PlaySound3DFollowTransform("YourSoundGroup", this.transform);
    6.    if (playResult.ActingVariation != null) {
    7.       // sound did play, record Audio Source for later use.
    8.       audSrc = playResult.ActingVariation.VarAudio;
    9.    }
    10.  }
    11.  
     
  2. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    1,334
    I guess I'll have to familiarize myself more with the API and the inner workings of MA to use it to full effect.
    Thank you for your patience.
     
  3. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    No problem, and we're always here if you run into things that aren't clear.
     
    _geo__ likes this.
  4. techniquea2z

    techniquea2z

    Joined:
    Jun 3, 2017
    Posts:
    37
    Is there a way to determine auditory range on playing SFX through code? Like playing at a specific transform but at a given earshot range.
     
    twobob likes this.
  5. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Could you please rephrase the question? I'm not sure what you mean.
     
    twobob likes this.
  6. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
     
  7. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    That's outside of the realm of my knowledge, but no, we don't have anything like that.
     
    twobob likes this.
  8. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Eh I provided a ridiculously detailed answer. It contained at least three way of doing that. One insanely easy one. Be right.
     
  9. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Meant to say . about 7 years ago... nice guitar.. 0ffb7712a4328a211180c41132f73707[1].png
    That's one of mine there. Enjoy your day
     
    jerotas likes this.
  10. techniquea2z

    techniquea2z

    Joined:
    Jun 3, 2017
    Posts:
    37
    Pretty much asking: Can we define a circle radius of influence for sounds with Master AAA, when playing sounds?

    IE. I have 2D sprites that play a footstep sfx from Master AAA, but I can hear the footsteps while being in a different room.

     
  11. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Not sure what you mean by "circle of influence", but you can define your normal 3D Sound settings of MinDistance / MaxDistance the same as if you're not using Master Audio. Hope that answers your question. You can apply Sound Group Templates to Sound Groups in bulk, or you can tweak the Max Distance individually with the Ambient Sound component and others.
     
    Last edited: Aug 25, 2021
  12. dark_tonic

    dark_tonic

    Joined:
    Mar 23, 2011
    Posts:
    138
    I think the basic answer to this is yes, it is already there.

    When you set up a sound on an object there is a spherical range within which the listener (which is generally attached to the camera, but could be attached to a player character, etc) will hear the sound.

    Master Audio doesn't know / track the distance from listener to sound emitter, just triggers and plays based on these spherical audio objects.

    There is a falloff inside this sphere where the sound is loudest at the center and fades to 0 as you approach the bounds of the sphere. This falloff curve is editable. You can see in the attached image a sphere collider I added to show the min range for the ambient sound (within which sound is at max volume).

    There are also means to set up audio occlusion so that walls and closed doors would block sounds / filter them, but allow the sound to play when the door is open or wall is destroyed, etc.
     

    Attached Files:

  13. dark_tonic

    dark_tonic

    Joined:
    Mar 23, 2011
    Posts:
    138
    oh I forgot there's a gizmo already showing the sphere... I keep them turned off so I totally forgot about that, no need for the collider :D
     
  14. wagenheimer

    wagenheimer

    Joined:
    Jun 1, 2018
    Posts:
    323
    I'm having trouble playing a Looped sound and FadeIn it.

    Code (csharp):
    1.  
    2. MasterAudio.PlaySound("cauldronloop", 0f);
    3. MasterAudio.FadeSoundGroupToVolume("cauldronloop",1f,1f);
    4.  
    The volume simply remains at 0, it does not FadeIn.

    To make it work I had to do this :
    Code (csharp):
    1.  
    2.   var sound = MasterAudio.PlaySound("cauldronloop", 1f);
    3.   sound.ActingVariation.AdjustVolume(0);
    4.   sound.ActingVariation.FadeToVolume(1f, 1f);
    5.  
    Is the first example supposed to work?
     
    Last edited: Aug 25, 2021
  15. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    What you need to know: the total volume of the Variation's Audio Source is always calculated as: (Variation volume) times (Group volume) times (Bus volume, if there's a bus) times (Master Mixer volume).

    So no, the first one would never work and is behaving as designed. You have specified zero volume for your *variation* in that PlaySound command. Regardless of what your Sound Group volume is at any time (as you fade the Group Volume), the total volume would end up being zero.

    So when you change the volume of the Variation (your 2nd example), that will be audible, unless your Group volume was zero, or the Bus volume was zero, or the Master Mixer volume was zero.
     
  16. techniquea2z

    techniquea2z

    Joined:
    Jun 3, 2017
    Posts:
    37
    Thanks for the reply, I've found the blue gizmos indicating range.

    I have another question --

    I am switching between two different main cameras in my game, one for the overworld and another for the battle scene.



    I want to be able to not simply pause/unpause, but to crossfade between the Sound Groups, even across different camera audio listeners.

    Is there a way to do this, even when the FollowTransform changes or gets deactivated?

    Let me know if I need to rephrase.
     
  17. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Well when you change Audio Listeners, you will need to tell Master Audio set setting the Audio Listener via this code:
    Code (csharp):
    1.  
    2. MasterAudio.AudioListenerChanged(yourNewListener);
    3.  
    It will not auto-detect as that's terrible for performance.

    If you want to crossfade between Sound Groups, you'll basically need to fade out one and fade another in. Or do the same on buses if you want to perform the action on a whole range of classified sounds.
     
  18. techniquea2z

    techniquea2z

    Joined:
    Jun 3, 2017
    Posts:
    37
    Got it, this makes sense.

    When I fade out, am I able to return to where I was? Like a pause, for example?
     
  19. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Yes, if you do it from code. There's an optional System.Action parameter you can pass in as the last parameter, that executes after the fade completes.
     
  20. techniquea2z

    techniquea2z

    Joined:
    Jun 3, 2017
    Posts:
    37
    Got it, thanks you've been extremely helpful!

    Another question:

    Say, I have a clip of audio I want to loop. However, the START of the loop is say, 13 seconds into the clip.

    Can I cut a clip of 0-13seconds in so it plays the start only at the first play and loops the second clip that goes from 13s-90s?

    Like have the first "start" of the music as the top sound group variant and the loopable clip under it that looks indefinitely. And set the Variance Sequence to "Top to Bottom".

    Going to give this a shot now, but also just thinking out loud. I see that clips with a custom end position can't be looped, but it would be nice to specify regions of an audio to loop indefinitely and ones that are only played from the first playthrough... if that makes sense!



    EDIT: Basically, I want the first Sound Variant to play once! Then loop the bottom clip indefinitely.

    I could probably manually code this, but I was wondering if there's a built-in solution.

    I tried an "Looped Chain", but it returns to the first variant after playing the second. I only want it to play the first group ONCE upon being played, then loop the second indefinitely.
     
    Last edited: Sep 3, 2021
  21. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    No, you can't loop just a portion of the clip. Although it is a feature I am currently working on, but for Playlist songs only, currently, since it requires 2 Audio Sources and Playlist Controllers already have 2 for crossfading. I may be able to do it for Sound Groups afterward. However, this new feature will be going into a paid upgrade only: Master Audio 2022. It will also include all the Multiplayer functionality of Master Audio Multiplayer.

    This is the first I've spoken of the paid upgrade. We will be ceasing updates for the current Master Audio product at the end of the year.

    Now, you can always actually split your clip into 2, one that's the intro and one that loops. That's pretty easy to do with many wave editing programs such as SoundForge.

    You could use the Linked Group feature to do what you want if you split the clip into 2. The steps:
    1) Put intro sound into Sound Group 1.
    2) Put loop sound into Sound Group 2.
    3) Set up an "End Linked Group" on Sound Group 1 to play Sound Group 2.

    Hopefully it will be seamless, but not guaranteed. Let me know how it works out!

    Hope that helps,
    -Brian
     
  22. techniquea2z

    techniquea2z

    Joined:
    Jun 3, 2017
    Posts:
    37
    This seems to be working out just fine!

    Nice to hear about Master Audio 2022. I hope upgrading wont be too difficult :). I'll definitely be upgrading when the time comes.
     
  23. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Thanks for the support! Upgrading will just be a normal install, nothing additional to do.
     
  24. shubhank008

    shubhank008

    Joined:
    Apr 3, 2014
    Posts:
    107
    Does it support any kind of pooling ?

    I am using Umbrace PurePool and wanted to pool the audio inits because my game is realtime battle arena game which is spawning 50-100 audios within secs on atatcks
     
  25. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    No, because that could be bad for performance. We do however disable all the Audio Sources and scripts that aren't playing at that time. Everything is created on startup so it will always be ready for use.
     
  26. techniquea2z

    techniquea2z

    Joined:
    Jun 3, 2017
    Posts:
    37
    Another question you likely have answered --

    Speaking to transitions between scenes, is it possible to have audio (like a music track) continue to play when transitioning scenes?

    Each scene in my game has it's own Main Camera with an AudioListener attached.

    Or would I have to cache the duration and play the sound at the cached duration in the next scene?

    I suppose making a single Camera and DontDestroyOnLoad is an option, but just checking before engineering my own solution.
     
  27. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Of course. There's a checkbox for "Persist Between Scenes" on the Master Audio game object. Just check it.

    If you need to "change" between multiple AudioListeners, you will need to call a line of code to tell Master Audio to find the new enabled one.
     
  28. shubhank008

    shubhank008

    Joined:
    Apr 3, 2014
    Posts:
    107
    Does it instantiate a audio source for every voice weight actor ?
    I am triggering weapon fire (gun shot) sound in a real time arena game using event sounds and had to increase voice weight for my VFX to 50 as 25 players playing and it started putting lot of performance strain on the game
     
  29. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Yes it does. As I said all non-playing Audio Sources are disabled. It should have no effect performance-wise that I've seen. Also, since Unity 5, it won't even take any extra memory for duplicated Audio Clips.

    If you are playing mp3's for sound effects or actually playing 50 clips at once, that could of course affect the performance and is normal. Not much that can be done about that if you're using optimized Audio Clips.

    And you are aware you can only play 32 voices at once by default, right?
     
  30. Doomchecker

    Doomchecker

    Joined:
    Apr 5, 2021
    Posts:
    109
    Hi,
    is Opsive Third Person Controller integrated as well or only First Person?
    (dumb question probably)

    Thanks for the Info!
     
  31. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Neither. As far as Opsive we have support for Behaviour Designer. If you'd like to reach out to Opsive to request integration, or have us do it, we'd be happy to do so. The integrations are usually written by the author of the other asset (Opsive in this case).
     
    Doomchecker likes this.
  32. Doomchecker

    Doomchecker

    Joined:
    Apr 5, 2021
    Posts:
    109
    Ahh ok I got it wrong there.
    One quick follow up question I have then:
    Is there a build in functionality to play different footsounds on different terrain textures?
    (With the footstep system?)
    Thanks!
     
  33. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Footstep Sounds script doesn't know about textures unfortunately, only tags and layers. You may be able to find a script for textures on the Unity scripting forum, then add Master Audio API calls to it.
     
    Doomchecker likes this.
  34. Zilk

    Zilk

    Joined:
    May 10, 2014
    Posts:
    333
    One thing I've noticed when building a larger project is that it would be great to be able to have GameObjects under the MasterAudio prefab to be able to sort sound groups. Like Enemy-Effects, Player-Effects, Environment etc etc.
     
  35. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Yeah you are looking for "Bus Folders". I tried to implement it awhile back and there were unfortunately too many issues to get it to work, so it was removed from the roadmap.

    Ultimately, what you'll want to do is *not navigate Sound Groups inside the Hierarchy*. You should be able to do absolutely everything from inside the Master Audio Inspectors. You can also filter by bus and do Sound Group Text Filters, etc, down in the Master Audio mixer section. It works at a large scale.
     
  36. deslandesn

    deslandesn

    Joined:
    Mar 24, 2014
    Posts:
    3
    hey there,

    It seems like mecanim events don't fire when the event is on a different animation layer. Am I mistaken? All my base layer mecanim sounds go off properly, but I have a dive animation on a different animation layer and it seems like there isn't a call.
     
  37. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I'm not sure, working in layers makes my head explode. Perhaps you need to add the Mecanim behavior (Mecanim Sounds) to the other layer as well. I think that's probably what it is.
     
  38. deslandesn

    deslandesn

    Joined:
    Mar 24, 2014
    Posts:
    3
    I just added a mecanim state behaviour instead and used the custom events. I'm not here for any head exploding lol.
     
  39. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I'm not sure why that would fix the issue. The code wasn't firing from the sound of it, whether that was playing a sound or firing a custom event. The "animation entered" trigger code is the same on both of those.

    -B
     
  40. deslandesn

    deslandesn

    Joined:
    Mar 24, 2014
    Posts:
    3
    An issue I am running into, and i'll post it here in case someone else runs into it -

    I'm trying to fire a sound programmatically. Everything works up until the sound actually playing. It logs that its queued to play the sound but I can't hear anything. Am I missing a step?

    added these two lines
    using DarkTonic.MasterAudio;

    MasterAudio.PlaySound("ItemEquip");


    The mixer even shows it playing sound but I can't hear anything. Audio seems to be working in every other usage (Custom events and Mecanim events) but just not through code. I even switched from code to mecanim at one point to see if it was something I did wrong in the audio setup and the audio played fine.

    Using unity version 2020.3.11f1

    Thanks so much for your help.
     

    Attached Files:

  41. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    If you can't hear anything, then you're playing it in 3d and your MaxDistance for the Audio Source is less than the actual distance to the AudioListener.

    You can either "Force to 2d" your sound or Bus, or increase the MaxDistance, using Audio Source Templates in the Mixer section applied to one or more groups.

    -Brian
     
  42. amynox

    amynox

    Joined:
    Oct 23, 2016
    Posts:
    178
    Hi,
    First of all thanks a lot for this great asset.

    I want to know if there is a way to tell Master audio playlist component to hold a pause of certain duration when the current playing sound ended and before starting playing the next sound in the Playlist ?
    Thanks
     
  43. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    No you're going to have to code that yourself. You can subscribe to the song ended event of the playlist controller and then do whatever you like such as wait 3 seconds.

    There is a way to do it in sound groups but not playlists
     
  44. sheepjeffery

    sheepjeffery

    Joined:
    Nov 3, 2016
    Posts:
    3
    i have 4 speakers for 4 Players.All speakers connect to the same PC.
    I want to play BGM on all speakers at the same time, and each speaker plays the battle sound of the corresponding player separately.
    Could Master Audio deal with that?
     
  45. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I have no idea if Unity natively supports that or not. If it does, then Master Audio will. We don't add any non-native capabilities to Unity. Since there's only 1 Audio Listener, I'm thinking not. But I could be misunderstanding the question.
     
  46. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Last edited: Oct 17, 2021
    Weblox and Doomchecker like this.
  47. Doomchecker

    Doomchecker

    Joined:
    Apr 5, 2021
    Posts:
    109
    Hey,
    I have 2 questions if you don't mind, would help me greatly to understand :)

    1) I can't get the dynamic playlist with the DSGC element to be recognized by the Playlist Controller. Playlists only appear in the controller when I create them in the MasterAudio component.
    That being said, what would you recommend to handle the following case: I have one main scene with the MasterAudio component. When I load the levels (additive scenes), a specific playlist should start playing.

    2) I use scripting for playing sounds like fighting stuff. Is there any way to play those sounds independent from any transform i.e. not where the MasterAudio (or dynamicSoundGroupCreator) is but the same as music being played?
    Is it still possible to enable ducking of the playlist with this script-fired sounds?

    Thanks a lot for helping out!
     
    Last edited: Nov 17, 2021
  48. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    No problem.

    1) If you're talking about the Initial Playlist dropdown on the Playlist Controller, that will not show Playlists defined in DSGC, and that's correct behavior. If you want to play a Playlist not defined in the MasterAudio game object, you will need to use code, Custom Events, or other means to make that happen. Scene-dependent music could be in DGSC, or you could simply put ALL music into the MasterAudio game object, as long as they're Resource Files, streaming or Addressables. That way they won't take up any room except when they're playing. It's up to you whether you want separate Playlists or not. That's more up to whether you play tracks at random or anything like that.

    2) If you want to play a sound from an actor, make an actor for it. That could be an invisible game object in the position you like. If you don't care about 3D sound at all, you don't need an actor and can just play the sound in 2D from any location (not specifying the location is fine) and it will be at max volume regardless of position. Music is usually played in 2D so perhaps that's what you want. You can "Force to 2D" the Bus or the entire Mixer by using the controls in the Inspector.

    -B
     
    Doomchecker likes this.
  49. CitrioN

    CitrioN

    Joined:
    Oct 6, 2016
    Posts:
    97
    Is it possible to provide the system new audio clips/groups at runtime? My game has mod support and has the option to use audio clips from a custom mod. Is this possible and if so where in the documentation should I look for how to get this functionality working?
     
  50. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    509
    Hi,

    As far as I understood its not possible to play a song from the playlist and make it loop if its not set to loop in the inspector. I need the song to loop through EventSound. In that case, do you recommend creating a playlist called "Loops" and putting all of the loop songs there even if they exist in other playlists?

    I also have one more question, lets say I dont set an initial playlist because I want to manually handle it from the scene, then I have these events to change to Loops playlist and play song "SpaceExplorationLoop" on start, what happens with that setup is that a random song is played from that playlist. I found out that you need to have a running playlist and then change songs instead of doing it in an event like that which I think is a bug we should be able to go from a non running play list to playlist A and start a song on the same frame. I'm using a method to load from Resources btw.

     
    Last edited: Dec 2, 2021