Sysex MIDI Channel

I was looking at some of the Sysex presets (Roland MKS-50, D550) and they hardcode to MIDI channel 1 (00) in the bytes. To make that flexible and use the device’s MIDI channel, is a LUA function returning device:getChannel() the best approach?

In short: Yes of course.

One should never program a byte that is considered as a variable by the manufacturer (such as a MIDI channel or a Device ID) as a fixed value in a SysEx message.
It is easy enough in lua to adress a variable with the right value in the first lines of the code, and then use a small function to return that value inside the SysEx. Then it is fairly easy later on to change one or all of these variables without having to manually change each and every single SysEx message.

1 Like

Isn’t sysex omnichannel?
DeviceID is of course important and afair some manufacturers tie the device ID to the midi channel of the device, but actual sysex in. Midi is omni. (again AFAIK)

SysEx isomnichannel technically. That means all receivers will listen in, regardless of the MIDI channel there are tuned to.

However, some manufacturers have the midi channel built in into their SysEx to distinguish between various devices of the same model.

The way to distinguish between same model devices was supposed to be with a Device ID you configure in the synth, but not all followed that recommendation.

An example with a deviceID
The Waldorf Pulse, uses this to request the Globals setting:
image

In most of my synth lua, I start upfront with assigning the main synth characteristics in a set of variables to use anywhere in the code. The waldorf Pulse starts as follows:

sysexDeviceID=0 -- the device ID configured in the pulse
deviceId = 1 -- the device ID used in the E1 preset
device = devices.get(deviceId)
devPort = device:getPort() -- the port on the Electra 
channel = device:getChannel() -- the MIDI channel 

Please do remark the ‘device’ that is referred to in MIDI SysEx is not to be confused with the Device the front-end of the Electra One editor is referring to. For that reason, in lua it is recommended to call the first ‘sysexDeviceID’, while the latter is simply ‘deviceID’.

The function “sysexDevice” is quite simple

function sysexDevice()
  return sysexDeviceID
end

Another example: here’s the sysEx request for OSC1 PITCH on a Korg DS-8 FM-synth


As you notice, I had to insert the MIDI channel in the message, as follows:

-- returns a byte that DS8 uses to identify the MIDI channel
function getChannelByte(device)
return (0x30 + (device:getChannel() - 1))
end

The Korg M3 and 03R/W are using the same method, so I guess the M1 and 01W did it as well. But even a more recent machine like the KingKorg still does it.

Last example

The Yamaha TX7 is even using different bytes in sysEX to identify the MIDI channel, depending if it is a dump request or a parameter change:

-- returns a byte that TX7 uses to identify the MIDI channel
-- for a parameter change message
function getChannelByte(device)
  return (0x10 + (device:getChannel() - 1))
end

-- returns a byte that TX7 uses to identify the MIDI channel
-- in a dump request
function getRequestByte(device)
  return (0x20 + (device:getChannel() - 1))
end

Thanks for the info @NewIgnis, I’m aiming to start as I mean to go on and this makes sense. I’m new to Electra but not sysex and so yes ideally the Midi Channel and Device ID should be held separate in outside variables if possible.

Does the device object carry a deviceId, e.g. device::getId(), or is that more of an internal ID rather than the actual MIDI device’s ID? I note you are creating a variable for it above so I’m thinking the latter?

the object device in lua has nothing to with the notion device in SysEx, but with the notion device for Electra One, like the one below for a Pro-800.

I use that object to define port and MIDI channel without hard coding. So if anyone copies a preset and change the devices MIDI channel or Port, all lua code keeps functioning.

deviceId = 1 -- the device ID used in the E1 preset
device = devices.get(deviceId)
devPort = device:getPort() -- the port on the Electra 
channel = device:getChannel() -- the MIDI channel

OK thanks. It would probably be a reasonable feature request to have an optional “MIDI Device ID” property settable in the LUA device object and per your screenshot for completeness? @martin is this something you might consider?

Roland utilises device IDs and if two of the same devices are in the MIDI chain, it can resolve the correct device using sysex when the device IDs are set differently in the hardware. MIDI channel isn’t enough if the devices are multitimbral since there would be a clash, hence why device ID comes into play.

You don’t need a setting for it. Just make two presets. Or ln case you have a dozesn of the same model, add a parameter to your preset with which you choose the device to control.