[RELEASED] SoundManagerPro: Easy Game Music Plugin

"Your Asset has been published! And quite an impressive asset it is "
-- Unity Asset Store​

SoundManagerPro is a powerful and easy-to-use sound and music system for Unity, both Pro and Free (3.5.4f1 or higher).

This plugin features it's own music managing AI to make sound integration into your project quick and easy. Not only is it easy, but it is done with style to add that extra UMPH. Forget about saving programming music for last, make it quick, easy, impressive and FANCY with SoundManagerPro. All with minimal overhead.

SoundManagerPro works in an interesting way which separates itself from the competition. It uses its own SoundConnection class. SoundConnections tie a list of AudioClips, a method to play them, and various other variables to a scene. Then, the AI will take it from there. Each time you enter a scene, it will just know what to do. Don't worry, SoundManagerPro is flexible and this setup is not required. It just helps you quickly set up a backbone for your project. SoundManagerPro gives you the option to still use it's AI however you want to.

Added new 'audio preloading' feature that helps gapless music playback. WAV files are recommended unless you have software to create gapless MP3s.

Changelog in 2.6.7

Fix for event system ( which in turn also fixed the event system in the PlayMaker integration )

Added SFX Group actions to PlayMaker support

Changelog in 2.6.2:

New feature: SFX Groups! Current SFX Group features include: Pick SFX at random from within group; Set individual SFX caps per group;

Unity 4 warnings removed

Added a 'Check For Updates' feature in the AntiLunchBox menu. It will take you directly to the Asset Store page to update. If a new update is available, it will also automatically debug update alerts to you when you open your project.

Added custom SoundConnection functionality in the inspector. You can now create custom SoundConnections, and play them via level name

Removed limitation on SoundManager.PlayConnection. It now leaves the level setup intact

Added an overload to SoundManager.PlayConnection that takes a level name. Can be used to play regular and custom SoundConnections

A minor UI change to show which SoundConnections you have selected

Added SoundManager.CreateSoundConnection so you can easily make SoundConnections in one line

Updated PlayMaker actions for the new CreateSoundConnection and PlayConnection methods

Updated the DemoScene to show off the new changes

Hotfix for NGUI integration

Changelog in 2.3.6:

Fixed playback issues in the Editor on Mac's

Fixed playback issues with 'Maximize On Play' enabled

Disabled SoundManager prefab if not in scene

Fixed issues with changing volume during crossfading

Fixed issues with setting volumes to 0

New logo

Changelog in 2.3.2:

PLAYMAKER integration included. Custom actions for everything.

New functions including: Stop, Stop Music, StopSFX

UI Facelift, removed extra steps in process to make it easier to make SoundConnections

More variables are exposed in the inspector like: default resources path, and SFX cap amount

Moved everything to one folder so future updates will only need 1 folder to be replaced (Old users just delete your 'Editor/SoundManagerPro' folder before updating)

Couple small bug fixes

Changelog in 2.2:

FULL CODE RELEASE

NGUI integration included

Singleton Perfect package included Free

MonoDevelop Method Comments included! You no longer have to check documentation repeatedily, function descriptions are available as you type in MonoDevelop

Changelog in 2.1.1:

Removed unneccesarry scripts in the Components menu

Fixed issue with Mute Music actually calling Mute All

Revamped code structure (prepped for exposure in the Paid Version)

Application.LoadLevelAsync support (additive will not be supported)

Ability to Pause everything

Ability to get current playing song easily

Ability to get full current scene playlist easily

Ability to go to Next or Previous song in scene playlist

Fixed issue with minimizing unity

Added more to the demo scene, 2 pages of functionality now

Fixed issue with callbacks

In 2.1.1, the structure of the code is different so you'll have to at least reimport a couple things:
DemoTwo.cs (if you're using it)
SoundManager.dll
SoundManager.prefab

FYI, a change like this most likely won't happen again.

Just in case, I would click 'view all' on your current SoundManager prefab and take a screenshot of your SoundConnections and SFX. Worst case scenario, you'll have to recreate the SoundManager prefab and add the component from Component > AntiLunchBox > SoundManager.

Let me know if you have issues updating.

Changelog in 2.0:

New inspector layout

Added a Sound Effects Management and Pooling System

Added ability to cap sound effects so not too many will play at once (to prevent something playing 10 times at once and drowning everything else out)

Added ability to just play a clip without having to make a SoundConnection

Added ability to play a clip immediately and have it loop

Added ability to set music and/or sound effects enabled

Added ability to get a SoundConnection for a certain level

Completely removed excess components

Fixed issue with setting the volume to a higher volume not working instantly

Added callbacks for crossfading

Modified system to be able to handle temp change when the pitch is changed

Fixed issue with crossfade time changing forever if the clip length was less than the crossfade length

Fixed issue with volume not updating when the crossfade duration was 0, causing a new track to sometimes start at maximum volume

Fixed issue where if you played another track manually, but switched while it was crossing in-- it would finish the cross in before successfully crossing out

Clips will now be removed if you select none

Fixed issues with Unity4 deprecatd functions

Fixed issues with people who pause the game with Time.timeScale

Fixed Issue with LevelLoad sometimes being called twice in some people's games

Hey,
The plugin indeed takes that into account. It does not use AudioSource time. Instead, it uses the samples of the clip and divides it by the sampling rate in order to get the exact time in seconds regardless of platform or compression.

Looks good. There are now FOUR packages like this that I know of. Master Audio, Audio Toolkit, Wingrove Audio and yours - one of which was written by my company. You may be smart by categorizing this under Scripting / Audio, whereas the other 3 are under Editor Extensions / Audio. Or that may be a bad move, I'm not sure Anyway it's good to have competition, so welcome!

In the recent release there was a build issue. I have fixed this and the new version (2.1.1) is on the Asset Store.

The structure of the code is different so you'll have to at least reimport a couple things:
DemoTwo.cs (if you're using it)
SoundManager.dll
SoundManager.prefab

FYI, a change like this most likely won't happen again.

Just in case, I would click 'view all' on your current SoundManager prefab and take a screenshot of your SoundConnections and SFX. Worst case scenario, you'll have to recreate the SoundManager prefab and add the component from Component > AntiLunchBox > SoundManager.

Thanks to a fast response to from Unity Asset Store Team (thanks!), the update with the fix is now on the Asset Store. You can download it regularly from there.

Changelog in 2.1.1:

Removed unneccesarry scripts in the Components menu

Fixed issue with Mute Music actually calling Mute All

Revamped code structure (prepped for exposure in the Paid Version)

Application.LoadLevelAsync support (additive will not be supported)

Ability to Pause everything

Ability to get current playing song easily

Ability to get full current scene playlist easily

Ability to go to Next or Previous song in scene playlist

Fixed issue with minimizing unity

Added more to the demo scene, 2 pages of functionality now

Fixed issue with callbacks

In 2.1.1, the structure of the code is different so you'll have to at least reimport a couple things:
DemoTwo.cs (if you're using it)
SoundManager.dll
SoundManager.prefab

FYI, a change like this most likely won't happen again.

Just in case, I would click 'view all' on your current SoundManager prefab and take a screenshot of your SoundConnections and SFX. Worst case scenario, you'll have to recreate the SoundManager prefab and add the component from Component > AntiLunchBox > SoundManager.

In the two week time span, SoundManagerPro got a total of over 150+ downloads! Exciting!

As I said I would, the next release of the Full Version will include a full code release. It's already submitted to the Asset Store. The Free version will be getting a small update, but that's about it. This is where the two packages separate from each other. So now you can fiddle around with the code as you please.

ALONG with full code release, I will be releasing a couple new features:

-NGUI integration included. There is a package in SoundManagerPro that will update your NGUI to support NGUI sounds as SoundManagerPro sound effects. They will respect all SoundManagerPro features (SFX enabled, SFX volume and pitch settings). You can choose whether or not to use it. It does not work for Free Version users of NGUI. NGUI Free code is wrapped in a DLL.
-Free inclusion of a new package, Singleton Perfect, on it's way to the asset store. Turn any script you have into a singleton that will:

*Create itself if it is referenced (by function or variable) and it doesn't exist. Will name itself accordingly to your singleton name.
*Use itself if it's in a scene
*Deal with multiple instances of itself perfectly. (Thats how SoundManager creates itself if you call any of it's functions when it doesn't exist)​

Use this in your project for all your singleton needs, with a snap of a finger, all you have to do is inherit from the Singleton class!

- is this Plugin mobile-friendly (iOS/Android) ?
- has it PlayMaker-Support?

I just want to have some "small" audio-task within in my game, but want to have the option to "mess" around with some functions, so I hope this small tasks are possible with your plugin AND in combination with PlayMaker:

- playing a Background-Song for a Level
- repeating Sounds (for example when an Enemy is attacking the whole time)
- changing Song or Sound on demand

Yes, SoundManagerPro is mobile-friendly. I primarily work in mobile games so that was important for me. I stayed away from libraries that tend to crash on mobile (Linq, etc)

- has it PlayMaker-Support?

Click to expand...

Unfortunately, there isn't PlayMaker support right now. However, it's definitely something I'll look into. As you can see, I update and improve pretty often. The main reason there isn't PlayMaker support is because I personally haven't used PlayMaker. Integrating into NGUI was fairly easy though, I explained it in the README. If PlayMaker is as organized, you can do the same type of change. It is probably easy to find.

I just want to have some "small" audio-task within in my game, but want to have the option to "mess" around with some functions, so I hope this small tasks are possible with your plugin AND in combination with PlayMaker:

Click to expand...

With the full code release, you'll be able to do anything you want. The code is organized into partial class files so you can find what you need. There's also monodevelop descriptions on every function. So you can see what it does by looking at it OR when you start typing it. All to help you use SoundManagerPro better and with flexibility.

- playing a Background-Song for a Level

Click to expand...

Short Answer: Most definitely, absolutely, yes.
This is SoundManagerPro's specialty. It will automatically do this for you per scene. You can turn off this feature and manage it yourself if you want as well.

- repeating Sounds (for example when an Enemy is attacking the whole time)

Click to expand...

Short Answer: Yes!
This is accounted for in the SFX part of SoundManagerPro. I tried to think of every relevant way to want to use a sound effect. You can:
-play one shot sound effects
-play looping sound effects
-cap sound effects to a certain amount so it doesn't sound congested if too many request to be played
-play sound effects attached to game objects
-play sound effects attached to nothing
-force an audiosource to be 2D
-force an audiosource to be 3D
-play sfx at their own pitch / volume independent of global setting
-have extreme flexibility with your audiosource as the method call returns the audiosource it will be playing with
+more

- changing Song or Sound on demand

Click to expand...

Short answer: Yes.
This is available in SoundManagerPro in a couple different ways:
-You can go to the Next or Previous song in your song list
-You can completely change the songlist or replace it
-You can play a specific song
-You can play a specific song and have it run a function when the song ends or when the song starts crossfading out -- THIS, can lead to endless possibilities.

And you can do all these with the crossfade feature or not! It's pretty much up to your imagination. If you want a new feature--just request it!

Hi there. If I understand correctly, you can read external music files at run time, by specifying a filepath to them, and calling your audioClip object load function? Can you then get access to the music data in the audioclip to process for music visualization such as FFT analysis? I want to visualize the music ahead of time to be able to create gameplay around that.

Hi there. If I understand correctly, you can read external music files at run time, by specifying a filepath to them, and calling your audioClip object load function? Can you then get access to the music data in the audioclip to process for music visualization such as FFT analysis? I want to visualize the music ahead of time to be able to create gameplay around that.

Click to expand...

Unfortunately, that's not what it is. BUT I have extensively looked into that (for reasons other than this plugin) so maybe I can help.

What you can look into is check out Visualizer Studio, it seems to have pretty good FFT analysis. Now Unity isn't really great at letting you do analysis on a song that's not playing-- at least I haven't been able to find anything on the matter. The one analysis it can do isn't the one you're looking for. So what you can do is load the file in Unity(using either Resources.Load or import System.IO and use the File class to open an audio file on the device).

You can then try to turn off the sound while playing to song for your FFT analysis. You can either try muting, putting the volume to 0, changing the listener volume, or plainly just removing the AudioListener from the scene while this happens. One of them should work.

So the downside is that could take a while... So I would suggest trying to change the pitch while its playing. Because Unity has only one sampling rate, changing the pitch also changes the tempo. It'll go through the song faster and you can set it to a point where you don't lose that much data.

You can track the download progress / base your analysis on the current length of the song. And additionally, you also want to make sure you aren't using clip.length or audio.time. Do the time calculation with clip.samples, audio.timeSamples, and audio.frequency. It will be accurate to the device you are using.

I haven't tried it out so I don't know what affect it'll have on the data but I hope that helps.

Hi there AnttiLunchBox, Thanks for the reply. Yes I did look at Visualizer Studio, would be great to make use of it. I was trying to somehow get the song data and feed it into Visualizer Studio, before I play it, was hoping your plugin could help. I do appreciate your idea about playing silently and changing the pitch. Thanks for your help.

If I run the game in Unity and have the SoundManager object selected the playlist plays fine.

If I run the game also within the editor, but with Scene maximised and nothing selected the first track plays, but none of the others do.

Am running version 2.2 on OSX with the latest version of Unity. Some advice on what I need to do to resolve this would be much appreciated.

Cheers,
Adam.

Click to expand...

Hey Adam,

I was able to pinpoint the bug. It appears to be an issue with 'Maximize On Play' enabled. I did a quick google search and it seems that other custom editors have issues with Maximize On Play as well. I'm only seeing the bug happen in Unity 4 right now. I have a couple options as quick fixes for you.

The first option is to just turn 'Maximize On Play' off for now. It's a Unity Editor bug.

The second option (not thoroughly tested and not a good fix, but will get the job done) is to go to SoundManager.cs, and in the "CommonHandleApplicationFocus" function, add this to the beginning:

The problem has to do with Unity "losing focus" when it goes into 'Maximize On Play'. This matters to SoundManagerPro because unfortunately, Unity doesn't play audio right away when you come back from "losing focus" (this mainly happens when you minimize). So when the SoundManager resumed from "losing focus", Unity didn't have any audio sources playing yet. It would think that the current song was finished and move on the next one. I didn't want that to happen so I had to put in a check that would listen for when the application went out of focus.
Now, this relates to your problem because when you have 'Maximize On Play' enabled, the UnityEditor is always "out of focus." Boo. So, SoundManager isn't doing any checks until the focus comes back. So fortunately, this is only an Editor issue. The code fix I pasted above should fix it, but I'm going to look into a more appropriate fix for the next update. I may have to consult Unity support. Let me know if it works for you.

For Mac Users there's been some iffy behavior in the editor where it doesn't continue a playlist in certain conditions. I'm posting the fix in the next update. I'll try and have the fix go through approval faster (will be posting fix in free version as well).

If you want to fix it yourself for now (and have the full version), just go to SoundManager.cs and remove the OnApplicationFocus function. It should work after that. Sorry for the inconvenience.

Hey there, so I bought it just now and imported it. Just want to mention, that there are some Obsolete-Function-Warnings like:

Assets/SoundManagerPro/Scripts/Managers/SoundManager_SFX_Internal.cs(53,40): warning CS0618: `UnityEngine.GameObject.SetActiveRecursively(bool)' is obsolete: `gameObject.SetActiveRecursively() is obsolete. Use GameObject.SetActive(), which is now inherited by children.'

Hey there, so I bought it just now and imported it. Just want to mention, that there are some Obsolete-Function-Warnings like:

Click to expand...

Ah yes, they shouldn't be a problem for now though. Unity plans to replace it in the future. One of my earlier updates got overwritten (where I fixed this). I'll re-add it in the next update. If you're interested in removing the warnings you can replace a line like this:

Anyway. After some playing around with the full version, it's interface and the PlayMaker-Actions I can't stress enough how I love this Plugin
I talked with our Audio-Guys about the features and the ease of using.
I already posted in the PlayMaker-Forums about your PlayMaker-Support and the very well documented PlayMaker-Actions (hoping that a lot of PM-Users will use this plugin, as far as I know there is none Audio-Plugin which has full PM-Support but only some custom-made actions like "Play Track" and "Stop Track"...)

So, I'm looking forward for new updates and appreciate your great support. Going to write a 5 Star Review in the Asset Store later

PS: Is there a way to NOT crossfade a Clip? Meaning: my Level has only 1 track which I want to loop, but when it's set to loop (ContinousPlayThrough), it's crossfading (I don't need to explain you what that means I guess ), so it sounds a little bit odd the moment it's ending and starting again since the last seconds and the first seconds overlap. There a way to start the track right after the last second?

Anyway. After some playing around with the full version, it's interface and the PlayMaker-Actions I can't stress enough how I love this Plugin
I talked with our Audio-Guys about the features and the ease of using.
I already posted in the PlayMaker-Forums about your PlayMaker-Support and the very well documented PlayMaker-Actions (hoping that a lot of PM-Users will use this plugin, as far as I know there is none Audio-Plugin which has full PM-Support but only some custom-made actions like "Play Track" and "Stop Track"...)

So, I'm looking forward for new updates and appreciate your great support. Going to write a 5 Star Review in the Asset Store later

Click to expand...

Thanks! I really appreciate it!

PS: Is there a way to NOT crossfade a Clip? Meaning: my Level has only 1 track which I want to loop, but when it's set to loop (ContinousPlayThrough), it's crossfading (I don't need to explain you what that means I guess ), so it sounds a little bit odd the moment it's ending and starting again since the last seconds and the first seconds overlap. There a way to start the track right after the last second?

Click to expand...

Yes there is. There are a couple different ways to do this. You can either set the cross duration to 0 in the inspector or set the cross duration to 0 in code (SoundManager.Instance.crossDuration = 0). I unfortunately don't have a PlayMaker action for it, but I can add it.

So, I made a quick PlayMaker-FSM where I just hit a Button in order to play a Soundeffect. Working great, and I know it's intended for every hit on the Button that a new instance of the Sound is made, but they only deactivate themself after finishing. If I hit the Button nonstop it's creating instances over and over again. Is there a way to pool them within your plugin or should I do that myself?

So, I made a quick PlayMaker-FSM where I just hit a Button in order to play a Soundeffect. Working great, and I know it's intended for every hit on the Button that a new instance of the Sound is made, but they only deactivate themself after finishing. If I hit the Button nonstop it's creating instances over and over again. Is there a way to pool them within your plugin or should I do that myself?

Click to expand...

Hey Mayhem,

I think I understand what your asking, but let me know if I'm wrong.

The sounds are currently being pooled and they do re-enter the pool once they are done playing. So if you have a long sound effect and hit the button a bunch of times, it will add new SFX objects to accommodate none being free yet. As soon as that first SFX object gets free (and you're still pressing the button), then it'll start reusing sfx objects.

Thats why the PlayCappedSFX function is in there (it also uses pooled sfx objects). You can set it to cap a certain sfx(or group of sfx) to an string ID, say "button sound". If the cap is set at 3, no more than 3 sfx pooled objects will play sfx with the "button sound" string ID -- no matter how many times you click that button.

Now is the function you were looking for 'PlayCappedSFX'? Or were you looking for an overload that would cap the sfx, but restart them each time?

But one generel question regarding Music/Sounds and Performance: should one pay attention NOT to overload the running scene with too much soundeffects? I can't foresee the future scenes, but I guess we'll have one Background-Song and around 10-30 SFX-Instances playing simultaneously.

"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.