Just some notes on Sonic Pi
- To accompany this tutorial: http://tinyurl.com/wwc-sonic-pi
- Link to this page: http://tinyurl.com/sonic-pi-cheatsheet
- Walkthrough for live demo during intro: https://gist.github.com/claritee/753811cc42ee4d304dba3399a4d57fa1
play 60
play :C4
Lowest (0) to highest (100)
Middle C is 60
:C4
is a symbol for C in 4th Octave
play [50, 55, 62]
play choose([50, 55, 62])
play [50, 55, 62][1]
sleep 0.5
Sleep for 0.5 sec
play 60, amp: 0.3
play 60, amp: 0.9
play 60, amp: 10.0
play :c4, release: 1.0
Hold the note for 1 sec
loop do
play 60
sleep 0.5
play 62
sleep 0.5
end
2.times do
# code
end
Pre-recorded sounds e.g. bells, beeps
use_synth :fm
play 60
Other ones to try:
- mod_saw
- blade
- dtri
- pretty_bell
sample :loop_amen
sample :perc_bell, rate: (rrand 0.125, 1.5)
play_pattern_timed scale(:c3, :major), 0.3, release: 0.5
Same as
play_pattern_timed [:c3, :d3, :e3, :f3, :g3, :a3, :b3, :c4], 0.3, release: 0.5
Define the method
define :ring_perc_bell do
sample :perc_bell, rate: (rrand 0.125, 1.5)
sleep rrand(0,2)
end
Then use the method:
loop do
ring_perc_bell
end
play chord(:E3, :minor)
play_pattern chord(:E3, :m7)
play_pattern_timed chord(:E3, :m7), 0.25
# 1st thread - melody/backing track
in_thread do
loop do
# code
end
end
# 2nd thread - the actual notes
in_thread do
loop do
# code
end
end
Music can be changed and adapted in real time, not just play pre-written programs.
define :my_loop do
play 50
sleep 1
end
loop do
my_loop
end
To change this in real time:
- Press play, then change the note, press play again. The music changes live
live_loop :foo do
play 60
sleep 1
end
To change this in real time:
- While playing, change the note and press play