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
    Hey thi,

    Thanks for that catch. The fix should be up for download now. Update!

    ALB
     
  2. thi-donada

    thi-donada

    Joined:
    Apr 23, 2014
    Posts:
    17
    It's Ok now, thanks.
     
  3. mujee

    mujee

    Joined:
    Mar 9, 2012
    Posts:
    54
    hi
    I want to play sfx on loop but it give me an error

    SoundManager.PlaySFX(SoundManager.Load("TiredBreath"),1.0f,true);

    Error:
    error CS1502: The best overloaded method match for `SoundManager.PlaySFX(UnityEngine.GameObject, UnityEngine.AudioClip, bool)' has some invalid arguments

    error CS1503: Argument `#1' cannot convert `UnityEngine.AudioClip' expression to type `UnityEngine.GameObject'

    please give me some suggestion
    tanx
     
  4. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    Please add a simplier way to play Delayed SFX! =)

    Instead of

    SoundManager.PlaySFX(SoundManager.Load("sfx-slip"),SoundManager.Instance.volumeSFX,SoundManager.Instance.pitchSFX,default(Vector3),false,1f);

    I would like :

    SoundManager.PlaySFX(SoundManager.Load("sfx-slip"),1.0f);


    Another suggestion :

    Why don't use only the SFX name instead of pass SoundManager.Load("sfxname") always?
     
  5. AntiLunchBox

    AntiLunchBox

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

    Thats the wrong overload. You can do SoundManager.PlaySFX(SoundManager.Load("TiredBreat h"),1.0f, 1.0f, Vector3.zero, true);
    or use any of the over loop overloads that play on a gameobject.

    Sorry this is like that because loop and delay were added late to that particular function, so I didn't want people to have errors on update. I may rearrange the parameters anyway for consistency.

    ALB
     
  6. AntiLunchBox

    AntiLunchBox

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

    As I said above, sorry this is like that because loop and delay were added late to that particular function, so I didn't want people to have errors on update. I may rearrange the parameters anyway.

    As for your suggestion, sure I'll include that no problem. Sounds reasonable.

    ALB
     
  7. AntiLunchBox

    AntiLunchBox

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

    Just update and you'll find the changes you asked for. As for the delay, i still included the looping parameter before it. So you can just do:
    SoundManager.PlaySFX("sfx-slip", false, 1f);

    for a 1 second delay.

    ALB
     
  8. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Changelog in v3.4.3:
    * ALERT * SOME PARAMETERS FOR SFX FUNCTIONS HAVE CHANGED SLIGHTLY!
    • Rearranged parameters for some PlaySFX functions for consistency (loop and delay on one overload changed)
    • Added string overloads to PlaySFX functions so there is no need to use SoundManager.Load manually

    I will also be updating the documentation shortly!

    ALB
     
  9. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    Thanks! Best Support evet! =)
     
  10. RowdyMrB

    RowdyMrB

    Joined:
    Dec 8, 2012
    Posts:
    83
    Looks like the new update broke the Playmaker Actions. Now receiving the following errors:

    Assets/PlayMaker SoundManagerPro/Actions/4SFXControl/PlayPooledSFX.cs(61,38): error CS1502: The best overloaded method match for `SoundManager.PlaySFX(UnityEngine.AudioClip, bool, float, float)' has some invalid arguments"

    "Assets/PlayMaker SoundManagerPro/Actions/4SFXControl/PlayPooledSFX.cs(61,38): error CS1503: Argument `#2' cannot convert `float' expression to type `bool'"

    "Assets/PlayMaker SoundManagerPro/Actions/4SFXControl/PlayPooledSFX.cs(63,38): error CS1502: The best overloaded method match for `SoundManager.PlaySFX(UnityEngine.AudioClip, bool, float, float)' has some invalid arguments"

    "Assets/PlayMaker SoundManagerPro/Actions/4SFXControl/PlayPooledSFX.cs(63,38): error CS1503: Argument `#2' cannot convert `float' expression to type `bool'"
     
  11. RowdyMrB

    RowdyMrB

    Joined:
    Dec 8, 2012
    Posts:
    83
    By the way the smiley faces are supposed to be 8's ;)
     
  12. CORPSEGRINDER

    CORPSEGRINDER

    Joined:
    Feb 6, 2014
    Posts:
    6
    Hi does SoundManager Pro support WP8?
     
  13. SteveJ

    SteveJ

    Joined:
    Mar 26, 2010
    Posts:
    3,085
    I've found a strange issue has been introduced since updating yesterday to the new version.

    I have a GUI camera in my scene (which is stationary around 0,0,0) and a main camera attached to the Player. The main camera has the audio listener on it, and the GUI camera doesn't have one.

    It appears that the GUI camera is acting as a listener though. The further I get away from 0,0,0 coordinates, the softer sounds get until I can't hear them at all.

    Any thoughts?
     
  14. SteveJ

    SteveJ

    Joined:
    Mar 26, 2010
    Posts:
    3,085
    Nevermind - figured out that if the game object or transform aren't specified, it defaults to 0,0,0 rather than the position of the object it's attached to.
     
  15. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Oh, yes I'll fix that.
     
  16. AntiLunchBox

    AntiLunchBox

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

    It is 98% compatible, there's only one feature that's omitted in WP8. It's the audiosourcepro custom event subscriptions. There was an old WP8 bug that prevented submissions, but that has long been fixed. Let me know if you're still having issues.

    ALB
     
  17. AntiLunchBox

    AntiLunchBox

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

    There are overloads that play sfx on certain gameobjects or audiosources. Those don't default to 0,0,0

    ALB
     
  18. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    K rowdy, that should be fixed now.

    ALB
     
  19. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
  20. McSteed

    McSteed

    Joined:
    Apr 26, 2014
    Posts:
    18
    I think what I want to do will work but I want to clarify before buying.

    I want to tie which sound FX gets looped based on angular velocity (for a motorcycle). (I don't need to cross fade) Such as between 0-500 play Idle sound, 500-2000 play Accelerating sound, etc. Everything I do now is starting the sound again with each update.
     
  21. AntiLunchBox

    AntiLunchBox

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

    You can do this with AudioSourcePro's easily. So you'd have all the clips you need in the SoundManager, and then have X amount of AudioSourcePros on the perfab you are using. If you have events on a script on that same gameobject, they'll be automatically added to the AudioSourcePro. You can then use that to say, PlayLoop and Stop.

    Kind of confusing, but here's an example of the setup:

    Script on the gameobject has two events:
    public delegate void MotorCycleState();

    public MotorCycleState Idle;
    public MotorCycleState Accelerating;
    public MotorCycleState Cruising;

    THEN, whenever you change between the states, you just call Idle(), etc.

    THEN, when you have AudioSourcePro's added to that GameObject, Idle, Accelerating, and Cruising will be added to the event list automatically. You can then subscribe PlayLoop and Stop to the appropriate events and they'll automatically fire.

    Make sense? It'll make more sense if you look at the second demo scene in the project.

    ALB
     
  22. McSteed

    McSteed

    Joined:
    Apr 26, 2014
    Posts:
    18
    Cool thanks.
     
  23. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    Some of my SFX are not playing on iOS and Android.

    There is some option I need to set when importing my SFX to unity? I'm using OGG Files...
     
  24. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    I found the problem... I have a SoundManager for each scene... not all scenes need all SFX loaded on memory, so I want to unload the unused SFX. Am I doing it wrong?
     
  25. monoclesociety

    monoclesociety

    Joined:
    Jan 2, 2013
    Posts:
    8
  26. Shiffty

    Shiffty

    Joined:
    Jul 20, 2012
    Posts:
    5
    Do you have a timeline for a fix to the Playmaker Action issues found in the latest update?

     
  27. markfrancombe

    markfrancombe

    Joined:
    May 26, 2009
    Posts:
    155
    Hi Just downloaded SMP, and dropped a music track into somewhere and it played... OK
    Now... er... wheres the docs?
    I don't mean YouTube videos, or code... or list of functions.. I want some instructions!
    I am using PlayMaker, wheres the instructions for using that (I have run the actions asset and seen it populate into PM, nice!)
    but what next?
    I have a million questions, Can I just ask away here?

    Regards

    Mark
     
  28. AntiLunchBox

    AntiLunchBox

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

    Yes that's wrong. You'll need to use the SaveSFX and DeleteSFX functions for that. When you load into a scene, if a SoundManager already exists it will destroy the new soundmanager and keep the old one. There are overloads of those functions that make it easy. Or you can delete the SoundManager before changing scenes, but that could interrupt background music.
     
  29. AntiLunchBox

    AntiLunchBox

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

    You emailed me and I answered your question I believe.

    ALB
     
  30. AntiLunchBox

    AntiLunchBox

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

    I believe I already posted that fix. You should be able to update (it says it in the update description). But I may have made a mistake and uploaded the wrong file, which is totally possible! Let me know if you are still having issues.

    ALB
     
  31. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    hey mark,

    Yes you can ask here, but I am able to respond faster when you use the support page: http://antilunchbox.com/contact-us/

    ALB
     
  32. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    This has come as a more and more frequent request, so I decided to go ahead and do it. People have been wanting to switch between tracks--but have the new track start from the same time as the previous. With this, the ability to do it to a SoundConnection, where any clip could be chosen. So I implemented it...welcome Track Sync

    Changelog in 3.5:
    • Track Sync implemented
    • Switch between SoundConnections and start where the previous soundconnection left off, at any track you want.
    • New Demo Scene to show off Track Sync

    ALB
     
  33. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hey guys, FYI, I'm seeing a bug with the Track Sync in certain versions of 4.x

    I'm looking into it.

    ALB
     
  34. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hey all, the bug has been fixed for 4.x users. Go ahead and update!
     
  35. Raveler

    Raveler

    Joined:
    Sep 24, 2012
    Posts:
    40
    Hey guys,

    I'm having a serious problem! Whenever a track is playing in the background and I encounter a NullPointerException somewhere in my code, the SoundManager goes into an infinite loop and blocks Unity, forcing me to end the process and reboot. When the SoundManager is disabled when the NullPointerException hits, I just get a simple proper NullPointerException error in the console, so I'm sure it has something to do with SoundManager.

    When I attach the Monodevelop debugger to Unity and pause during the hang/infinite loop, I get the following stack trace:

    System.MonoCustomAttrs.IsDefined (obj={System.Object[] param}, attributeType={System.ParamArrayAttribute}, inherit=true) in /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System/MonoCustomAttrs.cs:298
    System.Reflection.ParameterInfo.IsDefined (attributeType={System.ParamArrayAttribute}, inherit=true) in /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/ParameterInfo.cs:241
    System.Attribute.IsDefined (element={System.Object[] param}, attributeType={System.ParamArrayAttribute}, inherit=true) in /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System/Attribute.cs:348
    System.Attribute.IsDefined (element={System.Object[] param}, attributeType={System.ParamArrayAttribute}) in /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System/Attribute.cs:294
    System.MonoType.InvokeMember (name="Crossin", invokeAttr=The requested item has been unloaded., binder={System.Reflection.Binder.Default}, target={SoundManager (SoundManager)}, args={object[1]}, modifiers=(null), culture=(null), namedParameters=(null)) in /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System/MonoType.cs:429
    UnityEngine.SetupCoroutine.InvokeMember (behaviour={SoundManager (SoundManager)}, name="Crossin", variable={object[2]}) in C:\BuildAgent\work\d3d49558e4d408f4\Runtime\Export\Coroutines.cs:19
    SoundManager.PlayClip (clip2play={Mayan Ambient Track_V1 (UnityEngine.AudioClip)}) in D:\code\unity\Clockwork Riot\Assets\SoundManagerPro\Scripts\Managers\SoundManager_Internal.cs:460
    SoundManager.PlaySoundConnection () in D:\code\unity\Clockwork Riot\Assets\SoundManagerPro\Scripts\Managers\SoundManager_Internal.cs:800


    This happens on the following line:
    StartCoroutine("Crossin", new object[]{audios[notPlaying],crossDuration});

    It seems as if Unity goes into an infinite loop when a Coroutine is started during a pause/break, maybe? I'm not sure how that is even possible. Do you have an idea? This is very problematic for development, as I can't get a proper readout on errors when the game always hangs.
     
  36. AntiLunchBox

    AntiLunchBox

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

    That's really strange. What is the code you are using? Does this still happen in the demo scene provided?

    Pat
     
  37. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hey guys, I submitted another update 3.5.2

    it:
    -Namespaces some enums
    -Fixes a couple delay bugs in AudioSourcePro and the AudioSource extension methods caused by a previous update.

    ALB
     
  38. Raveler

    Raveler

    Joined:
    Sep 24, 2012
    Posts:
    40
    It even happens when I'm not using any code at all. Here's a more useful stack trace. It seems as if your own code is triggering the creation of a SoundManager if there is none, which triggers an error, which triggers another creation, ad infinitum:

    antilunchbox.Singleton<object>.get_mInstance () in D:\code\unity\Clockwork Riot\Assets\SoundManagerPro\Scripts\Managers\Singleton.cs:42
    SoundManager.get_Instance () in D:\code\unity\Clockwork Riot\Assets\SoundManagerPro\Scripts\Managers\SoundManager_Essentials.cs:10
    SoundManager.Setup () in D:\code\unity\Clockwork Riot\Assets\SoundManagerPro\Scripts\Managers\SoundManager_Internal.cs:23
    SoundManager.Awake () in D:\code\unity\Clockwork Riot\Assets\SoundManagerPro\Scripts\Managers\SoundManager_Internal.cs:9
    UnityEngine.GameObject.AddComponent (componentType={SoundManager}) in C:\BuildAgent\work\d3d49558e4d408f4\artifacts\EditorGenerated\UnityEngineGameObject.cs:426
    UnityEngine.GameObject..ctor (name="SoundManager", components={System.Type[1]}) in C:\BuildAgent\work\d3d49558e4d408f4\artifacts\EditorGenerated\UnityEngineGameObject.cs:455
    antilunchbox.Singleton<object>.get_mInstance () in D:\code\unity\Clockwork Riot\Assets\SoundManagerPro\Scripts\Managers\Singleton.cs:42
    SoundManager.get_Instance () in D:\code\unity\Clockwork Riot\Assets\SoundManagerPro\Scripts\Managers\SoundManager_Essentials.cs:10
    SoundManager.Setup () in D:\code\unity\Clockwork Riot\Assets\SoundManagerPro\Scripts\Managers\SoundManager_Internal.cs:23
    SoundManager.Awake () in D:\code\unity\Clockwork Riot\Assets\SoundManagerPro\Scripts\Managers\SoundManager_Internal.cs:9
    UnityEngine.GameObject.AddComponent (componentType={SoundManager}) in C:\BuildAgent\work\d3d49558e4d408f4\artifacts\EditorGenerated\UnityEngineGameObject.cs:426
    UnityEngine.GameObject..ctor (name="SoundManager", components={System.Type[1]}) in C:\BuildAgent\work\d3d49558e4d408f4\artifacts\EditorGenerated\UnityEngineGameObject.cs:455
    antilunchbox.Singleton<object>.get_mInstance () in D:\code\unity\Clockwork Riot\Assets\SoundManagerPro\Scripts\Managers\Singleton.cs:42

    You have the following line in antilunchbox.Singleton, which triggers the creation of a new SoundManager:

    linr 42: GameObject gO = new GameObject(typeof(T).Name, typeof(T));

    In SoundManager.Setup, you do a call on the singleton to get the SoundManager, which is not yet set at this point!

    line 23: if (Instance Instance.gameObject != gameObject)

    ... which triggers the creation of ANOTHER SoundManager, by calling get_mInstance and ending back at line 42 of antilunchbox.Singleton

    This goes on forever.

    This should help you fix it!

    This happens literaly all the time in my project (even when I have sound/music sfx turned off during dev). I have to kill Unity every 20 minutes, but I can't really disable SoundManager because it's deeply intertwined with my code.
     
    Last edited: May 22, 2014
  39. AntiLunchBox

    AntiLunchBox

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

    Does it happen in the demo scene? I ask because it'll help me reproduce your problem on my end.

    And if it doesn't happen in the demo scene, it could be something where a scene gets loaded twice at once---causing some funky behavior. This would also help me diagnose the problem.

    Right now I can't reproduce it, but if you could send me a small environment (a small scene with a simple script) where I can reproduce it, along with your Unity version, I can totally fix it ASAP. You can send it to my email directly and I'll take a look.

    I was testing the Singleton file with MustHave iOS yesterday, so I don't think that's the problem but it's good to make sure.

    Thanks!
    Pat
     
  40. Raveler

    Raveler

    Joined:
    Sep 24, 2012
    Posts:
    40
    Hey,

    The problem is that the crash only occurs randomly after x minutes of playing, so it's hard to find a reproducable version. But I can give some pointers.

    I do some funky stuff to set up the SoundManager. Because I don't know in which order the scenes will be loaded, I needed a way to make sure that there is always only ONE SoundManager around, no matter which scene is started first. So I made the SoundManager into a prefab, and wrote a small script that checks if a SoundManager exists, and if not, instantiates one:

    public class SoundManagerSingleton : MonoBehaviour {

    public SoundManager soundManagerPrefab; // inspector

    private static SoundManager soundManager;

    public static SoundManager getInstance() {
    return soundManager;
    }

    public void OnEnable() {
    if (soundManager == null) {
    soundManager = Instantiate (soundManagerPrefab) as SoundManager;
    soundManager.gameObject.AddComponent<AudioListener>();
    }
    }
    }

    I add this to every scene. This way I can edit the soundmanager and configure it from the editor, no matter which scene is open. When I don't use this script and let the SoundManager function from an instance in the scene, there are no issues. So maybe this has to do with making SoundManager a prefab and instantiating it from there?
     
  41. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Ah,

    So I see where the problem is. SoundManager already inherits from the Singleton.cs class included. What that does is that it always makes sure "1" SoundManager in the scene. So it covers these situations automaticalyl for you:
    - if you call a SoundManager function and one doesn't exist, it'll create itself.
    - if you enter a scene with it's own SoundManager but you have an existing SoundManager already, it'll delete the new SoundManager automatically before it even gets a chance to initiate.

    Now all you have to do is have the SoundManager prefab in your starting scene, and it'll persist across any scene changes. So you don't need to do that extra work.

    As a bonus, let's say you are working in Unity and want to start from a scene that's not your starting scene (for testing purposes). You don't have to start from your starting scene in order to have the SoundManager you configured. Just prefab the SoundManager from your starting scene, and drag it into every scene in your project. That way you'll always have an up-to-date SoundManager based on the original prefab. And playing from the beginning won't be an issue because extra SoundManagers are already automatically deleted for you.

    So you don't need to do any of that! That's why you're getting errors.

    ALB
     
    Last edited: May 23, 2014
  42. Raveler

    Raveler

    Joined:
    Sep 24, 2012
    Posts:
    40
    I didn't know about the prefab trick. Because the last point you made was why I was doing the singleton in the first place. Okay, I'll get rid of my singleton and let you know if I have any more problems.
     
  43. aeonbringer

    aeonbringer

    Joined:
    Oct 28, 2013
    Posts:
    6
    It was probably asked before, but what should I do if I want to fade out a looping sound effect before stopping it?

    Thanks
     
  44. gokzor

    gokzor

    Joined:
    Jul 27, 2012
    Posts:
    5
    I cant for the life of me figure out what is causing this...

    Invalid event binding configuration - Source:SoundManager.ValueChanged, Target:dfEventDrivenPropertyBinding.MirrorTargetProperty
    UnityEngine.Debug:LogError(Object)
    dfEventBinding:Bind() (at Assets/Daikon Forge/DataBinding/Scripts/dfEventBinding.cs:88)
    dfEventDrivenPropertyBinding:bindTargetEvent() (at Assets/Daikon Forge/DataBinding/Scripts/dfEventDrivenPropertyBinding.cs:228)
    dfEventDrivenPropertyBinding:Bind() (at Assets/Daikon Forge/DataBinding/Scripts/dfEventDrivenPropertyBinding.cs:92)
    dfPropertyBinding:OnEnable() (at Assets/Daikon Forge/DataBinding/Scripts/dfPropertyBinding.cs:70)
     
  45. gokzor

    gokzor

    Joined:
    Jul 27, 2012
    Posts:
    5
    Im getting 7 errors like this :/ I have a slider set up controlling the volume of the music from the sound manager.
     
  46. gokzor

    gokzor

    Joined:
    Jul 27, 2012
    Posts:
    5
    So I tracked it down to this component attached to the sound manager.. I cant see why this would cause the error though it seems perfectly valid.. ?

    $Untitled-1.jpg
     
  47. gokzor

    gokzor

    Joined:
    Jul 27, 2012
    Posts:
    5
    The image isnt showing.... jeez

    Ambient audio is just and audio source pro with a clip playing...

     
  48. gokzor

    gokzor

    Joined:
    Jul 27, 2012
    Posts:
    5
    Figured it out.. it needs to be polled instead of event driven to work without errors. Oh well!
     
  49. retox

    retox

    Joined:
    Sep 12, 2012
    Posts:
    29
    Hello,

    I'm getting the bool errors linked to Playmaker which was discussed on the previous page. Was there a fix for this?

    I've updated SMP but get the issue.

    I had updated Unity to 4.5, but there were a host of issues with SMP and PM so rolled back to 4.3.4.f1.

    Thanks in advance.

    $Screen Shot 2014-05-28 at 16.17.20.png
     
  50. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    SoundManager.Crossout function