This screencast will show you how to let your DJ control the frequency of a repeating soundusing the scrollbars on the screen. DJs mix short sounds, called samples, of other musicor sounds into the underlying track to create a new song. As the DJ drags the scrollbar,the sound of the sample speeds up or slows down.
First, choose the sample sound that you want to mix into your song. Just like with themusical loop track, you want it to play forever once the flag is clicked. Go ahead and addthe blocks needed to play the sound forever and to start running the code when the flagis clicked. This block stack probably looks quite familiarto you by now. There is the starting event block "when flag clicked" that will startrunning this stack when the flag is clicked...and since there are two of these, both the "meow"sound and the "techno" sound will start when the flag is clicked.
This example shows a forever loop and the “play sound” block that will make themeow sound keep playing over and over again once it is started.
Try out the code. That doesn’t sound so good, does it? The meow is playing over andover again so quickly, no single meow ever finishes. Try adding a “wait” block tospace out the sound more. Usually, the best way to solve a problem like this one is tokeep trying blocks and testing the code until you find the fix that works for your project.
That's better! But what if you want to speed up or slow down the “meow” sound? Youcan change the “1” second to any number you want...like 4. That works, but it wouldbe too hard to keep changing that number while the user is mixing in even more sounds. Computerscientists like you often build tools others will use. So, they need to keep the usersof their programs in mind when they build. For example, the computer scientists who builtthe DJ mixing tools you saw in today’s starting screencast had to think about making a toolfor the DJs that was both powerful and easy to use. You want this tool to be as easy touse as possible for future contestants in your “battle of the DJs.”
It is too hard to change the number to control the speed of the sound and press the spacebarto make the sound play at the same time. In the next screencast, you'll learn how to makea sliding control to adjust the speed of your repeating sound.
Now, it's your turn. Add a sound that will play repeatedly once the green flag is clicked.
Remember, if you get stuck, you can always ask a neighbor for help or put up your stickyto get the attention of your CS First Guru.