Cycle through values with 1 button

258 viewsCSS Community ScriptsButton counter cycle
0

I know how to switch between 2 values but how to make a button to cycle through 0, 65, 127?

edit 1: answering to myself here’s a script applying this to a modifier value. But it could be useful to cycle through a list instead. I continue to investigate…

i = self.get_modifier_value("m1")
m = 3
n = 1

if i + n < m:
    i = i + n
else:
    i = 0

self.set_modifier_value("m1", i)

self.log_message("csslog: " + str(self.get_modifier_value("m1")))

edit 2: an attempt for list… any comment to improve is welcome

i = self.get_modifier_value("m1")
l = [0,50,100]
m = len(l)

if i + 1  < m:
    i = i + 1
else:
    i = 0

self.set_modifier_value("m1", i)

self.set_modifier_value("m2", l[i])

self.log_message("csslog: " + str(self.get_modifier_value("m2")))

edit 3: add this script to apply to a selected parameter.

self.song().view.selected_parameter.value = self.get_value_from_ranges(False, m-1, False, self.get_modifier_value("m2"), l[0], l[m-1], 0, self.song().view.selected_parameter.min, self.song().view.selected_parameter.max, 2, False)

Fabrice Planquette Edited question December 5, 2024

Why is it impossible to add file to my post when editing it?

1

You could do this using the ‘get value from ranges’ option within the Reactions mapping type.
Here is a video which explains it: https://youtu.be/1Bni9Yqtks0?si=CPrcPoAfmpHfilvw

Fabrice Planquette Posted new comment November 30, 2024

Hi John, I watched this tutotrial but I still can’t figure out how to apply this to a button (not a knob).

I can increment OR decrement but not cycle on each clic like 0, 65, 127, 0, 65, 127, and so on…