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
    Thank you sir :)
     
  2. Pedro-Alaiagames

    Pedro-Alaiagames

    Joined:
    Apr 15, 2014
    Posts:
    28
    Hello:
    Since Ive updated MasterAudio plugin I found this error.
    Any help Please?

    Assets/DarkTonic/MasterAudio/Scripts/Events/EventSounds.cs(358,40): error CS1061: Type `Button' does not contain a definition for `onClick' and no extension method `onClick' of type `Button' could be found (are you missing a using directive or an assembly reference?)

    The error refers to this piece of code in EventSounds.cs

    Code (CSharp):
    1. void OnEnable() {
    2.         #if UNITY_4_6 || UNITY_5_0
    3.             if (slider != null) {
    4.                 slider.onValueChanged.AddListener(SliderChanged);
    5.             }
    6.             if (button != null) {
    7.                 button.onClick.AddListener(ButtonClicked);  //ERROR .Onclick not found event
    8.             }
    9.         #endif
    10.  
    11.         #if UNITY_IPHONE || UNITY_ANDROID
    12.             // no mouse events!
    13.         #else
    14.             mouseDragResult = null;
    15.         #endif
    16.  
    17.         RegisterReceiver();
    18.  
    19.         if (this.useEnableSound) {
    20.             PlaySounds(enableSound, EventType.OnEnable);
    21.         }
    22.     }
    23.  
    24.     void OnDisable() {
    25.         #if UNITY_4_6 || UNITY_5_0
    26.             if (slider != null) {
    27.                 slider.onValueChanged.RemoveListener(SliderChanged);
    28.             }
    29.             if (button != null) {
    30.                 button.onClick.RemoveListener(ButtonClicked);  //ERROR .Onclick not found event
    31.             }
    32.         #endif
    33.  
    34.         UnregisterReceiver();
    35.  
    36.         if (!this.useDisableSound || MasterAudio.AppIsShuttingDown) {
    37.             return;
    38.         }
    39.  
    40.         PlaySounds(disableSound, EventType.OnDisable);
    41.     }
     
    Last edited: Dec 17, 2014
  3. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    What version of Unity are on you on? I haven't seen the error. If it's Unity 5, I'll need the exact beta version #.
     
  4. kewlking

    kewlking

    Joined:
    Dec 2, 2014
    Posts:
    6
    So, a fairly open ended question here - would really appreciate any pointers:

    I am trying to prototype something like a touch guitar, if you will - where you can move your fingers across the screen and depending on where your pointer is, the corresponding clip gets played. See image for an idea of the layout. Each 'band' fires a separate audio clip.

    Here is what I am observing:

    If I use native unity and use the AudioSource.Play/Pause combo to trigger and stop the sounds, the app seems more 'responsive' or 'lively' whereas if I use the MasterAudio.PlaySoundAndForget and PauseSoundGroup to start and stop the sound group, there are 'pauses' between the various sounds that get played.

    Is there a different paradigm that I can use to minimize the latency between the various SoundGroups getting triggered? Alternatively, is there a way I can get these soundGroups to fade nicely into each other - that would work well also. I am going to see if using the SoundGroupVariation to fade out the sample sounds better without a huge overhead in CPU/Memory.

    Thanks in advance for any pointers.

    ScreenClip [2].png
     
    Last edited: Dec 18, 2014
  5. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    There should be no difference except possibly a very slight (fraction of milliseconds) delay as sounds play with Master Audio as compared with non-Master Audio code. It still would sound during the same frame, unless you have set up your sounds as Resource files? Also, if you're playing any mp3's instead of wav or ogg files, that can cause a *considerable* delay. So make sure you're not using mp3's for any Sound Group Variations. Also, make sure you're not streaming any of those, as that takes time for Unity to startup the sound as well.

    Also, check your audio latency settings (Unity feature, not MA). Sound Groups do not fade into each other, unless you're using a "Dialog mode" Group, although you can set up a custom fade for each Variation, and you can also fade a Sound Group whenever you like.

    If you have code that stops a previous sound and starts another sound, let's see it.
     
    Last edited: Dec 18, 2014
  6. DirtyHippy

    DirtyHippy

    Joined:
    Jul 17, 2012
    Posts:
    224
    Just upgraded to the latest version from one a month or two ago. I create all my sound groups dynamically. DynamicSoundGroupVariation required an Audio component with RequireComponent until this last update. Without it my bootstrapping code fails as I assume that component will be there in order to set some metadata. Was this intentional? This change must have been recent. Adding the RequireComponent back in myself fixed the issue.
     
  7. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Doesn't ring a bell. I'll take a look.
     
  8. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Yeah I needed to remove that to get the code to copy the custom rolloff curve from the Variation template. You will need to work around this by adding it yourself.
     
  9. Pedro-Alaiagames

    Pedro-Alaiagames

    Joined:
    Apr 15, 2014
    Posts:
    28
    Im using 4.6.0f3 version of Unity

    Thanx for your Help!
     
  10. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I am on that exact version as well and I have no errors with the latest Master Audio.

    Please try upgrading to the latest (I believe Unity 4.6.1 is out), and also delete the entire Dark Tonic folder and reimport Master Audio. Let me know if you still see any errors.
     
  11. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    Chances are that you have a class in your project that is named "Button". Master Audio wants to access the onClick event of the Button class from Unity's new UI, but the compiler might only be seeing the other class. If that is the case, change your class' name from "Button" to something else. :)

    On another topic, is there any chance that we can specify a "fade" duration for music ducking? Music seems to duck immediately, but I wanted to let it fade to the duck volume for some time (imagine 0.5s).
     
  12. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    No you can't. Traditionally, ducking has never worked work like that. It's meant to be able to hear the very beginning transient of the sound first and foremost, so it always ducks instantly. You can control when the volume starts unducking only (percentage of time length of the ducking sound) - defaults to 50% for each sound.

    I don't think that the Unity 5 ducking will allow what you want either.
     
  13. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    Hmm, that makes sense. I imagine the common use of ducking is for sudden, loud, sounds. In my case I want to play a short melody and make the background music quickly fade to a certain low volume when the melody starts, but the sudden duck is harsh. I'll have to do it "manually", then. Thanks for the quick response. :)
     
  14. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Then duck the volume less (maybe 20% instead of 50%)? Shouldn't even be noticeable as harsh.
     
  15. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    Unfortunately, louder duck volumes make the background music mix too much with the melody, which sounds bad. This is a specific case, so I'll have to work on it. In the worst case scenario I'll keep the sudden duck as it is.
     
  16. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    For all users that don't have a Unity pro license, I was browsing the Asset Store and came across these FREE 7 effect plugins: https://www.assetstore.unity3d.com/en/#!/content/19328

    I'm not sure of the quality (someone please take a listen and tell me) but free is definitely a good price, and it says they are mobile friendly.
     
  17. Pedro-Alaiagames

    Pedro-Alaiagames

    Joined:
    Apr 15, 2014
    Posts:
    28
    Problem solved!

    The other Class called Buttom was in Unity Sample Assets package from asset store. I`ve updated this package to the new beta version for 4.6+ Unity version, where this problem is solved too.

    Thank you very much to you and to jerotas for your help.
     
    CanisLupus likes this.
  18. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Great to hear! Thanks for letting us know you're all good.
     
  19. 99thmonkey

    99thmonkey

    Joined:
    Aug 10, 2012
    Posts:
    525
  20. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I like it! Great job and thanks for sharing!
     
  21. 99thmonkey

    99thmonkey

    Joined:
    Aug 10, 2012
    Posts:
    525
    Thanks. I had a hard time getting it down to the right size for Kongregate. Plus I have a few Leaderboards as well.
     
  22. Liviuss

    Liviuss

    Joined:
    Apr 2, 2014
    Posts:
    101
    Hi,

    Does Audio Group with single clip and N+ pitch variations work? I'm on Unity 4.6.1f1 MA 3.5.6.9 and i'm trying to achieve an "increase" effect by adjusting the pitch of variations. The group is set top to bottom with refill at 3 sec but it play always at original pitch. The file it's a WAV.

    Thanks.
     
  23. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    How are you playing the sound? From your own script / EventSounds / Playmaker? If you have specified a variation name, then it will only play that one and not the other variations. That might be your problem. You have set up the pitch of the Variations in the Inspector before pressing play right?

    I've done what you are describing, and it works fine for me. In fact there's a Group Template for that (Pitch Rising Chromatic).
     
  24. Liviuss

    Liviuss

    Joined:
    Apr 2, 2014
    Posts:
    101
    Yeah, forget to mention that. The code look like these:
    Code (CSharp):
    1. MasterAudio.PlaySound3DFollowTransform ("Pickup", transform, 1f, Time.timeScale, 0f, null, false, false);
    Where "Pickup" is group name.
    And i added the clip with the template you mentioned. And there is no limitations on voices etc.
     
  25. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    You are passing Time.timeScale for the pitch parameter. When you pass a non-null pitch like this, it will use the pitch you specified (and not the pitch specified in the Variation itself) when it plays the sound.

    It is playing all the Variations in succession when you trigger the sound a bunch of times - it's just not using the pitch there because you're overriding it. This is working as designed. You were probably just confused how to use it. Also, no need to specify the params that have defaults when you are using the default values. Try the following, it works for me:
    Code (CSharp):
    1. MasterAudio.PlaySound3DFollowTransform ("Pickup", transform, 1f);
     
  26. Liviuss

    Liviuss

    Joined:
    Apr 2, 2014
    Posts:
    101
    Thanks, it works as expected.
     
  27. jerotas

    jerotas

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

    sicga123

    Joined:
    Jan 26, 2011
    Posts:
    782
    Hi Jerotas, rather simplistic question. I'm using Adventure Creator for a game and the audio in that kit needs to be 2D. I take it Master Audio also deals with 2D as well as 3D audio? I looked through the docs and stuff quickly but nothing jumped out to confirm this so I thought it would be quicker just to ask for a yes or no answer before I start delving into things in more detail to know that I am not barking up the wrong tree.
     
  29. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Yes of course it can do 2D the same. That actually has nothing to do with Master Audio - it's just native Unity functionality. You just set each AudioClip to 2d on its import settings. I believe the default when you import clips is 2d actually.

    One point for Master Audio though: no point using "follow caller" code or settings for 2d sounds. That's the default for EventSounds component but it does take a little extra CPU, so just pay attention and turn it off.
     
  30. sicga123

    sicga123

    Joined:
    Jan 26, 2011
    Posts:
    782
    Thanks for the quick reply at this time of year.
     
  31. jerotas

    jerotas

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

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    New video showing how to use the EventSounds script to trigger audio from uGUI (Unity 4.6 GUI) objects.

     
  33. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Sale ends tonight, so pick it up for $20 while you still can!
     
  34. Liviuss

    Liviuss

    Joined:
    Apr 2, 2014
    Posts:
    101
    It doesn't open saying it's private.
     
  35. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Sorry about that, looks like I forgot to click the publish button. It's live now!
     
  36. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Hello there and happy new year!

    I updated to the latest version and I am now getting two errors:
    Assets/DarkTonic/MasterAudio/Scripts/Events/EventSounds.cs(355,40): error CS1061: Type `Slider' does not contain a definition for `onValueChanged' and no extension method `onValueChanged' of type `Slider' could be found (are you missing a using directive or an assembly reference?)

    Assets/DarkTonic/MasterAudio/Scripts/Events/EventSounds.cs(378,40): error CS1061: Type `Slider' does not contain a definition for `onValueChanged' and no extension method `onValueChanged' of type `Slider' could be found (are you missing a using directive or an assembly reference?)

    Any ideas what am I doing wrong or how it got messed up? I re-imported and can't see the menu item Master Audio Update tool or anything related to Master Audio.

    Also, how do I decrease the master audio volume given a condition? And switch it back to the default when false?

    Thanks
     
  37. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Looks like you're probably on a beta version of Unity 4.6. We only support the released version. Please install Unity 4.6.1 and those errors should go away. Everything compiles fine on my 4.6.1.

    To switch volume you'll need to use a line or 2 of code. Music volume and mixer volume are controlled separately.

    Code (csharp):
    1.  
    2. MasterAudio.MasterVolumeLevel = .5f; // set mixer volume
    3. MasterAudio.PlaylistMasterVolume = .6f; // set music volume
    4.  
    You can see all this on the API website here for future reference.
     
  38. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Weird... I have 4.6.1
     

    Attached Files:

  39. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Well that makes no sense. Uninstall it and download a fresh copy to reinstall.

    I will do the same.
     
  40. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Error still persists
    Deleted Unity from my applications folder, and even deleted the project's library folder.
    Assets/DarkTonic/MasterAudio/Scripts/Events/EventSounds.cs(355,40): error CS1061: Type `Slider' does not contain a definition for `onValueChanged' and no extension method `onValueChanged' of type `Slider' could be found (are you missing a using directive or an assembly reference?)

    Assets/DarkTonic/MasterAudio/Scripts/Events/EventSounds.cs(378,40): error CS1061: Type `Slider' does not contain a definition for `onValueChanged' and no extension method `onValueChanged' of type `Slider' could be found (are you missing a using directive or an assembly reference?)
     
  41. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I still think your Unity installation is somehow messed up. I have just uninstalled Unity 4.6.1 on 2 computers, re-downloaded it and installed it. Then opened Master Audio.

    I have zero compile errors.

    If you have multiple versions of Unity installed, that also could cause the problem.

    By the way, the Unity documentation for Slider still shows onValueChanged. So that's further proof. http://docs.unity3d.com/ScriptReference/UI.Slider.html

    Or.... it's possible you have more than one class in your project called Slider?
    Go into code mode and see what pops up from Intelli-sense when you start typing "Slider". Let me know if there's more than one.
     
    Last edited: Jan 5, 2015
  42. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    gegagome, I've added code to EventSounds so that even if there's another Button or Slider class in the project, it will use the right one. Will submit fixed version now to Asset Store.
     
  43. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Master Audio V 3.5.7 will be live in 20 minutes. Changelog:

    - Some variable names were too close to property names, so had to be changed. These will reset to 1 so your volumes will be lost.
    1) Playlist Volume on Playlist Controller (will revert to 1 so please re-set your Playilst Controller volumes).
    2) Master Mixer Volume on Master Audio (will revert to 1 so please re-set it on the Master Audio prefab).
    3) Master Playlist Volume on Master Audio (will revert to 1 so please re-set it on the Master Audio prefab).
    - Fixed some weird caching bugs when using persistent MA prefab with a non-persistent Playlist Controller.
    - Fixed bug: If you had another class called Button or Slider (besides Unity GUI ones), EventSounds script wouldn't compile.
     
  44. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    I tried everything.
    Installed 4.6.1 twice and nothing. Installed patch 4.6.1 p2 and nothing.

    I grabbed the DarkTonic folder from my backup project and it worked again.

    Not really sure what happened, ¿except that updating to MA latest version caused this problem? But it is working fine again, albeit not the latest version.

    I will try the 3.5.7 shortly and will get back to you.


    Thanks
     
    Last edited: Jan 5, 2015
  45. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Reporting back about 3.5.7
    I am now getting a bunch of:
    MissingComponentException: There is no 'AudioSource' attached to the "0" game object, but a script is trying to access it.
    You probably need to add a AudioSource to the game object "0". Or your script needs to check if the component is attached before using it.
    SoundGroupVariation.Awake () (at Assets/DarkTonic/MasterAudio/Scripts/Settings/SoundGroupVariation.cs:128)

    So maybe the project got messed up but it is alive again. yay
     
  46. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    If you don't have an Audio Source on any SoundGroupVariation, then add it. It's required. They are added automatically when you create Sound Groups, you shouldn't ever have to add them unless you accidentally deleted the component somehow. You may have other problems if you got into that situation. I've never had that problem before...

    You'll have to do some investigating.
     
    Last edited: Jan 5, 2015
  47. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Thanks for your support really

    It wasn't that big of a deal. I had to remove and re-add MA groups sound files in the first scene and now I am moving on to the other scene.

    Thanks again
     
  48. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Glad you are fixed. But I have no idea why you had to do that. We haven't heard of such a thing ever.
     
  49. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Weird. Glad my two scenes contain very few sounds but I will try to be more careful next time so I can document issues more thoroughly.

    Thanks
     
  50. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Is there a method that fades all groups to a certain volume with fade time? I found a couple of methods that do that but these act on groups, so I would have to have a method for each group.

    Thanks