Posting this in Csound Noobs instead of Cabbage Slugs as I haven’t determined if this is a bug or just me yet lol
Using Cabbage 2.9.98
I’m building a terrain based footstep designer and i’ve had some trouble updating button UI text and the instrument state depending on button states. Hope somebody can spot the issue:
I have three buttons currently:
Drone: On/Off
Steps: On/Off
Sneak: On/Off
button bounds(10, 50, 80, 30), channel("toggleDrone"), identChannel("toggleDroneID"), text("Drone: OFF"), latched(1), colour(150, 0, 0), fontColour(255, 255, 255)
button bounds(100, 50, 80, 30), channel("toggleSteps"), identChannel("toggleStepsID"), text("Steps: OFF"), latched(1), colour(0, 150, 0), fontColour(255, 255, 255)
button bounds(190, 50, 80, 30), channel("toggleSneak"), identChannel("toggleSneakID"), text("Sneak: OFF"), latched(1), colour(150, 150, 0), fontColour(255, 255, 255)
I have an instrument called DetectTriggers:
instr DetectTriggers
kToggleDrone chnget "toggleDrone"
kTrigDrone changed kToggleDrone
kToggleSteps chnget "toggleSteps"
kTrigSteps changed kToggleSteps
kToggleSneak chnget "toggleSneak"
kTrigSneak changed kToggleSneak
; Drone Button
if kTrigDrone == 1 then
if kToggleDrone == 1 then
chnset "text(\"Steps: OFF\")", "toggleStepsID"
chnset "colour(0, 0, 0)", "toggleStepsID" ; Set Steps colour to black when OFF
chnset "text(\"Drone: ON\")", "toggleDroneID"
chnset "colour(150, 0, 0)", "toggleDroneID" ; Set Drone colour for ON state
event "i", "ControlSteps", 0, 0
event "i", "Footstep", 0, 0
event "i", "Footstep", 0, -1
else
chnset "text(\"Drone: OFF\")", "toggleDroneID"
chnset "colour(0, 0, 0)", "toggleDroneID"
endif
endif
; Steps Button
if kTrigSteps == 1 then
if kToggleSteps == 1 then
chnset 0, "toggleInstrument"
chnset "text(\"Drone: OFF\")", "toggleDroneID"
chnset "colour(0, 0, 0)", "toggleDroneID"
chnset "text(\"Steps: ON\")", "toggleStepsID"
chnset "colour(0, 150, 0)", "toggleStepsID"
event "i", "Footstep", 0, 0
event "i", "Footstep", 0, -1
event "i", "ControlSteps", 0, 0
event "i", "ControlSteps", 0, -1
else
chnset "text(\"Steps: OFF\")", "toggleStepsID"
chnset "colour(0, 0, 0)", "toggleStepsID"
event "i", "ControlSteps", 0, 0
endif
endif
; Sneak Button
if kTrigSneak == 1 then
if kToggleSneak == 1 then
chnset "text(\"Sneak: ON\")", "toggleSneakID"
else
chnset "text(\"Sneak: OFF\")", "toggleSneakID"
endif
endif
endin
DetectTriggers is called continuously like so in the Cscore:
i “UpdateMixer” 0 z ;
i “DetectTriggers” 0 z ;
My aim is to have Steps turn off if Drone is turned on, and vice versa Drone should turn off if Steps is enabled, as they represent two different playback modes.
Drone = ON should disable Steps processes, Steps = ON should disable Drone processes and both cases should change the text/colour appropriately to reflect the state of each button.
For some reason, the text is not updating for the Drone or Steps button when clicked, Sneak however works fine and toggles the text to ON/OFF
I’ve tried simplifying the code through testing Drone button in isolation (removing Steps button) and only leaving the visual changing logic, the button changes colour fine but the text still doesn’t update?:
; Simplified Drone Button
if kTrigDrone == 1 then
if kToggleDrone == 1 then
chnset "text(\"Drone: ON\")", "toggleDroneID"
chnset "colour(150, 0, 0)", "toggleDroneID" ; Set Drone colour for ON state
else
chnset "text(\"Drone: OFF\")", "toggleDroneID"
chnset "colour(0, 0, 0)", "toggleDroneID"
endif
endif
I feel like there may be an issue in my attempted logic. Can you spot any possibly conflicting conditions in my code that may cancel out my expected changes?