Accesso rapido:  

Forum: General Discussion

Topic: Send MIDI signal back to controller to toggle Button light ON and OFF
I am custom mapping a midi controller. So far the buttons are mapped with actions. However, there are some buttons defined as TOGGLE in the midi controller, that I want to turn on and off if the button in Virtual DJ on the computer is pressed so the midi controller button lights on or off depending on the state (e.g. playing or paused)

The following mapping works
<map value="0-SLIDER63" action="play_button" />

How to send back the MIDI code to change the toggle button in the midi controller?

<mapper device="SIMPLE_MIDI_2372_308" version="850" date="2023-01-08">
<map value="0-SLIDER2" action="level" />
<map value="0-SLIDER3" action="pitch" />
...
<map value="0-SLIDER13" action="eq_high" />
<map value="0-SLIDER14" action="eq_mid" />
....
<map value="0-SLIDER63" action="play_button" />
## How to toggle back a button in the MIDI controller when is pressed?
## Light in the MIDI controller button should be ON when Play is paused and OFF for DECK 1
...
<toggle cc="0x63" name="Play" channel="0"/>
## This does not work
</mapper>
 

Inviato Sun 08 Jan 23 @ 8:46 am
You cannot map LEDs with simple "SIMPLE MIDI Wrap" mapper.

In order to control LEDs you'll have to create a device definition for the device.
In that file you can specify (define) what each element of your controller is, and what data VirtualDJ should expect to receive OR SEND.
Then you map those elements with actions.
 

Inviato Sun 08 Jan 23 @ 11:53 am
Thanks, I now have created two (2) files: a) the definition file and b) the mapping file. Followed instructions to obtain the sysexid by looking at the log file as well as by obtaining it with the miditrace tool. vid and pid obtained from log and from windows device manager The file definition contains this key elements
	<device version="101" decks="2" description="my midi kontrol" type="MIDI"
vid = "0x0944" pid = "0x0134" sysexid="F07E0006024237010000????????F7"
name="#vid_0944&pid_0134"> </device>

However, VDJ does not receive any midi input from the controller. I also have changed the name as the name reported in the log, with no effect. If I delete the file definition, VDJ is able to receive midi signals from the controller, defaulting the name as "SIMPLE_MIDI_2372_308 - custom mapping (which means it is not an issue of communication or driver), but I need the custom file definition and the mapping file working together to be able to send signals back to leds. Am I missing something? I would appreciate any hints or an example of two files that work.
 

Inviato Tue 10 Jan 23 @ 9:09 pm
Definition:

<device name="MYDEVICE" version="850" decks="2" description="my midi kontrol" type="MIDI" vid = "0x0944" pid = "0x0134" sysexid="F07E0006024237010000????????F7" >
<button note="0x12" name="PLAY" channel="0" deck="1" />
<button note="0x12" name="PLAY" channel="1" deck="2" />
<led note="0x12" name="LED_PLAY" default="PLAY" channel="0" deck="1" />
<led note="0x12" name="LED_PLAY" default="PLAY" channel="1" deck="2" />
</device>

Mapper:

<mapper device="MYDEVICE" version="850" date="2023-01-08">
<map value="PLAY" action="play_button" />
<map value="LED_PLAY" action="play ? on : blink 300ms" />
</mapper>


Keep in mind that when a MIDI element is NOT defined on the definition file it will also NOT appear on the mappers tab window.
In other words, with a "blank" definition file you won't get any keys inside VirtualDJ mappers tab as you were getting with simple MIDI wrapper. VirtualDJ simply ignores any messages that don't match the defined ones.
 

Inviato Wed 11 Jan 23 @ 12:01 am
It does not work for my setting (no play at all and no effects on button's lights and no capture of any midi key).
I have the two buttons to play deck 1 and 2 respectively using the same midi channel 1 ("0" in the definition file) but different "notes" (although I also remapped the midi device to match the notes and the channels as per your suggestion) With this special mapping coupled to the definition file, at the start of VDJ I am prompted to confirm the connected device , but at the mapping screen, am I suppose to see activity of the midi keys on the upper right of the mapping screen (see screenshot, nothing appears there when pressing midi keys , unless the file is deleted)? Again, if I deleted the custom definition file, all midi keys are capture by VDJ but not with the def file in place.

Here is the xml definition modified:
<device name="MYDEVICE" version="850" decks="2" description="my midi kontrol" type="MIDI" vid = "0x0944" pid = "0x0134" sysexid="F07E0006024237010000????????F7" >
<button note="0x63" name="PLAY_L" channel="0" deck="1" />
<button note="0x81" name="PLAY_R" channel="0" deck="2" />
<led note="0x63" name="LED_PLAY_L" default="PLAY_L" channel="0" deck="1" />
<led note="0x81" name="LED_PLAY_R" default="PLAY_R" channel="0" deck="2" />
</device>


and the mapping file
<?xml version="1.0" encoding="UTF-8"?>
<mapper device="MYDEVICE" version="850" date="2023-01-10">
<map value="PLAY_L" action="play_button" />
<map value="PLAY_R" action="play_button" />
<map value="LED_PLAY_L" action="play ? on : blink 300ms" />
<map value="LED_PLAY_R" action="play ? on : blink 300ms" />
</mapper>


I appreciate your help
 

Inviato Wed 11 Jan 23 @ 3:00 am
djdadPRO InfinityDevelopment ManagerMember since 2005
Perhaps doublecheck the sent Midi messages with MIDIOX
 

Inviato Wed 11 Jan 23 @ 10:51 am
locoDogPRO InfinityModeratorMember since 2013
try

<button note="0x3F" name="PLAY_L" channel="0" deck="1" />
<button note="0x51" name="PLAY_R" channel="0" deck="2" />


I'm guessing you confused decimal with hex
 

Inviato Wed 11 Jan 23 @ 11:00 am
Ooops! Good catch @locodog. Now both play buttons work. But there are two issues
1. The led lights do not receive the signal to change accordingly. The buttons of the midi are set up as "toggle buttons" and by default they light up with value of 127 (0x7F) and are off with 0x0. There are two possibilities: a) the definition is wrong or b) the midi device does not allow the individual led light to be program.
I tried this in the definition file
<led cc="0x3F" name="LED_PLAY_L" default="PLAY_L" channel="0" deck="1" />
or
<led cc="0x3F" value="0x7F" ccoff="0x00" zero="0x00" sendstatic="true" name="LED_PLAY_L" default="PLAY_L" deck="1" channel="0" />
none of them worked
2. With the definitions of buttons as "note" I have to press twice twice the button to play the track. I converted the button to "cc" and now they work pressing them only once. Is there any side effect on using cc as "opposed" to "note"?
<button cc="0x3F" name="PLAY_L" channel="0" deck="1" />
<button cc="0x51" name="PLAY_R" channel="0" deck="2" />
 

Inviato Wed 11 Jan 23 @ 5:12 pm
locoDogPRO InfinityModeratorMember since 2013
try your LEDs with note?
 

Inviato Wed 11 Jan 23 @ 6:44 pm
No effect on lights. I set up the key as "note" first as "momentarily" then as "toggle" Upon pressing the key, the track plays but there is no effect on lights (the default behavior remains the same, meaning the lights is on only momentarily when pressing the midi key)
 

Inviato Wed 11 Jan 23 @ 8:37 pm
Solved by editing the midi controller to leds "externally" controlled (default was "internally" controlled)
 

Inviato Thu 12 Jan 23 @ 10:13 pm
Also:
Why do you define PLAY_L and PLAY_R ?
If the buttons are going to do the same thing, then you need to define them both as PLAY.
This will eventually save you a lot of space on the mapper, and it will make it less prone to mapping errors.

<button cc="0x3F" name="PLAY" channel="0" deck="1" />
<button cc="0x51" name="PLAY" channel="0" deck="2" />

The deck="1" / deck="2" handles the deck assignment automatically.
This means that on your mapper you can use <map value="PLAY" action="play_button"/> and VirtualDJ will automatically know which deck to trigger.
For simple actions separating the buttons on definition level just makes the mapper bigger.
However if you are going to use complex mapping and scripts, "duplicating" them and making sure everything works as intended, becomes more difficult. Also if you ever decide to remap something "on the fly" (I do that more frequently than I would like to admit on my own controllers) you'll have to remember to change it on two places!

So, as a personal advice I would advise you to "merge" identical buttons unless you absolutely have a specific well thought reason for not to..
PS: You can always "split" merged buttons on mapper level with action_deck
action_deck 1 ? play : action_deck 2 ? loop


 

Inviato Thu 12 Jan 23 @ 10:48 pm
Thank you! Learning always something that was not too evident to me. I made my mapping code so much clear and short!
 

Inviato Fri 13 Jan 23 @ 1:49 am