Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Master Audio - AAA Sound Solution. #1 audio plugin on Asset Store!

Discussion in 'Assets and Asset Store' started by dark_tonic, Jan 28, 2013.

  1. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    You're going to need to be more specific than that. There are numerous tutorial videos. What does your Master Audio prefab look like and is that error being triggered by EventSounds? If so, what event(s) are you using? Oh, and you prefer, you can use our dedicated support forum here: http://darktonic.freeforums.net/
     
  2. hemdanw

    hemdanw

    Joined:
    Nov 5, 2012
    Posts:
    14
    Hi,

    I was following this tutorial:
    http://www.youtube.com/watch?v=AOo6qfNSEww

    Really, just trying a very basic example...
    Added MasterAudio and PlayerlistController.
    The in MasterAudio, added a sound group, gave it a name "Explosions", then opened the group and added 2 more variations with random pitch and volume. Then went to my Explosion prefabs, and added the EventSounds script, using the "Enable" trigger to play a sound from the "Explosion" sound group with Variation Mode "Play Random"... I am probably missing something as this is my first time trying out this tool.

    This is the detailed error message:
    MasterAudio not finished initializing sounds. Cannot play:
    UnityEngine.Debug:LogError(Object)
    MasterAudio:playSound3DAtTransform(String, Transform, Single, Nullable`1, Single, String, Boolean) (at Assets/DarkTonic/MasterAudio/Scripts/Singleton/MasterAudio.cs:832)
    EventSounds:performSingleAction(AudioEventGroup, AudioEvent, EventType, Boolean) (at Assets/DarkTonic/MasterAudio/Scripts/Events/EventSounds.cs:571)
    EventSounds:playSounds(AudioEventGroup, EventType) (at Assets/DarkTonic/MasterAudio/Scripts/Events/EventSounds.cs:534)
    EventSounds:OnEnable() (at Assets/DarkTonic/MasterAudio/Scripts/Events/EventSounds.cs:189)
     
  3. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Oh ok, I think I see the problem. If your prefab using the Enable event is in the Scene when the Scene begins, then Enable should not be used because Master Audio isn't completely done initializing until Start.

    There's even a green message in the Enable event at the top saying this. So I believe if you change from Enable to Start event, it will work.

    The above limitation is not there if you are using Master Audio in persistent mode and have changed to a different scene. Hope that helps!
     
  4. hemdanw

    hemdanw

    Joined:
    Nov 5, 2012
    Posts:
    14
    Hi,

    Thank you for the quick reply.

    This solved the problem with the error logs, but I still do not "hear" any of the sounds. I tried pausing the game during play, and clicking on the speaker icon next to the sound. I see sound bars moving, and the index next to the group name is incremented to [1] and so is the Total Active Voices, but I do not hear anything. I verified that the original clip works from the unity preview and is audible. I also checked all volume bars are at maximum. I am trying to play 2D sounds (not sure if that matters).

    My current playlist is empty and gives a warning on start, but I think this is for music so it should not be causing this. I do have other sounds playing from the game as I will be transitioning it over MasterAudio - could that be causing the problem?

    Another thing is that ALL objects in my game are pooled - so they are simply deactivated and recycled. Would the "start" event still work... Also, is it possible to just make a call to PlaySounds directly from code - and not use the events script. The "PlaySounds" method seems to need an event type parameter which may not be applicable if I am calling the method myself.

    Thanks,
    hemdanw
     
  5. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    As far as not hearing the sounds, read my reply on our support forum for this same issue another user had: http://darktonic.freeforums.net/thread/5/trigger-event-playing-sound

    All objects in your game are pooled - great! That's a good practice to get into. In that case Start would only fire the first time, so don't use the Start event. If you are using Pool Manager (the norm for Pooling) or the Pooling built into our other plugin Core GameKit, the Spawned event is the event you will use instead in EventSounds. To get that one to appear in the list of events, check the "Pooling Events" checkbox up top in EventSounds. If you're using a different pooling product, you'll need to check how to get code to execute every time a prefab is recycled (spawned).

    Yes, you can also call MasterAudio.PlaySoundAndForget and another slew of methods by code if you prefer. The API is here: http://bit.ly/1bkiRei

    Other sounds playing from the game outside of MA will not cause any problems. They just won't be controlled and visible in voice counts or adjustable by any MA controls.
     
    Last edited: Apr 22, 2014
  6. hemdanw

    hemdanw

    Joined:
    Nov 5, 2012
    Posts:
    14
    This looks great!
    Thank you very much for the quick responses.
    I shall try it out and let you know if I run into other issues.

    Thanks again,
    - hemdanw
     
  7. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Excellent, we hope you enjoy the product and help us to grow it wherever it may lack. Have fun!
     
  8. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
  9. atmospherium

    atmospherium

    Joined:
    May 12, 2013
    Posts:
    38
    Thanks for posting a link to the Audial Manipulators thread, jerotas!

    If anyone wants to see some of these effects in action, check out the trailer or an web-player demo. I'm wanting to develop a full set of effect filters that meet people's needs, so feel free to contact me and let me know what you would like to see added to the package. Looking forward to hearing from you!
     
  10. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Master Audio V 3.5.2 will be live in 20 minutes. We now have a Mechanim event in EventSounds!! No need to wait for Unity 5 to come out :)

    Changelog:

    • Put Master Audio Manager object creation back to "not hooked to the prefab" so that updating the plugin doesn't delete your settings. A couple customers reported this happening.
    • Fixed SoundGroupAttribute so it works even in a Scene with no Master Audio prefab.
    • In Clip Manager, changed filter text field to filter on full path (folder name as well as file name).
    • In Clip Manager, added a folder dropdown filter to select a single folder to view, or view all.
    • Added Mechanim State Entered Event to EventSounds. You can add any number to a single component. Only works on layer 0, you specify the state name.
    • Fixed bug where disabled Custom Events in EventSounds would still show expanded.
     
  11. ImpossibleRobert

    ImpossibleRobert

    Joined:
    Oct 10, 2013
    Posts:
    521
    I really don't understand where this restriction with the bootstrapper scene comes from. If I look at the requirements they are:


    • Have exactly one "MasterAudio" gameobject
    • Have any number of playlist controllers BUT they must not have the same name

    I added this to MasterAudio awake()

    Code (csharp):
    1.     void Awake() {
    2.         if (persistBetweenScenes) {
    3.             if (GameObject.FindObjectsOfType<MasterAudio>().Length > 1) {
    4.                 Destroy(gameObject);
    5.             }
    6.         }
    and this to PlaylistController awake()

    Code (csharp):
    1.     void Awake() {
    2.         // check if two controllers with this name exist now
    3.         PlaylistController[] existing = GameObject.FindObjectsOfType<PlaylistController>();
    4.         int count = 0;
    5.         for (int i = 0; i < existing.Length; i++) {
    6.             if (existing[i].gameObject.name == gameObject.name) {
    7.                 count++;
    8.             }
    9.         }
    10.         if (count > 1) {
    11.             Destroy(gameObject);
    12.         }

    Voila. No more bootstrapping needed and works just fine. Am I overlooking something? :)
     
  12. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Clever. If that works for you, go right ahead. I wouldn't use it myself (and won't add that code to the package) as I wouldn't trust that it would always destroy the right Game Objects, even though it looks like it would. Even if it always worked, that is just *extra code* to me as you could just use a Bootstrapper Scene and not need that "band-aid code" to fix your setup. Is there some reason you're opposed to using one?

    Besides, destroying objects is bad on performance.
     
  13. ImpossibleRobert

    ImpossibleRobert

    Joined:
    Oct 10, 2013
    Posts:
    521
    Actually I have seen very similar setups many times already. I do not see anything dubious about it and also the performance impact is minimal IMO. Also, it don't see how it can grab the wrong object.

    Concerning bootstrapping scenes: this is an unnecessary complexity. Why would you impose such a requirement? The games I work on currently should start up as fast as possible. If I have a scene is in there which is just for loading this will give a penalty of 1sec+ which is felt a million times heavier than doing this simple check in the beginning :) Also, this scene would need to reload the loading picture of Unity in a way that it does not flicker or seem broken while loading continues. Why all this effort?

    I'd really recommend to put it in the code base. Why not put a safety parameter around it in addition to "persist between scenes", like "persist without bootstrapper", that we can activate so in case there are any side effects one can always go back to the old behaviour. And after some time when there are no complains one could remove the switch.
     
  14. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Ok sure I'll add it, possibly with a 3rd mode as you suggested. I will also make it log a warning or info into the console when it actually destroys an object in case it happens when someone doesn't realize why.

    I still think it's of limited usefulness. This is why. This code will only exist for the Master Audio plugin, and usually (at least in my games) there are a handful of objects that need to be persisted. Instead of adding code like this to each one of those plugins (since none of them come with code like this), it's easier to just use a Bootstrapper Scene. We currently do this for Playhaven, StoreKit, Facebook and I think one other plugin besides Master Audio. It doesn't seem to take anywhere near 1 second on my old iPad. Anyway, that will give the option to do either one.
     
    Last edited: Apr 24, 2014
  15. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I feel I need to point out a potential problem with using this "no bootstrapper" persist approach. If in the Awake event of any object, you call any Master Audio method, it's not guaranteed to use the correct Master Audio prefab (the one not about to be destroyed), and that's a race condition whether or not that happens. Avoiding problems like this is the reason I rejected the idea of allowing it originally. Same thing goes for the Playlist Controllers. Do you still think we should add this functionality? Or should we allow it and just put in a disclaimer that this problem may occur if you choose to operate this way?
     
  16. ImpossibleRobert

    ImpossibleRobert

    Joined:
    Oct 10, 2013
    Posts:
    521
    Great to hear that! Looking forward to seeing it integrated. So far the MasterAudio plugin seems like a very recommendable tool and I will certainly check out your other plugins.

    PS: maybe this technique is also interesting for your other plugins as well.
     
    Last edited: Apr 24, 2014
  17. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Yeah, it might be. I'll take a look.
     
  18. Kromer

    Kromer

    Joined:
    Apr 25, 2014
    Posts:
    1
    Hello Dark tonic and users.
    I'm currently working on a music system using Master audio.
    I have a problem when using variations in a group: When the clips are launched they have a slight fadein removing all "punch" from the first part of the music.
    The clips are not set to be looped (because variations are used) and they are loaded into memory as "Clip" and not "resource file". Using a custom fade of 0 or 0.01-0.001 does not fix the problem.
    I hope someone can help me fix this problem giving me back my punch :)
     
  19. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Turn off custom fade then. Besides that there is no volume-controlling code for Variations. I use both Resource file and Clip with none of the symptoms you are hearing, so I cannot reproduce what you're seeing.

    Playlists have crossfade but Variations do not.

    If you'd like to send us a project that reproduces the problem we'll take a look.
     
  20. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    If you put MasterAudio.cs and PlaylistController.cs higher in the Script Execution Order settings, it would ensure their Awake methods get called before any others. There's a way to include the execution order for a script in an asset store package since I know NGUI does it but I'm not sure how exactly.

    Though I personally prefer having a bootstrapper scene. In my current project we started out with the manager objects in all the scenes getting auto-destroyed if there were copies, but kept running into issues where somebody would change one in one scene and forget to apply the changes to the prefab, or try to change something for a scene just to test it and forget to revert it, leaving it to get carried through to other scenes and then things would break in all sorts of annoying ways. So we switched to having all the global objects in one scene and things have been much smoother.
     
  21. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Thanks for that tidbit, I'll add it to the readme.
     
    Last edited: Apr 26, 2014
  22. ImpossibleRobert

    ImpossibleRobert

    Joined:
    Oct 10, 2013
    Posts:
    521
    I would still go for including this option. I finetuned it a little more as there was a small bug in the code. After the destroy you actually need to call return; Otherwise the code after the destroy will still be executed. The tip with the script order is really valuable!

    So far I did not encounter any other errors but I'll definitely look for console warnings and strange effects.
     
  23. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Yeah, I added it last night to the upcoming version, and also added a return statement. Also I took out the check for persist mode. We don't really care if the new one is persist or not. Keep the old one, destroy the new.
     
  24. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    In case anyone's interested, here's a small addition to MasterAudio.cs that's been useful:

    Code (csharp):
    1.  
    2.     public static IEnumerator PlaySoundAndWait(string sType, float volumePercentage = 1f,
    3.         float? pitch = null, float delaySoundTime = 0f, string variationName = null, bool isChaining = false)
    4.     {
    5.         if (!SceneHasMasterAudio)
    6.         {
    7.             yield return null;
    8.         }
    9.  
    10.         if (!SoundsReady)
    11.         {
    12.             Debug.LogError("MasterAudio not finished initializing sounds. Cannot play: " + sType);
    13.             yield return null;
    14.         }
    15.  
    16.         var sound = PlaySound(sType, volumePercentage, pitch, delaySoundTime, variationName, isChaining);
    17.         bool done = false;
    18.         sound.ActingVariation.SoundFinished += () => done = true;
    19.         while (!done)
    20.             yield return new WaitForEndOfFrame();
    21.     }
    22.  
    Then you can use it within Coroutines to wait until a sound stops playing before moving to the next line, like this:

    Code (csharp):
    1.  
    2.     public IEnumerator MyCoroutineExampleSpritePopup()
    3.     {
    4.         sprite1.enabled = true;
    5.         yield return StartCoroutine(MasterAudio.PlaySoundAndWait("Sound1"));
    6.         sprite2.enabled = true;
    7.         yield return StartCoroutine(MasterAudio.PlaySoundAndWait("Sound2"));
    8.         sprite3.enabled = true;
    9.         yield return StartCoroutine(MasterAudio.PlaySoundAndWait("Sound3"));
    10.     }
    11.  
     
  25. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Yeah looks useful, thank you!

    It looks like it needs some changes though. If the sound is "busy" or loops, you'll never get to the next line I think. You should probably have it abort if ActingVariation is null or both ActingVariation.SoundPlayed is false and ActingVariation.SoundScheduled is false.

    Also you should avoid repeatedly creating the class WaitForEndOfFrame, that takes up performance. I'll make those changes and put it in the code base :)
     
    Last edited: Apr 27, 2014
  26. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Master Audio V3.5.3 will be live in about 20 minutes. Changelog:

    • Added code to delete "duplicate" Master Audio and Playlist Controller prefabs that may exist when changing Scenes when you don't use a Bootstrapper Scene. A white "info" is logged when this happens to tell the user in case they didn't plan for that to happen.
    • Added methods to Master Audio: PlaySoundAndWaitUntilFinished, PlaySound3DAtTransformAndWaitUntilFinished, PlaySound3DFollowTransformAndWaitUntilFinished. These need to be called with StartCoroutine and will wait until a sound finishes playing (or can't play), before continuing. This way you can chain any number of sounds together. Playing sounds with these methods always plays the Variation non-looped, so that you don't get into a situation where your CoRoutine might never end.
    • Added a checkbox for "Bus Dialog Mode", only visible and available if you have bus voice limit set to 1. If you check the box, the bus will now behave like a Dialog Sound Group. In other words, every time a sound is about to be played through the bus, all sounds already being played by the bus will be stopped.
    • Changed colors of buses so they're distinct from Sound Groups on the mixer.
    • Mixer's Group active voice count now shows red any time all Variations are busy, not just when the optional Polyphony limit has been reached.
     
  27. uniphonic

    uniphonic

    Joined:
    Jun 24, 2012
    Posts:
    130
    PlaySoundAndWaitUntilFinished sounds like a very handy addition!

    Does this have sample accurate timing, so that it could be used to chain gapless loops without any delay in between, or could it potentially have some minuscule gaps? If the timing is only accurate down to a frame level, then there could potentially be a minuscule gap in between.

    Thanks!
    Jacob
     
  28. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    For performance reasons, we only check for "end of clip" in a Coroutine every .1 seconds, so it will not be gapless. The vast majority of our users are on mobile, and they don't want expensive scripts running all the time. Are you saying that a gapless option would be handy?
     
    Last edited: Apr 27, 2014
  29. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    More than that. Even if your loop was called constantly, it still wouldn't be gapless because of the code that detects and calls SoundFinished, which is also written to be not performance intensive.
     
  30. uniphonic

    uniphonic

    Joined:
    Jun 24, 2012
    Posts:
    130
    Yes, though from what I've read, the more precise way to play without gaps is with AudioSource.PlayScheduled

    https://docs.unity3d.com/Documentation/ScriptReference/AudioSource.PlayScheduled.html

    Now that I'm thinking about it maybe it would be better handled by a playlist controller? Would it be possible for you to switch the way that the Playlist Controller triggers it's next audio to use the PlayScheduled, calling it enough in advance to ensure that it will be sample accurate seamless (gapless) transition between audio files in all situations?

    According to the docs: "This is the preferred way to stitch AudioClips in music players because it is independent of the frame rate and gives the audio system enough time to prepare the playback of the sound to fetch it from media where the opening and buffering takes a lot of time (streams) without causing sudden CPU spikes." They also give a nice example of it's usage.

    Thanks!
    Jacob
     
  31. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Thanks for the info! I'm writing it down for later. Playlist Controller is already usually (always?) gapless because it checks for end of clip during every frame. PlayScheduled is only available in Unity 4+, so we can't make that a core feature. I think when Unity 5 comes out, we will probably drop support for Unity 3, but for now we can't add core features that require U4. We have a good number of customers on Unity 3. Hopefully they will upgrade to 5 (and just skip 4).
     
  32. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    By the way, I'm giving a 10-minute demo of "how to hook up Master Audio to a game with no audio" at the Seattle Unity User Group meeting this Wednesday 4/30 at 7pm. Any of you users or potential users in Seattle might want to come check it out. I'll be hooking up our game Treasure Tombs: Ra Deal and showing Playmaker actions, EventSounds (including Mechanim event sounds), Variations, Playlists, simple code and more.

    I'll try to have it recorded but I'm not sure if the quality will be good enough to post.
     
  33. uniphonic

    uniphonic

    Joined:
    Jun 24, 2012
    Posts:
    130
    Checking every frame is not a completely reliable way to be gapless. Even if your game runs at a reliable 60 fps on all systems (which would be difficult to guarantee), that still means that there are 16 milliseconds between each frame, so the previous audio clip could end any time in those 16 ms. This means that in some situations there could be as much as a 16 millisecond gap between audio clips. A 16 millisecond gap is easily perceived by the human ear, especially if there is a sustained sound in both audio files being stitched together. If the game is running at 30 fps, then the gap could be double that.

    My vote would be to add the sample accurate stitching now, with the existing functionality as fallback for Unity 3.5 users. It's possible to add compiler directives for Unity versions ( https://docs.unity3d.com/Documentation/Manual/PlatformDependentCompilation.html ), so it seems like it would be doable, though I understand that could add more difficulty for debugging. Either way, I'm guessing it could take a fair amount of effort to change, so it's understandable if it will be a while before it's updated.

    Thanks!
    Jacob
     
  34. uniphonic

    uniphonic

    Joined:
    Jun 24, 2012
    Posts:
    130
    Thanks for the info! Don't know if I'll be able to make it this time, but I might try to attend some time in the future. :)
     
  35. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I hear you on that. I think most people just use a short crossfade between songs and call it "good enough". We certainly do that in our games. We do know about the compiler directives for Unity versions and we're already using them in several places in both our plugins. We prefer to keep that for only non-core features so we don't have to code things 2 different ways and have to worry about supporting both.

    Anyway, I've put this on our to do list and we'll investigate how difficult it is while keeping the existing as a fallback, as you've suggested. Thanks!
     
  36. bieronp

    bieronp

    Joined:
    May 1, 2014
    Posts:
    2
    Hi.

    I'm using ur master audio plugin, I'm having problem with performance, i notice that at the first time i play a sound, my game will be lag for a while, i used deep profiler and notice that ur master audio cost quite much performance, after that, it work very well, how can i get solve this problem? i want to cache or somethings like that to able play smooth at the first time, and in settings, i already use clip, and sure that all sounds 're loaded in to memory, i attack some screenshoots below, plz take a look and help me. Thanks

    this is first time
    $Screen Shot 2014-05-01 at 5.45.03 PM.png

    this is second time
    $Screen Shot 2014-05-01 at 5.45.20 PM.png

    this is my settings
    $Screen Shot 2014-05-01 at 5.48.43 PM.png
     
  37. Ninjuit

    Ninjuit

    Joined:
    Jul 7, 2012
    Posts:
    9
    I'm having trouble figuring out how to even start using your program. I've looked at the documentation, but my Master Audio prefab looks nothing like what's in the documentation?

    $3d1f5dd3048f3a13450dfe62424c90bb.png

    I apologize if I'm doing something wrong here, but is this due to me using Unity 4.3?

    Ah. I'm in debug mode: I'M DUMB.
     
    Last edited: May 2, 2014
  38. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I did that a few times before I figured out what debug mode even was! Haha no big deal. Let us know if you have any other questions.
     
  39. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I took a closer look tonight with deep profiler and made 4 code changes that made it faster, by up to about 40%. There was a couple lookups I now cache, a list that got converted to a dictionary for faster lookup, and some other slow code. Now fixed. But the rest is out of my hands until we get the new multi-threading capabilities of Unity 5. It's still not nearly as fast as I'd like, however I believe there are a series of red herrings in there. For instance, I don't believe the profiler saying that operations like "List.Remove" take 45 milliseconds when there's only 3 items in the list. And then the second time they take 0-2 milliseconds with the same number of items after the pool refills? Simply not possible. I think a lot of that is just the profiler being innacurate.

    Now for a hack, you could add code like this to silently trigger and then stop a Sound Group instantly, at the end of the Awake event in MasterAudio.cs.

    Code (csharp):
    1.         var result = MasterAudio.PlaySound("Arrow", 0f);
    2.         if (result != null  result.SoundPlayed)
    3.         {
    4.             result.ActingVariation.Stop();
    5.         }
    And then the next time you really want to hear it, it will run much more quickly. I don't see why this hack actually works, since I believe all the code is optimized now. But it does. Maybe Unity has some weird "wake up script" stuff going on when you first use a MonoBehavior? I can't figure it out.
     
    Last edited: May 2, 2014
  40. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Master Audio v3.5.3.1 will be live in 20 minutes.

    Changes are the above performance increases for playing sound effects, by ~40% on my computer.
     
  41. bieronp

    bieronp

    Joined:
    May 1, 2014
    Posts:
    2
    cool thanks, i'm waiting for new version now ^^
     
  42. cloudcamaleoniv

    cloudcamaleoniv

    Joined:
    May 17, 2013
    Posts:
    57
    So, about a week ago, I've sent you a demo about having issues with playlist transitions when Time.timeScale = 0.

    You sent me a quick-fix and a few days later uploaded the new version with it.

    The tests were okay on the computer, and only yesterday I've created a build for the android. And the problem is still happening there, but ONLY sometimes (???), sometimes it plays the next song, sometimes it doesnt.

    Do you have any idea what might be causing this?
     
  43. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I do not. I assume you have no crossfade and are wanting to immediately go to the next song when the previous one is over?
     
  44. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    By the way, there may be some "pre-warming" I can do in the Awake method to make things run faster when you really call them later. I'm still investigating. It might make a big difference. No promises though :(
     
  45. cloudcamaleoniv

    cloudcamaleoniv

    Joined:
    May 17, 2013
    Posts:
    57
    Yeah, sorry for the lack of info.

    It is exacly this. I have two audio files, one that represents the initial part of a song, and the other represents the loop. 0 crossfade time between them.
     
  46. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Ok. Can you try changing the Update method in PlaylistController.cs to instead be FixedUpdate? I believe that's guaranteed to run regardless of frame rate. See if that works inside Unity and if so, makes the problem go away on Android.
     
  47. cloudcamaleoniv

    cloudcamaleoniv

    Joined:
    May 17, 2013
    Posts:
    57
    No man, sorry, I've renamed the Update method to FixedUpdate inside PlaylistController's class and now it's not working on the PC either.
     
  48. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Right, that's because of zero time scale (slaps forehead). It won't even execute FixedUpdate in that case. Ok I'll see if I can reproduce this behavior somehow and do a fix for it.
     
  49. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Hey man, I did the prewarming code as I suggested to you as a hack, but in optimal mode. And it's actually shaving about 94% of the time off the first call! So I'm definitely going to roll this into the next version. I have one more speed optimization I'm going to see if I can fit in as well.
     
  50. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    What kind of frames per second are you getting on that game on an Android device? If you had an especially slow couple frames, it could miss the code that detects the end of song. You could try changing this variable in EventCalcSounds.cs:

    Code (csharp):
    1.     public const int FRAMES_EARLY_TO_TRIGGER = 2;
    Put it at 5 and see if that works for you. I probably won't have a quick fix and this might get you by in the meantime.