今日はSonic Piを。
DAWでできないようなループを作るのもいいけど、
ちゃんと16ビートとか作れたらなあと思って試してみた。
aは8ステップ、bは4ステップ。aを頭出しするときにbを1進める。
そうすることで実質 8 x 4の32ステップになる。
if文で音の出力を制御することで色々できる。
a = 0
b = 0
vol = 1
live_loop :_20180102 do
use_bpm 120
in_thread do
cue :synth
cue :chord
cue :bass
cue :beat
a = a + 1
end
in_thread do
use_synth :supersaw
if b == 4
play_pattern_timed chord(:A5, :maj9),0.5, amp:0.5
else
play_pattern_timed chord(:A6, :maj9),0.25, amp:0.3
end
end
in_thread do
sync :chord
use_synth :tri
if a < 4
play chord(:A3, :major), release:0.8
else
play chord(:G3, :major), release:0.8
end
if a == 8
play chord(:C5, :major), amp:1,release:2
end
end
in_thread do
sync :bass
if a == 7 && b == 2
play 48, amp:2,release:0.5 if one_in(4)
sleep 1
play 36, amp:2,release:2
end
use_synth :sine
if a < 4
if one_in(3)
play 45, release:0.8,amp: 1.5
else
rrand_i(3,5).times do
play 45, release:0.8,release:0.5,amp:rrand(0.8,1.2)
sleep 0.5
end
end
else
if one_in(5)
play 43, release:0.8,amp:1.5
else
3.times do
play 43, release:0.8,release:0.5,amp:rrand(0.8,1.2)
sleep 0.5
end
end
end
end
in_thread do
sync :beat
sample :bd_tek, amp:2
if b == 4
4.times do
sample :drum_snare_soft,amp:vol
sleep 0.25
end
vol = vol + 0.5
else
vol = 1
if a == 8
sample :drum_snare_hard,amp:1.8
sleep 0.5
sample :drum_snare_hard,amp:2
end
end
if a == 3 || a == 7
sleep 0.5
sample :drum_cymbal_open,amp:rrand(0.5,1),rate:3
else
sleep 0.5
sample :drum_cymbal_closed,amp:2,rate:1
end
end
sleep 1
if a == 8
a = 0
if b < 4
b = b + 1
else
b = 0
end
end
print a,b
end
b = 4の時のロールができたときは嬉しかったです。
慣れればもっともっと複雑なことができそう。