Getting a midi controller button to toggle or switch

Fresh

2008-05-12 21:30:26

How can I get a button on a midi controller to a toggle or switch,
so that when I press "down" it turns on and when I press "down" again it turns off.

The controller button sends two messages (on/off) when pressing "on" and two more messages when turning "off" (on/off).

I have read similar questions in the forum but I am unable to clearly understand how to apply the rules to create this switch.

I am using the pro trial version.
Thanks in advance.

joesapo

2008-05-12 23:08:34

Fresh wrote:How can I get a button on a midi controller to a toggle or switch,
so that when I press "down" it turns on and when I press "down" again it turns off.

The controller button sends two messages (on/off) when pressing "on" and two more messages when turning "off" (on/off).

I have read similar questions in the forum but I am unable to clearly understand how to apply the rules to create this switch.

I am using the pro trial version.
Thanks in advance.
It would help to know which MIDI controller you are using... Most current controllers have a built-in toggle feature that you can set...

If not, we can definitely do it in MT using some simple rules and global variables.

Fresh

2008-05-13 00:57:59

It's a Vestax DJ controller: VCI-100.

The unit does not come with any editing software that allows you to change the general operation of the buttons etc.
(I also have an Axiom 25 so I am familiar with this.)

This seems to be the trend with most DJ controllers, you are stuck with the factory settings.

joesapo

2008-05-13 01:42:25

Fresh wrote:It's a Vestax DJ controller: VCI-100.

The unit does not come with any editing software that allows you to change the general operation of the buttons etc.
(I also have an Axiom 25 so I am familiar with this.)

This seems to be the trend with most DJ controllers, you are stuck with the factory settings.
Indeed you are correct... The VCI-100 has static MIDI assignments that can't be changed.

To change your 'momentary' push buttons into toggle switches first you need to capture the data sent by the button you are going to be working with. This is covered in detail in the Defining Translators section of the manual.

Once you have captured your input data, you need to toggle a global variable (and variable that begins with the letters 'g' or 'h') to keep track of the state that the button should be in and what pressing the button will output.

For example; The following Translator will watch for an incoming MIDI message on Channel #1/CC76 with a value of 0. This will vary according to your MIDI controller of course...

What the code does is change the outgoing action depending on the global variable 'ga'. Every time you press the button, the value of 'ga' switches between 0 and 1, depending on if the button is 'toggled' or not. The 'ToggleOn' and 'ToggleOff' sections then changes the outgoing value of your button between 0 and 127, effectively creating a toggle switch.

Code: Select all

Translator 1: ToggleButton
Options: stop=true
Incoming: MIDI B0 4C 00 
Rules: 
  if ga==0 then Goto "ToggleOn"
  if ga==1 then Goto "ToggleOff"
  Label "ToggleOn"
  ga=1
  xx=127
  exit rules, execute Outgoing Action
  Label "ToggleOff"
  ga=0
  xx=0
  exit rules, execute Outgoing Action
Outgoing: MIDI B0 4C xx 
So the first time you press this button it will trigger the 'ToggleOn' section of code, outputting; Channel #1/CC76 value 127

Then the second time you press the button it will trigger the 'ToggleOff' section of code, outputting; Channel #1/CC76 value 0

I should note that this code could be greatly simplified, but for the sake of readability I'm giving you the 'exploded' version...

Let me know if this helps! Every situation is different with so many different MIDI controllers and apps, but I'd be happy to help you get this going correctly...

Joe :mrgreen:

Fresh

2008-05-13 20:25:47

Hey Joe,

I tried out the code last night and it worked great! Thank You!
Also the exploded version of it did help.

A couple other questions for you:

1. Besides the manual and the forums is there anywhere else (website etc.) that might help me in understanding the rules better and how to use them??

2. I am using the VCI-100 with Traktor 3 (if your not familiar without it, that's ok).

In Traktor you are forced to scroll through ten different effects (delay, reverb, etc) to find the one you want.
What I would like to is use a button to switch between two effects.
The effects in Traktor are setup on a control range from 1-127, so 8 would select one effect, 22 another, 36 another and so on.

How would I add control numbers to the switch code??

(There was a MT post I read called "Confused VCI-100 User" that was about this but it kinda stopped short of an answer I could understand)

Any light you can shed on either question would be great!

Thanks again
Fresh

joesapo

2008-05-13 21:55:03

Glad to hear the toggle button is working for you!
Fresh wrote:In Traktor you are forced to scroll through ten different effects (delay, reverb, etc) to find the one you want.
What I would like to is use a button to switch between two effects.
The effects in Traktor are setup on a control range from 1-127, so 8 would select one effect, 22 another, 36 another and so on.

How would I add control numbers to the switch code??
Easy! Let's say that the two effects you want to use are the ones located at values 8 and 36...

You could use the same toggle button code posted above, but change the outgoing values (the 'xx' variable) to the values of your effects...

So...

Code: Select all

Translator 2: FXToggle
Options: stop=true
Incoming: MIDI B0 4D 00
Rules:
  if ga==0 then Goto "Effect1"
  if ga==1 then Goto "Effect2"
  Label "Effect1"
  ga=1
  xx=8
  exit rules, execute Outgoing Action
  Label "Effect2"
  ga=0
  xx=36
  exit rules, execute Outgoing Action
Outgoing: MIDI B0 4D xx
This new translator would be a toggle between the values;

Channel #1/CC77 value 8

and

Channel #1/CC77 value 36

...effectively switching between your two preselected FX.

Joe :mrgreen: