How to create a reaction for a button in mode toggle ?

1.47K viewsCSS Community ScriptsButton toggle
0

Hello everyone
I’m trying to create a reaction for a button in toggle mode like for the “track mute” function. Example :
– Button 1 was pressed = set loop is ON
– Button 1 was pressed again = set loop is OFF
With a feedback LED on button 1.
Should I put button 1 on my controller and on the CSS in Momentary mode or Toggle mode?
Thanks in advance

Fabrice Planquette Answered question
2

In a Reaction, if your button sends a Momentary CC, then the Reaction that Listens to that button will fire each time you press AND release your button. Because you want the Reaction to act as a Toggle, you can account for this by making the first Action exit the Reaction whenever the button is released (in other words, whenever a value of 0 is sent by the button). This is how you could set the first Action up:

Listener

Button 1

Action Block 1

Condition: Button 1 value >> is equal to >> 0

Action: “Script” >> “Exit Reaction Here”

If you have set the button on your controller to Toggle, then you may skip that previous Action Block.

For the rest of your Reaction, you’ll need at least 2 Action Blocks: 1 for activating the loop and one for deactivating it. We can also give each Action Block an Action to send a value to the button itself, to give the button LED Feedback. This is how you can set up those Action Block (I’ll continue the numbering from the previous example):

Action Block 2

Condition: “set loop” >> is equal to >> 0 (in other words, only fire this action when loop is deactivated)

Action 1: “set loop” to 1

Action 2: “Send MIDI velocity value” of 127 to Button 1

Action Block 2

Condition: “set loop” >> is equal to >> 1 (in other words, only fire this action when loop is activated)

Action 1: “set loop” to 0

Action 2: “Send MIDI velocity value” of 0 to Button 1

I’m guessing the “loop” parameter you need can be found in the menu like this:

“Live Object Model” >> “Song” >> “Set Loop”

Glenn V. Answered question
You are viewing 1 out of 2 answers, click here to view all answers.