I tried to fix it, but it looks like Unity has closed off certain parts of the API. I get this error after fixing a few others:
`UnityEditor.AudioImporter.format’ is inaccessible due to its protection level
So what I am going to do is remove the Master Audio Clip Manager so it’s not visible from Unity 5 at all. It will still be available on previous versions. This may sound like a shock to some, but it’s actually no big deal. In fact, my post about why Master Audio is still relevant and needed after Unity 5 mentions up front that our ducking and Clip Manager probably won’t be used by Unity 5 users. Unity 5 already has the ability to bulk change import settings of Audio Clips (the lack of this feature in Unity 4 is why we built the Clip Manager).
I’m about to release the hotfix version. Anyone who doesn’t want to upgrade right now but uses Beta 14+ of Unity 5 can just delete MasterAudioClipManager.cs
Master Audio V 3.5.6.6 will be live in 20 minutes. Changelog:
Added Retrigger Limit controls to Footstep Sounds script. Applies to all tag / layer triggers at once.
Added an optional “fire ‘Items Created’ Custom Event” section in Dynamic Sound Group Creators, so you can be notified that the sounds are created and ready.
Removed Master Audio Clip Manager from Master Audio for Unity 5+. Certain parts of the Audio Importer API has been closed off by Unity so this code won’t work anymore. It’s fine though because Unity 5 has the ability to bulk change Audio Clip import settings (which is exactly what Clip Manager did).
Ok so, after a very frustrating session involving switching between 4 different Unity versions across two different machines/operating-systems (Windows/Mac) and creating several stand-alone scenes I finally figured out how to “fix” this in my particular case, and yet still being unable to reproduce this within a clean project. What’s important to note here is that within my project even clean/new scenes do this, however this was a clean/new setup imported (via .unitypackage) from an export clean project which does NOT have this symptom.
The problem:
The clip in my playlist, although master audio reports it’s playing even giving positional information, has no sound at all.
The “fix”:
It turns out that although music (playlist) this clip was, as I received it from yet-another unity asset store purchase (music pack) set to “3D Sound”. As soon as I disable this and apply (on the clip) everything works as expected. Again, it’s important, I feel, to emphasize that this exact same clip with the exact same settings (3D Sound) works as expected with Master Audio in a clean project with an identical setup on the same Unity version.
My suspicions of what’s going wrong:
I think this is a Unity bug, not Master Audio
I think it involves audio memory usage
… this is complete guess work on my part though
Additional information:
Using Assets/DarkTonic/MasterAudio/ExampleScenes/Audio/Music/bass.wav as a baseline for test sanity (haha - baseline - :]) I was able, within my own project, to reproduce this by using that clip itself and merely altering it’s import settings to “3D Sound” (checked/enabled) at which point it does not, within my project, play across scene loads (even though Master Audio reports it is doing so).
My project is an almost complete game and incredibly large at this point, I’m unfortunately not able to share it or it’s scenes and I’m not getting this symptom outside of this project.
What I’m using: Unity 4.6.0f3 + Master Audio v3.5.6.5.1 with build platform Android
Since I’m able to work around this (by setting “3D Sound” off for music – which it should be anyway) … I’m not going to spend any more time looking into this. I hope this “data dump” is useful however should something like this ever be reported again.
Whew! What a read. Thank you for doing the legwork, I appreciate your frustration. After reading all that, I actually don’t think it’s a Master Audio bug or a Unity bug. I think in your new 2nd loaded Scene, the Audio Listener is simply a lot further away from the location of the Playlist Controller, and therefore can’t be heard based on the 3d settings of max distance on the Audio Source in the Playlist Controller. Setting the audio to 2d though, would solve this problem in every case and is in fact my recommendation for all music (it’s mentioned in the best practices section near the end of the readme). I know it’s an easy thing to miss. I have done it before.
What’s good is that in Unity 5, all sound will default to 2d, and setting of 2d or 3d will be on the Audio Source, not the Audio Clip. So we’ll make a setting on the Playlist controller itself to control that.
Oh … wow, serious face-palm moment. And this kids is why you shouldn’t work till 5am
Sorry for wasting your time. Amazing product you’ve created - really can’t believe I’ve been hand-solving everything Master Audio does, in every game, every time. This is an insane time saver!
It’s not a waste of time if you’ve learned something
Thank you for the compliment. It would awesome if you posted a comment like that as a review on the Asset Store. This plugin has been a long, long time in the making. We are lucky enough to have used a thoughtful enough design at the beginning that could be expanded on without getting too unintuitive. And we’re also lucky to have had a few extremely demanding customers that threw us a lot of great ideas to expand the product.
Do let us know if you can think of anything you’d like added, or would like to see a video of (many videos are coming soon by the way). Sorry about the long amount of time since the last videos were made. I was having technical problems. They are solved!
Hi - can you please clarify how pooling works in Master Audio?
It looks like MA creates a bunch of AudioSources at runtime for each possible instance of a sound (each sound group’s Weight), but this could create many, many sources in the scene (it’s not unreasonable for a game to have 150 sound effects, with 5 or so variants each. That’s 750 AudioSources sitting in the scene, which will be idle most of the time).
Normally when I think of pooling, I’d expect something like the scene to have 10 or so AudioSources that get reused with different clips and positions each time we want to play a sound.
If MA works how it looks like it does, is there any impact of having that many idle AudioSources in the scene at once? (I’ve just done a quick test and it looks like 700 idle AudioSources adds about 10MB to a build’s memory footprint - not too bad). Does this cause any other problems for anyone? Or is this usually OK, and Unity handles large scene hierarchies?
I see what you’re saying. The main reason for wanting / using Pooling is to avoid the performance costs associated with Instantiate and Destroy and the Garbage Collection that occurs from them. Master Audio indeed never Instantiates or Destroys anything except during Scene startup. But yes, you are correct. Things are not reused for different purposes (except as the individual Variations are slightly tweakable at runtime). Someone once asked if we could make all the Variations that weren’t playing disabled Game Objects. But I did a prototype, and it didn’t seem to have any effect on audio memory (more below on this). Anyway, this wouldn’t really be feasible to do with Audio Sources moving around between Variations. It would probably hurt the performance a fair bit because it would become Instantiation of components.
A high number of Audio Sources doesn’t seem to matter much. What matters a lot more is how many of them are playing. If there are more than 32 playing, then the prioritization feature of Unity will take over and cull the rest. The “extra” Audio Sources with the same Audio Clips assigned don’t take up any extra audio memory (or very little if your tests are more extensive perhaps) or performance when they’re not playing. They are paused and do nothing. Also, all the scripts we have on those Variations do not run any code except when audio is playing, so it scales nicely with hundreds of sounds. We have about 150 sounds in our 2nd game, which is almost released.
You will find that with a lot of audio, the most important thing to do is to use Resource files for (probably) all music and a lot of infrequently played SFX. The audio you set up as Resource files in Master Audio will take up zero memory except while they are playing.
I’ll do some more testing about “extra” Audio Sources in Unity 4 and 5 and see what’s more correct.
I did some more profiling. On Unity 3 and 4, it costs about 0.8 Kb of audio memory for each additional “clone” that gets created for weights > 1 of Variations. So adding about 700 clones for polyphony reasons adds only about 0.6Mb. Insignificant really.
However it gets even better. You’ll be extremely excited to hear (as I am) that the extra clones take exactly zero additional audio memory on Unity 5!
Unity 5 integration has begun! We’ve now got a Mixer Group field for each bus! That will route all Groups assigned to the bus through the Unity Mixer Group you assign there. You can change buses or Mixer Group at runtime and it will switch instantly. This means you can do voice limiting (as shown) and sound variations easily on the awesome new Unity mixer! This will be in the next update.
Unity 5 integration is almost done! 4 out of 5 items are finished. We’ve got the above Mixer Group assignment for Playlist Controller and buses, and we’ve also added the ability to quickly set all SFX to 2d / 3d or whatever in between (or per Group) shown below. “Custom” shows you the 0-1 scale.
The same controls exist for the Playlist Controllers. Music defaults to 2D and SFX default to 3D.
The only item remaining for Unity 5 integration is to add snapshot transitions to the EventSounds script. This will all be in the next update!
Master Audio V 3.5.6.7 will be live in 20 minutes. Unity 5 integration is finished! Changelog:
(Unity 5 feature only) Added a field to specify a Unity Mixer Group for each Master Audio Bus. All Variations in all Sound Groups assigned to that Bus will be routed to the Unity Mixer Group when the Scene starts. If you change the bus the Sound Group is assigned to or change the Unity Mixer Group the Bus is assigned to at runtime, it will switch over instantly to the new Unity Mixer Group. It is recommended that you now name your buses identically to the Unity Mixer Groups to avoid confusion.
(Unity 5 feature only) Added a field to specify a Unity Mixer Group for each Playlist Controller. If you change the Mixer Group assignment during runtime, it will instantly switch over to that Group.
(Unity 5 feature only) Added “Music Spatial Blend Rule” dropdown to the Playlist Controller section in the Master Audio prefab. Choices are: Force All To 2D (default), Force All To 3D, For All To Custom, and Allow Different Per Controller. If you choose the last one, there will be a similar dropdown on each Playlist Controller with the first 3 choices. Changing these at runtime instantly switches the Spatial Blend of both Audio Sources on the Controller(s).
(Unity 5 feature only) Added “Group Spatial Blend Rule” dropdown to the mixer section in the Master Audio prefab. Choices are the same as the Playlist Controller dropdown. Works the same. If you choose the last option, you can choose the Spatial Blend for the Group on the Group’s settings.
(Unity 5 feature only) Added ability for EventSounds to do “Transition to Snapshot” in the Unity Audio Mixer.
(Unity 5 feature only) Added ability for EventSounds to do “Transition to Snapshot Blend” in the Unity Audio Mixer.
(Unity 5 only) - Using the pitch field on a Unity Mixer Group to a value less than 100%: It doesn’t change the pitch of the Audio Source(s) feeding it, so as soon as the Audio Clip is done playing (and stops), the slowed down one in the mixer will stop even if it’s in the middle of the clip.
DF-GUI users will need to re-install the latest Master Audio DF-GUI package to get the Unity 5 features in the DF-GUI version of Event Sounds.
Fixed bug: Creating a Dynamic Sound Group assigned to a muted bus didn’t mute the Group.
Bought this plugin and it’s really awesome. I have a question about Timescale and playback. When i change the timescale in game(a slow-motion effect) it seems that playback it’s not affected by Timescale and “Ignore Timescale” is not checked. Do i miss something? I have to handle pitches of all sounds programmatically? Any code samples?
I’m not sure why you would expect pitch to change from time scale slowing down. It doesn’t do that with Master Audio or with normal Unity Audio Sources (which is what Master Audio uses).
Ignore Timescale option is only needed to be turned on for cases like making the Playlist Controller auto-advance when TimeScale is zero and a couple other minor things.
In Unity 5, you could change the pitch of the Unity Audio Mixer as you slow down time, but doing this in Master Audio won’t be good. It may cause your sounds to stop early (before they are finished). Are you on Unity 5 or will you be soon? As of last night, Master Audio has full integration with Unity 5.
edit - I’ve now fixed the problem mentioned above with Master Audio stopping the sound early.
If you would like us to add a method to change pitch of already playing sounds, let us know and we’ll put it on the roadmap.
Yes there is a problem (but I’ve fixed it on the next updated version). Any non-looping sounds you slow down will be cut off early (based on their calculated end time when they started playing). Speeding up is no problem.
Thanks for the support!
The code example i provided is not ok since the Lerp will not animate the pitch and it will just jump between values, below is the corrected function.
For Play i don’t understand yet how to get all those params and in yours DemoScenes/Scripts i don’t see any examples.
I know you can define a custom event and trigger-it when you need, but in some cases it’s more convenient to trigger the sound directly from the code. It would be great to see some examples how to do it in the right way.