paalo
New Member
Posts: 4
Posts: 4
|
Post by paalo on Jun 7, 2020 23:56:27 GMT
Hi. I've setup a looping sound which should fade out when we stop it. I've already added a `Custom FadeInTime` and a `Custom FadeOutTime`, yet it doesn't work. So here's some debugging I did: Right after i Play the sound I have these values: PlaySoundResult.ActingVariation.useFades: true PlaySoundResult.ActingVariation.curFadeMode: FadeMode.FadeInOut
But right before I stop the same sound (or probably the next frame), the `curFadeMode`-field has been modified somehow, but the `useFades`-field is still true: PlaySoundResult.ActingVariation.useFades: true
PlaySoundResult.ActingVariation.curFadeMode: FadeMode.None --- We're using this to set the reference for the PlaySoundResult variable: playSoundResult = MasterAudio.PlaySound("myDSG") And we're using this to stop the current variation's loop: playSoundResult.ActingVariation.Stop();
So what am I missing here? Why aren't any of the fades triggering? It's really bad, the sounds get very audibly cut short when using `PlaySoundResult.ActingVariation.Stop()`. So is there a different way to stop the current object's loop to get the fades working? Here are the Sound Variation's settings on my Dynamic Sound Group: imgur.com/a/c5t6LPVThanks in advance! Pablo Sorribes Bernhard Composer, Sound Designer & Programmer contact@pablosorribes.com pablosorribes.com
|
|
|
Post by DarkTonic Dev on Jun 8, 2020 7:11:12 GMT
It sounds like you think that a fade starts when you tell a sound to stop. No, stop means stop. No fade, nothing, just stop. If you want a looping to fade you can call FadeOutNow() on the ActingVariation.
I've had a few people ask this same question before, but I'm not sure why one would think that "stop" means to start a fade. Is there some documentation that's not clear?
Anyway, that should fix you.
-Brian
|
|
paalo
New Member
Posts: 4
Posts: 4
|
Post by paalo on Jun 8, 2020 8:52:55 GMT
Hi Brian. If I can activate a property called "Use Custom Fading" which has two floats "Fade In Time" and "Fade Out Time", I will assume that FadeIn is coupled with Playing the sound, and FadeOut is coupled with Stopping the sound. I have almost never wanted/needed to abruptly stop a sound without at least a small fade out (~0.125-0.250s) before stopping it, especially loops since they are the ones that most often need fading to sound good. I also want to stop the sound to save resources, cause a sound at lowest volume is still going to take some memory/CPU, unless MasterAudio does some magic behind the scenes and stops the sound for me, which in that case the name "FadeOutNow()" doesn't really convey that that is happening.
What I mean is that other in audio middleware applications, if you have added settings/modulation for fading out, they fade out the sound for you on Stop. Eg. FMOD has a bool "allowFadeout" when you're stopping an event, which you can override if you don't want to allow the event to play out its FadeOut when you stop it. Else the event will fade out exactly as you have designed it, which I would see as expected behaviour.
So what I would like to have is a Stop() method which receives a float for fading out (or just takes the values from the SoundGroup's "FadeOutTime"-property), and optionally gives you the alternative to send in a method/action that is going to be executed when the sound has been stopped, eg:
// Default Stop function - takes the fade out time (if any) from the SoundGroup void Stop(System.Action onStoppedAction = null)
// Overload where the user can force a fadeout void Stop(float fadeOutTime, System.Action onStoppedAction = null)
Or use a nullable float if you want to make it into one function:
// Using nullable float to avoid having two functions void Stop(float? fadeOutTime = null, System.Action onStoppedAction = null) Hope this clarifies the reasoning behind my question.
Regards,
Pablo Sorribes Bernhard Composer, Sound Designer & Programmer
contact@pablosorribes.com
pablosorribes.com
|
|
|
Post by DarkTonic Dev on Jun 8, 2020 16:00:18 GMT
Hi Brian. If I can activate a property called "Use Custom Fading" which has two floats "Fade In Time" and "Fade Out Time", I will assume that FadeIn is coupled with Playing the sound, and FadeOut is coupled with Stopping the sound. I have almost never wanted/needed to abruptly stop a sound without at least a small fade out (~0.125-0.250s) before stopping it, especially loops since they are the ones that most often need fading to sound good. I also want to stop the sound to save resources, cause a sound at lowest volume is still going to take some memory/CPU, unless MasterAudio does some magic behind the scenes and stops the sound for me, which in that case the name "FadeOutNow()" doesn't really convey that that is happening. What I mean is that other in audio middleware applications, if you have added settings/modulation for fading out, they fade out the sound for you on Stop. Eg. FMOD has a bool "allowFadeout" when you're stopping an event, which you can override if you don't want to allow the event to play out its FadeOut when you stop it. Else the event will fade out exactly as you have designed it, which I would see as expected behaviour. So what I would like to have is a Stop() method which receives a float for fading out (or just takes the values from the SoundGroup's "FadeOutTime"-property), and optionally gives you the alternative to send in a method/action that is going to be executed when the sound has been stopped, eg: // Default Stop function - takes the fade out time (if any) from the SoundGroup void Stop(System.Action onStoppedAction = null)
// Overload where the user can force a fadeout void Stop(float fadeOutTime, System.Action onStoppedAction = null)
Or use a nullable float if you want to make it into one function: // Using nullable float to avoid having two functions void Stop(float? fadeOutTime = null, System.Action onStoppedAction = null) Hope this clarifies the reasoning behind my question. Regards, Pablo Sorribes Bernhard Composer, Sound Designer & Programmer contact@pablosorribes.com pablosorribes.com It doesn't concern me what other middleware does. What concerns me is to make the product logical. Stop does not mean fade, it means stop. Plain and simple. What you proposed it not logical to me - it's actually counter-intuitive and confusing, plus there's already a way to do it. Maybe you would never call Stop but some people do. You call FadeOutNow, which actually uses the Custom Fading settings you have set up. If your sound was not looping, the fade would happen automatically without any coding. And then if you want it to stop when it's done fading, there are checkbox under Fading settings in Advanced Settings to make that the default. Thanks, -Brian
|
|
paalo
New Member
Posts: 4
Posts: 4
|
Post by paalo on Jun 10, 2020 22:33:31 GMT
Hi Brian, From a programmer's point of view, then yes, "Stop means Stop". From a sound designer's point of view, calling "Stop" on an event which has been setup with a custom FadeOut should not mean "Stop your sound immediately and completely ignore the settings you've setup for your sound in the inspector". If so, the sound designer wouldn't have added any FadeOut-settings, or would have otherwise specified that the sound should be stopped abruptly for this specific instance / game event.
So it may not concern you what other middleware does, but the users of your product will most likely have a set of expected default behaviours from those other programs. And to completely ignore the FadeOut-option - which the user has specifically activated and setup for that sound - when calling Stop(), is in most cases not the expected behaviour. You even mentioned that yourself:
So it seems like several users are expecting a different behaviour, and the documentation isn't clear enough about that "PlaySoundResult.ActingVariation.Stop()" doesn't use any possible fades and just stops the sound abruptly. Maybe you could change the summary of the method to be something like this instead:
/// <summary> /// This method allows you to stop the audio being played by this Variation. /// <para> /// This will stop the sound immediately without respecting any fades. /// For fading out before stopping the sound: Set <see cref="MasterAudio.stopZeroVolumeGroups"/> to TRUE and /// use <see cref="FadeOutNow"/> instead. /// </para> /// </summary> /// <param name="stopEndDetection">Do not ever pass this in.</param> /// <param name="skipLinked">Do not ever pass this in.</param> public void Stop(bool stopEndDetection = false, bool skipLinked = false) { ---
I was obviously already calling Stop(). What I would want is to have an option to either respect the FadeOut-settings I added in the inspector, or to specify that I want to Stop the sound immediately instead.
---
Your suggestion works, but it's more of a workaround and really isn't an obvious way of achieving what we wanted to do. It's not obvious because the user has to know that they should go to the Advanced Settings, enter a submenu of settings, check one specific bool and then (most importantly) call "FadeOutNow()" to stop the sound using the fades that have been setup for the variation. And calling a function called "FadeOutNow" to stop the sound isn't in any way clean and readable code. Also, using your logic from before, normally: "FadeOutNow" doesn't mean "Stop". This workaround effectively makes "FadeOutNow" = "Stop", which isn't really in line with your logical standpoint from before.
Another issue with this workaround is that since this is a global setting, it removes the possibility of eg. fading out a SoundGroup, have it be quiet but still looping, and then after a while fade it in again. Now you'll have to trigger "Play()" in-between that and the sound will not continue playing and updating its position.
Finally, I think I've made my request and improvement suggestion clear, but if you can't see the point here, then let's agree to disagree.
------
WORKAROUND:
If someone else runs across this problem, we made this function in our GameAudio-class (a static class which wraps some of the MasterAudio functionality for us, etc) which gives us the ability to stop a sound and use the fades (if there are any) before stopping it OR to override any fades and stop the sound immediately instead. It's a workaround, but it gives us the functionality that we want and makes the code cleaner and more readable for us.
This is how you would call it:
//Allow any Fades to play out before stopping the sound. GameAudio.StopSound(playSoundResult);
//Override fade-settings and stop the sound immediately instead. GameAudio.StopSound(playSoundResult, stopImmediate: true);
And here's the function:
public static void StopSound(PlaySoundResult soundResult, bool stopImmediate = false) { if (soundResult == null) return; if (!soundResult.ActingVariation.IsPlaying) return;
//Ignore any fading settings in the variation and stop immediately if (stopImmediate) { soundResult.ActingVariation.Stop(); return; }
//No fades setup in the variation, will stop the sound immediately if (!soundResult.ActingVariation.useFades) { soundResult.ActingVariation.Stop(); return; }
//Incorrect "Advanced Fading Settings" in the MasterAudio-prefab for //automatically stopping the sound when fully faded out. if (!MasterAudio.Instance.stopZeroVolumeGroups) { Debug.LogWarning($"Trying to fade out a SoundGroup on Stop, but the Advanced Fading settings aren't correctly setup. \n\n" + $"Go to 'MasterAudio-prefab > Advanced Settings > Fading Settings' and set the 'Sound Groups'-toggle to TRUE. \n\n" + $"Meanwhile, we'll do a hard-stop instead.");
soundResult.ActingVariation.Stop(); return; }
//Use FadeOutNow if all requirements are met, since the "Advanced Fading Settings" in //the MasterAudio-prefab should take care of stopping the group when it reaches zero volume. soundResult.ActingVariation.FadeOutNow(); } Hope that helps someone else down the road!
Regards,
Pablo Sorribes Bernhard Composer, Sound Designer & Programmer contact@pablosorribes.com pablosorribes.com
|
|
|
Post by DarkTonic Dev on Jun 11, 2020 7:46:32 GMT
Thanks for remaining civil with your lengthy informative replies. You're actually the 2nd person to ever ask this question about the stop. We have many thousands of users. Yes, I was speaking from a programmer point of view. The majority of Master Audio that reach out to us for support haven't used any audio middleware before. Those who have usually stick with what they know and works for them. For those people there are no expected default behaviors. I have gone ahead and updated the C# comment for Stop to tell you how to do a fade and stop, thank you for that. I've also modified the warning box to the Variation's Inspector making it clear that fade out settings are not used automatically in looping clips, if you have loop checked and that you must call FadeOutNow to use them. Previously the Fade Out time setting was actually hidden for looped clips, which was an error. Correct that FadeOutNow does not mean "fade out and stop". The stop part is just an option that is global so that you "don't forget" to stop sounds that are silent. Yes it would disallow you from fading to zero and have it playing silently. Actually I was about to add an optional callback for FadeOutNow where you could call stop or whatever, but I saw that the code does stop the audio at the end of the fade all the time (that makes sense actually). So, I have changed the method to FadeOutNowAndStop I did add the callback as well for any other desired code. There's also a FadeToVolume method on the Variation that does a fade to a volume you specify and doesn't stop the Audio Source at the end. I've now added a completionCallback to that so you can stop if you like. Thanks, -Brian
|
|
paalo
New Member
Posts: 4
Posts: 4
|
Post by paalo on Jun 16, 2020 9:10:26 GMT
Hi Brian! Cool, thanks for the reply. Seems like very good additions to the API, I'm looking forward to using them. In what version are these changes present? /Pablo
|
|
|
Post by DarkTonic Dev on Jun 16, 2020 15:41:23 GMT
The version that isn't published yet.
Will do that hopefully later this week.
|
|