[Zapworks Studio] Fade audio

Is there any way to fade an audio in Zapworks Studio? I have a client who wants me to make an audio fade away instead of abruptly stopping. While the fade can be added in the audio itself, this solution doesn’t work if the audio can be stopped at any time (for example, the audio starts to loop, the user taps on ‘next’ and changes environment, stopping the audio at any point).

Is there any way at all to make the audio fade in Studio? If not, please add a way to do it. Thanks!

1 Like

You can do it with a frame handler and an audio_node.volume([left_vol,right_vol]) call, feeding it values from 1 down to 0.

20 steps is a reasonably graceful fade (vol -= 0.05 each frame), not too fast on a modern phone, not too slow on an old one. It’d be nice to have a more automatic method, but this is flexible, at least, and if you want to get all smarty-pants you could do a logarithmic fade, or take the frame time delta into account.

2 Likes

I just thought of this as well…I can just animate the volume. How did I not think about this before?

1 Like

Hey @marks,

Spot on @howiemnet, Audio nodes have a .volume(number[]) property, you can update that over time to fade in / out the audio clip.

Please be aware, I think Safari rounds the volume value to either 0 or 1, so this might not be a fully functional solution in WebAR. Worth a test though!

George

FWIW it’s been working well with my devices (mostly recent iOS, couple of Android phones). May have to try and dig out some older phones to double-check with, though as long as it works well on most devices (and especially the one in your client’s hand) it’s not exactly a show-stopper if the audio does just cut off