Search Unity

[RELEASED] SoundManagerPro: Easy Game Music Plugin

Discussion in 'Assets and Asset Store' started by AntiLunchBox, Jun 12, 2013.

  1. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    At that point, it's up to you.

    Unity does a good job at handling audioclips if they're in the scene (playing 30 instances of 1 clip isn't 30 individual audioclips in memory). I'm pretty sure that playing the SFX simultaneously won't be an issue, but loading them into memory can.

    Memory problems shouldn't be an issue if you keep most of them on SoundManager so you don't have to use Resources.Load (which can cause some hook ups in gameplay). This way, all your sfx will just load when the first level loads.

    I would play it by ear. And as always, using wav's instead of mp3s is better. If it appears to be a problem, there are a couple things you can do:

    --If simultaneous play is slowing the game down, group your SFX with the string IDs so too many won't play at once.
    --If it's slow all around you can create a manager to handle which SFX are loaded per level. There is a function in there called SaveSFX that adds audioclips to the stored list of SFX in SoundManager. If you know which SFX will play in a certain level, you can clear the stored SFX (SoundManager.Instance.storedSFXs.Clear()) and use SaveSFX() to add new clips (so you aren't carrying around SFX you don't need).
     
  2. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Great, thanks for the advice!
     
  3. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hey guys,

    An update on the situation--the most recent update is pending review. There's a couple important fixes and an update to the look. Will keep you updated when that comes out. It'll be changed everywhere. The plugin's in a good spot right now. The next update will most likely be a new feature set i have planned, which includes custom SoundConnections (not only tied to levels!).
     
  4. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Ah great! What I personally would also love would be this:

    - create your SoundConnection in the Inspector
    - instead of ContinousPlay and the other options one could select also something like "Stand By"
    - play the whole created SoundConnection or single tracks via PlayMaker (switches from StandBy to...for example ContinuesPlay)

    I know one can create the SoundConnection with PlayMaker, but I love the Inspector-Interface. Though I like the idea controlling my setup Tracks and Soundeffects via PlayMaker
     
  5. ostone88

    ostone88

    Joined:
    Jul 25, 2013
    Posts:
    5
    alb,

    I got this a while ago, love it, just one question.

    I'm trying to use your load function to get a file in my project. I'm using SoundManager.Load("myclip name", "custom path stuff")

    What is the format of the custom path? "resources/blah/blahblah/clipname"?
     
  6. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hey Mayhem,

    You can create your SoundConnection in the inspector, in the AddSoundConnections section. If you mean for the custom SoundConnections I'm planning, yes they will be create-able in the inspector. However, you probably will still need to call SoundManager.CustomEvent("MyEvent") for it to fire. I will make a PlayMaker action for this. I'm also playing with adding event components that you can add to any object that will fire SoundManager functions. I'll see what's most user friendly.

    If you don't put a SoundConnection (or put an empty one) for a level, it will consider it as stand by. But with this new custom SoundConnection system, I will have to put a stand by method anyway. So coming soon!

    You can use SoundManager.PlayConnection or SoundManager.Play for both of these. The PlayMaker actions should exist for those.

    You don't have to only use PlayMaker actions to make SoundConnections! You can use the inspector! The playmaker actions are purely complimentary. If you want to use the inspector, you can! I figured the PlayMaker actions for SoundConnections were if you wanted to create SoundConnections on the fly at runtime. You can use both PlayMaker and inspector interchangeably. It's up to you.
     
  7. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hey ostone,

    The custom path originates from a resources folder and only needs to point to the enclosing folder. So lets say I want to play these files, located here:
    I would need to use these to access them:
    Code (csharp):
    1.  
    2. SoundManager.Load("crazysound", "MySounds/SFX");
    3. SoundManager.Load("walksound");
    4. SoundManager.Load("staggersound","CrippleState");
    5.  
    You can put a "/" at the end or beginning, doesn't matter. The Load function will automatically correct it for you.

    You could also just add the SFX to the stored sfx in the inspector. Then all you'd have to do is call:
    Code (csharp):
    1. SoundManager.Load("clipname");
    You don't HAVE to use the custom path.
     
  8. ostone88

    ostone88

    Joined:
    Jul 25, 2013
    Posts:
    5
    thanks for the detailed explanation! got it to work thanks! I just needed to load a sound at one specific instance so i wanted to use the custom path rather than the stored sound effects. Thanks!
     
  9. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422

    I know I can create the SoundConnection in the Inspector. I think you didn't understand what I tried to explain :D
    Okay:

    I wanted to combine the Inspector-made SoundConnection with the PlayMaker-Actions. When I create a SoundConnection with all the Songs and Soundeffects in the Inspector, then I also have to choose a PlayMode (for example ContinousPlay) and once I hit the "Play"-Button of Unity the first songs starts playing. That's not what I want. I want them to stand by till I tell them with PlayMaker-Actions to play.
    And here I want to control the whole SoundConnection I made within the Inspector with PlayMaker. So I'll have an action where I can select a Song or SFX out of the SoundConnection I made earlier in the Inspector and Play it (or Stop, Pause, etc.).

    So simply put: I want to create the SoundConnection in the Inspector and control the Audio (Songs and SFX which are dragged in the SoundConnection in the Inspector) with PlayMaker.
     
  10. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Ah I see, yeah that's how I'm going to implement the custom SoundConnections in the next update! You'll be able to create them and call them whenever you want (the SoundManager.CustomEvent I talked about earlier). I'll let you know when that's done.

    ALB (i like the abbreviation :])
     
  11. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Ah, I see! Well, I'm looking forward to! :D
     
  12. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hey guys, new update just went up!

    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
     
  13. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hey guys,

    2.3 is in a stable state so I'm going to continue with new features. Heres what's planned for v2.4...

    Upcoming Features in Future Updates:
    • 2D Toolkit integration
    • Custom Event SoundConnections
    • Setup for Javascript option
    • AudioSource pre-editing manager (configure and save AudioSource settings to apply to any sound)
    • Ability to play a new music track within a currently playing SoundConnection (without stopping it)
    • Event triggers
    • More info coming soon!
     
    Last edited: Jul 27, 2013
  14. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hey all, in case you're wondering how to use SoundManagerPro with javascript-- do this:

    Move 'Assets/SoundManagerPro/Scripts' and 'Assets/SoundManagerPro/EditorHelper' folders to this folder:
    'Assets/Plugins'.

    It should work for you then. Thanks to androos for asking! I'll be including a "Set Up For Javascript" option in the next update to automatically do it for you.

    Have a great weekend,
    ALB
     
  15. ostone88

    ostone88

    Joined:
    Jul 25, 2013
    Posts:
    5
    Hey ALB, just wanted to say your plugin works great. Finally something that works. Looking forward to future updates and features. Recommended.
     
  16. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Thanks,
    Appreciate it! Still working on the new features but I'll let you know as soon as they are almost ready.

    ALB
     
  17. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Could you please tell some details on the 2DToolkit-Integration? Especially looking forward to that! :)
     
  18. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Sure, it's pretty simple really. Any Tk 2d UISound Item or anything that runs through Tk 2d AudioManager will go through SoundManagerPro instead.

    I'm looking to simplify the integration with a Menu Item rather than a Unity Package this time. If successful, I'll do it for the NGUI integration as well.

    ALB
     
  19. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Oh, the benefit of that is that any sounds used by 2d toolkit or ngui will respect your soundmanager audio settings, etc.
     
  20. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Just submitted version 2.4 with:
    2d toolkit integration
    Setup for JavaScript
    and more menu items that will integrate the addons and take you to documentation/forums easily.

    Will let you guys know when it's up! Still working on custom soundconnections in the editor since it has a bigger affect on the plugin all around. But, it will be coming soon.
     
    Last edited: Jul 30, 2013
  21. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hey all!

    I want to keep you guys updated, I didn't forget!

    I'm still working on custom SoundConnections in the editor (so if you want to do custom SoundConnections you don't HAVE to do them in code). It's taking a bit longer since I want to still keep an easy flow for you guys! I want to make sure that SMP will still be easy to use and intuitive. And, I also have to make sure it's not breaking any other systems in there =].

    During my implementation, I noticed a couple foolish design choices that really acted as limitations for SMP (mainly the PlayConnection function). I'm removing those limitations! Which also unfortunately is going to push this update back. But in the end, you'll thank me =]. I just want to make SMP as good as it can be

    Happy gamemaking,
    ALB
     
  22. Hesham

    Hesham

    Joined:
    May 29, 2008
    Posts:
    147
    Hi,

    I'm using Unity 4.2 and latest NGUI and SMP and I get this error when trying to import the NGUI package:

    Assets/NGUI/Scripts/Internal/NGUITools.cs(105,40): error CS0103: The name `source' does not exist in the current context
     
  23. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hey Hesham,

    You probably have a different version of NGUI (I tried to use the most recent version released). In the README that came in the package, it explains how to integrate it if you are getting errors. It's pretty easy.

    ALB
     
  24. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Update:

    The upcoming update will be finished today. I'm going to submit it tonight so it will overwrite my last submission (that included 2D Toolkit integration, etc). That means that the updates will be combined and the 2d Toolkit integration will come later than expected.

    This update has quite a bit in it though, so it's worth it. Right now, all I have left is to update the PlayMaker actions with the new API and it should be good to go!

    Will let you know when it's submitted and when it's live!

    Happy game making,
    ALB
     
  25. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hey guys, the update got submitted yesterday and is getting vetted through the system fast. It should be out very soon.

    -ALB
     
  26. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hey all,

    The 2.5 update is live on the asset store.

    Changelog in 2.5:
    • 2d Toolkit Integration added
    • Added "Setup for JS" option in 'Window/AntiLunchBox' menu
    • Added addtional functions in 'Window/AntiLunchBox' menu, including all integration methods (NGUI, PlayMaker, TDTK), links to documentation and forums, etc
    • 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

    -ALB
     
  27. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Hey ALB (I like that, too! :D )

    I updated the plugin and extracted the PlayMaker and NGUI Extensions, and I got this error with the nGUI Extension:

    Code (csharp):
    1. Assets/NGUI/Scripts/Internal/NGUITools.cs(105,40): error CS0103: The name `source' does not exist in the current context
    2.  
    Edit:

    Shall I just comment out the "return source"?
    Since it looks like it belongs to the commented part:

    Code (csharp):
    1. /*    REPLACED!!!!
    2.                 AudioSource source = mListener.audio;
    3.                 if (source == null) source = mListener.gameObject.AddComponent<AudioSource>();
    4.                 source.pitch = pitch;
    5.                 source.PlayOneShot(clip, volume);
    6.                 */
     
    Last edited: Aug 7, 2013
  28. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hey Mayhem,

    [Edit]
    Wow I must be really tired... It should actually be:
    Code (csharp):
    1.  
    2. return SoundManager.PlaySFX(mListener.gameObject, clip, volume, pitch);
    3.  
    -ALB
     
    Last edited: Aug 7, 2013
  29. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    The NGUI integration fix has been submitted to the asset store. Should be up in the couple days. For anybody else interested, use this in the ReadMe instead:

    Code (csharp):
    1. return SoundManager.PlaySFX(mListener.gameObject, clip, volume, pitch);
     
  30. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hey @mayhem and @hesham,

    The update actually got a quick approval and is already up on the asset store. You can grab it if you like.

    -ALB
     
  31. Muckel

    Muckel

    Joined:
    Mar 26, 2009
    Posts:
    471
    hey, thx for the quick updates!
    I really like your Plugin.... my fav SoundManager ;-)
    Well i prefer EZGui for my Gui Stuff... will you support it also in the future ?

    :pKerstin
     
  32. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Hey ALB,

    after the Update I get two other errors :D

    And

     
  33. Playlectric

    Playlectric

    Joined:
    May 22, 2013
    Posts:
    27
    How does SMP handle incoming phonecalls on iOS and Android?

    Will playback of both SFX and background music resume when the user returns to the game?
     
  34. Muckel

    Muckel

    Joined:
    Mar 26, 2009
    Posts:
    471
    Request:

    need a notification @ the end of a SFX...
    can you implement it ?

    well and in your Demo this works only after the second activation of the Button...
    bug ?
    SoundManager.Play(sample3, false, ChangeButtonColor);

    If you push the Btn the first time no call back after finish... if you push again call back works...

    Another Request:
    Random Playlist for Songs SFX
    Like i have 3 different variations of my SFX Sound and i want them play in random order...

    thank you!
     
    Last edited: Aug 7, 2013
  35. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Is there a way to add, localization, or multiple languages to each sound?

    For instance, my app is for young children and it is multilingual, does this plugin allow this functionality?


    Thanks
    German
     
  36. OhiraKyou

    OhiraKyou

    Joined:
    Mar 27, 2012
    Posts:
    259
    Does this handle 3D (positional) audio? Multiple listeners for split screen (local) multiplayer?
     
  37. Superflat

    Superflat

    Joined:
    Mar 19, 2009
    Posts:
    354
    Hello!

    I noticed SoundManager because of the sale haha. And I was wondering now if SoundManager Pro actually does anything to optimize usage for mobile devices? Like load background music from disc, store sfx in memory. etc etc.

    Thanks!
     
  38. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hey guys!

    Wow you guys are up early! I just woke up, so I'll start answering your questions! Early bird gets the worm I guess haha

    ALB
     
  39. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470

    Hey Muckel,

    It's not in the queue right now but I can take a look into it!

    ALB
     
  40. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hey Mayhem,

    I feel like an idiot right now haha. Didn't follow my own documentation :3. In that function there is an extra parameter in there for looping so it should be:

    return SoundManager.PlaySFX(mListener.gameObject, clip, false, volume, pitch);

    I was fixing it without NGUI in the project so it didn't bring up errors for that. Anyway, that will work!

    -ALB
     
  41. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hey Playlectric,

    Not quite sure what you mean by incoming phonecalls. It doesn't do anything with handling any microphone input. And Unity gets paused when phonecalls come in so it shouldn't be a problem. SoundManagerPro takes into account when Unity gets paused so it should handle a call interrupting the game fine.

    As for playback of SFX and background music, yes they will resume when the user returns to the game. I am aware of the weird behavior when pausing and it takes that into account, even when you are in the editor. Unity tends to not resume the audio right away when it comes back, which would make any other audio plugin think that the audio isn't playing. However, SoundManagerPro waits for the callback from Unity saying that it is in focus again.
     
  42. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hey Muckel,
    Yes this can be implemented, but it's also easy to do on your end. PlaySFX returns the AudioSource that the audioclip will be played on. So you can do something like this:

    Code (csharp):
    1. AudioSource checkThisSource = SoundManager.PlaySFX(SoundManager.Load("Snd1"));
    2. while(checkThisSource.isPlaying);
    3. endofSnd();
    This is actually by design. It runs the function at the end of the clip you requested, not the clip playing before it. That's why it fires the next time you click the button. It would fire anytime the clip you played (the first time you press it) ended. However, if you want to add an event to any playing background song, you can use the instance variables--there's more information on them in the documentation (at the bottom):
    So you can do
    Code (csharp):
    1. SoundManager.Instance.OnSongEnd += endofSnd;
    This will only fire once, so if you want it to keep firing, you have to keep hooking that up on song end.

    The random playlist is already included for songs! When you make a SoundConnection (whether is regular or custom) there are 3 different Random playmethods you can choose:
    These will play in a random order (the same song never repeated twice, and each time it goes through the full list of songs, it will re-randomize the playlist)

    As for random SFX lists, that is definitely a good idea and something I'll look into! For now though, you can do something like this:
    -Name the SFX the same with a different number in the back (Punch1, Punch2, Punch3)
    -When you go to play the SFX use this:
    Code (csharp):
    1. SoundManager.PlaySFX("Punch"+Random.Range(1,4).ToString());
    Hope this helped!

    ALB
     
  43. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Hey ALB,

    thanks for the support, got it working ;)

    Another question:

    Does your Plugin work on Blackberry, Windows Store and Windows Phone?
     
  44. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hey gegagome,

    SoundManagerPro can't localize sounds for you (as in re-create your sound in another language). I don't think any audio plugin can do that.

    However, if you have the sounds in different languages already made--you can definitely do that. There is no built-in functionality for it, but it's not hard to implement with the flexibility of SMPRO. So if you have background music with alternate languages, you can make custom soundconnections for each language using level names like this:
    And then, when you want to fire the Level1 playlist, you just use:
    Code (csharp):
    1. SoundManager.PlayConnection("Level1-"+Application.systemLanguage.ToString());
    and Voila! It will play the right playlist.

    You can do a similar thing with SFX, with:
    Code (csharp):
    1. SoundManager.PlaySFX("Punch-"+Application.systemLanguage.ToString());
    In the case that you want to save memory, you can load these manually on app start. So if you know your language you can use these two functions to add specific SoundConnections and SFX to soundmanager (without adding the other languages):
    You can use SoundManager.Load to get those audio clips from resources as well.

    It's really easy to use.

    -ALB
     
  45. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hey OhiraKyou,

    SoundManager does handle 3D positional audio. The PlaySFX has an overload that allows you to specify the location of the sound to be played. You can also use the custom SoundConnections to play different songs at different points in a big world. The plugin also provides a script called SoundManagerTools. You can force an audio source to play 3d or 2d (in case you forget to set you audioclip settings to 2D or 3D):

    Code (csharp):
    1. SoundManagerTools.make2D(ref yourAudioSource);
    2. SoundManagerTools.make3D(ref yourAudioSource);
    As for multiple listeners, that is something I haven't tried to be honest. Two different background musics won't work (though I would imagine nobody would ever use that), but SFX should work fine.

    -ALB
     
  46. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hey Superflat,

    The very beginning stages of SoundManagerPro was actually intended for mobile! I'm primarily a mobile developer myself. Unity already does an excellent job handling audioclips (playing 30 of the same audioclip isn't 30 instances in memory). If you use the SoundManager prefab for you SFX, they will be optimized and used in memory. It will not load the audioclips from resources and clog up your game. All the loading will be done while your game is loading it's first scene. There are some other things you can do (like use WAV files instead of MP3s) to further your optimization. You can also control how and when audioclips are loaded with a variety of functions provided with SoundManagerPro.

    SoundManager.SaveSFX and SoundManager.CreateSoundConnection will allow you to use the prefab on the fly at runtime (in case you want to load some clips only at certain parts of the game). If you want to go deep into that, SoundManagerPro is definitely flexible enough if you need it to be.

    -ALB
     
  47. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hey Mayhem,

    That's something I haven't personally tried. If you have any problems let me know
    -ALB
     
  48. badbod99

    badbod99

    Joined:
    May 3, 2011
    Posts:
    36
    Hi,

    Can you tell me how it handles 3D positioned sound if the object is moving? I see you have a position param for play sound, but that won't give the same result as an audio source attached to a moving car for example.

    Thanks

    - Simon
     
  49. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hey badBod,

    The function PlaySFX returns the audioSource that the sound is playing on so you can use that to get the gameObject and attach it to another game object.

    So,

    Transform child = SoundManager.PlaySFX("thisSound",...,theParent.transform.location).transform;
    child.parent = theParent.transform;
     
  50. badbod99

    badbod99

    Joined:
    May 3, 2011
    Posts:
    36
    So that's not going to mess-up the pooling? When the sound has finished playing will it auto unparent? When another object wants to play a sound will it not consider this object as a candidate to play it (even though it's now a child of another object)?