Quick Sign In:  

Forum: General Discussion

Topic: Struggling to map pitch bend
rgrrbtPRO InfinityMember since 2023
I am attempting to map pitch bend to a button such that it applies only when the button is pressed. With the below script, the behavior is a continuous pitch bend persisting after release of the button. What am I missing in this script to stop the pitch bending action? I have checked to ensure the button to which this action is mapped is functioning in gate mode.

deck left pitch_bend -0.5% 200ms & set 'bendminus' while_pressed
 

geposted Wed 15 Nov 23 @ 4:38 pm
deck left pitch_bend -0.5% 200ms while_pressed & set 'bendminus' while_pressed

OR (but not 100% sure it will work, test it)

deck left (pitch_bend -0.5% 200ms & set 'bendminus') while_pressed
 

geposted Wed 15 Nov 23 @ 6:56 pm
rgrrbtPRO InfinityMember since 2023
Thank you for the reply. The former script has the same effect as my original script (i.e. pitch bend persists after button release) and the latter has no effect (perhaps an invalid syntax). This leads me to believe that the while_pressed component of the script has a syntax error. I am using a midi tracer to confirm that the button is sending both an on (7F) and off (00) signal, so I don't believe it is an issue with the button. Any other ideas on why this script isn't working as intended (i.e. momentary vs persistent)?
 

geposted Wed 15 Nov 23 @ 8:47 pm
First script works fine here.

I tried on both a custom button on the GUI and on a controller.

Any chance the button you're trying to use is actually a toggle (latch) button and not a "gate" button ?
A toggle button sends 7F on first press and 00 on second press
A "gate" button sends 7F when pushed down, and 00 when released.

Also if it's a button that's used on a supported controller, please let us know which button (and on which controller) it is, since sometimes some buttons have more "complex" functions programmed to them when the device is running "full-time" VS when it runs as simple MIDI.

PS: I'm sure it won't make a difference, but have you tried to just use the pitch_bend part of your script alone ? Just to exclude any typos ?
deck left pitch_bend -0.5% 200ms while_pressed

PS2: If you're trying to use Traktor X1, then open NI Device Editor and set ALL buttons to "gate" mode.
 

geposted Thu 16 Nov 23 @ 1:26 am
rgrrbtPRO InfinityMember since 2023
Thank you for your efforts. This one really has me puzzled.

"Any chance the button you're trying to use is actually a toggle (latch) button and not a "gate" button ?
A toggle button sends 7F on first press and 00 on second press
A "gate" button sends 7F when pushed down, and 00 when released."


Using MIDI-OX I have confirmed that the button is in gate mode. When pressed 7F is sent. When released 00 is sent. Would the fact that this button's MIDI event is a CC: Bank LSB as opposed to a simple Control Change have an impact?

"Also if it's a button that's used on a supported controller, please let us know which button (and on which controller) it is, since sometimes some buttons have more "complex" functions programmed to them when the device is running "full-time" VS when it runs as simple MIDI."

This is button CC 32 (sending Hex 20) on channel 1. The controller is the NI Traktor Kontrol X1 Mk1. It is running in MIDI mode.

"PS: I'm sure it won't make a difference, but have you tried to just use the pitch_bend part of your script alone ? Just to exclude any typos ?
deck left pitch_bend -0.5% 200ms while_pressed"


You are correct. I tried this script and it did not change the behavior of the persistent pitch bend (i.e. the while_pressed component continues to not take effect).

"PS2: If you're trying to use Traktor X1, then open NI Device Editor and set ALL buttons to "gate" mode."

I did this and it also had no impact on this action's behavior.

I'm convinced that, together with your independent testing, the problem is not the script. That leads me to believe it has something to do with the MIDI signal. Any ideas?
 

geposted Thu 16 Nov 23 @ 4:21 pm
Are you creating a device definition file ? Or you're using the generic MIDI wrapper inside VirtualDJ ?
If you're creating a device definition file then you need to know that you MUST name your device.xml file in a particular way in order to override the internal one. You have to use to use "force-" in front of the filename.
So, you should use force-Traktor Kontrol X1.xml for your file to override the internal definition of the controller.

Also, yes, CC and NOTE messages are different, and you should define them properly.

The button in question is defined like this inside VirtualDJ:
<button cc="0x20" value="0x7F" off="0x00" name="BEAT-" deck="1" channel="0"/>

Finally, Trakor Kontrol X1 (MK1) is a natively supported device.
It should get recognized by VirtualDJ and work fine with the default MIDI template loaded on it (on NI device editor)
Then you should be able to remap it (if you need) without worrying about the MIDI messages and all the technical stuff.

If your device doesn't get recognized properly by VirtualDJ, then you should troubleshoot that issue instead.

I don't have Kontrol X1, but from what I remember, all you have to do is to load and use the default MIDI template for it. Of course Native Instruments Device Editor must be installed on your system as well, and be able to recognize the device.

X1 MK2 is a different (and far more easy) case as it's supported via HID instead of MIDI. MK1 does not have HID.

PS: It has been ages since the last time I used Device Editor so I may get a few terminologies kind of wrong :P

PPS: The script you're trying to use is already present on default mapping of X1 when you press SHIFT and then press the BEAT- button.
So, the issue has most likely to do with changes made to the unit inside Device Editor.
My memory doesn't serve me well, but I think besides editing a device you need to also save the changes to the device if you want them to be persistent. So, set everything to gate mode and see if you need to save a profile or something to make those changes permanent. Search around the menus of Device Editor and you should understand what I'm talking about..
 

geposted Thu 16 Nov 23 @ 4:43 pm
rgrrbtPRO InfinityMember since 2023
Thank you for the reply. Yes, I know that the decice is natively supported. I wrote a custom definition file in order to accomplish a few things that are not possible with the VDj's internal definition file. In the native definition file, the left and right encoders are named as the same button, for example, and I am using them for two different purposes.

I am aware of the naming convention for custom definition files. I have been able to successfully implement mapping for every function except this one. I am curious as to how the native definition file has the Shift Beat- button defined as, like you stated, it is performing the pitch bend function without issue in the native mapping. Given that the native definition file is not available for end users to see, I have no idea why it is behaving differently in my custom definition file and mapping (using the same script).

As far as the Controller Editor, yes, I am aware of its functions. I have created a mapper using the default settings (i.e. all buttons in gate mode) and it also displayed the strange behavior on the pitch bend (i.e. pitch bend persists).

There must be something in the way VDJ's natively supported device definition file is structured differently such that the "while_pressed" takes effect. Do you have access to the native definition and could you share just the section that defines the button in question? (edit - I reread your post and see that you have provided that; I'll give it another try by defining the on and off state values explicitly in my definition file to see if that helps.)

Again, thank you for your help and patience.
 

geposted Thu 16 Nov 23 @ 5:27 pm
rgrrbtPRO InfinityMember since 2023
That was it! By adding

value="0x7F" off="0x00"


The button now respects the 'while_pressed' component of the script. Without the off="0x00" the off MIDI signal wasn't being interpreted by VDJ when the button was released.

As a point of clarification to anyone who may read this in the future, all buttons in Native Instrument's Control Editor DO NOT have to be set as gate mode for this to work. I have saved a combination of buttons - some in gate mode, others in trigger mode.

Thank you again for your help!
 

geposted Thu 16 Nov 23 @ 5:36 pm
rgrrbt wrote :
Thank you for the reply. Yes, I know that the decice is natively supported. I wrote a custom definition file in order to accomplish a few things that are not possible with the VDj's internal definition file. In the native definition file, the left and right encoders are named as the same button, for example, and I am using them for two different purposes.

In such cases you can split them like this: device_side 'left' ? this : that or like this: action_deck 1 ? this : that

rgrrbt wrote :
As a point of clarification to anyone who may read this in the future, all buttons in Native Instrument's Control Editor DO NOT have to be set as gate mode for this to work. I have saved a combination of buttons - some in gate mode, others in trigger mode.

They have to be in gate mode for the NATIVE implementation to work.
For custom device definitions, sure you can do whatever you please, as long as you remember that you need to define the "trigger" mode buttons as <toggle /> and not as <button /> as decribed on the SDK:
https://www.virtualdj.com/wiki/ControllerDefinitionMIDI
You could even change through Device Editor the MIDI messages that the unit sends to different values and define/map those instead. No problem there!


PS: You could have saved a lot of time if you had provided clear information of what you're trying to do on your first post:
Quote :
I'm creating my own definition for Traktor Kontrol X1, and I have a button with this definition code <button cc="0x20" name="BEAT-" deck="1" channel="0"/> that doesn't work with this script <map button="BEAT-" action="deck left pitch_bend -0.5% 200ms & set 'bendminus' while_pressed"/>
Can anyone help ?

Then it would be quite easier for us to find out what's wrong and help you much quicker.
I'm not trying to be hard on you.
I'm just trying to explain for anyone who may read this in the future how clear and detailed descriptions of a problem can vastly improve the responses we give out! :)
 

geposted Thu 16 Nov 23 @ 7:47 pm