How do I make each sound file play separately on different screens? p5

I have 8 seperate sound files for 8 different screens (Want to play the first one for screen 1, the second one for screen 2 etc), however it's playing them all at once in every screen?

Currently I have this in a function called chooseSong(); (for all 8 sound files):

if(screen === 1){
song1.loop();
song1.play();
} else {song1.stop();
       }

if(screen === 2){
song2.loop();
song2.play();
} else {song2.stop();
       }

What am I doing wrong lol, I'm just a beginner with p5 so I have no clue :)

Tagged:
Sign In or Register to comment.