Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

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,344
    Ok, you're saying that the DGSC can't use its own Custom Events (at least the UI says that). I'll fix this in the next version or 2. Thanks!
     
    Exbleative likes this.
  2. Exbleative

    Exbleative

    Joined:
    Jan 26, 2014
    Posts:
    211
    I've just tried solo'ing a bus, but it doesn't seem to have the intended effect of muting all other buses. I'm just using MasterAudio.SoloBus("mybus");

    I can see the S icon light up green on MasterAudio, so it seems to be doing something, however nothing else is muted.

    Alternatively, muting the other buses does seem to work. Am I missing something?
     
  3. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    Solo Group doesn't work either. Weird, I'm 99% certain this used to work properly. This will be fixed in the next update.
     
    Exbleative likes this.
  4. Exbleative

    Exbleative

    Joined:
    Jan 26, 2014
    Posts:
    211
    Great, thanks!

    I'm doing some multi-scene stuff now and am having an issue with a null PlaySoundResult.

    MasterAudio is in a ManagerScene that's always loaded, then I additively load separate scenes for each level + cameras + player.
    In my level scene, on one of my objects, on Start(), I do:
    mySound = MasterAudio.PlaySound3DFollowTransform("mySoundName", this.transform, 0);
    This works for the first scene, however when I load the second scene (and remove the first), and the above code Start()s again, I get a null reference for the result.

    I checked that mySound had available voices etc, and Caller Despawn Mode = Stop. I can also still see the sound in MasterAudio I'm trying to use, so it hasn't been destroyed. The sound is also not a part of the DSGC, it's on MasterAudio in the manager scene.

    It seems it may be related to my Dynamic SGC object, because when I remove that from my first scene, the problem resolves itself.

    The DSGC exists in my level scenes, so is loaded/removed along with the scene as it is additively loaded in.

    Any ideas?
    Thanks again!
     
  5. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    If you get a Null result then simply turn on "Log Sounds" for that Sound Group (or for all Sound Groups on Advanced Settings). It will tell you in the Console why it didn't play.
     
  6. Exbleative

    Exbleative

    Joined:
    Jan 26, 2014
    Posts:
    211
    Thanks, funnily enough it was related to the above issue, the sound wouldn't play because of the solo'ing. Kinda thought that solo just adjusted volume though, not whether a sound would play. I thought it'd play at zero volume.

    I'll keep that logging in mind in the future, as it immediately told me the issue, cheers!
     
  7. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    Ok.
     
  8. Exbleative

    Exbleative

    Joined:
    Jan 26, 2014
    Posts:
    211
    I'm using a Top to Bottom Looped Chain to play a sequence of dialog, each separated by N seconds. I want to know when the looped chain has completed playing all the sound variations, but PlaySoundAndWaitUntilFinished seems to be per variation.

    ActingVariation.SoundFinished wouldn't seem to be the solution either as that will only tell me once a variation has finished.

    It seems there's some knowledge of when a looped chain finishes, though:
    • Number of Loops: Only visible if you chose Number of Loops. Specify the number of times the entire Group shall be played. The Group will stop playing after this number of loops.
    Any idea how I'd get notified of all variations or a loop having finished?
     
  9. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    Neither are possible currently. I suppose you could play the bottom-most Variation in your Top to Bottom Group first, and subscribe to its SoundFinished event, which means that the entire group is done, but it wouldn't play the other Variations the first time around...

    The only thing is - the SoundFinished event clears all subscribers after notifying. So you'd need to re-subscribe again each time.

    Anyway, will add an item to the roadmap for this request.
     
    Exbleative likes this.
  10. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    359
    Hi again

    Is there a way to play a sound that transitions from one scene to another?

    Like taping a scene button that takes you to such scene and the sound keeps playing in between these two scenes.


    Thanks
     
  11. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    Absolutely. For that to work, the Master Audio game object must not be destroyed when the Scene changes. If it is, all sounds playing will be stopped abruptly. So check the "Persist Across Scenes" checkbox in Advanced Settings and know that the Master Audio game object in your other Scenes will not be used because it will be destroyed when you get there...
     
  12. VirtualVassal

    VirtualVassal

    Joined:
    Oct 5, 2015
    Posts:
    13
    Hello, picked up MA on sale and really liking the feel, but I haven't yet been able to trigger audio. Did the intro tutorials, but no dice yet.

    I'm using Playmaker; I have a gameobject with an FSM that is using the "Play Sound" event when the player triggers the object.

    The Playmaker tutorial did seem a bit short, so I'm just wondering, do I need to have an Event Sounds script on my object if I'm using Playmaker Events? In the Playmaker example scene it doesn't seem so, but I haven't gotten it to work yet. My audio clip is in a group.

    Pic included, let me know if you need anymore info. I'm probably missing something simple, but I've been fumbling around for a couple hours with it. Thanks in advance.

     
  13. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    Absolutely not (don't need to use EventSounds with Playmaker). In fact, I suspect when your game is fully set up for all your audio, you will be using the PlaySound Custom Action about 1/10 as often (or less) as you use EventSounds. EventSounds is meant to replace Playmaker in most cases as the no scripting solution.

    I don't see anything weird in your screen shot. Have you tried clicking the speaker icon for your Sound Group at runtime? Does the voice count go from 0 to 1? Have you turned on "Log Sounds" for that Sound Group and read the console? Are your sounds 3D? Have you turned off "Follow Audio Listener" in Advanced Options? These are some things to check.
     
  14. VirtualVassal

    VirtualVassal

    Joined:
    Oct 5, 2015
    Posts:
    13
    Alright, so I got it to work, but I'm not sure if I'm experiencing normal behavior. I changed the Voices (Weight) slider to 100, which got it to trigger the sound, but also spawned 100 instances of the sound at runtime. Is that normal? I thought the weight slider controlled priority of variation, but I called be wrong there.

    I then changed the Voices slider to 1, still got the sound, and it only triggered 1 instance. Assuming this is normal, I have it working. Thanks a ton for the quick reply, too, really appreciate that.

    Pic related.

     
  15. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    Yes that's entirely normal. And unnecessary. Putting the weight at 100 means you're able to play 100 of that sound effect simultaneously. You should put that number no higher than what you'd need.

    Absolutely nothing to do with "priority", which is a field on the Audio Source, but does have to do with probability. If you have 2 Variations with one at 4 Voices and 1 at 1 Voice, then the one with 4 Voices will play 4 times as often.
     
  16. VirtualVassal

    VirtualVassal

    Joined:
    Oct 5, 2015
    Posts:
    13
    Appreciate ya, that makes complete sense. I must've misread/misinterpreted something. Everything is much clearer now, having a lot of fun with the asset.

    Thanks again.
     
  17. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    No problem.
     
  18. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    V 4.0.6 will be live in 20 minutes! Changelog:

    • Breaking change: MasterAudio.FireCustomEvent now requires a Transform to be passed in instead of a Vector3. The Transform's position will be used as the Vector3 was. Please change any of your own code calling this or you will not be able to compile. This is necessary for the new "Send To Receiver" modes coming of "same game object", "children" and "parents".
    • Possible breaking change: Added "Song Start Time Mode" dropdown in each song. Choices are "Beginning", "Specific Time", and "Random Time". The default is Beginning so if you previously had set a Start Time of non-zero, you will need to select either Specific Time or Random Time. Random Time gives you 2 fields for min and max seconds.
    • Fixed bug: Deleting a bus with a sound playing would not adjust the volume of the sound in Unity 4.
    • Fixed bug: Adjusting more than one bus volume during play would incorrectly re-max sound effects on the first lowered volume bus.
    • Fixed bug: Sometimes the "save changes" feature would log an error about duplicate key.
    • Fixed bug: Master Audio would fail to play a sound when the only variation left in the random leftover pool was already playing before the pool refilled.
    • Fixed bug: Immediately trying to call AdjustVolume on a sound that you just started playing would not work.
    • Fixed bug: Calling AdjustVolume on a sound that you just started playing at zero volumePercentage would not adjust and not be audible.
    • Fixed bug: Changing to another Scene with a non-persistent Master Audio game object and occlusion enabled would sometimes log errors to the Console.
    • Fixed bug: Auto-advance Playlists with short clips would not be truly gapless on some songs when Gapless was enabled.
    • Fixed bug: Pausing and unpausing a gapless Playlist would not always restart the scheduled song at the right time.
    • Fixed bug: Fading code so that it still fades for the proper amount of time even if you don't have a stable frame rate.
    • Fixed bug: All Group Templates so Retrigger Percentage is set to 100% (uninterruptible).
    • Fixed bug: Gapless song transition occasional bug with single playlist.
    • Fixed bug: Start on Awake with gapless combo for Playlists that would schedule multiple songs instead of one, creating weird overlapping audio.
    • Fixed bug: Muted Sound Groups will now play silently instead of not at all.
    • Fixed bug: When there is a Soloed Sound Group or Bus, non-soloed Sound Groups will now play silently instead of not at all.
    • Fixed bug: Mute / Solo switches now work at runtime on already playing Sound Groups.
    • Fixed bug: Numerous display bugs with mute/solo reset & mixer mute coordination.
    • Fixed bug: Deleting then undeleting a Sound Group (pressing undo) at runtime would break that Sound Group (can't play). Now it works.
    • Made MasterAudio.GetCustomEventByName public.
    • Updated Playmaker, NodeCanvas & Behavior Designer optional packages to compile with the breaking change above. You will need to reinstall the latest version of these if you are using them.
    • Added new Send To Receivers modes to Custom Events: OnSameGameObject, OnChildGameObjects, OnParentGameObjects, OnSameOrChildGameObject, and OnSameOrParentGameObject. These work as expected. A good way to limit recipients when you can't depend on position.
    • Added new Random and Distance criteria to Custom Events. Field: "Valid Receivers". Options: All (default), Random and Closest. For the latter 2 options you specify a number. That means you can have only the 3 closest receivers receive the event, or 2 random receivers.
    • Changed default "Retrigger Percentage" on Sound Groups to 100, so they are uninterruptible and can't be stolen while playing.
    • Changed last remaining "Resume" API's to "Unpause" instead. If you are using these from your own code, please update their usage.
    • Jukebox control now appears on each Playlist Controller's Inspector at runtime.
    • Variation and Group Inspectors now show "paused" indicator instead of "playing X%" when it's paused.
    • Added "StopPlaylistAfterCurrentSong" to EventSounds, MasterAudio and PlaylistController. It cancels all queued / scheduled songs, stops looping the current song and disables auto-advance for the Playlist Controller.
    • Added a way to specify code to execute for "LastVariationInSoundGroupFinishedPlaying" for a Sound Group. Call MasterAudio.SubscribeToLastVariationPlayed and add your code there.
     
  19. summerian

    summerian

    Joined:
    Jul 6, 2014
    Posts:
    137
    Hello,

    Thanks for a nice plugin.

    How can I set the time position of a playlist track?

    When I leave a scene I want to store the current time position so the next time the scene is loaded I resume the playlist track from the same time.

    Thanks!
     
  20. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    Actually, there's a feature for that built-in! I believe it will work cross-Scene as long as you are using the same Master Audio game object between the two (persistent MA).

    In the Playlist settings, there's a dropdown for "Song Transition Type" which defaults to "New Clip From Beginning". Instead, change that to "New Clip From Last Known Position". However, it will affect all songs in the Playlist, not just the last one you played.

    If that last part is a deal-breaker, you could get around this by using a different Playlist for the rest of the songs if you need to.
     
  21. Khena_B

    Khena_B

    Joined:
    Aug 21, 2014
    Posts:
    273
    Hey there,

    I'm interested in the plugin but after watching some of the videos i'm still unsure of the workflow, the script would be on a gameobject in my persistent scene as a singleton, does this mean that i would be adding all the sounds in my game to the group mixer by dragging them all in there?

    If so, doesn't it get difficult to navigate when there are hundreds of groups in the group control pannel? And are the sounds from the groups loaded into memory or "pooled" ?

    Thanks
     
    Last edited: Nov 28, 2016
  22. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    You don't have to use a persistent game object unless you need sound to play across scene changes.

    There are a lot of different ways to set things up. Yes you can put "all" sound effects into the one game object, which is a simple way but as you noted it may be difficult to navigate. To assist, we group Sound Groups by assigned bus. You also can filter by bus or only show Sound Groups whose name matches a wildcard you type.

    You also can use per scene MA game objects or use a persistent one but only put core sounds there and use the Dynamic Sound Group Creator prefab to set up "temporary", per scene SFX. They will get added to the MA game object when the DGSC becomes enable and leave there when it becomes disabled.

    There is no pooling but there are options for which audio you want always loaded into memory vs loaded when you need them via Resource files or unchecking the "preload audio data" check box on the Audio Clip import settings. These both will cost a bit of latency while the sound loads before it can be played, but when done being played the memory is freed back up, so this is a very valuable trick. Pooling wouldn't really work anyway with all the options we provide. I can think of a couple unsolvable problems with specific features if we did pool.
     
  23. Khena_B

    Khena_B

    Joined:
    Aug 21, 2014
    Posts:
    273
    The ambient sounds will persist across scenes and the music as well, right now each of my actors have their own audio source and clips played with PlayOneShot for the SFX, but the player is a singleton with his audio persisting with him.

    PlayOneShot is giving me problems and i don't want to have an audio source for each SFX on an actor, sounds need to overlap so i can't just change the aucio clip of a single audio source. I'm looking for a simple solution.
     
  24. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    We do not use PlayOneShot at all and for good reason - you lose all control over doing anything to single shots once you tell them to play. And the way you work with Master Audio is to not have Audio Sources on any other game object. Master Audio holds all the Audio Sources. This basically gets rid of all problems with the normal Unity workflow and adds massively on top of the Unity 5 stuff. More info here: http://darktonic.freeforums.net/thread/130/unity-great-master-audio-absolutely. Yes the sounds can overlap in Master Audio, and you need to tell it precisely what's the max number of voices for each sound effect since it defaults to 1. But in this way you maintain strict control so things don't get out of hand.

    Our plugin has a learning curve but it's not too bad. And we're always here for support anyway.
     
  25. Khena_B

    Khena_B

    Joined:
    Aug 21, 2014
    Posts:
    273
    Yeah, i know the basics of what the plugin offers from watching the videos and reading the documentation, i'm just unsure it would be the solution i'm looking for VS making my own audio manager. The workflow needs to be simple and intuitive.

    As i said i want the audio to be persistent since each rooms in my 2D game are new scenes, i want the transition to be seamless. For example i don't want the SFX to be interrupted abruptly when changing rooms and i want ambient sounds and the music to be constant during scene changes.

    What worries me is to add all he SFX of the game to the one persistent Master Audio gameobject, i wanted to know if this would affect performance/memory or if those sound groups were just references to the audio files and not being pooled/loaded into memory. It would still be a pain to have every single sounds in there even ones i rarely use, I'd prefer for every actors to have their own audio clips ready to be passed the the main audio manager to be played, have the audio manager to only act as a pair of speakers and not hold all the audio clips in the project.

    For the ambient sounds i've placed audio sources around my persistent world so that this layer of ambient sounds is seamless across scenes and stuff from other scenes can be heard in the distance such as approaching a scene with a big waterfall. I'm not sure how efficient this is but i don't see any other way to do this, even with Master Audio.

    Anyways, i'll keep reading the documentation and see if this is the right tool for me, thanks again.
     
  26. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    I think our workflow is intuitive, but I wrote it :)

    Regarding performance and merely "holding references", I don't think you realize how this would really work. i.e. holding a reference (having a public variable of type AudioClip) that is in a script in a game object in the current Scene means that if the Audio Clip's import settings are set to "Preload Audio Data", you've already told Unity that - yes - it will be taking up audio memory the entire time that game object exists. And if that game object with the reference wasn't in the Scene, well you couldn't do anything meaningful with it anyway until it was, so that's moot. The only way to get around this memory usage is to use Resource files (since you're only holding the path to the resource and not the clip itself) or by turning off "Preload Audio Data" on some of the less used clips.

    So even if you wrote your own, you will run into this same issue (holding a reference = taking up audio memory).

    Re: Ambient Audio, the current way to do it is to place an EventSounds component on the game object that's in the position you want to use, and use the Start or Enabled event, and tell it to play a Sound Group. Unfortunately this can result in you having 30+ Audio Sources playing in your Scene just from the ambient sounds, and Unity caps audible Audio Sources at 32, so you're going to have to use Master-Audio's auto-prioritization feature to make sure the closer ones are the ones heard.

    However, I'm almost done creating a standalone Ambient Sound script which will create a trigger the width it's Sound Group's max distance (on the Audio Source) so only ones within range of the Audio Listener will be playing at any one time. Which will be awesome, it's almost done.

    About wanting to hear Audio Sources from other Scenes, I have no idea how that would be possible unfortunately...
     
  27. Khena_B

    Khena_B

    Joined:
    Aug 21, 2014
    Posts:
    273
    But that's what worries me and what i've been asking about, if i made my own manager every actors would hold their own audio clips and only a few actors would be active per scenes so just a few sounds ready to be played, but instead of having their own audio source using PlayOneShot to play the clips, they'd tell the persistent audio manager to play these clips on demand and the sounds wouldn't get cut off between scenes as they're being played by a persistent audio manager, with the Master Audio plugin every sound clips in the game would have do be constantly loaded, probably hundreds of sound groups, the whole project's sounds! That's what worries me, i'm pretty sure that the plugin is great but it might not be the right one for my project.

    Like i said the ambient audio sources are positioned on the persistent layer, they're audible to every scenes as they're always there in the background with all the other persistent gameobjects ready to be played when in hearing range.

    Thanks again for the quick responses.
     
  28. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    Negative. In your scenario you would use a MA game object with zero sound effects in it, and only populate it with per scene sounds via the Dynamic SGC. Very easily done. And then you're only having that scene's sounds in there at once. Not everything.

    You could add code to use a trigger on the DGSC so it doesn't remove its audio from MA until its a certain distance away, then you could accomplish the last scene stuff as well.
     
  29. Khena_B

    Khena_B

    Joined:
    Aug 21, 2014
    Posts:
    273
    That's interesting, it's getting late but i'll take a closer look at the dynamic sound group creator section in the documentation tomorrow and see if this would work for me, i'll let you know if i have any more questions, thanks!
     
  30. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    You're welcome.
     
  31. netics

    netics

    Joined:
    Aug 23, 2011
    Posts:
    102
    BugReport:
    The sequence is
    1. MasterAudio.PlaySound("Something");
    2. MasterAudio.PauseSoundGroup("Something");
    3. MasterAudio.UnpauseSoundGroup("Something");
    4. MasterAudio.FadeOutAllOfSound("Something", 0.1f);

    But it doesn't fade out at all.
    MasterAudio Prefab's "Keep Paused Resources" option is checked state.
     
  32. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    Thanks, I'll take a look. If I can't reproduce the issue I will be asking you for a small project that reproduces the issue.
     
  33. TheBullet

    TheBullet

    Joined:
    Mar 1, 2016
    Posts:
    28
    How can I change the Listener Transform for the occlusion? I have more than one cameras in the scene and when the game starts Master Audio selects one as a listener, when I disable this camera it still being the listener and I can't use the occlusion with my main camera. Only changes if I destroy this gameObject, but I don't want to do it. How can I change it? Thanks.
     
  34. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    Currently not possible. The code auto-selects a new only when the AudioListener is gone, not disabled. I'll add this to the roadmap and hopefully get it in the next update. I'll post back here if I squeeze it in.
     
  35. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    Try replacing this method in MasterAudio.cs with the following. It should fix this issue:

    Code (csharp):
    1.  
    2.   public static Transform ListenerTrans {
    3.      get {
    4.      // ReSharper disable once InvertIf
    5.      if (_listenerTrans == null || !DTMonoHelper.IsActive(_listenerTrans.gameObject)) {
    6.      _listenerTrans = null; // to make sure
    7.  
    8.      var listeners = FindObjectsOfType<AudioListener>();
    9.      // ReSharper disable once ForCanBeConvertedToForeach
    10.      for (var i = 0; i < listeners.Length; i++) {
    11.      var listener = listeners[i];
    12.      if (!DTMonoHelper.IsActive(listener.gameObject)) {
    13.      continue;
    14.      }
    15.  
    16.      _listenerTrans = listener.transform;
    17.      }
    18.      }
    19.  
    20.      return _listenerTrans;
    21.      }
    22.   }
    23.  
    Let me know if that does the trick or not so I can include it in the next update!
     
  36. TheBullet

    TheBullet

    Joined:
    Mar 1, 2016
    Posts:
    28
    It works! Thank you very much!

    By the way, another interesting feature I've missed is the possibility of adjusting the occlusion frequency individually on each bus, some sounds need less occlusion than others.
    And you could also add a transition time between occluded and not occluded sound to make the sound doesn't change suddenly and get a more realistic result.

    Maybe you can add it in next updates...

    Thank you for your help!
     
    Last edited: Dec 22, 2016
  37. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    Unfortunately we can't be adding more fields to the buses as they don't have their own Inspector (and can't). I'm not sure what you mean by the 2nd request, but that sounds extremely difficult.
     
  38. TheBullet

    TheBullet

    Joined:
    Mar 1, 2016
    Posts:
    28
    About the second request, I don't know how the occlusion works, but I imagine that some sound values were changed to create the occlusion effect. You could create an IEnumerator that modifies slowly these values over half a second or over a second to get a smoother change.
     
  39. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    The occlusion just modifies a Low Pass filter on the sound. I'll add this to the roadmap. I think it would only sound realistic if it does it pretty fast though.
     
  40. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    Master Audio Multiplayer is now live on the Asset Store! It's the ONLY multiplayer audio solution for Unity - yes, even the big players such as Fabric, WWise and FMod do not offer this. No RPC's to write. More info here, and there is upgrade pricing for existing Master Audio users. Currently requires Photon, UNET compatibility coming soon.
     
  41. netics

    netics

    Joined:
    Aug 23, 2011
    Posts:
    102
    Any progression?
     
  42. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    Well I did fix it but the fix causes other things to fail, so I'm still working on it. Will be a bit since I'm taking some days off for Xmas.
     
  43. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    I've got it fixed. You can email support@darktonic.com for the update or wait for the next version.
     
  44. cloudcamaleoniv

    cloudcamaleoniv

    Joined:
    May 17, 2013
    Posts:
    57
    So, I'm calling MasterAudio.StopAllOfSound(soundGroupName) and I'm getting this error on Android.

    Do you know what is causing this?
     

    Attached Files:

  45. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    From the look of it, it sounds like you're calling the Master Audio API from a background thread (not the main thread) and since we call the Unity API, that is not allowed. If you're using some kind of threading plugin, that would be why. If you're not, I assume it's some kind of Unity export error or other Unity error.
     
  46. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    359
    Hi there

    I have a couple of UGUI sliders that control volumes for SFX and voiceovers and it works. However I get two errors (that don't prevent me from playing the game) when I run:
    Code (CSharp):
    1. aSlider.value = (float)PersistentAudioSettings.GetBusVolume("SFX");
    The error is this:
    InvalidOperationException: Nullable object must have a value.
    System.Nullable`1[System.Single].get_Value () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Nullable.cs:108)
    SliderAwakeReset.SliderUpdater (System.String sliderName) (at Assets/KIDpedia Menu/Scripts/SliderAwakeReset.cs:22)
    SliderAwakeReset.Awake () (at Assets/KIDpedia Menu/Scripts/SliderAwakeReset.cs:13)

    Full code:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.UI;
    4. using DarkTonic.MasterAudio;
    5.  
    6. public class SliderAwakeReset : MonoBehaviour {
    7.  
    8.     Slider aSlider;
    9.  
    10.     void Awake ()
    11.     {
    12.         aSlider = GetComponent<Slider>();
    13.         SliderUpdater(gameObject.name);
    14.     }
    15.  
    16.     void SliderUpdater (string sliderName) {
    17.         if (sliderName == "BackgroundSlider") {
    18.             aSlider.value = (float)PersistentAudioSettings.GetBusVolume("SFX");
    19.         } else if (sliderName == "VoiceSlider") {
    20.             aSlider.value = (float)PersistentAudioSettings.GetBusVolume("Voiceovers");
    21.         }
    22.     }
    23. }
    Do you know how to solve this problem?

    Thanks
     
  47. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    You should not cast those to float, they are Nullable floats for a reason. You should be using the .value property and first check .HasValue property. But anyway if you're getting that error with your code, there is nothing persistent stored for that bus volume - it is returning null. Correct checking code should look like this:

    Code (csharp):
    1.  
    2. void SliderUpdater(string sliderName) {
    3.    if (sliderName == "BackgroundSlider") {
    4.       var sfxBusVol = PersistentAudioSettings.GetBusVolume("SFX");
    5.       if (sfxBusVol.HasValue) {
    6.         aSlider.value = sfxBusVol.Value;
    7.      }
    8.    } elseif (sliderName == "VoiceSlider") {
    9.       var voiceBusVol = PersistentAudioSettings.GetBusVolume("Voiceovers");
    10.       if (voiceBusVol.HasValue) {
    11.          aSlider.value = voiceBusVol.Value;
    12.       }
    13.    }
    14. }
    15.  
     
    Last edited: Jan 18, 2017
  48. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    359
    Thank you so much for the explanation and will pay more attention to nullables. Haven't coded one yet so thank you for the heads up and sorry for the inconvenience.
     
  49. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,344
    No problem. Just glad to get it working for you.
     
  50. pako

    pako

    Joined:
    Nov 21, 2012
    Posts:
    87
    Hi,

    I have a Windows Store Universal Windows Platform project, which I run inside Visual Studio 2015 on Windows 10, Unity 5.5.0f3.

    Before showing a Windows Ad, I call MasterAudio.MuteEverything() so that all sound is muted while the advertisement is playing. However, the sound is not muted, and the game background music keeps playing simultaneously with the advertisement sound.

    Is there something I'm doing wrong? shouldn't all sound be muted with MuteEverything() ?
     
unityunity