Skip to content

Instantly share code, notes, and snippets.

@jackdreilly
Last active November 18, 2017 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackdreilly/a547d82e0d7f3e549701e10066542b9d to your computer and use it in GitHub Desktop.
Save jackdreilly/a547d82e0d7f3e549701e10066542b9d to your computer and use it in GitHub Desktop.
Sonic Pi Confessions III - BadBadNotGood
use_synth :tech_saws
use_bpm 120
# Base scale
song_scale = scale :cs3, :aeolian, num_octaves: 2
# There are two phrases played by the lead, x1, and x2.
# They are two different 16th note riffs.
x1 = [5,7,8,5,7,8,8,5,7,5,7,8,8,5,7,8]
x2 = [6,7,8,6,7,8,8,6,7,6,7,8,8,6,7,8]
# The lead cycles between repeating each phrase.
seqs = (ring x1, x1, x2, x2)
# The lead line live_loop.
# I used a live loop here so that all other threads can
# cue on :sax.
live_loop :sax do
# Grab the next sequence to play.
cs = seqs.tick
# Loop through each note in the sequence.
cs.size.times do |i|
# Play this note.
# We subtract one so that x1 and x2 can be written
# in a 1-indexed fashion.
n = cs[i] - 1
# We cannot use play_pattern_timed since we want to make
# the release and attack varied between each note.
play song_scale[n], release: rdist(0.1, 0.4), attack: rdist(0.03, 0.05)
# Sixteenth notes.
sleep 0.25
end
end
# This thread cues the song structure.
in_thread(name: :cuer) do
# HOW DO WE MAKE THIS 4 INSTEAD?
# We want the sax by itself for 4 measures.
# We sync 3 times on sax since this thread "misses" the first cue.
3.times do
sync :sax
end
# Now Start the bass drum
cue :bass_drum_cue
4.times do
sync :sax
end
# Now start the high hat.
cue :highhat_cue
4.times do
sync :sax
end
# Now start the bass guitar.
cue :bass_guitar_cue
end
# The rhythm of the bass drum and bass guitar.
bass_rhythm_spacing = [0, 0.5, 1.0, 1.25, 1.75, 2, 3.5]
# The odds that a particular note should be played in the bass rhythm.
play_note_odds = [1,1,0.7, 1, 1, 1, 0.7]
# What to play for each measure of the bass.
define :bass_drum_loop do
at bass_rhythm_spacing, play_note_odds do |i, j|
sample :drum_bass_soft if rrand(0,1) < j
end
end
# Bass drum thread.
in_thread(name: :bass_loop) do
# Wait for the cuer thread to start us.
sync :bass_drum_cue
loop do
sync :sax
bass_drum_loop
end
end
# The bass guitar shares the same rhythm as the
# bass drum. but changes its root note, based on
# this sequence.
bass_notes = (ring 1, 1, 6, 6, 5, 5, 6, 6)
# Same structure as bass_drum_loop, except playing a note based on the bass_notes ring.
define :bass_guitar_loop do | note |
at bass_rhythm_spacing, play_note_odds do |i, j|
play note, release: rdist(0.1, 0.3), attack: 0.0 if rrand(0,1) < j
end
end
# Bass guitar thread.
in_thread(name: :bass_guitar_loop) do
use_synth :subpulse
# Wait for the cueing thread to kick this off.
sync :bass_guitar_cue
loop do
sync :sax
bass_guitar_loop (song_scale[bass_notes.tick - 1] - 12 * 2)
end
end
in_thread(name: :highhat_cue_loop) do
sync :highhat_cue
loop do
sync :sax
at [1, 3] do
sample :drum_cymbal_pedal
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment