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.
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.
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.
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.
3.16.69.199