matthes
New Member
Posts: 14
Posts: 14
|
Post by matthes on Oct 2, 2015 15:26:12 GMT
Hello, i have a problem where the triggered sound effects is delayed by about a second. I have also the feeling that they than dont play overlapped (like multitrack) but sequentially. In that way its possible that the level is finished (i stay in the scene) and i have several sounds still playing for some seconds which where triggered before.
This is happening on HTC Desire HD and Iphone 4. Its not happening in the editor and Ipad4.
I am not 100 percent but pretty sure that this didnt happen in older versions of the plugin/unity. Currently I use Unity 5.2.1f1 and Master Audio 3.5.8.6 and trigger the sounds with Playmaker "Play sound" Action.
Any ideas?
|
|
matthes
New Member
Posts: 14
Posts: 14
|
Post by matthes on Oct 2, 2015 18:43:54 GMT
I made further tests. This delay is NOT happening when playing Unity sounds directly! Only with the sound groups in master audio plugin! I triggered them side by side. I also changed the latency setting in the Unity Audio Manager but it didnt change the behaviour.
|
|
|
Post by DarkTonic Dev on Oct 2, 2015 20:00:14 GMT
I made further tests. This delay is NOT happening when playing Unity sounds directly! Only with the sound groups in master audio plugin! I triggered them side by side. I also changed the latency setting in the Unity Audio Manager but it didnt change the behaviour. This does not happen with our game and I have no way to troubleshoot just based on words. You will need to use the profiler to narrow down where the problem is. Note that there have been zero reports of this before now. Are you using Resource files or Internet files? Those are expected to have delays. Did you write a script to play the Sound you tested outside of Master Audio for comparison? May I see that script? Also if you can check on an older version of MA and find a version that behaves differently, that would be useful information.
|
|
matthes
New Member
Posts: 14
Posts: 14
|
Post by matthes on Oct 3, 2015 10:07:29 GMT
Hi, thanks for your answer. Did you do tests on older mobile devices with your game? I am not using resource or internet files. The same project worked on the particular devices without lag in the past.
I will do further tests trying to narrow the problem on monday. I use Git so i can try to find the last version where everything was okay. I will also try to create a small repro project to make sure its not project specific.
I use Playmaker for 90 percent of my coding so i use the Playmaker action "play sound" to compare to your "Master audio play sound" action. This is the code of the "play sound" action (which wil cause no delay):
// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.
using UnityEngine;
namespace HutongGames.PlayMaker.Actions { [ActionCategory(ActionCategory.Audio)] [Tooltip("Plays an Audio Clip at a position defined by a Game Object or Vector3. If a position is defined, it takes priority over the game object. This action doesn't require an Audio Source component, but offers less control than Audio actions.")] public class PlaySound : FsmStateAction { public FsmOwnerDefault gameObject; public FsmVector3 position; [RequiredField] [Title("Audio Clip")] [ObjectType(typeof(AudioClip))] public FsmObject clip; [HasFloatSlider(0, 1)] public FsmFloat volume = 1f;
public override void Reset() { gameObject = null; position = new FsmVector3 { UseVariable = true }; clip = null; volume = 1; }
public override void OnEnter() { DoPlaySound(); Finish(); }
void DoPlaySound() { var audioClip = clip.Value as AudioClip;
if (audioClip == null) { LogWarning("Missing Audio Clip!"); return; }
if (!position.IsNone) { AudioSource.PlayClipAtPoint(audioClip, position.Value, volume.Value); } else { var go = Fsm.GetOwnerDefaultTarget(gameObject); if (go == null) { return; }
AudioSource.PlayClipAtPoint(audioClip, go.transform.position, volume.Value); } }
} }
|
|
|
Post by DarkTonic Dev on Oct 3, 2015 16:55:48 GMT
That code for the custom action looks fine. We have used Master Audio with iPhone4, iPad2 and Samsung Galaxy 3 as far as old devices. No problems were apparent with our games. Let me know if you find a version that behaves differently or find a line number in particular that has bad performance. We've already done in-depth optimizations a couple times.
|
|
matthes
New Member
Posts: 14
Posts: 14
|
Post by matthes on Oct 5, 2015 9:19:55 GMT
Okay i think i narrowed down my problem.
Because of debugging another problem (broken unity splashscreen on iOS) i deactivated "Preload Audio data" in all my sound files. This caused the delay! Reactivating the Preload and my problem is gone!
I am a bit confused now what is the best way to load and unload the Audio. I already re-read the last two chapters of your manual.
My game has only one scene (which doesent reload during a session) and I am using two dynamic sound groups (switchable audio skins, instantiated on demand). With "Preload Audio data" enabled I have a quiet long load time on Scene load because everything is loaded into memory, even the second not yet instantiated dynamic sound group is loaded.
Is there a way to do the preloading manually? I would like to preload the content of the dynamic sound group only on instantiation instead of scene load. Would it make sense to deactivate "Preload Audio data" and load each clip with "AudioClip.LoadAudioData" command after instantiating the dynamic sound group?
Thanks for your help!
|
|
|
Post by DarkTonic Dev on Oct 5, 2015 17:45:09 GMT
I believe a reference to your Dynamic Sgc in another game object (the one that instantiates it) is causing the audio to preload even when not instantiated. You will need to eliminate that somehow. You may have to load the Dynamic Sgc as a resource...
|
|
matthes
New Member
Posts: 14
Posts: 14
|
Post by matthes on Oct 5, 2015 19:06:48 GMT
Yes thats the case. Maybe its a Playmaker issue. I switched from instantiation to an additive async scene load (using an empty scene just the Dynamic scg prefab)that way its not preloaded on entering the main level.
thanks again.
|
|
|
Post by DarkTonic Dev on Oct 5, 2015 20:05:05 GMT
No problem
|
|