Sorry it's taken me all day to get an example up here.
This is a small test, so you'll have to do a bit more leg work to get it up and configured the way you want, but this should give you a good push.
The big idea is that the operator "table_lookup" contains 4 columns:
* the incoming midi channel
* the panel element it should target
* the panel val that should be targeted (u, v, state)
* if that value should be inverted
A chop execute does all of the leg work of making that happen:
- Code: Select all
lookup = op( 'table_lookup' )
def valueChange(channel, sampleIndex, val, prev):
# general set-up
# on value change we set these variables dynamically
# based on the contents of our lookup table
target_panel = lookup[ channel.name, 'target_panel' ].val
panel_val = lookup[ channel.name, 'val' ]
invert = lookup[ channel.name, 'invert' ]
# check to see if we're working with a slider
if "s" in target_panel:
# check to see if we're targeting a u panel par (horizontal slider)
if panel_val == "u":
op( target_panel ).panel.u = abs( val - invert )
# if we're targeting a v panel par (vertical slider)
elif panel_val == "v":
op( target_panel ).panel.v = abs( val - invert )
# check to see if we're targeting a button
elif "b" in target_panel:
# check to see if we're targeting state
if panel_val == "state":
op( target_panel ).panel.state = abs( val - invert )
# in case you wanted to target something other than state
# empty else statement in case there are other possible ui elements
Our first step is to create a few variables on value change - this uses the name of the channel that's changed to look up the other target values - if the channel named "s1" has changed we know that we want to look at that row in the lookup table. Next we grab all of the other elements we need - the target panel element, the panel val we want to update, and if we want that value to be inverted.
Next we have a few branches to ensure that we perform the right operations - for example if "s" is int he channel name we know we have a slider. If we have a slider we'll probably want to change either u or v depending on if the slider is horizontal or vertical. Next we can take the absolute value of the channel val less our invert amount to determine if we flip invert the behavior of our slider. That's a little goofy, but check it out - if the invert value is 0, nothing changes. If the invert value is 1 our we subtract our value from one, which would be a negative number - but if we take the absolute value of that operation we get a positive value. That means that decreasing vals now have a rising slope, and increasing vals now have a falling slope. If that's a little wonky for you, try it out with a math CHOP and a tail to see it in action.
Because this script changes the panel vals of the ui elements, our TD panel will update with the changes from our controller - but we'll also still be able to use our TD panel to make changes. It's the best of both worlds.
Finally, the select CHOP that's after the container1 COMP would be the CHOP you'd want to use to drive any changes in your network.
Hopefully that makes sense.