Device ID onLoad()?

For some applications, it’s useful to have the deviceId early.

I know that I can use message:getDeviceId() to retrieve the device ID inside a control.
Also, if I happen to have a format or function call associated with a control, it is executed on load and I can use valueObject:getMessage():getDeviceId(0 inside there to get it, but that is called every time those functions are executed, which seems a bit wasteful.

Is there any way onLoad() we can get the device ID associated with the preset? For me, it’s useful so that I can properly set the MIDI port and channel for the device.

Side note - in the JSON, I’ve seen multiple device ID associated with the preset. I guess this is so that a single preset could maybe talk to multiple devices?

More device ID headaches –

I am sharing a preset with another developer. When the preset was started, the device ID was set somewhere to 20. Most of the controls created have device ID 20, but some do not.

If I go into the JSON, I can see the “bad” device IDs and change them and upload those changes to the Electra One.
However, those changes do not stick and the controls do not respond properly to the incoming data.

In general, it seems there are ways in LUA to get/set device ID info, but there’s nothing in the web UI to view/set/change the device ID. Even editing the JSON does not work.

EDIT – hmm, I think I see the problem. The device was originally port 2, channel 4, which maps to 20. In my device dropdown list I have been picking port 2, channel 4, but at some point that “label” is stored in slot 1 as well, so I have been selecting device 1 without knowing it.

The sequence that worked for me was –

  • in the web UI, click on the Highlighted/blue background “Generic MIDI”,
  • then click on the horizontal lines with bubbles below that to Edit Device,
  • verify that it shows up as the correct port and channel,
  • then I edit the name from Generic MIDI to something else and then exit that menu.

Now when I create a control I can see that name show up in the Device area.