Playing Musical Notes

In addition to playing audio files and different types of drum beats, Scratch lets you play musical notes with various instruments using the sound code blocks shown in Figure 11.6.

Figure 11.6. These sound blocks let you play notes using musical instruments.


The first code block plays a note for a particular number of beats. You can specify a note either by typing it into the code block’s first input box or by clicking on the drop-down list located inside the code block’s input field, which displays a graphic representation of a piano keyboard. Using this keyboard, you can select a note by clicking on one of the keyboard keys, as demonstrated in Figure 11.7. The range of available notes is from 0 to 127, with 60 representing the middle C note.

Figure 11.7. Selecting a note is as easy as clicking on a piano key.


The second code block shown in Figure 11.6 specifies the instrument to be used and is designed to be used in conjunction with the first control block. It supports a total of 128 different instruments, numbered 1 to 128. You can select an instrument by keying its number into the block’s input field or by selecting an instrument from the block’s drop-down list, as demonstrated in Figure 11.8.

Figure 11.8. Selecting the instrument you want play within your Scratch application.


The following script demonstrates how to use both of the code blocks shown in Figure 11.6 to play a C note followed by a D note using a harpsichord. Each note is played for .5 beats.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.240.26