Lua - adding a fixed number to MIDI values?

Hello, I’m fairly new to coding and looking for some help with a simple Lua script.

This is for a Sysex based E-Mu Vintage Keys preset which I plan to share once complete.

The voice samples in the E-Mu are listed in the menu as numbers 0 - 434, but in Sysex, the values are 0 for no sample, and then 1537 - 1970 for the voice samples (an addition of 1536).

So I’d like to keep the original numbers in the list for referencing the hardware and add 1536 to most of the values, something along the lines of:
if < 1, use value 0
if > 0, add 1536

I think I can just add a Lua function within the Sysex string to increase the value, but I’m unsure how to code the function.

Also, as there are over 400 samples to label and assign values to, I wonder if there’s any way to upload a CSV type list or create a list in script as it might be quicker to format in this way?

Many thanks!
Jamie

FYI, below is the Sysex string for changing the voice sample.
And attached I’ve added a screenshot of the list (with the first few items changed to the correct Sysex value).

[

“F0”,

“18”,

“0A”,

“00”,

“03”,

“29”,

“00”,

{

“type”: “value”,

“rules”: [

{

“type”: “sysex”,

“parameterNumber”: 13,

“parameterBitPosition”: 0,

“byteBitPosition”: 0,

“bitWidth”: 7

}

]

},

{

“type”: “value”,

“rules”: [

{

“type”: “sysex”,

“parameterNumber”: 13,

“parameterBitPosition”: 7,

“byteBitPosition”: 0,

“bitWidth”: 5

}

]

},

“f7”

]

Similarly, the Pan parameter uses values from -7 to +7 for panning left to right.
However in Sysex, these values are 0 to 7 for centre to right, and 255 for -1 down to 249 for -7 (hard left).
Is there an easy way to remap these values?

Thankfully, all other controls seem straight forward to program!

Please take a look at preset Emu parameters. There are examples of both parameters, sample selection using Lua functions inside the Sysex string and simple twos complement notation for the pan parameter.

That’s very kind, thank you ! That looks like it’ll do the trick :slight_smile:

This works perfectly, thanks!
One thing to note for E-Mu users in this case is you need a bit width of 14 (as in the screenshot), along with the defined Min/Max Values and “Two’s Complement” signing as in Martin’s preset.