Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    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,572
    Edit: bug reproduced and fixed in the update below.
     
    Last edited: Feb 12, 2015
  2. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Master Audio V 3.5.7.3 should be live in 20 minutes. Changelog:
    • Fixed Resource.Load command for Unity 5 beta 22. It wouldn't export as a standalone.
    • Added warning to Console if you checked Play on Awake on the Playlist Controller's Audio Sources. Those have no function in Master Audio and can lead to buggy behavior.
    • Added warning to Console if you checked Play on Awake on any Variation's Audio Source. Those have no function in Master Audio and can lead to buggy behavior.
    • Now Unity 5 users can load Resources asynchronously again on Unity 5 beta 22!
    • Fixed bug where when using Save Runtime Changes, Custom Events wouldn't fire sometimes because lastFrameFired didn't reset.
    • Fixed bug where immediately calling JumpToTime after playing a Variation would not work.
    • Fixed bug where Fade to Volume action on Playlists for Event Sounds always faded to 0 regardless of slider volume for non-uGUI events.
    • Fixed bug where Gapless song transitions didn't work any more.
    • Removed EventCalcSounds.cs from plugin. Should no longer be needed.
    • UI overhaul. Now it's much more intuitive and related controls are grouped into bordered boxes. It shouldn't confuse anyone who used it before.
    • Updated DF-GUI optional package.
     
    Teku-Studios likes this.
  3. frikic

    frikic

    Joined:
    Dec 22, 2011
    Posts:
    44
    Hello,
    I would like to report possible bug, i worked with Master Audio from the start of the my project and everything worked great, but ive started to get this error only recently. I have master audio set in all scenes but when switching from scene to scene i get these 2 errors, and they repeat several times at the start of the scene, but all sounds play normally. Ive updated to v3.5.7.3 now, but i started to get error from one week or so ago. I hope you can help me, and maybe i did something wrong in the scenes or called sounds too early? But as far as I understand the errors below, my scripts are not causing them..

    There is no Master Audio prefab in this Scene. Subsequent method calls will fail.
    UnityEngine.Debug:LogError(Object)
    MasterAudio:get_Instance() (at Assets/DarkTonic/MasterAudio/Scripts/Singleton/MasterAudio.cs:4854)
    MasterAudio:RemoveCustomEventReceiver(ICustomEventReceiver) (at Assets/DarkTonic/MasterAudio/Scripts/Singleton/MasterAudio.cs:4435)
    EventSounds:UnregisterReceiver() (at Assets/DarkTonic/MasterAudio/Scripts/Events/EventSounds.cs:1640)
    EventSounds:OnDisable() (at Assets/DarkTonic/MasterAudio/Scripts/Events/EventSounds.cs:411)

    NullReferenceException: Object reference not set to an instance of an object
    MasterAudio.RemoveCustomEventReceiver (ICustomEventReceiver receiver) (at Assets/DarkTonic/MasterAudio/Scripts/Singleton/MasterAudio.cs:4435)
    EventSounds.UnregisterReceiver () (at Assets/DarkTonic/MasterAudio/Scripts/Events/EventSounds.cs:1640)
    EventSounds.OnDisable () (at Assets/DarkTonic/MasterAudio/Scripts/Events/EventSounds.cs:411)

    Edit1:
    Forgot to say that im using Unity 4.6.2

    Edit2:
    Looks like a bug, i installed older version 3.5.7 and problem is gone

    Cheers
    Milos
     
    Last edited: Feb 12, 2015
  4. Teku-Studios

    Teku-Studios

    Joined:
    Sep 29, 2012
    Posts:
    257
  5. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Actually, I reproduced and fixed that bug (on my computer anyway) for V3.5.7.3. It is caused by Event Sounds "disable" event. Are you still seeing it? If you are, please give me your Unity version. I was a bit confused by the mention of multiple versions above.
     
  6. frikic

    frikic

    Joined:
    Dec 22, 2011
    Posts:
    44
    Sorry for confusion, now i see that i mention a version 3.5.7 which also can be Unity version, but i was thinking about Master Audio 3.5.7. But looks like i made another mistake and actual version that is working when i rolled back to it is
    3.5.6.7 ( ive got it from the ReleseNotes in the MasterAudio folder).

    So only versions of Unity that i tested on are 4.6.2f1 and 4.6.1, hope that clears up the confusion. :)
    And yes i was still getting the same error when i installed MasterAudio v3.5.7.3 with Unity 4.6.2f1
     
  7. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Ok. It looks like I fixed it only about half the time (very weird). I've made some more fixes for the next version and now I'm unable to get that error at all.

    It has to do with when the Scene ends and your objects are automatically destroyed. The disable event is fired when things are destroyed, but the Master Audio game object is also destroyed. I have some more checks in there now.

    Thanks!
     
  8. djfrail

    djfrail

    Joined:
    Jan 16, 2014
    Posts:
    124
    Small problem with the DelayBetweenSongs script - if I exit the scene in which I'm using DelayBetweenSongs by loading another scene and then reload the DelayBetweenSongs scene, the playlist will:
    - Play the first song all the way through
    - Then start playing another song for 1 or 2 seconds
    - Then jump to another song in the playlist and play it for another 1 or 2 seconds. This repeats until I exit the scene.

    Any thoughts? Thanks!
     
  9. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I'll need more detail. What game object is the DelayBetweenSongs script on? Are you using persist mode on Master Audio? Version of Master Audio and Unity you're using?
     
  10. djfrail

    djfrail

    Joined:
    Jan 16, 2014
    Posts:
    124
    The DelayBetweenSongs script is on my GameplayManager gameobject in the scene. GameplayManager goes away when the next scene loads.

    "Persist Across Scenes" is checked on in the MasterAudio GameObject in the editor.

    The graphic at the top of the MasterAudio component in the editor says v3.5.
    Unity version is 4.5.5f1
     
    Last edited: Feb 13, 2015
  11. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Master Audio V3.5 isn't nearly precise enough. What the top verison# in releaseNotes.txt?
     
  12. djfrail

    djfrail

    Joined:
    Jan 16, 2014
    Posts:
    124
    V 3.5.6.4
     
  13. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Please retest with the latest version from the Asset Store and let me know if the issue still happens or not. I fixed a related bug in the last version.
     
  14. djfrail

    djfrail

    Joined:
    Jan 16, 2014
    Posts:
    124
    Updated to V3.5.7.3 but still have the same issue.

    One thing to note:

    I added this function to DelayBetweenSongs and call it before I leave the scene.

    public void UnsubscribeToSongEnded()
    {
    _controller.SongEnded -= SongEnded;
    }

    If I don't call the above function, then I get this error when I re-enter the DelayBetweenSongs scene:
    MissingReferenceException: The object of type 'DelayBetweenSongs' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object.


    Also - I'm using .it tracker music files.
     
    Last edited: Feb 13, 2015
  15. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I was able to reproduce and fix this on my computer. There's a simple way to fix what you added, so that you won't need to call anything. Add the following instead to DelayBetweenSongs.cs:

    Code (csharp):
    1.  
    2. voidOnDisable() {
    3.    _controller.SongEnded-=SongEnded;
    4. }
    5.  
    This will be in the next release.
     
  16. djfrail

    djfrail

    Joined:
    Jan 16, 2014
    Posts:
    124
    Excellent.
     
  17. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    hi how simple would it be for me to do the following:
    i got 2 UGUI buttons in my main menu scene for muting purposes:
    MUSIC: ON
    SOUND: ON

    its pretty self explanatory but basically tapping music button mutes all the music in all my scenes and saves the preference.
    tapping sound button does the same for all sounds.

    i assume we can easily specify which sound files are "music" and which ones are "sounds".


    Also in my game scene i have a sound play in an OnTriggerFunction but the sound played depends on a boolean value, so there is an option of 2 sounds that could be played.
    Is there a way to specify in the Eventsound script component, if i have OnTriggerFunction selected, which sound to play based on the boolean inside a script on the gameobject?

    Also can i play sounds in a JS script? this isn't just C# right?
     
  18. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Our powerful EventSounds script can do that without any coding. Select actino type of "Persistent Settings Control" so it will save for all Scenes. For muting music, you select Command "Set Music Volume". For muting music, you select Command "Set Mixer Volume".

    For your custom logic you won't be able to use Event Sounds. You'll need to code that yourself. If you want to use JS (actually it's UnityScript), there are instructions in the readme. You'll need to move a certain folder into a different folder and then you can call anything from JS.
     
  19. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    thanks.
     
  20. jerotas

    jerotas

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

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Delete that script and AudioCalc.cs as well. The release notes mention that it was deleted, but upgrading without deleting the folder will leave "deleted" files in place. It's best practice to always delete the DarkTonic folder before deleting so this sort of thing doesn't happen.
    -Brian
     
  22. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Ok, can you care to explain how dynamic SGC works please?
     
  23. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    You can watch this short video which shows this and a lot more:


    Anyway a Dynamic SGC is like a mini-Master Audio prefab. You put Sound Groups, Playlists and Custom Events in it, and when the Dynamic SGC becomes enabled in a Scene, it transfers all its audio items over to the Master Audio prefab until the Dynamic SGC becomes disabled (usually happens when the Scene changes).
     
  24. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I see... so I can sort of keep the sounds that I want to always loaded into my master audio prefab and then put the ones that only being played in some specific scene into the SGC.. will the sounds in SGC be unloaded from the master audio prefab when I change my scene?
     
  25. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    It's flexible. You can choose to put them all in the SGC, or split up among many. With default settings, they are unloaded when the scene changes, but you can also specify that they never get unloaded at all, there's a checkbox.
     
  26. hike1

    hike1

    Joined:
    Sep 6, 2009
    Posts:
    401
    I loaded version 3.5.7.3 into my project, got a mess of 'script cannot be loaded, fix compile errors, etc' and these errors

    Assets/DarkTonic/MasterAudio/Editor/AudioCalcEventInspector.cs(20,73): error CS0117: `MasterAudioInspectorResources' does not contain a definition for `logoTexture'

    Assets/DarkTonic/MasterAudio/Editor/AudioCalcEventInspector.cs(99,82): error CS0117: `MasterAudio' does not contain a definition for `NO_GROUP_NAME'

    Assets/DarkTonic/MasterAudio/Editor/AudioCalcEventInspector.cs(20,25): error CS1503: Argument `#1' cannot convert `object' expression to type `UnityEngine.Texture'

    Assets/DarkTonic/MasterAudio/Editor/AudioCalcEventInspector.cs(20,25): error CS1502: The best overloaded method match for `DTGUIHelper.ShowHeaderTexture(UnityEngine.Texture)' has some invalid arguments

    When I deleted master audio all the 'cannot load' scripts were O.K. again
     
  27. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    That's correct, those files were deleted in the same version that the code was refactored. The release notes mention this. However if you updated the plugin without first deleting the plugin folder, the files will not automatically be deleted. So deleting them manually is fine. In the future, you should first delete the plugin folder, then re-import. It gets around Asset Store delivery issues such as this. :)
     
  28. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    hey i spent some time reading the Readme(a little overwhelming :) but awesome)

    For the custom logic, can't i just create 2 Custom Events, attach the event sounds script to any gameobject in my scene, and specify the sound clip actions i need in the inspector instead of coding it in my script?

    This way i can just call FireCustomEvent in 2 spots.
    MasterAudio.FireCustomEvent(string customEventName, Vector3 eventOrigin);

    I can avoid messing with any sound stuff directly from code, and simply call custom event functions :)


    I can rename Sound Groups in the hierarchy right? wont break anything?
     
    Last edited: Feb 20, 2015
  29. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    You could set up the event for Custom Action 1 & 2 in a single Event Sounds, then have another script you write that has OnTriggerEnter event code (or whatever event triggers it), and then uses "your logic" to call MasterAudio.FireCustomEvent with different event names depending on whatever. That seems to be the easiest way.

    Yeah, readme is quite long. I plan on making that into an online help website with "help" links next to every field, like what Bolt does. I think it would help tremendously.

    You can rename Variations, Groups, Custom Events and other things whenever you like. It's best to rename them right when you create them though, otherwise any other the dropdowns in our Inspectors that had the old name referenced will not fix themselves. You'll need to go find each one and change them to the new name.

    Don't worry if you don't want to look for them all though, because Master Audio will log an error to the console when a no longer existing *whatever* is fired or played. So you can find them that way too.
     
  30. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    ok cool got it all working.
    i got 2 custom events "mute" and "unmute" that i just placed on my sound button, and on clicking the button i run my own function in code that checks PlayerPrefs for audiomute variable and calls the "mute" or "unmute" events as needed.

    I did have to do a little bit of coding with PlayerPrefs to make sure if i muted audio, then when i launch the game again it remembers that it was muted and i can run the "mute" event in the Start() function of my script.

    but yea works great since before i used audiolistener to mute all sound there was this bug on mobile when the game loses focus and then gets refocused the audiolistener got reset which was annoying since i had to check the playerprefs on every single OnApplicationFocus to see if the sound should get muted again. Now i don't need that at all, i can just check once in my menu scene and forget about it.
     
  31. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Awesome!
     
  32. Ash-Blue

    Ash-Blue

    Joined:
    Aug 18, 2013
    Posts:
    102
    Master Audio stops firing mecanim sync sounds when I use SetActive(fasle) then SetActive(true) on an object. This totally breaks our cutscenes when characters are hidden then shown. Screenshot of our current player config attached. Help please >_<
     

    Attached Files:

  33. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    That's because it's a Coroutine to save on processor time for the checks. All Coroutines automatically stop when you disable a game object. I've added code to fix this, but I'm not posting the file here or releasing a new version for a bit. If you email me at support@darktonic.com I can get you the file.

    -Brian
     
  34. Ash-Blue

    Ash-Blue

    Joined:
    Aug 18, 2013
    Posts:
    102
    O man, thank you so much :D Would be best if I could just get the individual file I need to replace. I'll email you for the file with my invoice number.
     
  35. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Hi Brian,

    I found a possible bug on the last version.
    I have a scene with a dynamic SGC that use an existing bus. This bus is created only in the boostrap scene, so the temporary Master Audio prefab inside each scene will not contain that (it's completely empty).

    When I run directly this scene I get a Null reference exception at line 2669 of MasterAudio.cs:
    Code (CSharp):
    1. groupScript.busIndex = GetBusIndex(aGroup.busName, true);
    2. if (groupScript.BusForGroup.isMuted) {
    3.   MuteGroup(groupScript.name);
    4. }
    groupScript.BusForGroup returns null.

    I added a null check, and it works. The side effect is that in the Master Audio Mixer the sound groups of that bus show as [No Bus].

    How do you suggest to proceed? I created then the BUS on the temp Master Audio (I added and then removed a sound clip), but, of course I have to keep manually sync the volume of the BUS on all the scenes. I mean, if I will need to change the volume of this BUS in the bootstrap I'll have to do update all the scenes to avoid wrong volumes while testing a single scene.

    How you would proceed to organize the things better? How to have a global BUS available from the bootstrap and also in all temporary MasterAudio instances with the correct updated volume?

    Thanks
     
  36. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Show me what your null check change looks like so I can add it.

    You should have a single prefab that you use for all the "temp Master Audio" game objects in every scene except the Bootstrapper, so it won't be so bad. You can update it in only 2 places - the Bootstrapper and the other prefab which will affect every other Scene. If you haven't made a prefab out of that one, do so now.

    -Brian
     
  37. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Thanks, the solution you propose is definitely easy. I should have thought by myself :oops:

    Here is the null check:
    Code (CSharp):
    1. groupScript.busIndex = GetBusIndex(aGroup.busName, true);
    2. if (groupScript.BusForGroup != null && groupScript.BusForGroup.isMuted) {
    3.   MuteGroup(groupScript.name);
    4. }
    By the way, I have the Master Audio object as child of a persistent parent. It works fine, but you suggest to avoid it. Is only for the persistency or for something else? What could happen keeping like that?
     
  38. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    hey, i seem to be getting a new issue:
    I haven't noticed it before because i only tested a scene at a time, but in game when i go from one scene to another i get the following 2 attached errors

    I have a masteraudio prefab in both scenes that im using, and im not calling any sound code in Awake() anywhere, im only using custom event calls as well.

    I only use 1 playlist clip in one scene, and 2 Groups with one clip each in another scene, nothing persists between scenes.

    Also, sometimes the error doesn't happen on the first scene switch, as in i might get no errors going from scene 0 to 1, then 1 to 0, but then going again from 0 to 1 ill get the errors. It's kind of random.

    Is something trying to utilize the masteraudio prefab before it fully initialized or something?

    P.S.
    I use Unity 4.6.3f1
    I code in UnityScript.
     

    Attached Files:

    Last edited: Feb 22, 2015
  39. hike1

    hike1

    Joined:
    Sep 6, 2009
    Posts:
    401
  40. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I simply don't test the scenario of it being a child. I remember before people reported some obscure error and when they made it "no child" they went away. I can't remember what the error was. Thanks for the code.

    Definitely for persistency it would be a problem.
     
  41. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    You have a sound for "Disable" event, which will be firing automatically when the Scene is changed and the game object is destroyed.

    I fixed a very similar issue (possibly same issue) in the last version. Are you on the very latest Master Audio? If you are, you may need to send me a "sample broken project".
     
    Last edited: Feb 22, 2015
  42. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Cool! Notes on your tutorial:

    1) Yes you can drag the Variations in a Sound Group around to re-order them. No weird message will be given (I've done this many times).
    2) Custom Events can also be fired from Event Sounds by another event (such as Invisible / Trigger Enter) without writing any code. Then other game objects in the Scene can respond to the event.
     
  43. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    hmm i don't think i musing a disable event, but i don't mind sending you my whole project so you can see for yourself.
     
    Last edited: Feb 22, 2015
  44. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    You're probably right. I'll see what you have when you send it.
     
  45. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    here you go sir: http://www.2shared.com/file/qann_PgF/quotes.html


    just load either MENU scene and click PLAY button or GAME scene and click back arrow button. you may have to go back and forth more than one time for the error to happen
     
  46. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    From your error screen shot, I think the following will fix it. This is on ~line 4854 in MasterAudio.cs

    Code (csharp):
    1.  
    2. public static void RemoveCustomEventReceiver(ICustomEventReceiver receiver) {
    3.    if (AppIsShuttingDown || SafeInstance == null) {
    4.       return;
    5.     }
    6.  
    Go ahead and add the second part of that if statement and let me know if the error goes away. I'm not going to be at my computer for a day or so.
     
  47. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614

    heyyy yea it worked! thanks :)
    was it a bug or something?
     
  48. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Yeah, one I hadn't encountered before but it's been there a long time and no one reported it until now.
     
  49. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    whoohooo im contributing!
     
    jerotas likes this.
  50. Ross_S

    Ross_S

    Joined:
    Jul 10, 2012
    Posts:
    29
    Hi folks,
    I'm wondering how you best recommend we make a MUTE function in our game? I know there's Mute Bus and MuteEverything commands but they don't quite work as we need. For example if you call MuteEverything and then you enter a new scene and a looping ambience should start and then halfway through that scene the player decides to Unmute the game - play hasn't been called on that sounds.
    What we would like is something that is simply the equivalent of turning the volume to 0 on all sounds.
    I've tried setting volume to 0 for all buses but again this seems to interfere with whether or not sounds actually get started.
    thanks.