Send SysEx command once automatically before sending control values

I wonder if it would be possible to send a SysEx command once, every time the controller is used.

For example if I turn the control knob A:

  1. SysEx A
  2. CC…value23
  3. CC…value24
  4. etc.

Turning control knob B:

  1. SysEx B
  2. SysEx…value23
  3. SysEx…value24
  4. etc.

I’m not sure if it is possible (or even necessary at all) to i.e. create a pad behaving “Momentary”, connect it to a slider and set the slider to trigger it once before it starts sending its dedicated values. If so ideally this pad should be placed on another page so that it doesn’t take any space on the current working page.

Thanks in advance.

If you’re using LUA to script the sysex message + the CC message, the fastest way to implement it would be with a simple flag.

ctrlASysexSent = false

function sendMyCtlAStuff (valueObject, value)

   if (ctlASysexSent == false) then
      midi.sendSysex(PORT_1, message)
      ctlASysexSent = true
   end

   -- send my CC stuff here as usual

end

Then you could use something else to reset all the flags if needed based on the page loading or the preset loading or some other control being used.

2 Likes

Thanks so much @oldgearguy.

Indeed it was my fear that LUA scripting is needed to get something like this working. Unfortunately my scripting knowledge is below zero and my time too rare to start learning LUA with a command line writing “Hello” on the screen which I found through some searches as I bought the E1 last year.

I’ll take a look at some of the awesome Presets here which use LUA and see if I can adapt your example for my situation.

Thanks again and have a great evening.

1 Like

I turned what @oldgearguy suggested to a real-world example to make it easier for you:

This is the preset, you can take a copy and experiment with it.

https://app.electra.one/preset/o7BKMBpMoFA30WccKo6M

If you wanted to keep things simple then each control with this feature would need to have its own function and own flag if the message was sent already.

And, yeah. This is kind of difficult. Lua has been added to E1 to make it possible to script in any type of MIDI processing. It is close to impossible to have all user ideas converted to standard features of the web editor. But I fully understand that programming Lua is not really inline with creative process of producing music :slight_smile:

Anyways, if you need more help let us know. If you wanted me to make edits to your preset, just ping me on PM. I will help.

1 Like

Thanks so much @martin for this awesome help and even providing a ready to test preset. I really appreciate your kind help.

I experimented a bit with it using just two controls for testing purposes and got a working version which looks like this:

ctrlSysexSentBD = false

local ctrlMessage = { 0x43, 0x10, 0x7F, 0x1C,0x0C, 0x01, 0x10, 0x27, 0x00 }

function sendSysexBD (valueObject, value)

   if (ctrlSysexSentBD == false) then
      midi.sendSysex(PORT_1, ctrlMessage)
      ctrlSysexSent = true
   end
end
ctrlSysexSentSD = false

local ctrlMessage = { 0x43, 0x10, 0x7F, 0x1C,0x0C, 0x01, 0x10, 0x27, 0x01 }

function sendSysexSD (valueObject, value)

   if (ctrlSysexSentSD == false) then
      midi.sendSysex(PORT_1, ctrlMessage)
      ctrlSysexSent = true
   end
end

The result is that it sends the SysEx in between each of the control value steps like this:

SysEx		Yamaha 11 bytes	F0 43 10 7F 1C 0C 01 10 27 00 F7
Control	1	7	1
SysEx		Yamaha 11 bytes	F0 43 10 7F 1C 0C 01 10 27 00 F7
Control	1	7	2
SysEx		Yamaha 11 bytes	F0 43 10 7F 1C 0C 01 10 27 00 F7
Control	1	7	3
			
SysEx		Yamaha 11 bytes	F0 43 10 7F 1C 0C 01 10 27 01 F7
Control	2	7	1
SysEx		Yamaha 11 bytes	F0 43 10 7F 1C 0C 01 10 27 01 F7
Control	2	7	2
SysEx		Yamaha 11 bytes	F0 43 10 7F 1C 0C 01 10 27 01 F7
Control	2	7	3

Using the following adaption (“ctrlSysexSentBD/SD” also before the “end” with “= true” which was probably meant like this…

ctrlSysexSentBD = false

local ctrlMessage = { 0x43, 0x10, 0x7F, 0x1C,0x0C, 0x01, 0x10, 0x27, 0x00 }

function sendSysexBD (valueObject, value)

   if (ctrlSysexSentBD == false) then
      midi.sendSysex(PORT_1, ctrlMessage)
      ctrlSysexSentBD = true
   end
end
ctrlSysexSentSD = false

local ctrlMessage = { 0x43, 0x10, 0x7F, 0x1C,0x0C, 0x01, 0x10, 0x27, 0x01 }

function sendSysexSD (valueObject, value)

   if (ctrlSysexSentSD == false) then
      midi.sendSysex(PORT_1, ctrlMessage)
      ctrlSysexSentSD = true
   end
end

… sends each SysEx command just once turning the knob after loading the preset to the E1, then never again.

Ideal case would be if the SysEx were sent once each time the controller is used. The target unit I am using switches the kind of section with the SysEx before using the controller data. And I am not yet sure if the switch is necessary at some later point because in this pretty simple example using just CC07 it even works without switching the section because of the different MIDI channel.

But I can live with the working version. I am just not sure if the SysEx commands between the controller data might cause too much “data salad”. I had the E1 hanging once this morning during my tests.

EDIT: I got the second version of my adaption also working with a SysEx command but it behaves the same, the “one time SysEx” ahead of the controller SysEx is just being sent once. The first way didn’t work at all, it changed the controller SysEx data to “00” for the last three bytes (instead of >… 66, value, F7< it just sends >… 00, 00, 00<).

But please don’t invest too much time in this topic. I know you are very busy with your development and I am just in a phase of investigation and testing by myself. And I am quite happy even with this result.

Thanks again so much!

If I understand what you’re asking is this –

touch control A, send sysex once, then send CCs.
touch control B, send sysex once, then send CCs.

Touch control A again, send sysex once, then send CCs.

What is currently happening is that once a control is touched/used it does not send the sysex message again. Right?

The generic (non-code) answer is that you need to keep track of the last control touched and as long as that is the same, no need to send the system exclusive string again. If a different control is touched, send the sysex for that control and remember it and check against that one from now on. Repeat until done.

2 Likes

Thanks a lot @oldgearguy, that is exactly correct.

My (none-coder) solution will probably stay the first one which at least worked during my tests.

Even without any LUA knowledge at all I was trying to declare a variable in the format that is recommended on different pages through a Google search.

lastFunction = ""

In the script it looks like above (“” in orange) which obviously mean a Synthax Error. How should this be done in this particular version of LUA? Sorry for the “noobness”. :roll_eyes:

That syntax is correct. If no one chimes in, I will try to craft some code in the morning. (Eastern US)

2 Likes

Thanks so much @oldgearguy. That would be awesome. But please do not invest too much time because I’ll probably never have the chance to give something back. :wink: I’ll send you my current script via PN, maybe that can save some time.