Skip to content

Instantly share code, notes, and snippets.

@benjmin-r
Last active January 5, 2021 17:06
Show Gist options
  • Save benjmin-r/c306bddeec95509d327e291c135e9382 to your computer and use it in GitHub Desktop.
Save benjmin-r/c306bddeec95509d327e291c135e9382 to your computer and use it in GitHub Desktop.
Sonic Pi Intro Workshop

This collection of files exists to serve you as starting point in exploring different sounds and how they're programmed in Sonic Pi.
Copy & Paste them into your Sonic Pi editor and start tweaking the values to change the sound.

Keyboard Shortcuts

The Sonic Pi integrated editor has a lot of keyboard shortcuts. A handy list of all shortcuts is integrated in the tutorial browser or online on github.

Attack, Decay, Sustain, Release

This image explains nicely, the four important parameters to controlling played sounds in Sonic Pi.

Appendix

Videos

# taken from [Sam Aaron live coding an ambient electro set w/ Sonic Pi](https://www.youtube.com/watch?v=G1m0aX9Lpts)
live_loop :foo do
notes = (scale :e1, :minor_pentatonic, num_octaves: 3).shuffle
with_fx :lpf, cutoff: 80 do
with_fx :reverb, room: 1, amp: 2 do
with_fx :tanh, krunch: 30, amp: 2 do
n = synth :dsaw, cutoff: 130, release: 8, note: notes.tick, cutoff_slide: 1.5
control n, cutoff: 70
32.times do
sleep 0.125
control n, note: notes.choose
end
end
end
end
end
# taken from https://github.com/samaaron/sonic-pi/blob/master/etc/doc/tutorial/A.03-coded-beats.md
live_loop :amen_break do
p = [0.125, 0.25, 0.5].choose
with_fx :slicer, phase: p, wave: 0, mix: rrand(0.7, 1) do
r = [1, 1, 1, -1].choose
sample :loop_amen, beat_stretch: 2, rate: r, amp: 2
end
sleep 2
end
live_loop :landing do
bass_line = (knit :e1, 3, [:c1, :c2].choose, 1)
with_fx :slicer, phase: [0.25, 0.5].choose, invert_wave: 1, wave: 0 do
s = synth :square, note: bass_line.tick, sustain: 4, cutoff: 60
control s, cutoff_slide: 4, cutoff: 120
end
sleep 4
end
# taken from https://github.com/samaaron/sonic-pi/blob/master/etc/doc/tutorial/A.03-coded-beats.md
# a nicely broken beat ... play around with `phase` and `wave` (valid values are 0, 1, 2, 3)
live_loop :amen_break do
use_bpm 50
with_fx :slicer, phase: 0.25, wave: 0, mix: 1 do
sample :loop_amen, beat_stretch: 2, cutoff: 100
end
sleep 2
end
# taken from https://github.com/samaaron/sonic-pi/blob/master/etc/doc/tutorial/A.04-synth-riffs.md
# a randomly genereated melody
# ... tweak the values for `riff`, `use_synth` or `cutoff` and see how that changes the melody
live_loop :riff do
use_synth :prophet
riff = (ring :e3, :e3, :r, :g3, :r, :r, :r, :a3)
play riff.tick, release: 0.5, cutoff: 80
sleep 0.25
end
# taken from https://github.com/samaaron/sonic-pi/blob/master/etc/doc/tutorial/A.04-synth-riffs.md
# a randomly genereated melody
# ... tweak the values for `scale`, `use_random_seed`, `use_synth` or `cutoff` and see how that changes the melody
live_loop :random_riff do
use_synth :dsaw
use_random_seed 3
notes = (scale :e3, :minor_pentatonic).shuffle
play notes.tick, release: 0.25, cutoff: 80
sleep 0.25
end
live_loop :bass do
use_synth :subpulse
play_pattern_timed [:f2] *4, [0.5]
play_pattern_timed [:c3] *2, [0.5]
play_pattern_timed [:f2] *2, [0.5]
##| can also be written as
##| play_pattern_timed (knit :f2, 4, :c3, 2, :f2, 2), [0.5]
sleep 1
end
live_loop :bass2, sync: :bass do
use_synth :fm
n = chord :c2, :minor
n.size.times do
play n[tick], release: 5
sleep 5
end
end
live_loop :beat, sync: :bass do
sample :bd_haus, amp: 1 if (spread 6, 10).tick
sleep 0.5
end
# taken from https://github.com/samaaron/sonic-pi/blob/master/etc/doc/tutorial/A.04-synth-riffs.md
# Create a rhythm with some randomness
# ... start playing around with the value for use_random_seed and see which rhythm you like best
live_loop :drums do
use_random_seed 500
16.times do
sample :bd_haus, rate: 2, cutoff: 110 if rand < 0.35
sleep 0.125
end
end
live_loop :bd do
sample :bd_haus, cutoff: 100, amp: 3
sleep 0.5
end
# Loop through all available synths, playing a note with each synth
# Nice for getting a feel for the sound/timbre of each synth
synth_names.each do |name|
use_synth name
play 60
sleep 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment