Search Unity

[RELEASED] 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. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    389
    Hi Brian

    I wanted to check on the best way of using MA to play 2D sounds?

    Essentially I have a racing game and use MA to play 3D sounds, but there are also sounds that I want to play that are simple stereo sounds in 2D (e.g. in a menu overlay)

    If I play these using PlaySoundAndForget() they are located at the position of the MA prefab in the scene which is at (0,0,0) by default, so instead my current solution is to have the MA prefab as a child of the camera.

    Is there a better way to handle this? ... because when I use this approach if I have Doppler in Audio Settings set to anything other than 0, I sometimes get inconsistencies and strange sounds.

    I tried playing the sounds at the position of the camera, but I am not sure if this is the best way to achieve what I want.

    Hope this makes sense, and any help gladly appreciated.


    cheers

    Nalin
     
  2. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    Hi, the normal way is to go to the actual Audio Clips you want to play in 2d and make the change there. There's a "3d" checkbox or something like that. Turn it off and hit apply. Or you can use the Master Audio Clip Manager to do it in bulk.

    You can then use any of the PlaySound methods to play it and it will be 2d. You don't need to play it at any certain position or mess with the doppler settings.
     
  3. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    389
    Thanks Brian

    I did look for a 3d checkbox but I could not find one - maybe my eyes are deceiving me?

    N

    MA.png
     
  4. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    You aren't in the right place. It has nothing to do with Master Audio, it's part of Unity. Click on the Audio Clip itself from that Inspector and it's on the Audio Clip's Import properties dialog.
     
  5. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    389
    D'oh - missed that!

    Thank you so much!

    cheers

    Nalin
     
  6. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    No problem Nalin!
     
  7. BortStudios

    BortStudios

    Joined:
    May 1, 2012
    Posts:
    48
    I was wondering, is there a way to access all currently acting variations in MasterAudio? What I need are the positions of all audio that is playing in the game. Currently, I made my own static class what has a managed list of all PlaySoundResults that were generated, and can access them like that, but I was wondering if MasterAudio had its own internal way of keeping track of the acting variations' positions?
     
  8. schmosef

    schmosef

    Joined:
    Mar 6, 2012
    Posts:
    816
    I just tested the latest release and can confirm that the Unity 4.6 compile issue I reported has been fixed.

    Thanks for the quick support.
     
  9. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    No, there isn't a way to do that right now. What are you using it for?
     
  10. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    No problem!
     
  11. BortStudios

    BortStudios

    Joined:
    May 1, 2012
    Posts:
    48
    I need to attenuate the volume level for sources based on their angular position around the character, regardless of their actual distance away, so that those in the back are not picked up at all and it is a smooth curve with those directly in front being at normal loudness. The only way I could think to do it was to just go through all of the currently acting variations and modify their volume
     
  12. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    Ok, what would like to assist you in doing this? How about:

    MasterAudio.GetAllPlayingVariations()

    with an option of single sound group? I can add it fairly easily if so. If you'd like different options let me know.
     
  13. BortStudios

    BortStudios

    Joined:
    May 1, 2012
    Posts:
    48
    It would be good for my purposes if the GetAllPlayingVariations() function only accessed a list that was being kept by MasterAudio behind the scenes (as opposed to the function actually searching for and retrieving the variations when it's called). Since I'm messing with the volume levels of the playing ones each frame, if it had to dig through the masteraudio structure in the scene and find them all it'd probably be slower than what I am doing

    But then again I'm certainly not the creator of this thing, and I don't know what would be more efficient than other things since I'm certainly no expert programmer, so if were a way to grab them all (I'm imagining something like an accessible List in MasterAudio which keeps only the currently playing ones in the list behind the scenes?) that would be awesome.

    Thanks!
     
  14. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    There's an internal list already kept per Sound Group of active Variations (for voice limiting purposes). So I'd just need to loop through the Groups and return the combined list. The Groups are also kept in an in-memory variable. If you want to send me your code I could suggest optimizations, then add this to the plugin officially.
     
  15. BortStudios

    BortStudios

    Joined:
    May 1, 2012
    Posts:
    48
    Well, so currently all I did was create a public static class which has a List of PlaySoundResults, and a public function to add a PlaySoundResult onto the end, so whenever I have anything play a sound they do the function to generate a PlaySoundResult and send that to the static function via its public method. And when it is added, I have each one add a function to run when the variation completes, and all the function does is go through all the soundresults in the list and remove the ones which are not playing (which should only be one). Like this:


    Code (CSharp):
    1. public void AddSoundResult(PlaySoundResult result)
    2.     {
    3.         if (result != null)
    4.         {
    5.             sounds.Add(result);
    6.  
    7.             result.ActingVariation.SoundFinished += RemoveVariation;
    8.         }
    9.         else
    10.             Debug.Log("That result isn't loaded!");
    11.     }
    12.  
    13.     void RemoveVariation()
    14.     {
    15.         // Removes everything in the list which isn't playing
    16.         sounds.RemoveAll(x => !x.ActingVariation.IsPlaying);
    17.     }
    The biggest failures I see with this is what it is difficult to maintain because it isn't all encapsulated in one place (I have to rely on myself to activate the AddSoundResult function every time I write for anything to play a sound or else it won't work) and that each time a variation ends it has to run through the whole list of playsoundresults. I was trying to think of some way so that when the variation ended it would call RemoveVariation with also the information as to what its position is inside of the list, so that the list could target it and remove it via its index, but couldn't really wrap my head around event handlers and all that
     
  16. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    Yeah that's problematic. I'll add this to the feature backlog.
     
  17. hexdump

    hexdump

    Joined:
    Dec 29, 2008
    Posts:
    439
    Hi,

    I have seen Master Audio just got Unity 5 ready state. Would you mind commenting what does this mean? I mean, does this mean it uses the new built-in audio features in Unity 5? Or, does it mean that it just compiles on Unity 5 as it did in unity 4 with no extra features?

    Thanks in advance.
     
  18. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    It compiles and has no extra features "integrated" yet. However, you can use all the new Unity 5 audio stuff in conjunction with Master Audio by making changes at the Audio Source level. They do not step on each other at all. For instance, you could:

    1) Set both Audio Sources of a Playlist Controller to a certain Unity mixer channel. That would enable you to put filter FX onto the music (only with Unity pro). Currently this is impossible in Unity 4 because there's a Unity bug with multiple Audio Sources on the same Game Object.
    2) Do similar things with Sound Groups.
    3) Set up any ducking you like with the new Unity ducking - I wouldn't use Master Audio ducking once you're on Unity 5. It's much more limiting than what they have in there.

    Our official product backlog thread is here: http://darktonic.freeforums.net/thread/87/feature-roadmap-master-audio-suggest with a somewhat vague feature for Unity 5 new integration. You may want to request something more specific? If so, post on that thread there.
     
  19. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    331
    Hello again!

    I am now working on the Numbers scene for my app and decided to make some updates including Master Audio's and I am getting this error:
    One or more Variations of Sound Group 'Spawn' do not have the SoundGroupVariationUpdater component and will not function properly. Please stop and fix this by opening the Master Audio Manager window and clicking the Upgrade MA Prefab button before continuing.
    UnityEngine.Debug:LogError(Object)
    MasterAudioGroup:Start() (at Assets/DarkTonic/MasterAudio/Scripts/Settings/MasterAudioGroup.cs:127)


    I am not sure how to fix this as this appears to be a new feature, is there a way to solve this without messing up my Shapes scene?

    Thanks
     
  20. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    It sounds like you were on a version earlier than 3.5.5. I believe you need to go into each Scene that has a Master Audio game object in it, then open the Master Audio Manager window and click the button in the lower right. Says something like "Upgrade to MA 3.5.5" - pretty much what the log message says :)

    That should fix it.
     
  21. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    I'm having a problem with my music tracks. I'd like them to load or stream or whatever as needed and not all load into memory up front.

    I have 23 music tracks, and initially I left the default value of "Clip" for the Clip Create Mode of each playlist and the Audio Origin of each file. The problem was that it then took 50 seconds total to launch the game from the editor. Especially when you're testing stuff, that really adds up, of course.

    So then I changed every Clip Create Mode and Audio Origin value to "Resource File" and re-dragged all 23 tracks back in to get the resource filenames. The game then launched in 14 seconds (which includes about 10 seconds of activity before the game really launches), but now I'm getting no music. All of the music files are in folders that have a parent folder of "Resources" so I would have thought that would work.

    Any ideas on what I'm doing wrong? The music files themselves are set to "Stream from disc" if that makes a difference.
     
  22. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    Resource files can't stream. Unity doesn't allow it. They are loaded in memory fully when they need to be played. So you can go ahead and turn off "stream from disk" for all those.

    If you aren't having any music playing, there will be some helpful messages in the console window saying something like:

    Resource file 'King2' could not be located from Playlist 'Bass'.

    If you are seeing a message like that, your Resource Filename is incorrect (and we will need to examine your folder structure and Resource Filename if so). If you aren't seeing any message at all, try selecting one of your songs from the Jukebox "Active Clip" dropdown and you will.

    Let me know what it says.
     
  23. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Yep, you're right. I had warnings turned off so I didn't notice them, but yeah, I do get that message for each music file that my game tried to play. (I wish I could say that missing warnings like that was the first time I made that mistake...)

    I figured it out. Seems to be a basic Unity thing I didn't understand. Apparently you can't have subfolders under "Resources" - the files have to be directly under a Resources folder. I created new Resources folders under each category and moved some of my music files into those, and they started working. So my bad.

    Is there a way to use "Stream from Disc" on files with Master Audio though? Seems like that would be ideal for OGG and MP3 files.
     
  24. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    No, that's incorrect. You can indeed have subfolders under Resources. Master Audio will populate the correct Resource Filename (including folder path) when you drag it in. For example, if you drag in a file from Resources/Music/level1.wav, then Resource Filename will say Music/Level1, which is correct. The only time it will not populate the subfolder name is when it's a special language folder name, for the localization feature. If that part is not working for you, let me know how you got it to break. I just tried it and it works for me.

    To keep it simple, I would move ALL resource files (music / sfx) into a single Resource folder in Unity - with subfolders - so you don't have to look all over for them your project.

    Streaming works just fine with Master Audio. The only thing is you can't use it with Resource files, because Unity doesn't allow it. I don't really know about ogg files (are those compressed?) - we don't use them.
     
    Last edited: Nov 3, 2014
  25. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    There have been complaints that you have to add X Event Sounds scripts to an object if you want to play X different footstep sounds depending on the tag / layer collided with. So we've made a new FootstepsSounds script that lets you do as many as you want in one script. Here's a preview below. It will be in the next version. Obviously this could be used for other conditional collision / trigger sounds as well (not just footsteps).

    Capture.PNG
     
  26. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    I'm taking requests for new tutorial videos for Master Audio. Anyone want to see something specific? Besides footsteps because I don't have the assets or set up for that :)
     
  27. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    OK, I guess the problem was that when I drug the music files into the clips of the playlists (where it says "Drag Resource Audio clip here to use its name!"), I only got the resource name and not the full path. Since I don't feel like dragging all of those back and already changed the folders around, I'm OK with it as is.

    I'm a bit confused on your streaming comment though. I *had* originally set all music files as "Stream from disc" and took the defaults in Master Audio as well (those were "Clip" as opposed to "Resource File"). But that caused 600 MB of audio to be loaded into memory and that 50 second load time that I mentioned. Assuming that streaming is better than loading up the full tracks into memory on the fly, how would I get that to work? (my original question I guess)

    I'm running v3.4 if that makes any difference. Only 1 out of 23 of the tracks I'm using is in OGG, so I'm not sure that is significant. But yeah, OGG is basically just an open source equivalent of MP3.

    Thanks!
     
  28. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    As I said, when I tried it today, dragging Resource subfolder files into the drag area does populate the folder. If you don't see that happen, please give me a screen shot of your folder structure, because I cannot reproduce that bug you're seeing. I suggest you update to the latest version so you'll have bugs like this fixed (there were many).

    Streaming does have considerable overhead. And, unfortunately all the playlist's clips will be loaded into memory even if they are marked as streaming it seems, except for the one that is playing. Or you're seeing incorrect streaming memory usage on the profiler (it does have bugs like that). Regardless, that's too slow of a startup time. So I think Resource files is your only option. However, I'm pretty sure Resource files is always the best option for music in 99% of all cases. That's all I use any more.

    You might want to split that into multiple playlists. 23 seems like a whole lot of songs. But then, when you use Resource files, it doesn't really matter much.
     
  29. Ross_S

    Ross_S

    Joined:
    Jul 10, 2012
    Posts:
    29
    Hi...
    I'm adding 300 sound files (individual groups) and I'd like them all in a particular BUS .... do i actually have to assign each one individually...? can't see how this is batched... thanks
     
  30. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    You either have to create one, clone the group 299 times (which copies the bus setting) and then drag the clips in, or assign it 300 times. I'd say the 2nd (your idea) is faster.

    Why would you have so many sounds on one bus? Do you have other buses too? I hope a bunch of the sounds are Resource files or you may be looking at memory problems.

    I'll try and think of a way to batch assign buses.
     
  31. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    No worries, I changed the folder structure all around already and things are working. I will update to a newer version eventually, but I tend to be kind of careful about updating assets. No need to spend time on something that may already have been fixed and that isn't causing problems now anyway.

    Ah, if that's the proper way to do music, I'm perfectly fine with it. :) Everything's working now and the startup time is fast again.

    Yeah, I actually have nine playlists. But it still appeared to be loading *everything* at startup. Some tracks are short ones for player death, menu music, end credits, title, etc. I also have different playlists for what's happening in the game (super-chill ambient, what I call "heightened ambient", and full-on combat). I probably have too many ambient tracks, so I may end up thinning those out over time.

    Thanks for the reply! I have a better understanding of this stuff now.
     
  32. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    Ok cool. Yes all those Playlist clips in all Playlists (that aren't Resource files) will be loaded when the Scene starts. So definitely best to use Resources files for all. I think only if you have 1-3 songs (that aren't very long) would it be possible for streaming and non-Resource files to be the better option. Resources files are the way to go.
     
  33. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    Huge news!!! The next release will have the ability to save any changes made during runtime to the mixer, Master Audio prefab, Groups and Playlist Controller!
     
  34. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    Another nice timer-saver is now done for the next release. Bulk mixer editing! Check a few (or all) rows in the mixer, then bulk mute / solo / change volume / assign buses. Great time saver! Works at runtime too.
    Capture.PNG
     
  35. DrFantome

    DrFantome

    Joined:
    Oct 15, 2012
    Posts:
    5
    Hi guys, I'm setting up dynamic music in my game using clips.
    Is it possible in master audio and synkro to get access when a clip end so I can launch another clip??? I can see in master audio a variable that show the position in variable of each clip but I don't see where I access this variable, thank you!
     
  36. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    There's a SongEnded event in PlaylistController that you can subscribe to that fires when the song is totally done. Look in the Readme for how to add the couple lines of code.

    You also can fire a Custom Event per song (settable in the Playlist) and set up an Event Sounds component to listen to that Custom Event and play the next song if you like. But that doesn't allow any decision making if you need that.
     
  37. Alic

    Alic

    Joined:
    Aug 6, 2013
    Posts:
    110
    Hey, this is probably very simple and I should just dig around in the code a bit -- I read through the documentation and couldn't find anything about this, though I may just be confused by the terminology. I'm wondering if there's an easy way to change the volume of one instance of a looping sound -- so, let's say I have a sound coming from a glowing crystal which starts playing when the player is nearby and then loops until the player moves far enough away, and the crystal also has an animation that makes it gradually get brighter and dimmer. I want to also "animate" the sound's volume, and maybe pitch as well, so the brighter the crystal glows, the louder the sound plays. I don't see an obvious way in the docs to change the volume of just that one looping sound instance, rather than that sound's whole group (which would apply to all crystals calling that sound, wouldn't it?)

    I'm looking for a solution in code or out -- either one is fine.

    Anyway, I feel bad asking a question before poking around in the code, but I thought it might be helpful to point out that the documentation (to me at least) was confusing in this respect.

    I'm really enjoying Master Audio, and looking forward to making some dynamic music!
     
  38. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    You are correct that normally you only have things available to change the volume of the whole Group and that's not what you want to do. The one instance is called a Variation.

    By "documentation" you mean the readme right? It's not meant to cover everything you can do via code (it's already too long as it is), and this is definitely something you'd need to do from code. I don't think it's confusing but the fact is - it's not in that document at all. For code reference, go to the API website here: https://dl.dropboxusercontent.com/u/40293802/DarkTonic/MasterAudio_API/Index.html
    You'll need to play the sound and adjust it's volume with the AdjustVolume command, like this:
    Code (csharp):
    1.  
    2. var result = MasterAudio.PlaySound3DFollowTransform("Scream", this.transform);
    3. if (!result.SoundPlayed && !result.SoundScheduled) {
    4.        return; // sound wasn't played because voice limits exceeded or another limit you set. ActingVariation will be null.
    5. }
    6. result.ActingVariation.AdjustVolume(.5f);
    7.  
    8. // pitch would be:
    9. result.ActingVariation.audio.pitch = 1.5f;
    10.  
    To do things like this without code would require building RTPM (real-time parameter modification) like Fabric has and it's on the short list of things we'll probably never add which is on the roadmap 2nd post here: http://darktonic.freeforums.net/thread/87/feature-roadmap-master-audio-suggest. You'll need to code stuff like this. Mainly we want to keep Master Audio functionality in a small-ish area in the Inspector and don't want to build complex screens like that which take up most of a monitor.
     
  39. Alic

    Alic

    Joined:
    Aug 6, 2013
    Posts:
    110
    Thanks, I don't mind having to code more involved stuff at all -- that's preferred, even. I was looking through the documentation just to get a general sense of what I should code versus what I should use built in stuff for, and I think this part in the docs threw me off:

    After reading that I assumed that ActingVariation wasn't a good way to modify volume, what I missed was that there's a method on ActingVariation to adjust volume, and it's setting volume on the ActingVariation's audio reference directly that the doc is warning against.

    Thanks for your insanely fast response :)
     
    Last edited: Nov 7, 2014
  40. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    Awesome, document now has that missing detail! Thank you very much for taking the time to point me to the faulty paragraph!
     
  41. Alic

    Alic

    Joined:
    Aug 6, 2013
    Posts:
    110
    Ha, I still feel a bit guilty I didn't look at the code before posting. Thank you for your awesome work!
     
  42. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    No problem, at least I got to fix the readme :)
     
  43. ilesonen

    ilesonen

    Joined:
    Sep 11, 2012
    Posts:
    47
    Hello jerotas,
    Would it be possible to change clip origin type from resource mode to clip mode at runtime?

    For example if I'd have 50 clips in resource folder and game player could choose for example 5 clips of them and create a playlist which would use clip mode as clip origin. The reason for this is because clip mode has better sync and of course it's not wise to load 50 long clips in the memory.

    Thanks!
     
  44. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    No it's not, you could really do it with script but it wouldn't clean up the resource map that gets created in "Awake" so it would lead to errors.

    I think you might misunderstand how Resource files work, not just in Master Audio but in Unity. They are a way to *save* memory, not use more. If you turn on Gapless Transitions then only 2 of them will be loaded into memory at any time. If you use cross fading (no Gapless) then only 1 will be loaded into memory except during the brief cross fade. So for memory purposes it's far preferable to use Resource files over clips. That's all we use for music any more. There shouldn't be any sync problems.
     
  45. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,228
    Hi. Sorry if this was asked already, but I couldn't find an answer. I'm trying to add an audio filter (AudioReverbFilter) to a Playlist. Adding it to the PlaylistController (of which I have only one, with 2 audioSources for 2 different tracks) manually produces no effect and the filter is completely ignored. It works instead if I add it manually at runtime (which I would like to avoid). In short, any indications on the correct way to add audio filters to playlists (not to sound fx, for which I see that you can use variations, but playlists don't have them). Thanks.

    That said, awesome plugin: it's giving me great joy to use it ;)
     
  46. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    There's no support for it. It doesn't work, there's some kind of bug in Unity where an Audio Filter will only work on one (or the other) Audio Source in the same Game Object. That's weird that it works if you add it at runtime.

    The good news is that this will be possible on Unity 5 since each Audio Source can be routed to a Unity mixer channel, and those channels can have Filter FX on them.
     
  47. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,228
    Awwwww, I use audio filters on music a lot :( Since it works at runtime, I suppose it might "catch" the audio that is currently playing: I will setup a system to do that then and see if I can manage. Thanks.
     
  48. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    Unity 5 beta 10 (or higher?) is out. It's pretty stable, you could consider use it.

    Or if you don't need the Playlist functionality (crossfade) in particular you could play music with a Sound Group, which can have filters. The Chained Loop group mimics auto-advance and/or shuffle mode. Just no crossfade.
     
  49. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,228
    Thanks for the additional help (no Unity 5 for me since I can't buy the Pro at the moment) :) I'm using another kinda hacky solution for now: I store the filter I want on a separate GameObject, then attach a copy of it to the PlaylistController at runtime. As long as the crossfading has elapsed, and thus only one AudioSource is active, it seems to work and catch the currently playing AudioSource.
     
  50. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,052
    Ok, no crossfading FX isn't ideal, but that's cool.