form size(500, 290), caption(""), pluginID("plu1")
button bounds(420, 16, 80, 30), channel("But01"), text("Show Values"), fontcolour("white"),latched(0)
button bounds(420, 50, 80, 30), channel("But02"), text("Update"), fontcolour("white"),latched(0)
rslider bounds(420, 120, 60, 60),range(0, 280, 120, 1, 1), colour("red"), textbox(1),channel("Tempo"), trackercolour("pink"),textbox(0),text("Tempo")
button bounds(420, 50, 80, 30), channel("ButPlay"), text("Play","STOP"), colour:0("lime"),colour:1("red"),fontcolour("white"),latched(1),identchannel("ButPlayR")
groupbox bounds(0, 0, 390, 80), text("K I C K"), colour("lighgrey"), fontcolour("black"){
vslider bounds(0, 18, 10, 60),range(0, 127, 0, 1, 20), colour("red"), textbox(0),channel("S1_1")
vslider bounds(10, 18, 10, 60),range(0, 127, 0, 1, 20), colour("lightblue"), textbox(0),channel("S1_2")
vslider bounds(20, 18, 10, 60),range(0, 127, 0, 1, 20),colour("lightblue"), textbox(0),channel("S1_3")
vslider bounds(30, 18, 10, 60),range(0, 127, 0, 1, 20),colour("lightblue"), textbox(0),channel("S1_4")
vslider bounds(50, 18, 10, 60),range(0, 127, 0, 1, 20), colour("red"), textbox(0),channel("S1_5")
vslider bounds(60, 18, 10, 60),range(0, 127, 0, 1, 20),colour("lightblue"), textbox(0),channel("S1_6")
vslider bounds(70, 18, 10, 60),range(0, 127, 0, 1, 20),colour("lightblue"), textbox(0),channel("S1_7")
vslider bounds(80, 18, 10, 60),range(0, 127, 0, 1, 20),colour("lightblue"), textbox(0),channel("S1_8")
vslider bounds(100, 18, 10, 60),range(0, 127, 0, 1, 20), colour("red"), textbox(0),channel("S1_9")
vslider bounds(110, 18, 10, 60),range(0, 127, 0, 1, 20),colour("lightblue"), textbox(0),channel("S1_10")
vslider bounds(120, 18, 10, 60),range(0, 127, 0, 1, 20),colour("lightblue"), textbox(0),channel("S1_11")
vslider bounds(130, 18, 10, 60),range(0, 127, 0, 1, 20),colour("lightblue"), textbox(0),channel("S1_12")
vslider bounds(150, 18, 10, 60),range(0, 127, 0, 1, 20), colour("red"), textbox(0),channel("S1_13")
vslider bounds(160, 18, 10, 60),range(0, 127, 0, 1, 20),colour("lightblue"), textbox(0),channel("S1_14")
vslider bounds(170, 18, 10, 60),range(0, 127, 0, 1, 20),colour("lightblue"), textbox(0),channel("S1_15")
vslider bounds(180, 18, 10, 60),range(0, 127, 0, 1, 20),colour("lightblue"), textbox(0),channel("S1_16")
vslider bounds(200, 18, 10, 60),range(0, 127, 0, 1, 20), colour("red"), textbox(0),channel("S1_17")
vslider bounds(210, 18, 10, 60),range(0, 127, 0, 1, 20),colour("lightblue"), textbox(0),channel("S1_18")
vslider bounds(220, 18, 10, 60),range(0, 127, 0, 1, 20),colour("lightblue"), textbox(0),channel("S1_19")
vslider bounds(230, 18, 10, 60),range(0, 127, 0, 1, 20),colour("lightblue"), textbox(0),channel("S1_20")
vslider bounds(250, 18, 10, 60),range(0, 127, 0, 1, 20), colour("red"), textbox(0),channel("S1_21")
vslider bounds(260, 18, 10, 60),range(0, 127, 0, 1, 20),colour("lightblue"), textbox(0),channel("S1_22")
vslider bounds(270, 18, 10, 60),range(0, 127, 0, 1, 20),colour("lightblue"), textbox(0),channel("S1_23")
vslider bounds(280, 18, 10, 60),range(0, 127, 0, 1, 20),colour("lightblue"), textbox(0),channel("S1_24")
vslider bounds(300, 18, 10, 60),range(0, 127, 0, 1, 20), colour("red"), textbox(0),channel("S1_25")
vslider bounds(310, 18, 10, 60),range(0, 127, 0, 1, 20),colour("lightblue"), textbox(0),channel("S1_26")
vslider bounds(320, 18, 10, 60),range(0, 127, 0, 1, 20),colour("lightblue"), textbox(0),channel("S1_27")
vslider bounds(330, 18, 10, 60),range(0, 127, 0, 1, 20),colour("lightblue"), textbox(0),channel("S1_28")
vslider bounds(350, 18, 10, 60),range(0, 127, 0, 1, 20), colour("red"), textbox(0),channel("S1_29")
vslider bounds(360, 18, 10, 60),range(0, 127, 0, 1, 20),colour("lightblue"), textbox(0),channel("S1_30")
vslider bounds(370, 18, 10, 60),range(0, 127, 0, 1, 20),colour("lightblue"), textbox(0),channel("S1_31")
vslider bounds(380, 18, 10, 60),range(0, 127, 0, 1, 20),colour("lightblue"), textbox(0),channel("S1_32")
}
-n -d -+rtmidi=PortMidi -Q 4 -Ma -m 0 -d --midi-key=4
sr = 44100
ksmps = 64
nchnls = 2
0dbfs=1
iJM=1
giOn1 ftgen 0,0,32,2, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
gkTempo =120
gkCounter= 0
instr 1
kindexJM init 0
kindexJM = 0
loop:
S2 sprintfk "S1_%d", kindexJM+1
kTrig changed chnget:k(S2)
if kTrig==1 then
kOn1= chnget :k(S2)
kIdx=kindexJM
tablewkt kOn1,kIdx,giOn1
endif
loop_lt kindexJM, 1, 32, loop
kTrig2 changed chnget:k("But01")
if kTrig2=1 then
event "i",2,0,1
endif
kTrig3 changed chnget:k("But02")
if kTrig3=1 then
event "i",3,0,1
endif
kTrig4 changed chnget:k("Tempo")
if kTrig4=1 then
gkTempo chnget "Tempo"
endif
; Calling the play from this instrument does not work, metro in instr 4 never works correctly...
;kTrig chnget "ButPlay"
;printks "Ktrig %d%n",1,kTrig
;if kTrig == 1 then
; event "i",4,0,-1
; a1 subinstr 4
;else
; gkCounter= 0
; event "i",4,0,0
;schedule 4,0,0
;a1 subinstr 4
;endif
endin
instr 2 ;Print the values
prints "%nFunction Table %d:%n",giOn1
indx init 0
loop:
ival table indx, giOn1
prints "Index %d = %f%n", indx, ival
loop_lt indx, 1, 32, loop
;indx = 0
endin
instr 3 ; update the values
indexJM init 0
loop:
S2 sprintfk "S1_%d", indexJM+1
iOn1 chnget S2
tablewkt iOn1,indexJM,giOn1
loop_lt indexJM, 1, 31, loop
endin
instr 4 ;play the notes
kTrig chnget "ButPlay"
;to be implemented here :
; - Read Tempo rslider and calculate ticks for metro
; - Counter idx from 0 to 31 when tick is = 1
;- Read the table from 0 to 31 (see inst)
; send midi note : i.e. moscil 10, 36, kVelocityFromTable[idx], 0.5
; this is a test for sending midi
k1 metro 0.2
if kTrig == 1 then
if k1 >0 then
kn = 60 + rnd:k(12)
kv = 60+birnd:k(40)
printf "Note %d %d\n",kn,kn,kv
;midion 1,kn,kv
moscil 1,kn,kv,k1,0
endif
endif
;kJMtick metro 1 ;(gkTempo*4)/60
;if kJMtick==1 then
; printk2 gkCounter
; gkCounter= gkCounter+1
;endif
endin
i 1 0 1000
i 4 0.1 1000