Skip to content

Instantly share code, notes, and snippets.

@sumpygump
Created March 18, 2016 06:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sumpygump/5789d996d172c597b54e to your computer and use it in GitHub Desktop.
Save sumpygump/5789d996d172c597b54e to your computer and use it in GitHub Desktop.
Sonic Pi Songs
# Reticent Memory
# By Jansen Price 3/17/2016
# For Sonic Pi v2.9
use_bpm 124
# Don't log as much
use_debug false
# Set random seed
use_random_seed 7
# Defines
measure = 0 # Used for tracking measure
principal = true # Every 4th measure is a 'principal' measure
root = :c3 # Starting root note
# Main loop handles master clock
live_loop :main do
tick # Trigger tick every eighth note
# 1 2 3 4 5 6 7 8 <= eighth notes
# 1 3 5 7 <= quarter notes
beat = (look % 8) + 1 # Using eighths notes
measure += 1 if beat == 1
principal = (measure % 4 == 1) # Principal bar starts each hyperbar (4 bars)
# Display measure
print "Measure " + measure.to_s + '.' + (beat/2).to_s
# Pick a random note every 4 bars
if beat == 1 and principal
root = choose([:c3, :g3, :f3])
end
# Cue the clock
# These values are sent along to each live loop that syncs with this
cue :master, measure: measure, beat: beat, principal: principal, root: root
# Tock
sleep 0.5
end
# Kick drum
live_loop :kick do
m = sync :master
# Play kick drum every quarter note
sample :bd_fat, amp:2 if [1,3,5,7].include? m[:beat]
# Play another kick at the end of each hyperbar
sample :bd_fat, amp:2 if m[:measure] % 4 == 0 and m[:beat] == 8
end
# Drums
lfo_a = (range 60, 130, step: 10).reflect
live_loop :drums do
m = sync :master
# Cycle through a LPF cutoff frequency range
lpf_cutoff = lfo_a[m[:measure]]
# Reverb mix level
rev_mix = 0.4
with_fx :lpf, cutoff: lpf_cutoff do
with_fx :reverb, mix: rev_mix do
sample :perc_snap if [1].include? m[:beat]
sample :drum_cymbal_pedal if m[:principal]
sample :drum_cymbal_closed if [2,4,6,8].include? m[:beat]
sample :sn_dolf if [7].include? m[:beat]
sample :sn_zome if [3,7].include? m[:beat]
sample :drum_tom_lo_soft, amp: 2 if [4,6].include? m[:beat]
sample :drum_cymbal_hard if m[:principal] and m[:beat] == 1
end
end
sleep 0.5
end
# Bass 1
lfo_b = (range 60, 80, step: 0.1).mirror
live_loop :bass do
m = sync :master
# Cycle through a LPF cutoff frequency range
lpf_cutoff = lfo_b[m[:measure]]
# Play drone-like bass
sample :bass_trance_c, rpitch: m[:root]-note(:c3), cutoff: lpf_cutoff, attack: 0.1, release: 1
sleep 2
end
# Bass 2
live_loop :bass2 do
m = sync :master
use_synth :sine
with_fx :distortion do
play m[:root]-12
sleep 0.5
play m[:root]
sleep 0.5
play m[:root]-12
sleep 7
end
end
# Synth stabs
lfo_c = (range 70, 90, step: 0.2).mirror
live_loop :stabs do
m = sync :master
use_synth :prophet
# Cycle through a LPF cutoff frequency range
lpf_cutoff = lfo_c.tick
# Play stab first beat of every measure
play chord(m[:root]+12, :minor7), cutoff: lpf_cutoff, attack: 0, release: 6 if m[:beat] == 1
# Play additional stab every other measure on the 4th beat of measure
play chord(:ab4, :minor7), cutoff: lpf_cutoff if m[:beat] == 8 and m[:measure]%2 == 0
sleep 0.5
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment