I currently trying to explore a way to make the bgm fade in/out when I'm switching in a transition from a map to a new area. As the screen fades out (as a transition), I want the music to slowly fade out as well. Same thing when I'm entering a new map where I want the bgm to fade in.
Is there a way to get started with that? I've been looking around for some scripts.
Exercise: code it yourself. (Hint: use timers to change the volume in a smooth way.)
You should probably know before you try coding though, I don't think Solarus has two tracks for music, so crossfading would (as far as I can tell) be impossible, since playing a new track automatically overwrites the current track. I'd recommend a quicker fade so there isn't much silence. Or embrace the silence and compose tracks like Breath of the Wild's.
Something else I thought of- there's a few games I've played (Metroid, Hollow Knight) that when transitioning between areas, have a room with no music. The rooms also visually transition between the spaces, and you could use map:on_started() in the transition room to get the music that was playing from a savegame variable, and fade it out, then in the first room of each area use map:on_opening_transition_finished to fade in music that you start silently on map:on_started.