I’m getting to grips with Unity’s native plugin API and during my process callback I’m attempting to use the UnityAudioEffectState flags to determine whether the plugin is bypassed or not, like so:
auto isPlaying = ((state->flags & UnityAudioEffectStateFlags_IsPlaying) != 0);
auto isMuted = ((state->flags & UnityAudioEffectStateFlags_IsMuted) != 0);
auto isPaused = ((state->flags & UnityAudioEffectStateFlags_IsPaused) != 0);
auto bypassed = ! isPlaying || (isMuted || isPaused);
However the UnityAudioEffectStateFlags_IsPaused does not seem to be set when I pause the scene in unity. Oddly enough it does seem to be set if I then focus another application window and then return to Unity.
Am I misunderstanding the purpose of this flag, or is this a bug in the API?
UnityAudioEffectStateFlags_IsPlaying = 1 << 0, // Set when engine is in play mode. Also true while paused. UnityAudioEffectStateFlags_IsPaused = 1 << 1, // Set when engine is paused mode. UnityAudioEffectStateFlags_IsMuted = 1 << 2, // Set when effect is being muted (only available in the editor) UnityAudioEffectStateFlags_IsSideChainTarget = 1 << 3, // Does this effect need a side chain buffer and can it be targeted by a Send?
maybe it is useful, IsPlaying is true even in pause.
Sure, but the issue is that the _isPlaying flag doesn’t seem to be set correctly, which results in the plugin not being bypassed when pausing in Unity.
Isn’t it monitoring the audio source (play,muted,pause) connected to the mixer where the plugin resides and not Unity Editor. So I guess the audiosource is still playing (source is in pause but not stop) in unity pause mode.
If so, the plugin might be bypassed as soon as the source is stopped.
The mixer channels get bypassed as well as audio drops below the assignable treshold per mixer. This should bypass all effects in those channels as well.