I’m not sure if you just meant to say ‘channel names’ and not ‘MIDI Channels’ in the first line of your question. MIDI channels don’t really have much direct connection with widgets.
Anyway, maybe this answers your question: you can’t change the channel name of a widget after it has been created (I don’t think) but you can overlay two widgets and toggle their visibility. Here is an example:
SwappingChannels.csd (1.0 KB)
<Cabbage>
form caption("Swap Channels") size(200, 90), colour(58, 110, 182), pluginid("def1")
rslider bounds(5,5,70,70), channel("Freq"), range(50,2000,220,0.5), text("Freq."), identchannel("FreqID")
rslider bounds(5,5,70,70), channel("Ndx"), range(0,20,5), text("Index"), identchannel("NdxID"), visible(0)
combobox items("Freq", "Index"), bounds(90, 5, 80, 30), channel("Select")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
ksmps = 32
nchnls = 2
0dbfs = 1
giSine ftgen 0,0,4096,10,1
instr 1
; toggle visibility between two widgets
kSelect init 1
if changed:k(kSelect)==1 then
chnset sprintfk:S("visible(%d)",1-kSelect), "FreqID"
chnset sprintfk:S("visible(%d)",kSelect), "NdxID"
endif
kSelect chnget "Select"
kSelect -= 1
kFreq chnget "Freq"
kNdx chnget "Ndx"
aSig foscili 0.2, kFreq, 1, 1, kNdx, giSine
outs aSig, aSig
endin
</CsInstruments>
<CsScore>
i 1 0 z
</CsScore>
</CsoundSynthesizer>