Csound Csound-dev Csound-tekno Search About

if then on midi PC by a controller

Date2017-06-17 15:58
FromFrancesco Porta
Subjectif then on midi PC by a controller
Hi all,
i would like to use a midi controller to make some actions in csound.
The controller send only Program Change message and I'm trying to do this:
when i first push a pedal csound will start an instrument, the second time another, ecc.

My attempt is this (below) and is not working (obviously :)) because (i guess) every kcycle the array
at same index is update to a new value.
Now how can i resolve this?

Thanks in advance for any idea,
ciao,
francesco.


gkArrayStatus[] init 128

instr 30 

kstatus, kchan, kdata1, kdata2 midiin

if kchan==8 then && kdata1>0 then

	printks2 "PG: %d\n", kdata1

	if gkArrayStatus[kdata1]==0 then
		printks2 "REC array: %d\n", gkArrayStatus[kdata1]
		gkArrayStatus[kdata1] = 1
	elseif gkArrayStatus[kdata1]==1 then
		printks2 "PLAY array: %d\n", gkArrayStatus[kdata1]
		gkArrayStatus[kdata1] = 2
	elseif gkArrayStatus[kdata1]==2 then
		printks2 "PAUSE array: %d\n", gkArrayStatus[kdata1]
		gkArrayStatus[kdata1] = 3
	elseif gkArrayStatus[kdata1]==3 then
		printks2 "RE-PLAY array: %d\n", gkArrayStatus[kdata1]
		gkArrayStatus[kdata1] = 2
	endif

endif
endin

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here