Sound in games distorts


A team is adding music to their game. It sounds fine when they place the sound OUTSIDE the draw loop. It is super distorted to the point of static if they place it INSIDE the draw loop. They need it inside the loop to control when it plays. We can’t figure out why it’s distorted. Any ideas?


Figured it out! Well, this works:

function draw() {
playSound(“crab.mp3”, false);

They hadn’t stopped the sound. Adding that line of code makes it not distort inside the draw loop.



Great problem solving!



I’m throwing this back out there for more feedback. This solution doesn’t work consistently? Any ideas what we are doing incorrectly?



Hi Susan,

I think the main problem is that the sound is restarting every time you run the draw loop, which is causing distortion. It’s really hard to know without a link to the actual project, though. Can you click the “Share” button and paste the link here so other people try to help?