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
    Interesting about the ignoreListenerPause, but no (and I don't even see that field on the Audio source - is it script only? --shudder--). I'm not going to add weird side effect and mostly unknown code to Master Audio. We already have fine-grained Pause API's you can use.

    For your purpose, just add these calls to your pause and unpause methods.
    Code (csharp):
    1.  
    2.   MasterAudio.PauseAllPlaylists();
    3.   MasterAudio.UnpauseAllPlaylists();
    4.  
    And there are many more Pause API's as well.

    For your second question, there's a DelayBetweenSongs script you can use. If you don't need random length silence, you could also add another track and have its volume at zero.

    Also, read about the Looped Chain. It's a Variation Mode on Sound Groups. Basically it turns a Sound Group into a mini-Playlist. It has fading and random delay built in as options. Here's the help page for Sound Groups: https://dl.dropboxusercontent.com/u/40293802/DarkTonic/MA_OnlineDocs/SoundGroups.htm#VarMode
     
    Last edited: Jul 6, 2017
  2. Dwight_Everhart

    Dwight_Everhart

    Joined:
    May 11, 2014
    Posts:
    123
    Yes, the ignoreListenerPause property is only exposed via the AudioSource scripting API: https://docs.unity3d.com/ScriptReference/AudioSource-ignoreListenerPause.html

    I'm not trying to pause any audio. I'm trying to keep audio from being paused. Unity is pausing all audio automatically when my scripts set Time.timeScale to 0. The ignoreListenerPause property allows some audio sources to bypass that pause. All I'm asking is to add an option to the PlaylistController to set that property on its audio sources to true, if selected. It would be similar to the "Ignore Time Scale" option you have in MasterAudio's Advanced Settings.

    The pause functions you list only control whether MasterAudio is pausing or unpausing something it plays. They don't prevent Unity from pausing its entire audio system.

    Thanks. I'll look into these. Is there any technical difference between using a Playlist to play long music tracks, compared to using a Sound Group to do the same? In the end, they both go through an AudioSource, right? Are they both equally efficient?
     
  3. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Oh... yeah that's not cool. Why does Unity do that? Note that I've set Time.timeScale to 0 many times before on many platforms in our previous games, and it had no effect on audio already playing. Just tried it again in the editor, it did nothing. What version of Unity are you on? Maybe they changed this at some point? I tried it on 4.5 since that's our minimum version.

    I do still have the ignoreListenerPause property you're talking about, and I can set that and still compile, which is curious if it doesn't actually pause the audio anyway. Until I see the pausing happening on my computer, I'm not going to add any feature, so help me see it please.

    Playlist Controllers and Sound Groups both use Audio Sources yes. If you don't need crossfading (although you can kinda do it with Looped Chain via a combination of fade time and Custom Fading on the Sound Group), completely gapless track switching or synchronized layers, then you can use Sound Groups. Those are all features that only Playlist Controllers have. Whereas Sound Groups can use the Occlusion feature / auto-prioritization / Ambient Sound stuff (playing only when in range), Variations etc and the PC does not. Performance is pretty much the same. They will both run an "update" method every frame when they are playing sounds.
     
  4. Dwight_Everhart

    Dwight_Everhart

    Joined:
    May 11, 2014
    Posts:
    123
    Yeah, I've seen conflicting reports of it happening to some people but not to others. I think what may be happening is that the music isn't actually being paused; rather, it isn't being started.

    I'm not sure of the exact order things are occurring in, but, when my app starts, it displays a main menu using Unity's GUI, sets Time.timeScale to 0 to keep game elements from starting until the game is fully loaded, and it starts music playing. It's possible the time scale is being set to 0 before the music starts playing, and Unity is queueing up the music instead of playing it immediately. I think I read that in the Unity docs somewhere. So, in your testing, try setting Time.timeScale to 0 before starting a playlist. That might be the correct test case.

    I'm running Unity 5.6.1p3.

    Thanks for the explanation. I don't need crossfading or anything else that playlists offer. I just want to periodically play a music track. So I think Sound Groups will work. I'll give them a try. Thanks!
     
  5. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    That's a no go. I tried to set Time.timeScale = 0 before starting the Playlist and after. Neither did anything. I tried in Unity 4.6 and 5.6 as well on PC.

    By the way, PlaylistController.cs is the very first script that will run, because I've assigned it -80 in Script Execution Order. So if you're using "Start on Awake" for the controller, that will start the song playing before any scripts you've written (that may set the time scale) unless you've assigned them an even lower Script Execution Order.

    Anyway, I can't reproduce, so I'm reluctant to "fix" things I can't even see.

    If you find anything else I should try, let me know.
     
  6. Dwight_Everhart

    Dwight_Everhart

    Joined:
    May 11, 2014
    Posts:
    123
    Ok. It's not a big deal, as I was able to work around the issue with a simple script. Thanks for trying to reproduce the issue.

    Also thanks for the suggestion to use a Sound Group to play the ambient music tracks. That works great! The only issue I encountered was needing a delay of 1-3 minutes between tracks, but the inspector for setting the Clip Change Delay values limits the maximum value to 20 seconds. Fortunately, I was able to set longer values via the scripting API.
     
  7. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I'll up the max to 5 minutes. Thanks.
     
    Dwight_Everhart likes this.
  8. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I am not sure what I am doing wrong, but when I use say :

    Code (CSharp):
    1. MasterAudio.FadeAllPlaylistsToVolume (0.1f ,2);
    or
    Code (CSharp):
    1. MasterAudio.OnlyPlaylistController.FadeToVolume(0.1f , 2);

    Then it seems like the volume just becomes 1 instead of 0.1

    this is exact code I am using :
    Code (CSharp):
    1. MasterAudio.OnlyPlaylistController.StartPlaylist("BGM_Gameplay");
    2. MasterAudio.OnlyPlaylistController.PlayARandomSong(PlaylistController.AudioPlayType.PlayNow, false);
    3. MasterAudio.OnlyPlaylistController.FadeToVolume(oldVolume,2);
    where oldVolume is 0.1 (for sure)

    And when I check the inspector of Master Audio, it is indeed set as 0.1 but when I just click and drag the actual volume slider just a bit then the actual audio volume suddenly becomes the right value. So it appears to be 0.1 in inspector, but it actually sounds like 1 and then snaps to 0.1 if I use slider to make it 0.1 (or 0.11)

    Any idea?

    I am using 4.1
     
    Last edited: Jul 11, 2017
  9. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    You should call PlayRandomSong instead of PlayARandomSong, then you don't need to specify any parameters. But yeah it will behave the same, currently. You also shouldn't need to both StartPlaylist and PlayRandomSong. Just set the Playlist to shuffle and StartPlaylist.

    I'm not clear on what you're saying the bug is. Does it sound correct and just not display correct in the Inspector?
     
  10. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    The bug is :

    even if the playlistsound is set to some value, it always sounds as if it is max volume. ( the inspector shows a correct volume, but the actual sound is always max )

    After some experimentation, I think it only happens if there is some lag after the setting the volume.
    By lag I mean , some loading sequences etc, so maybe play list fading volume isn't working as intended.

    The code I showed earlier was called in between some level loading sequences so there is some lag after calling it to play a song.
     
  11. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    In that case, you're going to need to send me a project that reproduces the bug. You can use your project and strip out other stuff, or whatever you want to do. We usually aren't able to reproduce them otherwise.

    Thank you,
    -Brian
     
  12. Dwight_Everhart

    Dwight_Everhart

    Joined:
    May 11, 2014
    Posts:
    123
    @jerotas I encountered what I think is a bug with playlists. If a playlist controller that does not have "Auto advance clips" enabled is paused, the track it was playing is stopped, instead of being paused. I would expect the track to pause and later resume playing where it was paused, even if the controller doesn't auto advance clips.

    I was able to fix the problem by moving an "if" statement in PlaylistController.Update(). If the "if" statement at line 434 with the condition "AudioUtil.IsAudioPaused(_activeAudio)" is moved above the "if" statement at line 429 with the condition "(!IsAutoAdvance && !_activeAudio.isPlaying)", the playlist will be paused instead of stopped. I haven't noticed any negative effects from this change in my testing so far.

    I can send you a diff, if you want. I don't want to include source code in this public forum.
     
  13. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    It's just a small portion of the code, it's fine. I think you're saying to reverse the order of these 2 if blocks, right?
    Code (csharp):
    1.  
    2.                 if (!IsAutoAdvance && !_activeAudio.isPlaying) {
    3.                     CeaseAudioSource(_activeAudio); // this will release the resources if not auto-advance
    4.                     return;
    5.                 }
    6.  
    7.                 if (AudioUtil.IsAudioPaused(_activeAudio)) {
    8.                     // do not auto-advance if the audio is paused.
    9.                     goto AfterAutoAdvance;
    10.                 }
    11.  
    If so, I believe that will be ok. Let me know!
     
  14. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Already fixed. Email us with your asset store invoice PDF asking for the beta or wait for update.
     
  15. Dwight_Everhart

    Dwight_Everhart

    Joined:
    May 11, 2014
    Posts:
    123
    Yes, those are the blocks I was referring to. I reversed them, and everything seems fine. Thanks.
     
  16. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Probably mid next week. I have to update a bunch of documentation.
     
  17. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Thank you for confirming, fixed in both plugins.
     
    Dwight_Everhart likes this.
  18. Dwight_Everhart

    Dwight_Everhart

    Joined:
    May 11, 2014
    Posts:
    123
    Thank you for applying the fix.
     
  19. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Naturally.
     
    Dwight_Everhart likes this.
  20. gypsycamp

    gypsycamp

    Joined:
    Sep 2, 2015
    Posts:
    9
    Hey, when i use stop oldest voices in the master audio main object there is an audible pop, is there a way to have the first sound that is stopped to have a tiny fade, say 10ms, to not make it pop, before the other is played or during? I use it for dialogue so it is very apparent. Thx!
     
    Dwight_Everhart likes this.
  21. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Sounds like we would need that for both the bus and for the Sound Group with Variation Mode set to Dialog. I'll add to roadmap now and see if it's feasible soon.
     
    Dwight_Everhart likes this.
  22. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    V 4.1.2 changelog, big release:
    • Fixed compile errors for Unity 2017 beta.
    • Fixed compile error in Unity 4.7.
    • Fixed bug: Silent Variations would stop a Chained Loop when "played". No longer.
    • Fixed bug: Occlusion didn't work outside of editor.
    • Fixed bug: Ambient Sound script was not able to play a "file on internet" if it was not finished loading by the time Ambient Sound told it to play.
    • Fixed bug: Playing an asyncronously loaded Resource file and then immediately telling it to FadeToVolume caused a Null Reference Exception.
    • Fixed bug: Pausing a Playlist Controller without auto-advanced on would stop the song.
    • Fixed bug: Occlusion didn't work if you started your Scene without an Audio Listener.
    • Added missing "Sound Spawn Mode" dropdown to Footstep Sounds script.
    • Added "timed to animation % complete" Sound Group + Custom Event firing for the 2 MechanimEvent scripts.
    • Added multi-timed Sound Groups and "stop sound on state exit" checkboxes to MechanimStateSounds script.
    • Added commands PauseBusOfTransform / UnpauseBusOfTransform / StopBusOfTransform. Added these to the Bus Commands on Event Sounds script as well.
    • Song Transition Type "New Clip From Last Known Position" now does not hide the Song Start Position fields, but they are only used the first time each song is played.
    • Added extension methods for all Master Audio methods that take a Transform object so now you can do the MA methods from the Transform itself. i.e. TransformVariable.StopSoundGroupOfTransform("SoundGroupName");
    • Added new method: MasterAudio.IsTransformPlayingSoundGroup(string soundGroupName) - returns boolean
    • Added new method: MasterAudio.GetAllPlayingVariationsOfTransform() - returns a list.
    • Added "Probability to Play %" field to Variations. Defaults to 100%. If you select something less than 100%, it will calculate a random number (0-99) whenever it is selected to play and if the random number is less than the field, it will not play.
    • Added 2-way tracking (added a component to caller game object shows all SFX playing from transform, with pause/stop/unpause buttons, and also has those buttons for each Sound Group and for all Sound Groups. This code only happens in the editor since it causes slight garbage collection.
    • Added new options of willStopAfterFade and willResetVolumeAfterFade to MasterAudio.FadeSoundGroupToVolume and MasterAudio.FadeBusToVolume. Added checkboxes to EventSounds with these options.
    • Added checkboxes for the new fade options to all the optional integration packages with other plugins.
    • Added new method: MasterAudio.IsSoundGroupPlaying(string soundGroupName); returns true if any voices are playing or paused.
    • Added play / stop / pause / unpause buttons in Group inspector.
    • Added Custom Event Categories for visual organization.
    • Upped Max Delay Between Looped Chain sounds from 20 seconds to 300.
    • Added IsSongPlaying(songName) API method to PlaylistController.
     
    Last edited: Jul 22, 2017
    Dwight_Everhart likes this.
  23. churi24

    churi24

    Joined:
    Sep 17, 2013
    Posts:
    98
    The occlusion was a great idea:cool: but there is a problem if you wanna do a realistic scene. :rolleyes:

    If the sound emitter is in a corridor and you walk and turn in the corner to another corridor, the occlusion activates as the ray hit the wall. The problem is that it is a corridor with a curve and if you are on the another corridor the occlusion should be really tiny. In this case the environment is open, not closed, here the occlusion should not be absolute, maybe a 80%.. maybe there is a way to solve this using some dummy on the corner to check the continuity of the space.:D

    Here is my horrible drawing to show you what I'm saying.


    In this case the sound shouldn't be occluded so drastically, maybe a little but not at 100%.:(
     
    Dwight_Everhart likes this.
  24. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Yeah I'd have no idea how to write more code to calculate "how occluded" it really is unfortunately. It either is or isn't.

    You can have controls of the Sound Group's occlusion frequencies though, so you could conceivably work around it by making another copy of the Sound Group with different lesser frequencies rolloffs and use that Group on the ones near a corner, maybe?
     
  25. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I had this idea for a while, and I am going to post it before I forget it again.

    When you use random pitch options, it would be nice to be able to preview its effect when you click on play button on the ui. So we can experiment and find the good value on the editor, not during play time. This will save a lots of time. The same may goes to the other options but I have not thought deeper about them except for the random pitches.
     
  26. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    It's actually not possible without losing your original pitch in edit mode. Since there's no "state" we have to actually change the pitch of the Audio Source component to do it. After which, there's no way to restore the original pitch again. Permanently lost. I tried to do it a long time ago and that's why it's not there.
     
  27. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Actually preview may have changed how I did it. I'll check if it's still impossible.
     
  28. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Yeah perhaps in edit mode and not in play mode, we could create "invisible" dummy audio source object and then play using it and then destroy it after wards?" :D I am not sure... I know it sounds a bit fiddly but just an idea.
     
  29. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    That's what I was trying to say. There's no later / afterwards in edit mode code. There's only: do this right now (this frame) and you can't remember anything for later. Still taking a look.
     
  30. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Ok, I've made the previewing in edit mode all able to use random pitch and random volume, which is possible since I switched to doing previews on the "previewer" Audio Source awhile back, that lives on the game object with the Audio Listener. The rest of the settings including weight are not possible.
     
    castor76 and Dwight_Everhart like this.
  31. Dreamcube017

    Dreamcube017

    Joined:
    Dec 20, 2009
    Posts:
    253
    So I'm working on a new sound effect and wanted the users to have the option to have a bit more flexibility with it. Is it possible to make the sound events or something that if users have Master Audio, they could get access to more advanced versions of the sounds?

    Here's a basic example of what I mean.
    If I were to make a footstep sound effects pack, normally you'd just get a bunch of .wav files and it'd be up to the buy to try and set up how they should work. However, if there was some way they could open a script or something that is compatible with Master Audio, I could have it all preset so that the footsteps would just "work" when they played the sound/event. Let me know if that doesn't make much sense. It'd be kind of like how Master Audio has PlayMaker support or something.

    Thanks either way.
     
  32. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    You could of course include any script compatible with Master Audio (in an optional package in case they don't have it) with your sound effects pack. You could also include a Sound Group Template (with weights / random stuff) and give instructions on how to "install" the Template and then how to drag your whole folder of clips to create your pre-made Sound Group using the template.

    Something you might want to think about.
     
  33. Dreamcube017

    Dreamcube017

    Joined:
    Dec 20, 2009
    Posts:
    253
    That's actually exactly what I was hoping for! Thanks!
     
  34. jerotas

    jerotas

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

    zukinet

    Joined:
    Oct 30, 2016
    Posts:
    51
    Hi,
    i'm interested to buy Master Audio, but...

    Can support below scenario ?
    "Receive speech from user, then convert it's pitch to more funny (talk back)...."
     
  36. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
  37. zukinet

    zukinet

    Joined:
    Oct 30, 2016
    Posts:
    51
  38. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    No idea. I would suggest searching the Asset Store for the word microphone.
     
  39. BrightBit

    BrightBit

    Joined:
    Jan 22, 2013
    Posts:
    265
    In the current version of Master Audio you are removing the AudioSource Component that is attached to the latest AudioListener you can find during the Awake() method. It would have been great, if you at least would have printed an info message to the console. It took me some time to find out that this package was the source of my problems.
     
    nirvanajie likes this.
  40. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Sorry that you wasted time on that, it is necessary and we wouldn't log anything because usually that was created by MA.

    We are removing it because in most cases it was added there by MA itself, although we wouldn't know if that was the case at runtime. It's used so that we can preview at the loudest volume. We must remove it so that the audio memory of the clip is released.

    You are not supposed to have any Audio Sources of your own except those created by Master Audio. They would be outside the control of MA and there's probably no good reason anyway to do it. We can chat in PM if you believe otherwise.
     
  41. OhiraKyou

    OhiraKyou

    Joined:
    Mar 27, 2012
    Posts:
    259
    Unless I'm missing something, there should be a way to automatically stop a sound once a fade out finishes. FadeOutAllOfSound, for example, leaves the sound playing at 0 volume.
     
  42. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    If you instead use MasterAudio.FadeSoundGroupToVolume, there's optional params at the end for stopAfterFade and resetVolumeToPreFade.

    There's also an option under Advanced Settings / Fading to always stop a Group / Variation / Bus when it fades to zero. Defaults to "off".
     
  43. OhiraKyou

    OhiraKyou

    Joined:
    Mar 27, 2012
    Posts:
    259
    Thanks! FadeSoundGroupToVolume did the trick. It tends to pop, but it does so less often than with a hard stop.
     
  44. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    If you fade it to zero it will not pop unless your fade is really fast. Make it longer.
     
  45. OhiraKyou

    OhiraKyou

    Joined:
    Mar 27, 2012
    Posts:
    259
    It's not quite as simple as increasing the fade duration until the popping stops. It's for underwater ambient gurgling in a platformer that's supposed to impart to the water a feeling of being a separate medium. When the camera enters/exits water, the sound is toggled. Having the underwater sound play for too long after the camera leaves the water sounds really, indefensibly bad. Even 0.3 seconds, which still occasionally pops, is super pushing the limits of latency I'm willing to accept. There's a point where you have to compare popping to unresponsiveness and decide which is worse.
     
  46. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Unfortunately this can be the case when we can only execute code during each frame and no more often, because that's all Unity allows. Thanks for the explanation.
     
  47. Hagen

    Hagen

    Joined:
    Aug 16, 2014
    Posts:
    36
    Hey Jerotas, how do I disable occlusion? I'm not worried about being realistic but on performance, and the occlusion for several missiles that I have on a scene are reducing my FPS, affecting the LateUpdate monobehaviour.
    Regards
     
  48. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    How many ray casts are going per frame? I'd first try cranking down (all the way to 1) the Max Ray Casts Per Frame setting in Advanced Settings / Occlusion and see if that's good enough.

    You can also disable Occlusion per Bus or Group instead of altogether. To do this, change Sound Group Usage to "Turn On Per Bus Or Group". Turning off Occlusion totally is in Advanced Settings there as well.

    Let me know what you discover!

    Link here to all the info: http://www.dtdevtools.com/docs/masteraudio/Occlusion.htm
    You know you can click the green question mark icon in all the Inspectors to go to the online documentation, correct page, right?
     
  49. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Hi, Has not the preview of using random pitch been implemented to Master Audio some time ago? I thought it has but I can't seem to get it working somehow. Using version 4.1.2
     
  50. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    It's done and in the version I will be submitting next, probably tomorrow.
     
    castor76 likes this.