CSD Unit 3, Lesson 17, Bubble 7

Hi:

My student is creating a game where one sprite turns into another and another, eventually showing 2-3 cars that are going to race.

A light appears which goes from red to yellow to green, and while each color appears a beeping sound occurs followed by a longer beep when the cars go.

The problem is that when the code is run, instead of the 4-second beep sequence playing, you hear a solid tone that never stops. It’s as if every time the routine runs, the sound starts to play but gets cut off as the code routine ends and starts again. The result is that something like a 1/100th of a second of sound plays from the start of the YouTube sound, and then the code is run again, causing another tiny burst of sound. This continues over an over in such a way that the tone played sounds like it goes on and on instead of the three beeps for red, yellow, and green. I hope that makes sense.

Originally, the student had the sound somewhere in lines 30-80, but all he got was the constant single, ongoing sound.

I thought that the beginning of the sound kept playing because it was in some form of loop. So the student put the sound at the end of the code - outside the draw loop, but nothing worked then.

YouTube Sound: Mario Kart Race Start - Gaming Sound Effect (HD) - YouTube

My student and I were trying to figure out why the code played the sound but not all of it. Is there a standard amount of time the a code routine allows for the playing of a sound each time it runs through the routine? How can you make the code stop for the whole sound file to play before going on with the routine?

(Also, this came up during the discussion: Is there a “repeat routine” command/loop we can use when writing the code? In the Hour of Code lesson with Elsa, there is a loop where you can write in how many times a routine should be run - and that was easy. But we can’t find something that helpful - ! - in CSD. Are we missing something?)

Thank you, very much.

Gary Ellis

Hi @gellis1,

The link you shared is unavailable. It says it is not available for sharing.

I do have an example that might work for you in this post or this project. Sound is a common problem to solve! If that doesn’t work, check the sharing settings on the link you posted so we can take a better look.

And yes, there are loops that run for a given amount of time. The “for” loop and the “while” loop. They are both in the control block section. I did try the while loop on the project above but the same issue you described occurred (It’s as if every time the routine runs, the sound starts to play but gets cut off as the code routine ends and starts again) so not sure that would work for you.

Hopefully the workaround above works. If not, let us know and try sharing the project again. Good luck!!

~Michelle