How do you control a button with midi?

Hey everyone,

I can’t figure out how to control a button with my midi controller. I’m using a BCR2000, TD sees it and midi is coming in. My button is set up, triggering a video file…All I want is to be able to push a button on the midi controller to control the button in Touch Designer. I’m sure this is very simple, but I can’t find out how to do this…Could you guys help me out here? I think I’ve read all the threads and watched all the videos out there…but nothing answers this question.

Thanks a lot for any help here : )

Hey JustinClient,

You’ll likely want to use an execute to get here - CHOP or the Midi in Callbacks DAT. You’ll end up using a script that’s something like:

op('button1').click()

The click() method mimics interaction and is often useful for these kinds of situations. You can read more about the methods associated with the button COMP here:
derivative.ca/wiki099/index. … COMP_Class

Hey Matthew!

Thanks so much for pointing me in the right direction - really appreciate your help! I think I’m almost there…My midi controller did trigger the TD button(s) - but only once, after that, nothing was changing anymore (and it also reacted to any button on the BCR2000 - the idea would be to be able to decide which button on the controller to use). I’m sure it has to do with telling TD which midi message/value etc. to “listen” to, but I don’t know where to specify that. I also duplicated your line of code for each of my buttons…not sure if that’s the way to do it? Maybe I should only use one MidiinDAT per button?

And you’ll recognize the network - it’s from one of your tutorials :slight_smile: They’re so incredibly helpful - thanks for all the great stuff you’ve put out there!

Hey JustinClient,

The considerations here would be to think about how you’re filtering your midi button presses. Right now it looks like you fire those buttons in succession when you press any button. Instead, you’ll need to think through structuring if statements to handle this correctly:

if message == 'theNameOfAMidiMessage': op('button1').click() elif message == 'theNameOfAMidiMessage': op('button2').click()

So you’d want to do this for each of your buttons making sure that you only click the corresponding button that matches your midi controller. This also gets complicated if you’re using buttons more like a menu selection rather than toggles - if your buttons are set to toggle then the second time you click them the button’s state goes from on to off, and your script inside won’t fire. Mirroring physical and virtual interfaces is much more complicated ball of wax than most folks realize, so kudos for tackling this challenge.

There are some other interesting discussions / threads about this issue that you might consider reading through here:

Hey Matthew, and thanks again for your help! I had no idea playing with midi would be that hard…but it’s cool, I’m learning TONS of stuff by just trying to make this work and reading your answers. I’m completely new to Python, and I can’t find out what to write as the midi message. I think I’ve tried all the possible names and combinations I could think of, but nothing seems to work. Shouldn’t it be ‘b0 41 7f’ as shown in the midi mapper? Isn’t that the midi message?

Now all the controls on the BCR are triggering button1 (which makes sense since I wrote Control Change) but what do you add next to Control Change to tell TD which message to listen to?

The best debugging approach is to start by printing.

For example, in the callbacks, something like:

print( message, channel, index, value )

Will print those to your text port for all midi events. Using the textport and printing out messages is a surefire way to be able to see what’s happening under the hood. From here you should end up with a way to differentiate between which button you’re using.

There’s a ton of material up here you can use for reference:
matthewragan.com/teaching-resou … hdesigner/

Even a bit specifically on what’s happening when it comes to using executes:
matthewragan.com/2016/07/06/pyt … hdesigner/