Sure:
https://editor.p5js.org/ejgutierrez74/sketches/kJqSEtqQg
The full project is here: GitHub - SinkorAzon/ProjectePacMan
The relevant code is to play sound when they test if the player have win, if player wins, sounds a music of win, and then as restartGame…they reset canvas, fillmap with images, and sounds and initial sound…
Something similar is when player looses. A sound of losing game and then restart game. Actually we want a initial sound, before beginning every game, and is overlapped with the losing sound and wining sound.
A very dirty solution would be to join the two mp3 in a bigger one, so it would play the loose or win sound + initial game sound.
If it doesnt exist could be interesting some treatment of more than one song…some parameter in play, that if the song doesnt finish, p5 could not advance to the following line of code.
If you need any more information id kindly try to help.
Thanks for your effort and time.