V3.6 - lua script not working as under v3.5

I don’t know how to describe what’s going on, but my preset ‘Yamaha A5000 remote’ contains some simple LUA to get the encoders to output relative SYSEX values.

  • Worked fine under v3.5.
  • Updated to v3.6 and it no longer produces a continuous string of values in either direction.
  • Reverted to v3.5 and it works again.

Welcome to download the preset and try it yourself (it’s in the Public preset library).
I would imagine this could be an important LUA bug between versions.

encoders 1-5?

or something else?

you can just use the value parameter directly (my debug shows value = 63,64,65 as I turn the encoder back and forth

1 Like

Hi, yes its the encoders on the middle row of the first page. They call a LUA function (which I think you actually sent to me!? back in October last year) to generate relative control data within a sysex string, to mimic the front panel encoders on the Yamaha A5000.

You can read all about it in the original thread here. It worked fine under v3.5, but under v3.6 it doesn’t.

right – that script uses this code:

   local swValue = valueObject:getMessage():getValue()

but all you really need (since you are just sending it along is this:

   local swValue = value
or even simpler:
   local a5kMsg = {0x43, a5kDevNum, 0x58, 0x03, swNum, 0x00, 0x00, 0x00, 0x00, 0x00, value}

BUT - you are right that it is a bug. If you change the range from 63 → 65 to 62 → 66 it works perfectly using your original code.

So @martin there seems to be an issue pulling the valueObject:getMessage():getValue()
when the range is +/- 1 on each side

1 Like

I think 62 → 66 will not work either. The reason is that as of 3.5+ Electra does send MIDI messages and calls functions / formatters only when value changes. Sending duplicate values was reported as a defect in 3.5 and I acknowledged that to be a defect.

I’d suggest to adjust the function so that it resets the encoder to the neutral position after the “relative” change is send out. Something like this:

a5kPort = PORT_1
a5kDevice = 0
a5kDevNum = 0x10 | a5kDevice
NEUTRAL_POSITION = 64


function sendDelta (valueObject, value)
   -- Ignore neutral position
   if (value == NEUTRAL_POSITION) then return end

   -- Get reference to associated messafe
   local message = valueObject:getMessage()

   -- Get the parameter number
   local swNum = message:getParameterNumber()
   
   -- Send the message out
   midi.sendSysex(a5kPort, {0x43, a5kDevNum, 0x58, 0x03, swNum, 0x00, 0x00, 0x00, 0x00, 0x00, value})

   -- Reset to neutral position
   message:setValue(NEUTRAL_POSITION)
end

That way, any movement of the knob will cause a change from the neutral position and will call the function. This will work with 3.5 as well as with 3.5+ just fine.

When I worked with a copy of your preset, I have set the default Control Set to 2 for “A5K Switches” page. It saved me an extra change of the active control set.

Thanks both, this is really great support. I will do as you suggest Martin.