Skip to content

Instantly share code, notes, and snippets.

@tn800
Created December 27, 2013 13:26
Show Gist options
  • Save tn800/8146906 to your computer and use it in GitHub Desktop.
Save tn800/8146906 to your computer and use it in GitHub Desktop.
シーケンスのサンプルをシンプルにしてみた
# sequenceのサンプルコードをシンプルにしてみた
# $はグローバル変数
$pattern = [
'x--- x--- xx-- xxx- xxxx xxx- x-x- x-xx'
'xxxx x--x --xx xxx- --xx xxx- x-x- xx--'
].map (x)-> (x.replace /\s+/g, '').split '' #二次配列に切り分けてる?
synth = SynthDef (freq, dur=0.25)->
Out.ar(0, SinOsc.ar(freq) * EnvGen.kr(Env.perc(), doneAction:2) * 0.3)
.send()
Task ->
freqs = [60,62,64,65].midicps()
Infinity.do syncblock (i)->
switch $pattern[0].wrapAt(i)#上のパターン1列目をまわす
when 'x' then Synth(synth, freq:freqs.wrapAt(i))
#xの時に音を出しているので、文字列から音列作るとかも楽しそう
switch $pattern[1].wrapAt(i) #上のパターン2列目
when 'x' then Synth(synth, freq:freqs.wrapAt(i)/2)
"bpm132 l4".wait() #bpm表記と4分音符
.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment