|
Post by nitrox32 on Dec 2, 2020 15:12:32 GMT
I have a number of characters that are starting the scene inactive. When a trigger is entered they become active. When they activate they sounds they are supposed to play stutter and start rapidly multiple times. Is there a way to stop this without having all the characters in the scene active at once?
|
|
|
Post by DarkTonic Dev on Dec 2, 2020 21:04:11 GMT
Are those Sound Groups already in Master Audio? I don't know why they'd do that. Assuming the sounds are in Master Audio, are they wav files? Did you set up streaming? I would try different import options on the Audio Clips.
|
|
|
Post by nitrox32 on Dec 2, 2020 23:06:28 GMT
Those sound groups are already in Master Audio. The clips are all .wav files. I did not set up streaming for these clips. Should I? I tried putting them in the resource folder, it didn't help.
|
|
|
Post by DarkTonic Dev on Dec 2, 2020 23:08:31 GMT
Streaming can cause audio hiccups. Other than that, I've never heard of any issues like this from any of our 18,000 users. So, I would try different audio import settings. If you like, you can send us a Scene that reproduces the problem as simply as possible.
|
|
|
Post by nitrox32 on Dec 3, 2020 3:57:00 GMT
I've figured out what the problem is. It stems from the Emerald AI integration I've been working on. In a recent post you helped me with the integration by removing all audio sources attached to the AI and replacing all PlayOneShots with the following to each function that plays a sound.
MasterAudio.PlaySound3DAtTransform(idleSounds, gameObject.transform);
This is working out fine for things that get called one at a time such as attack, death, blocking, etc. However, when an AI is idling, it's idling sound function gets called repeatedly thus causing the above code to execute with each frame. This is causing the stuttering and also causing the voice limit to be reached very quickly. Their solution was to check if the Audio Source is still playing, if so, do not start a new sound. If not, it's free to play. Since I no longer have an Audio Source attached to the AI, I need some way to prevent MA from playing a new sound if the an old one is still playing. Does MA have a way to check if an audio source is playing through script so I can prevent the above code from playing every frame?
|
|
|
Post by DarkTonic Dev on Dec 3, 2020 4:06:13 GMT
Of course. It will require you to change some code. You'll need to store a reference to the PlaySound command and check it later. Something like this would work.
private PlaySoundResult playResult; // define this at the class level
// later, check before playing. Make sure to do all your null checks! if (playResult == null || playResult.ActingVariation == null || !playResult.ActingVariation.IsPlaying) { playResult = MasterAudio.PlaySound3DAtTransform(idleSounds, gameObject.transform); }
|
|
|
Post by nitrox32 on Dec 3, 2020 4:56:06 GMT
Still having problems.
private PlaySoundResult playResult;// defined at the class level
public void PlayIdleSound() {
if (playResult == null || playResult.ActingVariation == null || !playResult.ActingVariation.IsPlaying) { Debug.Log("Idle"); MasterAudio.PlaySound3DAtTransform(idleSounds, gameObject.transform); } }
The debug.log is spamming the console. This warning is also spamming the console despite having the voice weights set to 75.
T: 86.01775 - MasterAudio: Bus voice limit has been reached. Cannot play the sound: OrcIdle until one voice has stopped playing. You can turn on the 'Stop Oldest Sound' or 'Stop Farthest Sound' option for the bus to change UnityEngine.Debug:Log(Object) DarkTonic.MasterAudio.MasterAudio:LogMessage(String) (at Assets/Plugins/DarkTonic/MasterAudio/Scripts/Singleton/MasterAudio.cs:8091) DarkTonic.MasterAudio.MasterAudio:CanStopLimitedBusVoice(GroupBus, Boolean, AudioGroupInfo) (at Assets/Plugins/DarkTonic/MasterAudio/Scripts/Singleton/MasterAudio.cs:2579) DarkTonic.MasterAudio.MasterAudio:PlaySoundAtVolume(String, Single, Vector3, Nullable`1, Nullable`1, Transform, String, Boolean, Single, Boolean, Boolean, Boolean, Boolean, Boolean) (at Assets/Plugins/DarkTonic/MasterAudio/Scripts/Singleton/MasterAudio.cs:2035) DarkTonic.MasterAudio.MasterAudio:PlaySound3DAtTransform(String, Transform, Single, Nullable`1, Single, String, Nullable`1, Boolean, Boolean) (at Assets/Plugins/DarkTonic/MasterAudio/Scripts/Singleton/MasterAudio.cs:1772) EmeraldAI.EmeraldAIEventsManager:PlayIdleSound() (at Assets/Emerald AI/Scripts/Components/EmeraldAIEventsManager.cs:69) EmeraldAI.EmeraldAISystem:Wander() (at Assets/Emerald AI/Scripts/System/EmeraldAISystem.cs:1684) EmeraldAI.EmeraldAISystem:Update() (at Assets/Emerald AI/Scripts/System/EmeraldAISystem.cs:1035)
|
|
|
Post by DarkTonic Dev on Dec 3, 2020 5:53:23 GMT
You missed that I specified to assign the return value of the PlaySound command to a variable, so your if statement isn't working and always playing a new one. My above code was correct.
playResult = MasterAudio.PlaySound3DAtTransform(idleSounds, gameObject.transform);
|
|
|
Post by nitrox32 on Dec 3, 2020 12:52:18 GMT
<abbr>Yep, that did it! Sorry I missed that detail. Great product btw, I've used it in all of my games so far. </abbr>
|
|
|
Post by DarkTonic Dev on Dec 3, 2020 17:03:52 GMT
Awesome!
|
|