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. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Unfortunately it doesn't resolve the problem. The sounds keep adding and playing.
     
  2. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    I think there may be a bug in footstepsounds.cs
    Basically i have a bullet object on which i put the script on:
    i set it to On Collision 2D and added 2 footsteps:
    footstep 1 plays a sound if collided with "enemy" tag
    footstep 2 plays different sound if collided with "upgrade" tag

    but what happens in game is only the first footstep functions. Colliding with "upgrade" tag doesn't play the corresponding sound group.

    If i remove the tag filters from both footsteps, then on any collision both sounds play fine.
    If i remove the "enemy" tag filter from footstep 1, then footstep 1 plays on any collision and footstep 2 plays only on "upgrade" collision.

    It seems like the tag filter gets passed down to the next footsteps or something.

    Using 2 separate footstep scripts for "enemy" and "upgrade" works fine but defeats the purpose of the script in the first place lol
     
  3. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    I found that in MasterAudio.cs, method RemoveSoundGroup, also there the SafeInstance check should be replaced by "Instance".
    Now it works.
    Thanks for your help
     
  4. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    The real fix I made after replying was this:

    1) Leave them both as SafeInstance as they were before.
    2) Change SafeInstance property code to the following:

    Code (csharp):
    1.  
    2. publicstaticMasterAudioSafeInstance {
    3.    get {
    4.       if (_instance!=null) {
    5.         return_instance;
    6.      }
    7.  
    8.       _instance= (MasterAudio)GameObject.FindObjectOfType(typeof(MasterAudio));
    9.       return_instance;
    10.     }
    11. }
    12.  
     
  5. hunz

    hunz

    Joined:
    Oct 16, 2012
    Posts:
    29
    Hey,

    I was wondering if anyone could help out with this;

    I'm using unity 4.6 and playmaker.

    I have an animation file that is synced to audio that is playing in the playlist.
    I have an FSM that starts the animation and the playlist
    What I'm hoping to do is have the playlist send an event when it loops so that I can sync the animation again.

    I've looked at Song ended event but I can't seem to figure it out.

    Any help or pointing in the right direction would be appreciated.
     
  6. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Thanks, I'll take a look and fix it ASAP.
     
  7. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    A song doesn't fire SongEnded when it loops, only when it stops playing. We don't have an event for that. I can add that to the roadmap right now.
     
  8. hunz

    hunz

    Joined:
    Oct 16, 2012
    Posts:
    29
    Oh wow, thank you very much that would be really appreciated! I'll find a work around for now.

    Thanks again.
     
  9. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    You can possibly "fake it" by not having the song loop but having the whole Playlist loop (checkbox on Playlist Controller game object). If it's only 1 song the SongEnded event would work fine.
     
  10. hunz

    hunz

    Joined:
    Oct 16, 2012
    Posts:
    29
    Oh yeah. That's how I've actually got it setup so I can do that. It is only one track but I'm using the playlist sync as well but I'm sure that doesn't impact things.

    I guess my noobyess can't figure out how to get the Custom Event / Song Ended to talk with an FSM so I can re-trigger the animation. I'll keep playing with it.
     
  11. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Unfortunately when you use "Synchronize Clips" all songs automatically loop. It would cause a myriad of weird crossfade bugs otherwise. You only need Synchronize Clips when you're either layering music or doing cross fades into alternate musics.
     
  12. hunz

    hunz

    Joined:
    Oct 16, 2012
    Posts:
    29
    Yeah. All my different enemies represent different instruments (like the game loco roco) that when they are appear they bring about new melodies and vocals and so on. I'm using .xm format to bring this to life to keep the size right down.

    I have them animating to their respective tunes but the overall playlist needs to loop and then reset the animations so everything is in sync with the loop point. Hope that makes sense.
     
  13. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    This bug is fixed and will be in the next update.
     
  14. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Ok. The code I will adding later (much later, there are 20 items in the roadmap now) would basically check if the PlaylistController's ActiveAudioSource.time value is less than the previous frame. If so it has just looped. Unfortunately there's nothing built in for that, so that's how you should do it if you don't want to wait possibly months for my implementation.
     
  15. hunz

    hunz

    Joined:
    Oct 16, 2012
    Posts:
    29
    Thank you! I can see that on the get property for playmaker so I should be able to make a checker for that. Much appreciated again, thank you for creating a plug that makes sense to a musician like myself ^_^
     
    jerotas likes this.
  16. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    I have a tricky sound scenario that I'm stuck on, not sure how to implement it.

    Basically i have a looping clip "fire" that i made into a 1 clip group with weight 10, and fade in and out of 1 second.
    When i set an object on fire in game:
    1)i spawn a fire particle prefab from poolmanager
    2)i have eventsounds script with Spawned event attached to fire particle prefab which does "Play Sound" with the "fire" group
    This works nicely because the fade in of 1 second synchronizes with the fire particle prefab 1 second lifetime.

    Within a script on the object on fire, it calculates when to stop the fire. When that frame occurs:
    1)I run Stop() on the fire particle prefab so after 1 second it automatically despawns into the pool
    2)I run a Custom Event "burnStop" attached to the fire particle prefab which does "Group Control", "Fade Out Sound Group Of Transform" with 1 second fade out.

    This all works great if i set fire to only one object at a time and wait for fire to stop, but i can't figure out how to make this work if i set for example 2 objects on fire, but the second object is set on fire just when the first object is about to stop, so because of the custom event the whole group fades out even though the second object was just set on fire.

    Is there any way to only fade out the variation that's supposed to fade out, and keep the other ones going until the object it's playing for is no longer on fire.

    before master audio i had an audio source on each fire particle prefab so the in code i could stop the sound on exactly the fire that was just finished, but with master audio i don't know how to be so specific, or if there's some trick way to do it from event sounds.

    I'm a little stumped here.
     
  17. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I don't understand the part that doesn't work. If you have 2 separate game objects that have fire, they should each fade out whatever sounds they made with FadeOutSoundGroupOfTransform and not affect the others.

    It's possible that you will need to not use EventSounds and write some code if you have multiple sounds made from a single game object and you want that granularity of fading out only certain ones. Each Variation does indeed have its own Fade methods as the API shows.

    Also, there's an option in each Sound Group to automatically fade out sounds when the called is despawned, if that's any help (Caller Despawned Mode).
     
  18. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    FadeOutSoundGroupOfTransform seems to affect all objects that have the custom event, which is by design right? masteraudio will call the event on all objects that have that custom event assigned. How would i call the custom event on a particular object if i have a reference to it?
     
    Last edited: Mar 14, 2015
  19. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614

    I tested using Despawn and FadeOutSoundGroupOfTransform and everything works perfectly, except the only thing is i want to call FadeOutSoundGroupOfTransform when the particle effect is Stopped, not when it's despawned, which is a 1 second difference in time.

    Calling a custom event that uses FadeOutSoundGroupOfTransform stops the sound on ALL objects that have that event, but using Despawn event stops the sound ONLY on the particle effect that's despawning.


    How would i achieve the same thing when on a particle effect Stop() method, if using a custom event doesn't work.
    If i have a reference to the particle effect prefab in my code, what's the masteraudio code to access the particular variation played by that prefab and stop it or fade it out.

    or is it possible to call the custom event on only the particle prefab i have referenced?


    UPDATE:
    hmm im checkin the API to see how to call a custom event manually inside the eventsounds script from a reference, but not finding anything so far. My API reading skills are very weak however.

    also my script is UnityScript so im thinking i can't call a function in the eventsounds script...

    maybe there's a way to add particle effect Stop() event to the eventsounds list? that would my problem immediately, i have absolutely no clue how to modify the script myself.

    UPDATE 2:
    WHOO HOOOO I FIGURED OUT A WAY!! i just ran this in my script:
    MasterAudio.StopSoundGroupOfTransform(burnEffectReference.transform,"zombie_basic_deadBurn");

    burnEffectReference is my particle effect.
    LOL i pretty much overcomplicated the hell out of the issue i guess.... just have to find the fadeoutfunction

    ignore all previous stuff i wrote :)
     
    Last edited: Mar 14, 2015
  20. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Yes, that's the correct way. If you fire a custom event, it does indeed activate however many objects in the Scene that listen to that event. You can only optionally narrow the scope by the distance of listeners. That's not what you want to do. It is however very useful for other things.

    To fade instead of the code you used, use MasterAudio.FadeOutSoundGroupOfTransform instead (pass the same 2 parameters).

    Have you been to the API website here? It has everything. https://dl.dropboxusercontent.com/u/40293802/DarkTonic/MasterAudio_API/Index.html
     
  21. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    yea ive been to the api, its well organized. Thanks.
     
    jerotas likes this.
  22. xdotcommer

    xdotcommer

    Joined:
    Aug 20, 2014
    Posts:
    33
    Just upgraded to unity 5 and my playlist plays in scene; however, sounds that are triggered (jumping, collisions, etc) - both with MasterAudio.PlaySoundAndForget and events - don't play.

    Here were a number of errors in my Master Audio Game object:

    ...There's 4 Audio Source Templates that aren't setup - locate them.

    And then I added the 4 prefabs 100, 500, 1000, 5000... and added them.

    Still no sound. And no errors to help me figure out why.
     
  23. xdotcommer

    xdotcommer

    Joined:
    Aug 20, 2014
    Posts:
    33
    Seems like things mostly work after assigning the sounds to busses.

    Still a few sounds aren't playing. And I'm unable to trigger any sounds by clicking on the speaker icon next to the sound in the inspector.
     
  24. xdotcommer

    xdotcommer

    Joined:
    Aug 20, 2014
    Posts:
    33
    Icons suddenly started working... no explanation.
     
  25. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I'm pretty sure the sounds are working. You do see the LEDs on the mixer light up when you preview the sounds in Play mode right? What most likely happened is you lost your 2d / 3d settings, which are now located on the Audio Source instead of on the Audio Clip.

    I'm guessing you were using 2D sounds, and the new Spatial Blend blend field is not set to 2d.

    To make all sound effects 2D, change the dropdown above the mixer for Spatial Blend Rule to "Force All to 2D" and when you hit play all will work as before.
     
  26. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Great! Thanks. :)
     
    Last edited: Mar 14, 2015
    jerotas likes this.
  27. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    @luniac update the code as suggested by jerotas. See the post just before your. It should resolve.
     
  28. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Correct. Try that because it will now use cached results and not look up every time.
     
  29. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    thanks for the tip, my issue was different though, i just didn't realize that calling a custom event like an attack sound when an enemy attacks would play the sound on EVERY enemy in the game that has the event, this was kiling my performance.
    I'm updating all my code to call the PlaySound functions directly within code now so it calls it per transform...

    but i am running into a problem though.
    When i call this line in my code:MasterAudio.PlaySoundAndForget("zombie_basic_criticalDeath");
    I get the following error: Internal compiler error: Array index is out of range..

    i don't understand why? it happens no matter what string i pass to the function.
     
    Last edited: Mar 14, 2015
  30. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I have no idea. Please put the entire stack trace message from the console here so I can see line numbers.

    Yes, custom events are supposed to work like that.
     
  31. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    The error was only on my script, all the error said was:
    assets/_turret_game/_game/scripts/GAME/Enemy.js(191,55): BCE0055: Internal compiler error: Array index is out of range..

    Line 191 contains: MasterAudio.PlaySoundAndForget("zombie_basic_groan3");

    if i comment it out then i get no compile errors.
     
  32. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    using the full method works:
    MasterAudio.PlaySoundAndForget( "zombie_basic_groan3", 1f, null, 0f, null );
     
  33. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Well that's good. I can't really give any advice on javascript usage, I only use C#.
     
  34. jerotas

    jerotas

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

    • Added namespace to all System.Action usages in case you have another Action class.
    • Fixed bug where Dynamic Sound Group Creator no longer removed temporary items on Unity 5.
    • Fixed bug where Event Sounds' Inspector didnt' line up multiple actions in the UI correctly.
    • Fixed bug where Footsteps script only played sound for the first footstep group.
    • Fixed Persistent Group & Bus volume to use Player Prefs (more permanent and works in multiple sessions).
    • Fixed bug where shuffle mode Playlists would log an error to Console on startup.
    • Now Custom Events that are created Dynamically can still be subscribed to.
    • Added "toggle mute bus" command to API and to Event Sounds script.
     
  35. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    I noticed a new problem:
    When i call MasterAudio.PlaySoundAndForget("turret_basic_flamethrowerShoot", 1f, null, 0f, null);
    it plays a looping clip

    in the same script i call:
    MasterAudio.StopSoundGroupOfTransform(this.transform,"turret_basic_flamethrowerShoot");
    it does absolutely nothing, and i know it gets called because if i change the string it tells me the group doesn't exist.
    The sound stops correctly If i call MasterAudio.StopAllOfSound("turret_basic_flamethrowerShoot");
    So this means that masteraudio didn't know that the variation was used by the current transform?
    The fading out function also didn't work in this situation using this.transform.


    I know you only code in C# but is there no way to make this work with unityscript to call the basic API functions?

    for example i can't call the following function because i get an error if i don't fill in the last 2 parameters which you say to not fill in the API:
    public static PlaySoundResult PlaySound(
    string sType,
    float volumePercentage = 1f,
    Nullable<float> pitch = null,
    float delaySoundTime = 0f,
    string variationName = null,
    bool isChaining = false,
    bool isSingleSubscribedPlay = false
    )
     
    Last edited: Mar 16, 2015
  36. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    I have this problem!

    I have a scene (musicsfx) where I have my main masteraudio. I have a main prefab on each scene (with DontDestroyOnLoad) where on Awake I do Application.LoadLevelAdditive("musicsfx");

    Ok... If I start the game from the first scene, everything is fine!

    But If I use an EventSound - Playlist Control - Change Playlist on a scene, I got
    "Playlist Controller is not initialized yet. It must call its own Awake & Start method before any other methods are called. If you have a script with an Awake or Start event that needs to call it, make sure PlaylistController.cs is set to execute first (Script Execution Order window in Unity)."

    I changed the script execution order, change from Start to Enable event, but I have this problem.

    How is the correct way of doing this?
     
  37. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    "Master Audio lets you specify the maximum number of each sound that can be playing at a single time."

    How do I do this? I can only now play 1 simultaneous song of each at time. How to increase this number?
     
  38. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    StopSoundGroupOfTransform will only stop sounds that have been made to "FollowTransform" or "AtTransform". Sounds played without passing in a Transform object are not considered a sound "of Transform". You will need to use a method like MasterAudio.PlaySound3DFollowTransform instead of PlaySoundAndForget.

    For the fields the API says not to fill, you have no choice but to pass the default (false). Those may not work properly with UnityScript for chained loop groups. There may be a workaround for UnityScript, but I have no idea. You could ask on the scripting forum: is there a way to use optional parameters with UnityScript?
     
    Last edited: Mar 16, 2015
  39. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    The "weight" field in each Variation defaults to a value of 1 and is the maximum number of voices of that sound that can play. Increase it to your desired max.
     
    Last edited: Mar 16, 2015
  40. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    First, make sure you're on the absolute newest version of Master Audio. I fixed a few bugs with that error in the last 2 versions.

    Are you saying you tried to play from the 2nd level, which doesn't have a Master Audio or Playlist Controller prefab? That would never work if so.
     
  41. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    Yes... but on that scene I have a Main Prefab, which on Awake does an Application.LoadLevelAdditive("musicsfx"); where on this scene there is an MasterAudio and PlaylistController.
     
  42. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    FYI, I've never used LoadLevelAdditive. I'm not sure how that works. Do game objects in the Scene you're loading call Awake methods like normal loads?

    Which Scene is the EventSounds that doesn't work in? Is it in the one that gets loaded additive? If so, what event are you using in EventSounds (Start / Enabled / something else)?
     
    Last edited: Mar 16, 2015
  43. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614

    ohhhhh ok i see. I there any way to play using 2D while following a transform? I have no 3D sounds in my game specifically because it makes my life easier without all the calibrations that go into 3D sound, like distance etc etc etc
     
  44. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    That doesn't really make any sense...2D sounds don't follow anything.

    Having said that, you should be able to do it anyway with the PlaySound3D commands I named (
    PlaySound3DAtTransform is better on performance than FollowTransform)
    . Just set your Spatial Blend Rule to "Force to 2D" and yes, you can "play 3d" a sound a 2d sound (it will really be 2d - pay no attention to the "3d" in the method name). I know that sounds ridiculous but it will work.
     
    Last edited: Mar 17, 2015
  45. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    Yes... they call Awake, but it seems to be delayed until the next update, maybe this is causing the problem?

    EventSounds is on other scenes. I tried in Start/Enabled and the problems remains. If I keep the EventSound disabled and enable it at a later time, it works!

    - I think the problem is that putting MasterAudio on a Scene Loaded with LoadLevelAdditive, for some reason, makes a delay on MasterAudio activation, and the EventSound is executed BEFORE the MasterAudio is ready for use.
     
  46. luniac

    luniac

    Joined:
    Jan 12, 2011
    Posts:
    614
    lol i guess what i meant was not follow in 2d but know which transform called the variation that started playing.

    yea i force everything to 2D already. Cool thanks for clearing stuff up.
     
    jerotas likes this.
  47. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    If that's the problem, it should be solvable by putting these files all into Script Execution:

    1) MasterAudio.cs
    2) PlaylistController.cs
    3) EventSounds.cs

    in that order.

    Start is the correct event to use. If the EventSounds that's giving you problems is in the scene you're *loading*, it should work like that.
     
  48. Eneco

    Eneco

    Joined:
    May 28, 2013
    Posts:
    16
    Hey, im moving from SoundmanagerPro to Master Audio AAA and got a problem here.
    With SMPro I was able to play multiple sounds from the same group at the same time. But with Master Audio there is always only one sound playing. But I need them to overlap slightly. I changed "active voices" to 32 but this hasn't changed anything. How do I achieve this?
     
  49. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    This is asked a couple times a month.

    The "weight (instances)" field in each Variation defaults to a value of 1 and is the maximum number of voices of that sound that can play. Increase it to your desired max. If you can think of a better label for that field that would make it more obvious, let us know and we'll consider changing it.

    Where is the "active voices" field you're talking about?
     
  50. OnePxl

    OnePxl

    Joined:
    Aug 6, 2012
    Posts:
    307
    Voices?