Skip to content

Instantly share code, notes, and snippets.

@mrjoshida
Last active January 3, 2021 21:05
Show Gist options
  • Save mrjoshida/8a9f8dacfd943812c60300f093b3712c to your computer and use it in GitHub Desktop.
Save mrjoshida/8a9f8dacfd943812c60300f093b3712c to your computer and use it in GitHub Desktop.
Exemplar code for the Chapter 3 project The Shape of Sounds in the book Coding and the Arts (creativecodingbook.com). Paste into Sonic Pi to run.
use_bpm 120
define :my_sound do |n|
play n,
attack: 0.5,
attack_level: 1,
decay: 0.25,
sustain_level: 0.4,
sustain: 0.75,
release: 0.5
end
2.times do
my_sound('C')
sleep 0.5
my_sound('D')
sleep 1
my_sound('C')
sleep 0.5
my_sound('E')
sleep 1
my_sound('C')
sleep 0.5
my_sound('F')
sleep 1
my_sound('C')
sleep 0.5
my_sound('G')
sleep 3
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment