Created
January 3, 2021 21:20
-
-
Save mrjoshida/72fbc7c039da3fc91b7bca42fa398e71 to your computer and use it in GitHub Desktop.
Exemplar code for the Chapter 3 project Scales and Intervals in the book Coding and the Arts (creativecodingbook.com). Paste into Sonic Pi to run.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use_bpm 120 | |
current_note = 60 | |
play(current_note) | |
sleep(1) | |
# C Major scale using single variable | |
current_note = current_note + 2 | |
play(current_note) | |
sleep(1) | |
current_note = current_note + 2 | |
play(current_note) | |
sleep(1) | |
current_note = current_note + 1 | |
play(current_note) | |
sleep(1) | |
current_note = current_note + 2 | |
play(current_note) | |
sleep(1) | |
current_note = current_note + 2 | |
play(current_note) | |
sleep(1) | |
current_note = current_note + 2 | |
play(current_note) | |
sleep(1) | |
current_note = current_note + 1 | |
play(current_note) | |
sleep(1) | |
# Minor scale using a list of intervals and a loop | |
intervals = [0, 2, 1, 2, 2, 1, 2, 2] | |
8.times do |index| | |
current_note = current_note + intervals[index] | |
play(current_note) | |
sleep(1) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment