I wrote code to play a rhythm. I want to reuse this code and use two different live_loops to simultaneously:
a. play a bassline by passing a sample as the argument to my function, and
b. play a melody by passing notes as the argument to my function
Unfortunately, if you are playing a note you use the keyword “play” and if you are playing a sample you use the keyword “sample”. Is there any way to write a function that will be able to, depending on the argument, produce the desired sound at the function-specified rhythm? (See code below)
# Code below is NOT functioning as desired
use_bpm: 140
define :songrhythm do |a, b, c, d, e, f, x|
play a, amp: x, sustain: 1.5
sleep 1.5
play b, amp: x, sustain: 1.5
sleep 1.5
play c, amp: x, sustain: 1.5
sleep 1.5
play d, amp: x, sustain: 0.5
sleep 0.5
play e, amp: x, sustain: 1
sleep 1
play f, amp: x, sustain: 1
sleep 2
end
live_loop :bass do
s = sample :drum_bass_hard
songrhythm s, s, s, s, s, s, 4
end
live_loop :melody do
use_synth :fm
songrhythm :b2, :b2, :b2, :g2, :g2, :g2, 1
end