Hi
I am not sure the best approach to do take for this but I think the most efficient method is to just change the labels for a row of pads, if it is possible.
Basically I have a row of pads that it is based on a matrix in VSL. I want to have a switch that changes the text labals for the pads. The switch will also send a CC command to VSL.
So basically rather then have numerous rows of pads I just want to have one row and use a switch to change the text labels for all of the pads. There are 12 pads in a row each with their own label. I would like to have a 5 way switch that changes the entire row of labels with 5 different arrays of labels.
Is this possible? Can anyone guide me on how to do it.
Changing a row of text labels for pads based on a switch
-
- Regular
- Posts: 315
- Joined: 02 Nov 2013 11:19
Re: Changing a row of text labels for pads based on a switch
For the Pads, you have to check Multilabel. If that is checked, you can use setattribute(Pads, 'labels', {'label1', 'label2', 'label3'}); to set the labels to whatever text you want.
For the switch, I might use a slider with grid turned on to get the stepped effect (or just let the math below fix the in between positions)
Then you can substitute labels as needed in your script logic:
i = floor(Slider.x * 5);
if (i == 0) {
setattribute(Pads, 'labels', {"L1', 'L2', 'L3', 'L4', 'L5', 'L6', "L7', 'L8', 'L9', 'L10', 'L11', 'L12'});
else if (i == 1) {
setattribute(Pads, 'labels', {"M1', 'M2', 'M3', 'M4', 'M5', 'M6', "M7', 'M8', 'M9', 'M10', 'M11', 'M12'});
}
There are ways you can reuse an array to save on space typing since you can directly substitute like this:
decl myLbls = {"L1', 'L2', 'L3', 'L4', 'L5', 'L6', "L7', 'L8', 'L9', 'L10', 'L11', 'L12'};
myLbls[5] = 'hello';
myLbls[6] = 'there';
but you'd have to update the labels if they changed between multiple values (i.e., if the switch was one, label 7 was 'hello', if it was 2 label 7 was 'bye', and all other times it was 'aloha', you'd have to make sure you substituted something for label 7 in each conditional branch).
For the switch, I might use a slider with grid turned on to get the stepped effect (or just let the math below fix the in between positions)
Then you can substitute labels as needed in your script logic:
i = floor(Slider.x * 5);
if (i == 0) {
setattribute(Pads, 'labels', {"L1', 'L2', 'L3', 'L4', 'L5', 'L6', "L7', 'L8', 'L9', 'L10', 'L11', 'L12'});
else if (i == 1) {
setattribute(Pads, 'labels', {"M1', 'M2', 'M3', 'M4', 'M5', 'M6', "M7', 'M8', 'M9', 'M10', 'M11', 'M12'});
}
There are ways you can reuse an array to save on space typing since you can directly substitute like this:
decl myLbls = {"L1', 'L2', 'L3', 'L4', 'L5', 'L6', "L7', 'L8', 'L9', 'L10', 'L11', 'L12'};
myLbls[5] = 'hello';
myLbls[6] = 'there';
but you'd have to update the labels if they changed between multiple values (i.e., if the switch was one, label 7 was 'hello', if it was 2 label 7 was 'bye', and all other times it was 'aloha', you'd have to make sure you substituted something for label 7 in each conditional branch).
Re: Changing a row of text labels for pads based on a switch
This will work but is there a way to do this with a switch. I see the problem a five way switch does not deliver a value between 0 and 4 based on the switch. Is there a way to do that?
-
- Regular
- Posts: 315
- Joined: 02 Nov 2013 11:19
Re: Changing a row of text labels for pads based on a switch
If you wanted to simulate a 5 way switch, you'd have to use an array of 5 switches and turn on radio mode. Then for each switch (internally they are switch[0] through switch[4]) you could explicitly set the labels using setattribute(). With radio mode on, you get one switch turning on at a time, so you can use firstof(x) in a script to see which one is on.gweston wrote:This will work but is there a way to do this with a switch. I see the problem a five way switch does not deliver a value between 0 and 4 based on the switch. Is there a way to do that?
The script for the switch would use i = firstof(x) to get which switch was pressed (returns 0-4) and then do the same if/else if/else if/... comparing i to 0, 1, 2, etc
Summary -
5 switches in radio mode
script set to execute On Expression x any
use firstof(x) to find which switch is which
use setattribute() to set target labels
-
- Regular
- Posts: 153
- Joined: 31 Dec 2011 17:12
Re: Changing a row of text labels for pads based on a sw
Just set-up a script that activates via your array of switches, then inside the script set your labels to be applied to your pads depending on which switch in the array is pressed.