| As a followup to this thread, here is the way I ended up implementing
it. I post this purely out of fondness for pedagogy.
The GUI basically just uses a checkbox object in Ma++'s MacCsound which
is basically just a named channel that accepts values 0 and 1, for off
and on respectively.
Incidentally, is there a way to disable Csound's default behavior of
changing which instrument MIDI input is assigned to via program change
messages ?
; one checkbox version
; the idea is get program change message 2 in
; display a toggle on the GUI checkbox
sr = 44100
kr = 441
ksmps = 100
nchnls = 2
gkcheck1 init 0
;//
opcode footarray, kk, 0
kstatus, kchan, kd1, kd2 midiin
kval = 0
if (kstatus == 176 && kd1 == 32) then
kval = 0
elseif (kstatus == 192) then
knum = kd1
kval = 1
endif
xout knum, kval
endop
;//
/*--- ---*/
instr 1
knum, kval footarray
if (knum == 1 && kval == 1) then
gkcheck1 = (gkcheck1 + 1) % 2
else
endif
outvalue "checkbex1", gkcheck1
printk2 gkcheck1
endin
/*--- ---*/
i1 0 3600
e
Version: 3
Render: Real
Ask: Yes
Functions: ioObject
WindowBounds: 242 44 914 789
Options: -b1024 -A -s -m7 -K -R
ioView background {0, 3818, 65535}
ioListing {7, 3} {374, 642}
ioCheckbox {436, 73} {30, 30} off checkbex1
; 4 checkbox version
; uses pgm change messages
; 2-5
sr = 44100
kr = 441
ksmps = 100
nchnls = 2
gkcheck1 init 0
gkcheck2 init 0
gkcheck3 init 0
gkcheck4 init 0
;//
opcode footarray, kk, 0
kstatus, kchan, kd1, kd2 midiin
kval = 0
if (kstatus == 176 && kd1 == 32) then
kval = 0
elseif (kstatus == 192) then
knum = kd1
kval = 1
endif
xout knum, kval
endop
;//
/*--- ---*/
instr 1
knum, kval footarray
if (knum == 1 && kval == 1) then
gkcheck1 = (gkcheck1 + 1) % 2
elseif (knum == 2 && kval == 1) then
gkcheck2 = (gkcheck2 + 1) % 2
elseif (knum == 3 && kval == 1) then
gkcheck3 = (gkcheck3 + 1) % 2
elseif (knum == 4 && kval == 1) then
gkcheck4 = (gkcheck4 + 1) % 2
else
endif
outvalue "checkbex1", gkcheck1
outvalue "checkbex2", gkcheck2
outvalue "checkbex3", gkcheck3
outvalue "checkbex4", gkcheck4
; printk2 gkcheck1
; printk2 gkcheck2
; printk2 gkcheck3
; printk2 gkcheck4
endin
/*--- ---*/
i1 0 3600
e
Version: 3
Render: Real
Ask: Yes
Functions: None
WindowBounds: 242 44 914 789
Options: -b1024 -A -s -m7 -K -R
ioView background {0, 3818, 65535}
ioListing {7, 3} {374, 642}
ioCheckbox {438, 69} {30, 30} off checkbex1
ioCheckbox {439, 108} {30, 30} off checkbex2
ioCheckbox {440, 144} {30, 30} off checkbex3
ioCheckbox {441, 180} {30, 30} off checkbex4
-David |