I'm working on some Macro's to make a keyboard encoder control my DAW (Ableton Live) track volume, using raw MIDI packets + HUI protocol (HUI uses the Pitch Bend data to control volume faders)
As far as sending the MIDI packets from KM to the DAW I got it functional, the Macros look like this:
I just increment/decrement a decimal variable, convert it to Hex and send the packet.
However, I also need to send MIDI packets from the DAW to KM in case I change the volume using my mouse as this would cause the variable I'm using to increment/decrement to be out of sync so the volume would jump around, this is what I am struggling with...
I tried to set up another Macro that only listens to what the DAW sends in order to update the %PitchWheel% Variable. For now, I only care about packets that start with "E0" as that relates to MIDI Channel #1, I've tried the regex "^E0*" on the Macro trigger to catch everything in MIDI Channel #1 and then convert the matches back to decimal to update the variable, like this:
The above is giving me what seems like random values so I messed up bad somewhere, I would really appreciate some help.
I use the following to read MIDI data, which differs to your code in that I do not read and decode the packet information. Not sure if this helps in your particular project or not, but maybe worth trying.
To listen to what the DAW is sending out, I use MIDI Monitor which is really useful,
I had a mistake on the last macro, "To Text" instead of a "calculation", I fixed it.
But I think there might be a bug related to raw packets.
Manual says this:
The %TriggerValue% token will the space-separated hex values representing the packet. You can easily access the individual parts using the token array notation, eg %TriggerValue % will be the third value (8.0.4+) — note the [space] in ][space]% , the space is the separator for the array, instead of the default comma.
But from a received packet that is exactly this: E0 65 6C,IAC Driver Bus 1
%TriggerValue % returns E0
%TriggerValue % return 65
But %TriggerValue % returns 6C,IAC - It's getting the last data byte but also a piece of the MIDI Port name, I think it's due to the separator being a comma instead of a space.. ?? @peternlewis Am I miss interpreting something or is it a bug?
The wiki omits that the TriggerValue token includes the source device name, so the format is BYTES,Device Name.
Since the %TriggerValue[n] % is using space separated entries, the last byte will also include the comma and part of the device name (up to the first space).
So you will need to first extract the bytes in to a variable, and then use the same technique to access the bytes.
This was not really a great choice for how to implement this, but it is what it is. There is no bug involved, just some unwise decisions which lead to a bit more work to extract the last byte of the packet.
Ohh... Thanks @peternlewis, I'm still pretty confused but got it working.
Now if I use the mouse on Ableton it changes the variable as well, everything is synced. The method I am using is probably terrible for efficiency, I'm using Search And Replace to remove the ,IAC text from the variable. Also, for some reason, I had to invert the data position on KM's Input... %TriggerValue % %TriggerValue % no idea why tbh...
I'll attach my Macro here in case anyone interested in Mackie HUI protocol wants to try and improve it.