Transition one piece of music to another

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Robster
:warning: Old Version Published before Godot 3 was released.

Hi all,

Does anyone have some tips on how to do this? I am using a Streamplayer and as the scenes change I change the music. It just cuts off though. I’d like to do a fade or even better a crossfade between song files.

:bust_in_silhouette: Reply From: Zylann

You could create a scene that is structured like this:

- Node (with script)
    - StreamPlayer1
    - StreamPlayer2

The script would expose helper functions for playing and cross-fading music.
Then save this as a scene, make it a singleton with auto-load, so it will continue playing/update as you change scenes, and you will be able to access it from all scenes.

Now all you have to do is to implement a “cross fade” within the script, which can be done by playing something on both StreamPlayers and using two Tweens to change the volumes over time.

Edit: it made me want to investigate that… and I came up with an easy to use music manager that can play music with multiple cross-fade and delaying support (without tweens though). Pretty basic but works well, I might submit it on Github and the assetlib :smiley:

You need only one tween though, as they can interpolate many values at once.

Bojidar Marinov | 2016-11-26 12:16

Ok I had no time to submit an asset yet, but here is the repo GitHub - Zylann/godot_music_manager: A simple music player that supports fading

Zylann | 2016-11-26 23:14

Thank you, good idea.

I guess I wanted to just keep the one streamplayer and hopefully play both songs at once in different channels or similar but that will definitely work.

I didn’t realise the tweening was so capable and able to be used in so many different ways. Thanks so much for the advice.

Robster | 2016-11-28 03:51