Quick Sign In:  

Forum: VirtualDJ Technical Support

Topic: Sending MIDI CC Commands
chaolaPRO InfinityMember since 2010
I use a USB-MIDI interface to send MIDI CC commands to devices. These are triggered by the POI. I created a device definition and a mapper.
Setup works. Now I would like to use variables instead of static CC values in the device definition and set them in the POI. Is this somehow possible?
If yes how?
 

Posted Wed 14 Dec 22 @ 1:23 pm
No, it's not possible to use any kind of VDJ Script code on device definitions.
Device definitions are just the way to "talk" to the device.
What you're "talking", is the mapper.

I don't know how you have set things up, so in order to help please provide us an example of how you have mapped it right now, and how (in theory) you would like to transform it.
 

Posted Wed 14 Dec 22 @ 1:46 pm
chaolaPRO InfinityMember since 2010
Thanks for your reply. Here my trys

device definition:
<?xml version="1.0" encoding="UTF-8"?>
-<device image="" decks="1" drivername="MIDI" type="MIDI" pid="0x0101" vid="0xFC02" author="Me" name="USB MIDI Interface">
<!--Device Definition-->
<led name="LED_PLAY" note="0x23"/>
<led name="LED_PGM" channel="15" zero="0x16" ccoff="0x15" value="0x18" cc="0x19"/>
<button name="PLAY" note="0x71"/>
</device>

Mapper:
<?xml version="1.0" encoding="UTF-8"?>
-<mapper date="15/11/2022" version="800" author="Me" device="USB MIDI Interface">
<map action="play? off : on" value="LED_PLAY"/>
<map action="play_pause" value="PLAY"/>
<map action="'$Pgm'1 ? on : off " value="LED_PGM"/>
</mapper>

POI
action 1 = set_var '$Pgm' 1
action 2 = set_var '$Pgm' 2

This works fine so far. But I would like to set the values for the cc massages in the POI editor to get more flexebility.

 

Posted Wed 14 Dec 22 @ 2:10 pm
If the LED_PGM for instance can take multiple values, then you could define it as a <bar /> element.
Then on your mapper you still use a variable to control it. However the variable now is a float number (ranging from 0.0 to 1.0) that transcends to the possible values defined in the <bar /> element.

https://www.virtualdj.com/wiki/ControllerDefinitionMIDI
 

Posted Wed 14 Dec 22 @ 8:00 pm
chaolaPRO InfinityMember since 2010
Thanks for the hint. Can you give me an example how to map this bar element in the mapper? I guess it works like the "mask" in the device definition...?
 

Posted Thu 15 Dec 22 @ 9:08 am
Could you share more info about the device itself ?
Is it a physical device, or just a bridge to control another app or something ?
Depending on the device type I can give you some examples..
 

Posted Thu 15 Dec 22 @ 6:52 pm
chaolaPRO InfinityMember since 2010
Our goal is to send program change messages to synthesizers and audio mixers via MIDI, depending on the loaded song. These should be defined in the POI Editor.
As far as I know, VDJ does not support program change messages. Therefore we have decided to transmit CC messages, which are converted by a MIDI translator into the desired PC messages. The final interface on VDJ will be a simple 4-port USB to MIDI interface.
Of course there are simpler solutions for this special task, for example a Digital Audio Workstation. But we have a DJ on board who plays a central role for the performance and cannot do without VDJ. I assume that such a solution is not only interesting for us.

So far, despite extensive research, I have not found an example for mapping the bar element.
Thanks for your interest!
 

Posted Fri 16 Dec 22 @ 11:08 am
A full CC message consists of 3 parts and it would be like BX YY ZZ
B is the message type (CC change) and X is the channel. So B0 is CC change at channel 0
XX is the MIDI CC itself. It can be any value from 00 up to 7F (HEX). So it's 128 possible values.
YY is the value of the given CC

B0 10 00 <- CC 10 change at channel 0 to value 00
B0 10 3A <- CC 10 change at channel 0 to value 3A

When you define a CC led, you actually define it like this:
B0 10 00 <- CC 10 change at channel 0 to value 00 = LED OFF
B0 10 7F <- CC 10 change at channel 0 to value 7F = LED ON

So, you can instead use a bar
<bar name="LED_VU" cc="0x10" channel="0" zero="0x00" max="0x7F" deck="1"/>
And map it like this:
<map value="LED_VU" action="get_level" />
Now what happens is that you send CC 0x10 all the time with different values.
Of course you need to adjust things accordingly on the receiving side as well.


If you want to use different CC's for some reason, you can also use the following approach:

<led name="LED_CC_000" cc="0x00" deck="1" channel="0" />
<led name="LED_CC_001" cc="0x01" deck="1" channel="0" />
<led name="LED_CC_002" cc="0x02" deck="1" channel="0" />
<led name="LED_CC_003" cc="0x03" deck="1" channel="0" />
<led name="LED_CC_004" cc="0x04" deck="1" channel="0" />

And:
<map value="LED_CC_000" action="var_equal 'CCOut' 0"/>
<map value="LED_CC_001" action="var_equal 'CCOut' 1"/>
<map value="LED_CC_002" action="var_equal 'CCOut' 2"/>
<map value="LED_CC_003" action="var_equal 'CCOut' 3"/>
<map value="LED_CC_004" action="var_equal 'CCOut' 4"/>

This approach allows you to just set a single variable on the POI editor and set it on the desired value.
However it also means that only ONE CC output can be "on" at a time.

PS: I don't know if you have take a look, but I have created a virtual MIDI bridge that receives and sends various messages to Freestyler (A DMX lighting application). If you haven't, download it and take a look at the files. It uses most, if not all, possible cases of defining and mapping you may need.
https://www.virtualdj.com/forums/218737/VirtualDJ_Plugins/The_Advanced_Freestyler_integration_thread.html?search=freestyler&page=1
 

Posted Fri 16 Dec 22 @ 12:09 pm
chaolaPRO InfinityMember since 2010
Thank you for your help.
The second example is exactly what I need. I will try it immediately.
I know my way around MIDI quite well. I have been building professional recording studios for many years. The first fader automations on audio mixing desks were controlled via MIDI.
Of course I also have your suggestion in the topic: "How can I send Midi signals with Points of Interest in Virtual DJ?" found and tested.
*********************************************
Example:
POI:
type=action, action=repeat_start_instant 'StartFunkyChase' 10ms 2 & toggle "$Chase1"
Mappers:
key=LED_CHASE1 action=get_var '$Chase1'
Device definition:
<led note="0x17" name="LED_CHASE1" channel="1" />
*******************************************

It works, but not without problems. The Stop button triggers this action again. I haven't had the time to figure out the cause yet.

By the way.... Is there an elegant way to debug in VDJ? I am currently using the browser via VDJ remote.

Thanks
 

Posted Fri 16 Dec 22 @ 1:42 pm
locoDogPRO InfinityModeratorMember since 2013
there is var_list & the debug scripts

debug being something like
get_var $a & param_cast & debug

fyi, rsi scripts the repeat time is fuzzy [if you stated 50ms, it might be 47ms one time and 52ms the next] , last time I checked the fastest it ran at was around 30ms

maybe stop is pulling playhead back to the apoi
 

Posted Fri 16 Dec 22 @ 1:59 pm
chaolaPRO InfinityMember since 2010
PhantomDeejay wrote :
A full CC message consists of 3 parts and it would be like BX YY ZZ
B is the message type (CC change) and X is the channel. So B0 is CC change at channel 0
XX is the MIDI CC itself. It can be any value from 00 up to 7F (HEX). So it's 128 possible values.
YY is the value of the given CC

B0 10 00 <- CC 10 change at channel 0 to value 00
B0 10 3A <- CC 10 change at channel 0 to value 3A

When you define a CC led, you actually define it like this:
B0 10 00 <- CC 10 change at channel 0 to value 00 = LED OFF
B0 10 7F <- CC 10 change at channel 0 to value 7F = LED ON

So, you can instead use a bar
<bar name="LED_VU" cc="0x10" channel="0" zero="0x00" max="0x7F" deck="1"/>
And map it like this:
<map value="LED_VU" action="get_level" />
Now what happens is that you send CC 0x10 all the time with different values.
Of course you need to adjust things accordingly on the receiving side as well.


If you want to use different CC's for some reason, you can also use the following approach:

<led name="LED_CC_000" cc="0x00" deck="1" channel="0" />
<led name="LED_CC_001" cc="0x01" deck="1" channel="0" />
<led name="LED_CC_002" cc="0x02" deck="1" channel="0" />
<led name="LED_CC_003" cc="0x03" deck="1" channel="0" />
<led name="LED_CC_004" cc="0x04" deck="1" channel="0" />

And:
<map value="LED_CC_000" action="var_equal 'CCOut' 0"/>
<map value="LED_CC_001" action="var_equal 'CCOut' 1"/>
<map value="LED_CC_002" action="var_equal 'CCOut' 2"/>
<map value="LED_CC_003" action="var_equal 'CCOut' 3"/>
<map value="LED_CC_004" action="var_equal 'CCOut' 4"/>

This approach allows you to just set a single variable on the POI editor and set it on the desired value.
However it also means that only ONE CC output can be "on" at a time.

PS: I don't know if you have take a look, but I have created a virtual MIDI bridge that receives and sends various messages to Freestyler (A DMX lighting application). If you haven't, download it and take a look at the files. It uses most, if not all, possible cases of defining and mapping you may need.
https://www.virtualdj.com/forums/218737/VirtualDJ_Plugins/The_Advanced_Freestyler_integration_thread.html?search=freestyler&page=1


I tested the 2nd variant. Unfortunately unsuccessful. The defined CC's are initialized after the start of VDJ and set to the value "0" . These are also output via the MIDI interface.
In the POI I set the variable 'CCOut' to the predefined values ​​0, 1, 2 one after the other at a time interval of
2 seconds. I can successfully track the changes of 'CCOut' using var_list.
No changes happen on the MIDI channel.

Here the device definition:

<?xml version="1.0" encoding="UTF-8"?>
-<device image="" decks="1" drivername="MIDI" type="MIDI" pid="0x0101" vid="0xFC02" author="Me" name="USB MIDI Interface">
<!--Device Definition-->
<led name="LED_DUMMY" channel="4" note="0x17"/>
<led name="LED_CC_000" channel="7" cc="0x00"/>
<led name="LED_CC_001" channel="7" cc="0x01"/>
<led name="LED_CC_002" channel="7" cc="0x02"/>
</device>

The mapper:

<?xml version="1.0" encoding="UTF-8"?>
-<mapper date="15/11/2022" version="800" author="Me" device="USB MIDI Interface">
<info>https://www.dropbox.com/s/xxxxxxxxxxx/manual.txt</info>
<map action="get_var '$Dummy'" value="LED_DUMMY"/>
<map action=""var_equal 'CCOut' 0"" value="LED_CC_000"/>
<map action=""var_equal 'CCOut' 1"" value="LED_CC_001"/>
<map action=""var_equal 'CCOut' 2"" value="LED_CC_002"/>
</mapper>


in the POI-Editor:

set_var 'CCOut' 1 and so on

Where is the mistake?




 

Posted Sun 18 Dec 22 @ 6:04 pm
If this is a direct copy/paste of your mapper, then I can see some double quotes that would render the mapper to not work properly:
You have: <map action=""var_equal 'CCOut' 0"" value="LED_CC_000"/> but the correct is <map action="var_equal 'CCOut' 0" value="LED_CC_000"/>
So, if this is a direct copy paste remove the double quotes around ACTION (action=""var)
 

Posted Mon 19 Dec 22 @ 1:01 pm
locoDogPRO InfinityModeratorMember since 2013
I think no deck specified in the def also be a further issue, what with you using a local var. As is it [the mapper] would only pull from the default deck.
 

Posted Mon 19 Dec 22 @ 1:07 pm
That as well, but without deck on the definition it would pull the actions from the "default" deck.
Therefore it should send something, but not always correct :P
But yes, please include deck as well.
Otherwise, convert the variable to global like set '$CCout' and var_equal '$CCout' 1
The dolar sign is what makes the variable global
 

Posted Mon 19 Dec 22 @ 1:41 pm
chaolaPRO InfinityMember since 2010
PhantomDeejay wrote :
If this is a direct copy/paste of your mapper, then I can see some double quotes that would render the mapper to not work properly:
You have: <map action=""var_equal 'CCOut' 0"" value="LED_CC_000"/> but the correct is <map action="var_equal 'CCOut' 0" value="LED_CC_000"/>
So, if this is a direct copy paste remove the double quotes around ACTION (action=""var)



That was exactly the problem! I use Microsoft XML Notepad to edit the xml and didn't realize in this moment that the app itself inserts the " ". grrrrrrrrr
I have now also defined the deck.

You don't see the forest because of the many trees!

Thank you guys
 

Posted Mon 19 Dec 22 @ 4:18 pm
Use Notepad++ instead (a free opensource text editor)
I use it all the time, and what's nice is that it also colorize the text (for XML formatting) and you can easily tell if something's wrong!
 

Posted Tue 20 Dec 22 @ 1:21 am