I’ve been thinking about an effective way to re-use GUI abstractions, and based on our previous discussion I thought i would float an updated idea by you all. This is just a rough draft but my thinking is that we could use xml files to declare plants, and corresponding Csound code. Each custom plant would need its own unique namespace to avoid conflicts. The xml file might look like this:
<plant xmlns="killerWidgets">
<name>radioValueButtonGroup</name>
<cabbagecode>
image bounds(0, 0, 160, 50) colour("red"){
button bounds(10, 40, 30, 30) channel("killerWidgets_button1") radiogroup(99), text(""), colour:1("red")
button bounds(40, 40, 30, 30) channel("killerWidgets_button2") radiogroup(99), text(""), colour:1("red")
button bounds(70, 40, 30, 30) channel("killerWidgets_button3") radiogroup(99), text(""), colour:1("red")
button bounds(100, 40, 30, 30) channel("killerWidgets_button4") radiogroup(99), text(""), colour:1("red"), value(1)
}
</cabbagecode>
<csoundcode>
opcode radioValueButtonGroup,k
kValue init 0
kIndex = 1
kTrig changed, chnget:k("killerWidgets_button1"), chnget:k("killerWidgets_button2"), chnget:k("killerWidgets_button3"), chnget:k("killerWidgets_button4")
if kTrig == 1 then
while kIndex<5 do
SChannel sprintfk "killerWidgets_button%d", kIndex
kValue = (chnget:k(SChannel)==1 ? kIndex : kValue)
kIndex+=1
od
endif
xout kValue
endop
</csoundcode>
</plant>
So the .csd file might then look like this:
<Cabbage>
import "plants.xml"
form caption("Presets") size(670, 580), colour(58, 110, 182), pluginID("def1")
killerWidgets.radioValueButtonGroup bounds(10, 10, 200, 100)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5 ;--midi-key-cps=4
</CsOptions>
<CsInstruments>
; Initialize the global variables.
sr = 44100
;kr = 4410
ksmps =32
nchnls = 2
0dbfs = 1
instr 1
kValue killerWidgets_radioValueButtonGroup
printk2 kValue
endin
The UDOs when called in Csound will have the plant namespace prefixed to them so there are no conflicts with other UDOs, or plants. I’d have to look into some way of making the UDO code visible to Csound, but that shouldn’t be too tricky. Ideas? Suggestions?
Note that I’d like to make this system as simple as possible to implement and maintain. And also simple for the end user to use. I don’t want to have to do lots of parsing and text replacement each time a plant is imported.