Login | Register 
FEATURES
APPLICATIONS
DOWNLOADS
EDUCATION
BLOG
WIKI
FORUM
STORE

Mapping Touch UI Sliders/Buttons to a Midi Device

Discuss graphics hardware, computer hardware, and input/output devices to use with TouchDesigner

Mapping Touch UI Sliders/Buttons to a Midi Device

Postby nes10bul » Mon Mar 20, 2017 10:04 am

I am suffering from an inability to connect the logic between two tutorials. I’ve been following along with Matthew Ragan’s fabulous tutorial series, and since hundreds of others are as well… maybe someone else might have had the same question and solved it.

The Task:

I would like to Map the UI Sliders/Buttons to a Midi Device like the one below for example the “Oxygen 25.”
Oxygen25-top.jpg
Oxygen25-top.jpg (174.31 KiB) Viewed 604 times
Specifically, I want to map Sliders that I built in touch (following Matthew Ragan’s tutorial https://www.youtube.com/watch?v=exGE68Jb5JQ ) that control Invert, Contrast, Hue Offset, Etc. to the knobs, keys, buttons to the above Midi Device.

So I understand this : https://www.youtube.com/watch?v=XLeghJmFBh0
which is to say that I understood the idea of mapping out particular Sliders/Buttons in The Midi Device Mapper Dialog to the respective physical dodad on the midi device.

I understand that you can theoretically map out your device once and then in “Local” plop the .tox file into a new project and point the base of the project to the .tox file with all those fine mappings that you just did. So this could save you time using your midi map on various projects.

But!

Now what?
I’m guessing now one would need a way to tell the Midi Mapper sliders/buttons in which you just assigned the proper Midi Channel/Controller that “hey you, s1 are going to control this UI slider— let’s say the “Invert” slider in the Touch Interface.”

I feel that I need another step here because I haven’t connected the UI sliders with the Midi Mapped button/sliders… but how on earth does one do that?

With a table? Or some swanky python script? Or… with a drag and drop that I just could simply not common sense my way upon??

Is it correct to think of this as a circle that needs to be complete?
QuestionDiagram.jpg
QuestionDiagram.jpg (513.63 KiB) Viewed 604 times


Thanks in advance for helping me complete my circle!
Very Best, Nesli
nes10bul
 
Posts: 2
Joined: Mon Nov 09, 2015 11:11 am
Location: Istanbul

Re: Mapping Touch UI Sliders/Buttons to a Midi Device

Postby raganmd » Mon Mar 20, 2017 1:34 pm

Good questions!

Looking specifically at the back and forth between your controller and your UI

This is the kind of principle we're chasing... it's an old post, but the idea is we want an outside control to override our UI, and our UI to override our outside control:
https://matthewragan.com/2014/04/11/osc ... hdesigner/

I would probably do this with a script to control panel vals. That gets a little tricksy, but the idea is you'd come up with a correspondence table - maybe the input midi control, and the target ui element, and the val to change (is it u, v, etc). Then write a simple value change script that checks the name of the channel that's changed, find's that in the correspondence table, and then changes the target ui element's target parameter.

You could also organize this with an override CHOP, but those can get a little wonky so I'd practice small before you go big.

I'll see if I can put together an example tonight - I know those are usually helpful for these kinds of things.
raganmd
 
Posts: 754
Joined: Thu Mar 28, 2013 5:21 am
Location: San Francisco, CA

Re: Mapping Touch UI Sliders/Buttons to a Midi Device

Postby raganmd » Tue Mar 21, 2017 1:37 am

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
      else:
         pass

   # empty else statement in case there are other possible ui elements
   else:
      pass

   return


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. :)
Attachments
base_midi_to_ui_example.tox
(2.58 KiB) Downloaded 40 times
raganmd
 
Posts: 754
Joined: Thu Mar 28, 2013 5:21 am
Location: San Francisco, CA

Re: Mapping Touch UI Sliders/Buttons to a Midi Device

Postby nes10bul » Wed Mar 22, 2017 12:01 pm

Wow!! Thanks for the incredible response Matthew Ragan.

I didn't have luck with the "Your First Movie Player" tutorial example, I will go back to it and try to figure out where I went wrong. Meanwhile, I switched examples and tried to simplify it as much as I could. I used "Your First VJ Mixer." https://www.youtube.com/watch?v=pyVL2HcXrSc&index=21&list=PLs0WlHa1rf20gT2LiSe_5drMnJvMkCE_C Since there is only one slider in question in that Tutorial... maybe, I thought, that would be a better jumping off point?

VJMixer.PNG
VJMixer.PNG (2.34 MiB) Viewed 565 times

VJMixer_Midi_Testing.3.toe
(10.36 KiB) Downloaded 32 times
container_deck_ctrl1.tox
(3.24 KiB) Downloaded 29 times
nes10bul
 
Posts: 2
Joined: Mon Nov 09, 2015 11:11 am
Location: Istanbul

Re: Mapping Touch UI Sliders/Buttons to a Midi Device

Postby raganmd » Wed Mar 22, 2017 1:07 pm

Nice work! This is very close to what you're after.

In your table_lookup try this - change "container1/slider1" to just "slider1".

In that lookup table, the target_panel column represents the path to the target panel element. In your case, since the chop execute and the slider are in the same part of the network you don't need any more than this.

Hope that helps!
raganmd
 
Posts: 754
Joined: Thu Mar 28, 2013 5:21 am
Location: San Francisco, CA


Return to Hardware

Who is online

Users browsing this forum: No registered users and 1 guest