Search Unity

[RELEASED] SoundManagerPro: Easy Game Music Plugin

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

  1. Ilona

    Ilona

    Joined:
    Aug 27, 2013
    Posts:
    10
    Thanks ALB and ClockworkWolf!

    Unchecking the "3D Sound" on the import settings solved the problem. We don't need 3D sound in our game, so this solution works great!
     
  2. ClockworkWolf

    ClockworkWolf

    Joined:
    Sep 12, 2013
    Posts:
    55
    Ilona: Glad it works! With the 3d sound enabled, it is still produced, just very soft as the audio location is probably very far from the listener. I had to crank up my audio interface to nearly 50% of max to hear it (i normally find 15% a bit too loud on my setup....)

    AntiLunchBox: That's good to know, didn't notice that! I'll be sure to give that a go later :) Cheers!
     
  3. GrooGadgets

    GrooGadgets

    Joined:
    Apr 2, 2009
    Posts:
    71
    Greetings,

    I'm keen to buy your plugin but I have a question regarding music playback and mixing functionality. I've looked over most of this thread and haven't seen an answer so please forgive me if it has been addressed earlier, her goes:

    What I have are two different mixes of the same song, both with the exact same length and tempo but one is quite heavy and the other is more acoustic (let's say versionA and versionB). What I would like to do is create an app that lets the user listen to one of the songs and have the functionality to crossfade at any time from versionA to versionB and vice versa.

    Would this be at all possible with your plugin?

    Thanks!

    Simon
     
  4. AntiLunchBox

    AntiLunchBox

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

    You can do that with SMP. It's pretty simple using code. You can just use any variation of the SoundManager.PlayClip function. Or, you can make a SoundConnection with both variations and then use SoundManager.Next (or Prev) to change between the songs. It's definitely possible but how you want to do it is up to you!

    -ALB
     
  5. GrooGadgets

    GrooGadgets

    Joined:
    Apr 2, 2009
    Posts:
    71
    Heya,

    I've downloaded the free version and I can't find a way to do exactly what I want. Let me explain more clearly:

    I have two versions of exactly the same song, both are 4.30 long and have a tempo of 100 bpm. verA is a heavy version while verB is a lighter acoustic version.

    What I want to do is have an app where the user starts listening to verA and at any time during the song it would seamlessly crossfade to verB of the song at exactly the same place in the song.

    So if the user listening to verA wanted to switch to verB at 0.45 seconds into the song, it would seamlessly transition to verB at the exact same point.

    I hope i've made myself clearer, am I able to do this out of the box or would new functionality need to be created?

    Cheers,

    Simon
     
  6. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Ah,

    I see what you're saying. Unfortunately, yes new functionality would have to be created. I can look into how to implement it if you are interested. It won't be possible to modify it in the free version since the code is packed in a DLL. But I can point you to where you could put in code to implement that feature. It actually wouldn't be hard to add that in. In the crossfade function you can just add some code that will take the current track's sample and apply it to the second track as soon as it starts playing. There's a private crossfade function that takes in 2 AudioSources. So before AudioSource 2 plays, you can just do something like this: AudioSource2.timeSamples = AudioSource1.timeSamples;

    And that should cover it. However, it would do that for every crossfade. So. it may be helpful to add some case checking to know when you want to do it exactly.

    -ALB
     
  7. Zaddo67

    Zaddo67

    Joined:
    Aug 14, 2012
    Posts:
    489
    Soundmanager was working great until I put splash scene in before the main menu scene loads with Soundmanger. If I run the main menu scene from the editor, soundmanager plays the music as it should. It just won't start if the scene is loaded from another scene....

    How do you give sound manager a kick to so it starts playing music?

    [EDIT] After a bit more digging. I found that the SoundManager.Instance.soundConnections only gets populated with the connections defined in the inspector, when I load my main menu scene directly. If I load the main menu scene from another scene, it has zero soundConnections. How do I get these connections loaded with information defined in the inspector?
     
    Last edited: Oct 26, 2013
  8. AntiLunchBox

    AntiLunchBox

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

    I just have a question for more clarification. Are you running SoundManager functions while in the splash scene? If a SoundManager doesn't exist in the scene, SoundManagerPro will instantly create itself if you reference it in anyway (by using SoundManager.anything). So if you use a SoundManager function in the splash screen, it'll create a empty SoundManager. Then, when it loads into your Main Menu scene, it'll use the SoundManager from your splash screen (that happens to have nothing on it).

    In that case, you can either:
    -wait to run those functions in the main menu scene
    -move the SoundManager to your splash scene
    -create the SoundConnections with code using SoundManager.CreateSoundConnection in your splash scene
    -use the same SoundManager prefab in you splash and main menu scenes

    Let me know if you need more help.

    -ALB
     
  9. Zaddo67

    Zaddo67

    Joined:
    Aug 14, 2012
    Posts:
    489
    Hi ALB,

    I am not referencing SoundManager from the splash scene. It is very simple, camera/guitexture/one script to load the main menu scene.

    If I can't find another solution, I will put soundmanager on the splash screen as you suggest.

    I will work on it a bit longer, my best guess at the moment is that the load sequence is somehow different when the main menu scene is loaded from another scene, and some other reference to soundmanager is creating an empy instance before the soundmanager object in the scene is created.

    Thx, Zaddo


    [EDIT]

    For whatever reason, the loading is different when the scene is loaded from another scene. I refer to SoundManager in the awake of another script with:

    SoundManager.Instance.OnSongBegin = SoundManagerOnSongBegin;

    This creates a different instance of soundmanager than the one in the scene. I did this so I could catch sound manager before it starts playing. This is so I can set it's volume to the player preferences I manage.

    I tried setting script execution order, but this did not fix the problem.

    What I need to know is, how can you set the default volume in soundmanger for music to mute?
     
    Last edited: Oct 26, 2013
  10. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Ah Zaddo,

    You want to avoid running a SoundManager function in the Awake function in a scene (it's okay if it's in Awake after the first Start of the Scene gets called, so like in the Awake function of a object instantiated in Start of another).

    It's a note at the top of the documentation. Unfortunately it just causes some funky behavior because the execution order of Awake and OnLevelWasLoaded.

    -ALB
     
  11. Zaddo67

    Zaddo67

    Joined:
    Aug 14, 2012
    Posts:
    489
    Thanks ALB. I just need to know how to start soundmanger with sound music volume at zero.
     
  12. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Just in start call "SoundManager.SetVolume(0f);"

    Or if you save the value with playerprefs it would be:

    SoundManager.SetVolue(PlayerPrefs.GetFloat("Volume", 0f));

    And make sure you call that in Start()

    -ALB
     
  13. AntiLunchBox

    AntiLunchBox

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

    I added an in-depth video for sound effects as well. It goes through all the options for playing and using sound effects as well as some very useful memory management options with SoundManagerPro. Take a look!

     
  14. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    URGENT UPDATE FOR iOS USERS!

    The latest update, which included the preloading feature, has a null reference on soundconnections when built out on an iOS device. The fix is submitted, but in the meantime its easily fixed like this:

    Go to SoundManager_Internal.cs

    Go to the bottom of the file to the function: SetNextSongInQueue()

    At the bottom of that function there is a line:
    if(!audios[notPlaying].clip.Equals(nextSong))

    Change that to:
    if(audios[notPlaying].clip == null || !audios[notPlaying].clip.Equals(nextSong))

    And that should fix it.

    -ALB
     
  15. AntiLunchBox

    AntiLunchBox

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

    Actually now my updates are gonna come faster. The fix is already up on the asset store. Feel free to download the fix!

    -ALB
     
  16. AntiLunchBox

    AntiLunchBox

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

    Also, when you get the chance, check out the new AntiLunchBox plugin: MustHave iOS

    It's on a 90% off launch sale!

    -ALB
     
  17. AntiLunchBox

    AntiLunchBox

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

    SMP is on the 24-Hour Deal sale at 80% off!

    Get it while it's cheap!

    -ALB
     
  18. Ilona

    Ilona

    Joined:
    Aug 27, 2013
    Posts:
    10
    Hey ALB,

    We are having some problems with SoundManagerPro on creating an iOS build.

    When I run the game in Xcode it plays for 1 or 2 seconds, then the game freezes and I get this error; "Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)" I have Xcode version 5.0.1 and the error occurs on devices with iOS 7 as well as iOS 6. The last trace I see is "Already playing BGM, check if crossing out(False) or in(True)." although I don't think that has anything to do with it. I'm not really familiar with Xcode yet, so i'm having a hard time figuring out where exactly the error is occurring. But when I set SoundManager pro to inactive I don't get the error. When I start the game on the device without Xcode it appears to be running okay.

    The second problem is that there seems to be a memory leak when using the sfx, the game gets slower after playing for a while, but when I turn the sfx off (but still leave the music on) the game seems to run fine. I can't check the actual memory usage in Xcode because of the error I'm getting. I use the following line to play the sfx in the game;
    Code (csharp):
    1. SoundManager.PlaySFX(SoundManager.Load(auidioName));
    Do I need to call something to clean the SFX from memory?

    Do you have any idea what could be the problem with Xcode?

    Any help would be appreciated.

    Ilona
     
  19. AntiLunchBox

    AntiLunchBox

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

    Have you updated to version 2.6.9?

    There was an issue with SoundConnections (when they were done crossfading) in 2.6.8. It was a bug in the latest feature, once it built out to the device. There was a missing null check that crashed on iOS. That has been fixed in the latest update (came out a couple days ago).

    -ALB
     
  20. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    I also cover memory management in the SFX video, if you want to take a look:

     
  21. Ilona

    Ilona

    Joined:
    Aug 27, 2013
    Posts:
    10
    Where can I find the version? I downloaded the latest update from the Asset Store today so I'm assuming that is version 2.6.9. But it still crashes in Xcode.
     
  22. Ilona

    Ilona

    Joined:
    Aug 27, 2013
    Posts:
    10
    Thanks, I'll have a look at the video.
     
  23. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    If you go to the asset store, and go to your downloads tab and check there. There should be an option to update.

    I would also try just downloading it again in a new project and running the demo scene to see if it crashes. It seems weird, but I have experienced the problem where the Asset Store will download a previous version for no reason. One time it even accidentally restored a super old version before-- I had to resubmit and have them push it again. The Asset Store can get a little bit buggy. But if the problem still persists, I can definitely look into it for you. Or you can send me your invoice ID, and I can send you the package personally (would have to happen later today).

    -ALB
     
  24. Ilona

    Ilona

    Joined:
    Aug 27, 2013
    Posts:
    10
    Because I already updated earlier today I couldn't press the update button. But I opened a new project, pressed download in the asset store (it seemed to refresh) and imported the files. Your demo scene starts fine, but when I press one of the buttons like "Load Level: MusicScene1" I got the error in Xcode also saying "Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)"

    I would appreciate if you could look into it for me. I will pm you my invoice ID, you can send me the package, so we can make sure I have the correct version. But I have to leave for today so I'll check back tomorrow.

    Thanks for the help so far!

    Ilona
     
  25. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Sure,

    I'll look into it. You should also check this:

    Go to SoundManager_Internal.cs

    Go to the bottom of the file to the function: SetNextSongInQueue()

    At the bottom of that function there should be a line:
    Let me know if that's true.

    -ALB
     
  26. Stilghar

    Stilghar

    Joined:
    Feb 4, 2013
    Posts:
    82
    You just got another customer! I couldn't resist the sale :D

    Quick question: what would be the best way to have a song playing in loop and trigger another song to play when reaching the end of the level (the level boss)?

    I'll let you know how it goes after we integrate it in our game.
     
  27. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hi Stilghar,

    That's pretty easy. If you already have a SoundConnection playing in a scene, you can just use the SoundManager.Play() or SoundManager.PlayImmediately() functions to play the boss music.

    You can also use SoundManager.PlayConnection() to play another SoundConnection for a combination of songs for the boss. For that, you can either use SoundManager.CreateSoundConnection in code or create a custom SoundConnection on the SoundManager. If you create a custom SoundConnection, you can just use the second overload of SoundManager.PlayConnection and reference it by name. It's pretty flexible there!

    -ALB
     
  28. bhecox65

    bhecox65

    Joined:
    Nov 6, 2013
    Posts:
    2
    This asset looks great! Thoroughly upset I didn't have a chance to buy it while I saw it was on sale.
     
  29. Ilona

    Ilona

    Joined:
    Aug 27, 2013
    Posts:
    10
    Thanks for the files. I added them to the project and checked the line you mentioned. I see the line
    Code (csharp):
    1. if(audios[notPlaying] == null || !audios[notPlaying].clip.Equals(nextSong))
    but not with the .clip as you mentioned in your post. I created a new empty project and checked for the line, but that also shows the line above, without the .clip. Could there have gone something wrong with the import? I even tried it twice in an empty project. Are you sure you send me the right files?

    I changed the line you mentioned and added the .clip after audios[notPlaying] and I'm not getting an error at startup in Xcode anymore, but later in the game it seemed to go in to an infinite loop, logging these lines;

     
  30. AntiLunchBox

    AntiLunchBox

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

    Actually that line is correct, I was trying to remember from memory >.<:
    Before the fix, that line that caused the error showed:
    So that seems to be correct--you can change that back. How about you go ahead and send me that empty project you created, if you don't mind. I have no idea why you are getting this error. It's working on my end, and I haven't gotten any other reports of this. Weird! But I'm happy to take a look for you.

    -ALB
     
  31. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    No worries! I actually decided to do a POST-SALE SALE, that will last through the end of the week. This sale has done so well like no other sale I've seen, so I decided to continue a sale at 75% off!

    Here of some stats on the sale!
    -During the 24-hour sale, SMP managed to sell over 550 copies!
    -SMP rose to #1 Most Popular asset of all assets on the store, even during the 15 day Birthday Bonanza!
    -SMP rose to #5 Top Paid of all assets! It's hard to even get on that list, its usually the same 10 assets all the time!
    -SMP rose to #1 Top Paid Scripting asset!
    -SMP rose to #3 Top Grossing Scripting asset!
    -SMP is the #1 Most Popular, Top Paid, and Top Grossing Audio plugin!

    Judging from previous sales, its pretty easy to get it to the #1 Most Popular in your category--but to get on the Top Paid and Top Grossing lists is something people normally just dream about! So with the great success, I'm going to continue SMP on a 75% OFF sale as a thanks. And to think SMP only came onto the scene about 3 months ago.

    Thanks Unity Community,
    ALB
     
  32. tomph

    tomph

    Joined:
    Nov 6, 2013
    Posts:
    33
    Hey ALB!

    Rather than bother you on twitter, I thought I'd put stuff on here so we can help everyone out at once.

    I've got the thing up and running, but I have a couple of questions...

    Can you explain the 2dToolkit integration? I cannot find anything around that explains it.

    also,

    Can you explain the feature added recently that manipulates Tempo (not pitch) ?

    Thanks! :)
     
  33. AntiLunchBox

    AntiLunchBox

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

    For the 2DToolkit integration, you want to go to the Scripts/Extensions folder and click the TDTK_SMPRO_INTEGRATION.unitypackage

    I probably should've named it 2DTK, but it's too late for that now haha. That package will replace the necessary files to use SMP for 2DTK sounds rather than itself--so it'll respect your SMP settings. However, in case this file is behind the 2DTK updates, there should be a README in there describing what to change.

    As for that tempo feature, that actually isn't possible with SMP. In fact that's really difficult, if not impossible, to do in Unity in general. It would require multiple sampling rates, etc which is very taxing on devices/the engine itself. So for now, using the SetPitch/SetPitchMusic/SetPitchSFX functions will have to do it for you. Changing tempo will have to effect pitch and vice versa.

    I will keep an eye out for updates on the matter though. Hope that helps,
    -ALB
     
  34. tomph

    tomph

    Joined:
    Nov 6, 2013
    Posts:
    33
    Ah, that's kind of what I thought about tempo! Thanks for confirming that!

    Great work on the plugin by the way! :)
     
  35. Ilona

    Ilona

    Joined:
    Aug 27, 2013
    Posts:
    10
    I did some tests, but I can't send you the test project I had because it is too big. I imported SoundManagerPro in to an empty project, included SoundManagerProDemoScene, MusicScene1, MusicScene2 and MusicScene3 in the build. When I run the build in Xcode I can reproduce the bug by pressing "Load Level: MusicScene1".

    In your code I changed the line to:
    Code (csharp):
    1. if(audios[notPlaying] == null || (audios[notPlaying].clip != null  !audios[notPlaying].clip.Equals(nextSong)))
    Because I noticed sometimes audios[notPlaying] was not null but audios[notPlaying].clip was. This solved the Xcode error at the startup and it seemed to be running fine, but I will do some more test. Does that line need to be changed in your source? Or am I doing something wrong with including the audio that audios[notPlaying].clip should never be null?
     
  36. AntiLunchBox

    AntiLunchBox

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

    That change should be fine. That just seems like an extra security null check.

    I'll do some more testing of it and update that. It's weird that I haven't heard of any other issues still, so I'm not sure exactly what it is. Regardless, that fix won't hurt. Thanks for checking that out!

    -ALB
     
  37. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Really Great asset. Bought it.

    I am starting to migrate my audio code from another package to SM pro and it's really fantastic to use.
    I've also started to migrate out of NGUI to DaikonForge GUI and finding it difficult because SM pro doesn't support Daikon.
    One small request.. Would you consider adding support for Daikon Forge, this will really make life so much easier. Especially since Daikon Forge is getting quite a lot of momentum and becoming quite a popular alternative to NGUI.

    Cheers.
     
  38. BoomWav

    BoomWav

    Joined:
    Mar 30, 2012
    Posts:
    7
    Hi! I started implementing SoundManagerPro in my project and I had a small question. I went through the documentation and I can't seem to find what I'm looking for. Is there a way to Stop and Resume a soundconnection? It seems to work with Pause and Unpause but.. I was looking for individual control for music and sfx. Also.. is there a way to Resume a Connection after you've stopped it? Thanks a lot!
     
  39. bhecox65

    bhecox65

    Joined:
    Nov 6, 2013
    Posts:
    2
    Wow!! Thank you very much! Purchased and very happy now :)
    Keep up the great work with your assets ALB.
     
  40. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Hi rocki,

    I can look in to it. I haven't used Daikon, so I may check it out.

    -ALB
     
  41. AntiLunchBox

    AntiLunchBox

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

    What exactly do you mean individual control for music and SFX? If you Stop a soundConnection, you can use SoundManager.PlayConnection("level name OR soundconnection name") to start it up again. However, that'll start the SoundConnection over. Pause and UnPause is the best option for stopping and resume a soundconnection at the same spot.

    Also, all of the SFX functions return the resulting AudioSource---so you can do some individual control there.

    -ALB
     
  42. maurocastanho

    maurocastanho

    Joined:
    Oct 22, 2013
    Posts:
    1
    Bought it yesterday and is a great asset.

    I think I found a bug. If there are two scenes, both with only a music clip in its SoundConnections, after changing scenes the music will stop abruptly when crossfading. It is strange because the error does not occur when running inside the editor.

    I traced back the error turning on "development build" and found that a test is wrong in the file SoundManager_Internal.cs, line 1120, causing a Null Reference Exception:

    original: if(audios[notPlaying] == null || !audios[notPlaying].clip.Equals(nextSong))
    corrected: if(audios[notPlaying].clip == null || !audios[notPlaying].clip.Equals(nextSong))

    This corrected the error for me.

    Mauro
     
  43. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    Thanks mauro,

    I'm about to submit an update tonight that will fix that line and change it to:
    I appreciate the investigation though,

    -ALB
     
  44. AntiLunchBox

    AntiLunchBox

    Joined:
    Jun 6, 2013
    Posts:
    470
    K the hotfix is live now on the Asset Store. Update to 2.7.0 for the hotfix above.

    -ALB
     
  45. Rafael-Costa

    Rafael-Costa

    Joined:
    Jul 7, 2012
    Posts:
    14
    Hi, I bought SoundManagerPro last week and now that I am integrating it to my project I noticed two things thats you may want to take a look:

    1. Assets/SoundManagerPro/Editor/SMPCleanup.cs(5,14): warning CS0618: `AssetModificationProcessor' is obsolete: `Use UnityEditor.AssetModificationProcessor'

    2. I know this is a rare case, but when we add any sound track to a SoundConnection that is shorter than the crossover time, Unity will crash upon loading the scene that uses that SoundConnection. Would be nice to throw a warning or make some checks to prevent this situation.

    Thanks and congrats for your work on this product.

    Rafael
     
  46. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Great, Appreciate it.
     
  47. AntiLunchBox

    AntiLunchBox

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

    Thanks for looking into that. I'll check into #1, it's a Unity 4 issue. Stuff that like sometimes pops up without me knowing because I have to submit in Unity 3.5 to keep the minimum requirement down (hopefully soon the Unity Asset Store will let you set your own minimum!). It's an easy fix though.

    As for #2, there should be a catch where if a track length is lower than the cross duration, it uses the track length as the cross duration. Seems to have gone wonky in some recent update. I'll also look into that! Thanks for bringing that up.

    -ALB
     
  48. Rafael-Costa

    Rafael-Costa

    Joined:
    Jul 7, 2012
    Posts:
    14
    Hi ALB,

    I installed Unity 4.3 today and noticed that after the project upgrade the music looping / crossfading stopped working. The track plays for the first time but fails to cross and loop.

    I also noticed that a lot of methods are now deprecated. I hope you can fix everything soon and release an update.

    Regards,

    Rafael
     
  49. AntiLunchBox

    AntiLunchBox

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

    I'll take a look at Unity 4.3 ASAP! A lot is new it seems.

    ALB
     
  50. AntiLunchBox

    AntiLunchBox

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

    Seems like I found the culprit. If you go to the 'PlaySoundConnection' function in SoundManager_Internal.cs, there is a line 4 lines in that calls:

    StopPreviousPlaySoundConnection();

    You can remove that to get it to work. I still have to do some case checking to make sure it doesn't break anything else, but I wanted to give you the heads up. In 4.3 there is a release note:

    I suspect that is causing the problem. It will be completely fixed soon!

    -ALB