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
    Are you on the latest version? This worked last time I checked, even when changing playlists. I assume you have set a non-zero Crossfade time right?
     
  2. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I reproduced this bug and I believe I found the problem. You can fix it in PlaylistController.cs, line 859-970, by making it like this:

    activeAudio = audioClip;
    transitioningAudio = transClip;

    if (SongChanged != null) {
    var clipName = String.Empty;
    if (audioClip != null) {
    clipName = audioClip.clip.name;
    }
    SongChanged(clipName);
    }

    I had the SongChanged event being fired before the 2 Audio variables were assigned. It should be the other way around, as shown above. This will be in the next version :)
     
  3. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    Thanks for your reply. Adding 0.1f delay before switching playlist solved the issue. I think the problem was that I have a prefab with MasterAudio and AudioListener in each scene(Although I call Destroy() at Awake) so when I switched playlist there were 2 of them, maybe....
     
  4. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I'm not sure what workaround you did exactly, but you shouldn't have to.
     
  5. Kensai

    Kensai

    Joined:
    Oct 24, 2013
    Posts:
    27
    Thanks, apparently that did the trick. I am now in the process of manipulating both songs volumes so that one transitions into the other (by fading one out, and the other one in) depending on the player's progress, but apparently, when I try to access PlaylistController.PlaylistVolume property, the volume is not really changed. I mean, I see the change in the editor, but the heard volume stays the same. Do you know what could be happening here?

    EDIT: Ok, I saw that if I call UpdateMasterVolume() after changing the volume, the volume change can effectively be heard, but this conflicts with crossfading. Any suggestion?
     
    Last edited: Jun 19, 2014
  6. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Are you sure you're not using the lower-case one (playlistVolume) . That's a public variable that has no effect on the volume. You need to use the property instead, which is the same but upper-case. I would love to make the lower-case one invisible to users, but it has to be public for the custom Inspectors to work.
     
  7. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392

    Cool, I will wait for the localization implementation! That'll be awesome!

    I am using 2D Toolkit for my scenes.... What would be the one line of code you mentioned? I could begin the non-voice over portion of my project until the language part is done.

    Thanks again!
     
  8. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Sure, you'll need to find out which events happens in 2D Toollkit when you tap on things and do a line of code like:
    MasterAudio.PlaySound3D("Blast", 1f, 1f);

    If you use MonoDevelop, the other parameters will show up.
     
  9. Kensai

    Kensai

    Joined:
    Oct 24, 2013
    Posts:
    27
    Yes, I'm using the one with uppercase. Positive. Check the EDIT on my previous post:
     
  10. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Ok, I figured you may have used auto-completed and used the wrong one, they are very similar looking. The reason it's not working is because the cross-fading will continually override the volume as it cross-fades. The other fades will mess with it as well (fade to volume etc). The only thing I can recommend is don't try to set it during any type of fade. It won't be guaranteed to work (probably will not). Clearly, volume manipulation over time would overwrite your manual volume setting.

    Oh.....Actually you can set MasterAudio.PlaylistMasterVolume if you only have a single Playlist controller (not layered music) and that should work, even during fades.
     
  11. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392

    I suppose I could also use that line anywhere in my code, right?

    Would "Blast" be an audio file of type .mp3?
     
  12. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Yeah, you can use anywhere. "Blast" is just the name of the Sound Group (row on the mixer) you want to play. It doesn't necessarily correspond with the name of any file. However it does automatically name the group after the first sound file you create the group with (but you can rename the group afterward if you like).
     
  13. eridani

    eridani

    Joined:
    Aug 30, 2012
    Posts:
    655
    Hello Jerotas, I finally got around to implementing Master Audio into one of my projects and I have a question...forgive me in advance if it's a dumb question.

    I'm using Playmaker on several enemy characters. Whenever each enemy shoots its gun, I use a Master Audio Playmaker Action ("Master Audio Play Sound") to start playing the sound in a loop, and attach the sound to that particular enemy game object. Every enemy plays the same shooting sound.

    Now, how do I get each individual enemy soldier to stop its own shooting sound individually when it is done shooting?

    I was looking for a "Master Audio Stop Sound" action to stop the sound on that particular enemy gameobject, but I don't see such an action... all I see is "Master Audio Stop All of Sound" which I think will stop the shooting sound for all the enemies in my scene, which I don't want. I only want to stop the sound for each individual enemy separately, because they will start shooting and stop shooting at separate times.

    Thanks, and I will clarify further what I want if this post didn't make sense.
     
  14. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    You are correct about Stop All of Sound. You want "Stop All Sounds of Transform", I believe is the name. I think I made a Playmaker Action of that, let me know if you don't see one (and delete and re-open the MA_Playmaker package to make sure you have the latest. That will do it, although it will also stop any other sounds made by that same enemy.
     
  15. eridani

    eridani

    Joined:
    Aug 30, 2012
    Posts:
    655
    I do not see this action which you described. I am using Version: 3.5.4.2 (Jun 16, 2014), which I downloaded yesterday. I reloaded the MA_Playmaker package again right now just in case but still don't see it. Thanks.
     
  16. Simod

    Simod

    Joined:
    Jan 29, 2014
    Posts:
    176
    Hello Jerotas,

    Two full days of the Master Audio experience here.

    One thing what is annoying us is the implementation of the "Sound Spawn Mode: Attach To Caller". It will not suit the fast moving objects like rockets, or fast cars for example.
    The code responsible for this is located at the SoundGroupVariation.cs. It's quite easy to modify, but we would like you make the changes, as long as you know your project very well.

    In fact we would prefer parenting or "Audio Source" component attached to "Event Sounds" caller instead of modifying "transform.position". In case if you want to stick with Coroutines I would suggest to try "WaitForEndOfFrame". Never used this before though.

    Thank you for your work.
     
  17. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Here's the action you need, just created it. It will be in the next update.
     

    Attached Files:

  18. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Many months ago, that is actually what it did (move its Variation including the Audio Source over to be a child on the Game Object). Unfortunately that led to occasional unsolvable bugs when changing Scenes and the parent object was destroyed without you manually "cleaning up" the Variations. The Variations were also destroyed and not able to be saved because of how Unity 4 doesn't allow you to change parent when an object is destroyed. And we *definitely* don't want to Instantiate to create replacements, for numerous reasons. So now it simply follows the Transforms and we have no bugs.

    I was not wanting to use once per frame just because that could cost too much performance when you have many objects using it. That's why we're using a slightly less often CoRoutine. However, I'll see if I can make this configurable (update every X frames maybe?)
     
  19. eridani

    eridani

    Joined:
    Aug 30, 2012
    Posts:
    655
    Thanks Jerotas. That is some fast technical support!

    I do have another issue now though. When I try to play multiple sounds on an enemy object very quickly, for example each time an enemy gets hit with automatic gunfire, it restarts a "pain grunt" type sound. I set some variations of the "pain grunt" sound and put it under a bus control with maximum voices of 1. So even through there are many variations of the "pain grunt," only one can play at a time.

    The problem is, every time the enemy gets hit, which could be multiple times per second, the audio sometimes squeaks and chirps and squeals very briefly each time the "pain grunt" sound is played.

    Can you please advise the settings to get rid of these squeaks and chirps? Thank you
     
  20. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Sounds weird. Sorry but I have no idea about that one. We haven't had such problems, and we use the "dialogue" 1-voice limit thing all the time. If you figure out what's happening or how to fix it, do let us know.

    The code should just be stopping the sound and playing it again. If you have random pitch, that is done at about the same time as well, but is not audible.
     
  21. eridani

    eridani

    Joined:
    Aug 30, 2012
    Posts:
    655
    Also, some other sounds occasionally and intermittently play at a very fast speed and high pitch. I have not set any random pitches on any sounds, so don't know why this would happen.

    Overall I'm getting some "chipmunk" sounding effects from Master Audio...has anyone ever reported anything like this? I am getting the unwanted effects both on my PC in the editor and on my phone with an Android build.

    FYI, I am using the DynamicSoundGroupCreator because I wanted to keep a persistent Master Audio main prefab to keep music playing between scene loads.

    Please advise if you can suggest anything, otherwise I will keep poking around. Thanks
     
  22. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Nope, nobody else has reported this. We have nothing to go by unfortunately.
     
  23. eridani

    eridani

    Joined:
    Aug 30, 2012
    Posts:
    655
    I will keep poking around at this. It's weird because it only happens intermittently...

    Another question in the meantime:

    Do you have a mechanism for allowing "silence" as a variation? For example, I want it so when an enemy gets hit, I have a "pain grunt 1" sound with a weight of 3, a "pain grunt 2" sound with a weight of 2, and "silence" with a weight of 5 (so in effect, half the time there will be no sound at all).

    I wonder if this is possible without putting in a dummy silent sound file. Thank you
     
  24. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Yeah I think currently it doesn't work to leave one Variation empty (no clip), let me know if it does. One thing you could do though is just make another variation (with any clip) that has zero volume set in the Inspector. That should do what you want, without creating an other sound files.
     
    Last edited: Jun 23, 2014
  25. jerotas

    jerotas

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

    • Fixed the Playlist Controller's Song Changed event. It was being assigned a bit too early which led to the wrong song returned on ActiveAudioSource if you called that immediately.
    • Update V 3.5.4.2 broke the refresh on the Master Audio Inspector when "Fast Refresh" option turned off. Now fixed again.
    • Added Playmaker custom action MasterAudioStopTransformSound, for stopping all or one Sound Group worth of sounds triggered by a particular transform.
    No I haven't gotten to the localization stuff yet. Hopefully in the next week or 2. I have deadlines to meet to get a free Windows phone and need to make sure and hit that. It will be coming though, hang in there!
     
  26. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    In my project, I have MasterAudio under an empty gameobject which I use as a folder to contain all the important stuff like GUI manager, game manager, etc.. Maybe that's causing problem but MasterAudio's group inspector doesn't always work in the editor in my project. 90% of the time, when I click a sound group, it just shows the script name(Master Audio Group(Script)) and no other editable stuff. Somtimes, it works but I don't know why. Is there any work around this?
     
  27. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Well, it's not supported to work with the Master Audio prefab as non-top level, because that wouldn't allow persisting to work, among other problems. Try pulling it out and see if you still have the same problem or not.
     
  28. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    Well ,yeah.. it works great on top level. But I have an obsession with sorting and ordering. If it's a must to put it on root level, that's fine. Just wanted to ask if there's another way. Thanks for your reply.
     
  29. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I have that obsession too :)

    You must realize that any game object that's allowed to persist and not be destroyed when going to a new scene must be on its own in the Hierarchy and not under another game object. Otherwise, you tell Unity not to destroy it, but its parent cannot be assumed to be not destroyed as well, and both get destroyed anyway. For this reason (and a couple others I forget at the moment), we enforce having it at the top-level. Nothing worse than a user deciding "ok, now it's working fine as a child prefab and I want it to persist. Why isn't that working?". I'd rather not deal with that sort of question over and over or even have to write a note about it in the already fairly long documentation. So let's keep it simple and go top-level. If enough people complain about it (you're the 2nd out of ~3,000 customers) I will consider looking into supporting non-top level, but for now I'll leave it alone.

    -Brian
     
  30. TommiH

    TommiH

    Joined:
    Jan 14, 2008
    Posts:
    253
    Hello.

    On the previous page, gegagome said that the "loop clip" checkbox was becoming unchecked at play. I think I'm having the same issue, but I don't understand the solution you suggested, jerotas. You said one would have to check the checkbox on each variation, but that's exactly what's getting unchecked. These screenshots show where the checkbox is and how it turns off as soon as I press Play:

    Edit: had wrong images before. Here are the correct ones:

    Edit mode:

    Edit Mode.png

    Play mode:

    Play Mode.png
     
    Last edited: Jun 24, 2014
  31. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    You have the same image there twice. I don't see anything unchecked in Play mode.
     
  32. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    Sorry if I sounded like complaining :p It's totally cool by me now I know it's the way it is.
     
  33. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Haha, I worded that poorly. I mean if more people want it to support top-level, not if more people "complain".
     
  34. Simod

    Simod

    Joined:
    Jan 29, 2014
    Posts:
    176
    Hello Jerotas,

    Took quite a time to investigate in this direction. It seems Unity 3D still gives an option to track objects destruction. In your case it would work like this:
    1. Once variation wants to follow a calling Object DO:
    • Put variation as the child of the calling Object
    • Add MonoBehavior component to the calling Object with OnDestroy event.
    2. Once calling Object is about destroyed or Unity wants to change a scene, OnDestroy will put variation back to the original parent.

    A very good example can be find at: http://answers.unity3d.com/questions/347975/child-detach-and-save-itself-when-parent-is-destro.html

    Please let me know your thoughts.
     
  35. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I read that thread as well when I investigated the issue. Unfortunately, it didn't work for me in Unity 4 (seems they added new protective code in Unity 4) . Yes, you can track the object destruction, but you can't "save" a child of the destroyed GameObject (the Variation). Unity gives you a warning something like "can't change the parent of an object that's been marked as destroyed" and it dies anyway.

    However, I'm not sure I tried the part about putting a MonoBehavior on the parent object (I may have though). In my mind, that wouldn't necessarily work, in the case that a new scene is being loaded and the Master Audio is being destroyed simultaneously. That may result in an uncatchable error or at least lots of warnings? I can look into this later on, but in the mean time, I will change the CoRoutine to WaitUntilEndOfFrame in the next version.

    I'm also not sure that the mixer functionality will work properly if we reparent Variations...
     
  36. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I've finished adding localization support for Resource file SFX! Just need a few days to put in a new example to illustrate and update the documentation. You set default language and supported languages, the rest is automatic! To use it, you'll create folders under Resources called "English", "German", etc, from this list of values, for each supported language: http://docs.unity3d.com/ScriptReference/SystemLanguage.html

    Then you mark each Variation as "use Localized folders" or not. Also dragging in a clip from a Resource file that starts with a special named language folder such as "German" will automatically check "use Localization" for you! You need to make sure and name the files identically under each language's folder for this to work properly. Sorry if that's not totally convenient.
     
  37. TommiH

    TommiH

    Joined:
    Jan 14, 2008
    Posts:
    253
    Hello, Jerotas.

    I checked and my images are different. They are the same except for the problematic part: both "Loop" on the Audio Source component and "Loop Clip" on the Sound Group Variation component are unchecked in the Play Mode image.

    Here are the images again, in case the forums somehow messed the uploads up:

    Edit mode:

    Edit Mode.png

    Play mode:

    Play Mode.png
     
  38. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Anyway I don't know how you managed that. I can't reproduce having loop become unchecked when you press play :(. If you'd like to send me a tiny project that reproduces the behavior I'll see if it happens on my computer.
     
  39. TommiH

    TommiH

    Joined:
    Jan 14, 2008
    Posts:
    253
    Hello again, Jerotas.

    The problem seems to be the "pre-warming" that gets launched from MasterAudio.Awake, line 543, in combination with SoundGroupVariation.Awake, line 220, which "restores" the loop setting on the audio source to SoundGroupVariation.audioLoops. However, this happens to run before the SoundGroupVariation.Awake, line 120, which sets the value of SoundGroupVariation.audioLoops in the first place. It's fixed if I put MasterAudio after SoundGroupVariation in the Script Execution Order, but that's kind of an ugly hack.

    Do you think the pre-warming could be moved into Start instead of Awake, or would that cause some other problem?
     
  40. TommiH

    TommiH

    Joined:
    Jan 14, 2008
    Posts:
    253
    I have another question: It seems that by default if I play the same variation over and over again (with retrigger percentage set to 0%), the first playback gets interrupted by the second and so on. This is fine for a lot of sounds, but we have some objects in the scene that should all make a sound (vehicles driving around to be exact), letting the camera's proximity to them determine which one (or several) is heard.

    Is there any way to do this within your system without creating an extra variation for every vehicle? It would seem this would require duplicating the audio source for that variation, but your system doesn't seem to do that.
     
  41. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Hm, well that combination of code doesn't turn off any of my loop checkboxes. Were you able to get that bug to happen with the included "DemoScene"? I was not.

    Putting prewarm code into Start could mean that you can't play one of your sounds in Start, because the prewarm code is already using it to "fake play" it for the side effect of prewarming.
     
    Last edited: Jun 28, 2014
  42. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    What you are describing is done through the Priority field in each AudioSource. Unity handles muting all but the 32 lowest priority Audio Sources at all times. You must have clones of the Variation for it to work properly (using the weight property). Each Variation will have an AudioSource with a priority. You can use the "Apply Distance Priority" checkbox in the Master Audio prefab Advanced section to set the priorities automatically for 3d sounds.

    Any reason you're averse to creating extra Audio Sources? To my understanding, only AudioSources that are playing take any performance. So if you have 10 but are only using 3, it should be the same as having 3.
     
  43. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    The documentation for Master Audio V 3.5.4.4, which includes new Resource file localization features, can be found here on Dropbox: https://dl.dropboxusercontent.com/u/40293802/DarkTonic/MA_ReadMe.pdf

    Section 18 is about localization and takes up 2 pages. You can read that to know all there is to know about how localization will work in Master Audio.

    As soon as I make an example localization Scene, I will submit this version. It's entirely done coding-wise.

    By the way, does anyone know if there are any audio plugins that support localization besides ours? Even including those sold outside the Asset Store. If this is an exclusive feature I'd like to advertise it as such.
     
  44. Tazman

    Tazman

    Joined:
    Sep 27, 2011
    Posts:
    94
    Fabric supports localization.... http://www.tazman-audio.co.uk/?page_id=485
     
  45. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
  46. dorukai

    dorukai

    Joined:
    Apr 16, 2014
    Posts:
    6
    I'm trying to get sound playing properly in my game (a 2d spaceship combat game).

    Players can potentially have the same ship, with the same thruster sounds (and all thruster sounds have the Loop flag set if that is relevant), but damned if I can get both to play at once.

    Ideally I'd like to start both ships thruster sounds on spawn with low volume, and just modify the volume of the audio that's already playing, however when I try to do that I get this error:
    NullReferenceException: Object reference not set to an instance of an object
    PlayerShipController.Update () (at Assets/Scripts/Arena Scripts/PlayerShipController.cs:85)

    Code looks something like this:
    (in the ship's engine):
    public MasterAudioGroup thrustAudio;
    (in Start):
    audioResult = MasterAudio.PlaySound3DFollowTransform(engine.thrustAudio.name, this.transform);
    (in update):
    audioResult.ActingVariation.AdjustVolume(1.0f);
    And once the player releases thrust I have the same thing, with AdjustVolume(0.1f)

    That works if I only have one of that ship in a scene. If I have two, the error above pops up.

    If I try having the audio start every time the player presses thrust, again, that works ok if only one ship has that thrust sound, if two try to thrust at the same time only the first one plays.

    Is it possible to have one sound playing twice in a scene, and if so how?

    I'm also going to need a bunch of identical weapon sounds playing at once, for rapid fire weapons.
     
  47. dorukai

    dorukai

    Joined:
    Apr 16, 2014
    Posts:
    6
    Actually figured this out (5 mins after posting, boo). I needed up increase the weight in the variation to allow multiples to play.

    Sweet!
     
  48. dorukai

    dorukai

    Joined:
    Apr 16, 2014
    Posts:
    6
    FWIW I was getting squeaks and chirps, and setting "Doppler Level" to 0 in the sound fixed it for me.
     
  49. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    That's correct. The 2nd ship would be "stealing" your single Variation away from the other ship. You also should make sure ActingVariation is not null before using it, every time. Once the Variation is "stolen" it may be null and give you a Null Exception Error like you saw if you don't check.
     
    Last edited: Jun 29, 2014
  50. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Awesome, glad to know that. If anyone else asked I'll give them the same advice.