Lag when changing music mid-game

When I change the music during my game, the game lags a lot for a couple of seconds before it loads the music. Is there a way to prevent this (maybe loading the sound file in setup but not playing it until it’s ready)?

I put all my sounds/music in one file, with short blank silences in between, and just played it starting from different places to get the different music. I didn’t notice any lag.

That’s a good idea. I was completely changing tracks.

@Ignatz How do I start the music from a different position?

@disorientedperson the reference is your friend:

https://codea.io/reference/Sounds.html#music.currentTime