The following code is intended to swap the first and second items in the array Smodules[] every time a button (“right1”) is pressed and print the second item to the terminal.
Currently it prints to the terminal each time the button is pressed, but as far as I can tell it only swaps the array items on initialization and never when the button is pressed. Given my understanding of strings, arrays, and the strcpyk opcode in Csound, I have no explanation for this.
Smodules[] fillarray "pitchmodule", "formantmodule", "partialsmodule", "smearmodule"
kArrowsChanged = changed(cabbageGetValue("right1"))
if kArrowsChanged == 1 then
if cabbageGetValue("right1") == 1 then
Stemp strcpyk Smodules[0]
Smodules[0] strcpyk Smodules[1]
Smodules[1] strcpyk Stemp
printks Smodules[1], 0
endif
endif