Created
February 7, 2018 12:55
-
-
Save kn1kn1/94cd517a63c1523e6ac0e510c4bb8359 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
live_loop :l1 do | |
loop_chop(:loop_mehackit2, 4, 5, 1.0, 1.5, true) | |
end | |
def loop_chop(loop_name, prob_chop = 0, prob_rev = 0, pitch_shift_mix = 0.0, amp = 1.0, pick = false, rate = 1.0) | |
dur = sample_duration(loop_name) * rate | |
onsets = sample_buffer(loop_name).onset_slices | |
onsets = onsets.shuffle if pick | |
onsets.each do |onset| | |
puts "onset: #{onset}" | |
with_fx :pitch_shift, mix: pitch_shift_mix, pitch: [3, 6, 12].choose, window_size: [0.001, 0.01, 0.05].choose do | |
start = onset[:start] | |
finish = onset[:finish] | |
idx = onset[:index] | |
s = dur * (finish - start) | |
r = 1.0 | |
r = -1.0 if one_in prob_rev | |
rate = r / rate | |
in_thread do | |
if one_in prob_chop | |
d = rrand_i(4, 8) | |
puts "d: #{d}" | |
d.times do | |
sample loop_name, onset: idx, amp: 0.25*amp, rate: rate | |
sleep s / d | |
end | |
else | |
sample loop_name, amp: 1.0*amp, start: start, finish: finish, rate: rate | |
end | |
end | |
sleep s | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment