+1 vote

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.

in Engine by (837 points)

1 Answer

+4 votes
Best answer

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 :D

by (29,090 points)
selected by

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

Ok I had no time to submit an asset yet, but here is the repo https://github.com/Zylann/godot_music_manager

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.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.