Skip to content

Instantly share code, notes, and snippets.

@bytezen
Created June 25, 2019 16:51
Show Gist options
  • Save bytezen/3180652c60c16ab1a3ef859b2b805984 to your computer and use it in GitHub Desktop.
Save bytezen/3180652c60c16ab1a3ef859b2b805984 to your computer and use it in GitHub Desktop.
ncgs workshop demo
##| National Coalition of Girls Schools
##| Conference 2019
##|
##| Hands-On Workshop
##| "From Bleep, Blip, Boop to Variables, Arrays, and Loops: Teaching with Sonic Pi"
##|
##| g(irl)-funk
##| by: bytezen
use_bpm 114
# Basic Kick Pattern - play the 1st beat of the first and third bar only
the_floor = bools 1,0,0,0, 0,0,0,0, 1,0,0,0, 0,0,0,0
# Snares will give us a back beat pattern
# Play the snares on the second and fourth beat of each bar
back_beat = bools 0,1,0,1, 0,1,0,1, 0,1,0,1, 0,1,0,1
# play the hats on the in between beats of the pattern
# the timing of this pattern is different.
# In this pattern every number represents half of a beat
hats = bools 0,1,0,1,0,1,0,1, 0,1,0,1,0,1,0,1, 0,1,0,1,0,1,0,1, 0,1,0,1,0,1,0,1
##| Below are the three loops that generate the 3 different patterns
##| in our drum section
##| All of the loops play AT THE SAME TIME because that
##| is the way that live_loop works
##|---------- this loop plays the kick sound
live_loop :kick do
on the_floor[ tick ] do
sample :bd_boom, sustain: 0.5, release: 0.15
end
# wait 1 beat before resuming the loop
sleep 1.0
end
##|---------- this loop plays the snare sound
live_loop :snare do
on back_beat[tick] do
sample :drum_snare_soft
end
# wait 1 beat before resuming the loop
sleep 1.0
end
##|---------- this loop plays the hi_hats sound
live_loop :hi_hats do
on hats[tick] do
sample :drum_cymbal_closed, amp: 0.4
end
# wait 1/2 beat before resuming the loop
sleep 0.5
end
##| Setup the structure for the bass line
notes = ring 41, 42, 42, 41,
39, 39, 41, 42,
42, 41, 39, 39,
41, 42, 42, 41,
39, 39, 41, 42,
42, 41, 39, 39,
41, 42, 42, 41,
39, 39, 41, 42,
42, 41, 39, 39,
41, 42, 42, 41,
39, 39
et = 0.5
st = 0.25
durations = ring et, st, et, st,
et, st, et, st,
et, st, et, et,
et, st, et, st,
et, st, et, st,
st, et, st, et,
st, et, st, et,
st, et, st, et,
st, et, st, et,
st, et, st, et,
st, st
##| da bass line
live_loop :bass_line do
play notes[ tick ]
sleep durations[ look ]
end
##| a simple chord progression over the bass line
live_loop :progression do
play 65, sustain: 3.5, release: 1, amp: 0.5
play_chord [53, 56, 60], sustain: [4.0, 5.0].choose # amp: 0.0
sleep 4
##| play
play_chord [54, 58, 61], sustain: [2.0, 5.0].choose # amp: 0
sleep 4
play_chord [63, 66,70], sustain: [4.5].choose #, amp: 0
sleep 4
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment