Skip to content

Instantly share code, notes, and snippets.

@xavriley
Created May 26, 2014 20:47
Show Gist options
  • Save xavriley/8ffcacc67853fb623d3f to your computer and use it in GitHub Desktop.
Save xavriley/8ffcacc67853fb623d3f to your computer and use it in GitHub Desktop.
Auto Dubstep example in SonicPi
# Welcome to Sonic Pi v2.0
# SonicPi ish interpretation of
# Dan Stowells' Dubstep Synth:
# All the usual caveats apply - this is just a first attempt at getting it working
# Refinements to follow
@current_bpm = 120.0 # because current_bpm doesn't work for me
use_bpm @current_bpm
define :wob do
use_synth :dsaw
lowcut = note(:E1) # ~ 40Hz
highcut = note(:G8) # ~ 3000Hz
note = [40, 41, 28, 28, 28, 27, 25, 35, 78].choose
duration = 2.0
bpm_scale = (60 / @current_bpm).to_f
# scale the note length based on current tempo
slide_duration = duration * bpm_scale
with_fx :lpf, cutoff: lowcut, cutoff_slide: slide_duration do |c|
play note, attack: 0, sustain: duration, release: 0
wobble_time = [1, 6, 6, 2, 1, 2, 4, 8, 3, 3].choose
c.ctl cutoff_slide: ((duration / wobble_time.to_f) / 2.0)
wobble_time.times do
c.ctl cutoff: highcut
sleep ((duration / wobble_time.to_f) / 2.0)
c.ctl cutoff: lowcut
sleep ((duration / wobble_time.to_f) / 2.0)
end
end
end
in_thread do
loop do
with_fx :reverb do
wob
end
end
end
in_thread do
loop do
[1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0].each do |kick|
sample :drum_heavy_kick if kick == 1
sleep 0.5
end
end
end
in_thread do
loop do
sleep 2
sample :drum_snare_hard
sleep 2
end
end
@samaaron
Copy link

:-) Much fun! Thanks for this.

@texas845
Copy link

i like it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment