2. Choose your Track and Play a Note


(Instructor) In this screen cast (techno music)

you select the main music track for your DJ mixer and add a sound that plays when the space bar is pressed.

This screen cast will walk you through creating the code, then you'll try it out.

With DJ music there's usually a consistent sound or repeating musical loop that underlines the entire track.

Then your DJ chooses other sounds to insert, or play over that track.

You need to choose a repeating musical loop that will play behind whatever your DJ adds to your music.

To do that click on your DJ sprite, then select a sound that is a musical loop from the music loops menu.

A music loop is a sound that is designed to play over and over to make a continuous song.

(techno music)

Add a block that will play your selected sound until it is done whenever the flag is clicked.

This will tell the computer to start playing the background music as soon as your program is run.

Test that code to see if it's working.

Remember it's important to test your code often while you're working to make sure it is doing exactly what you want it to.

(techno music)

Cool it works, but there's one problem, the music only plays once.

You want it to play continuously while the DJ's mixing on top of that track.

To make the happen place a forever loop around it, so it will play over and over again.

Now it will play forever.

Test that out.

(techno music)

The DJ should mix in a note on top of that track when the space bar is pressed.

To make that happen, click on the events tab and choose the one space key press block.

Select a sound that will play when the space bar is pressed.

Use a set instrument block to the instrument you want played and the play note block to choose the sound.

Remember you can click the block to test the instrument, and notes you selected, (music note)

to see if you like them.

(music note) If it doesn't sound quite right the first time keep trying.

(music note)

Choose choose a different instrument or sound (music note) and test it again until you find what works best.

Try it out and see if it works.

(techno and music notes)

Cool when the space bar is pressed a note plays.

You now have a DJ mix over a repeating track.

The DJ can add a single note to the sound while pressing a key.

Now it's your turn.

Choose a music loop and make it play forever when the flag is clicked.

Use the one key press block to set the instrument, and play a note.

Choose any sounds or notes you like for your music, and mix with the play note or beats values until you get a sound that you like.

When you are done with these steps return to this CS First tab and click the green arrow to move on to the next screen cast.


  1. Choose the main music track for your DJ Mixer.
  2. Program the main music track to play continuously when the green flag is clicked.
  3. Use a "forever" loop to make a musical note play forever.