Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Sail with me into the Pi (part 2)
module NumberMethods
def beat; self; end
def beats; self; end
def triplet; self.to_f / 3; end
def triplets; self.to_f / 3; end
def bar; self * 4; end
def bars; self * 4; end
end
::Numeric.send(:include, NumberMethods)
@vamp_synth = :tri
@bass_synth = :saw
def vamp(notes, length)
use_synth @vamp_synth
length.times do
with_fx :reverb, damp: 0.8, room: 0.4 do
play notes, attack: 0.01, sustain: 1.triplets, release: 1.triplet
sleep 1.beat
end
end
end
def bass_hit(root)
use_synth @bass_synth
root_note = note(root)
notes = [root_note, (root_note + 7), (root_note + 12)]
play notes, :sustain => 2.beats, :release => 2.triplets
sleep 2.beats
end
use_bpm 120
def bass_loop
in_thread do
bass_hit(:Eb2)
sleep 6.beats
bass_hit(:Eb2)
sleep 6.beats
bass_hit(:Db2)
sleep 6.beats
bass_hit(:Gb2)
sleep 2.beats
bass_hit(:Db2)
sleep 2.beats
end
end
def vamp_loop
in_thread do
vamp([:eb4, :gb4, :eb3], 6)
vamp([:eb4, :ab4, :eb3], 2)
vamp([:eb4, :gb4, :eb3], 6)
vamp([:eb4, :ab4, :eb3], 2)
vamp([:db4, :f4, :db3], 8)
vamp([:gb4, :db5, :gb3], 4)
vamp([:db4, :f4, :db3], 4)
end
end
vamp([:eb4, :ab4], 2)
vamp_loop
wait 8.bars
bass_loop
vamp_loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment