Making a button change between two codes?

I'm creating Arduino Mega drum pads for a friend and we would like a setup where we can change between the sounds with the click of a button. How could I combine two codes and switch between them?

Use an extra variable that toggles between the modes when the button becomes ‘activated’.

Use that variable to execute the one code or the other.