Hardware Reference
In-Depth Information
Click Play and the delay between the notes will decrease, giving the effect of speeding
up the tune. The value 150 in this code is the beats per minute (BPM).
FIGURE 7-7 Using a list in Sonic Pi to play notes
Repeating Lines in a Loop
Musical tunes are sometimes made up of repeating notes or phrases. For example, in
Twinkle Twinkle Little Star , the third and fourth lines, “up above the world so high” and
“like a diamond in the sky”, use the same notes. In your Sonic Pi code you could type
these lines out twice, like this:
play_pattern [67,67,65,65,64,64,62]
sleep 0.5
play_pattern [67,67,65,65,64,64,62]
Or instead you could use a loop:
2.times do
play_pattern [67,67,65,65,64,64,62]
sleep 0.5
end
Search WWH ::




Custom Search