The benefits of parameterMap.send already discovered?

Hi,
I was looking for a way to change a control from another place, and did this with parameterMap.set.
That works beautifully, only… apart from the changed value of the ‘slave’ control, nothing else was occuring: no MIDI messaging was happening, the attached function was not fired.

And now I have discovered the benefits of
parameterMap.send (deviceId, parameterType, parameterNumber)

This one allows you to trigger a control, after you have set its value from somewhere else. And that really opens up a set of possibilities:
For instance, I’m making a preset for a bi-timbral synth, which will allow me to control both timbres together or separately, based on a pad position. In this example, the slave control has a parameter number that is 108 above the master control. The master controls have been given the linkPar function below.
To cope with negative values (due to SysEx values generated with Two’s complement sign mode), I add 128 for any negative value. Works nicely
Be aware however, pad values obtained are always 0 or 1, you don’t get the assigned On /Off values with the code below.
The link variable = when 1 both controls are tied together, when 0 they work independent

function linkPar(valueObject, value)
    if link == 0 then
        return
    end

    local message = valueObject:getMessage()
    local parameterNumber = message:getParameterNumber()

    if value < 0 then
        value = value + 128
    end

    parameterMap.set(deviceId, PT_SYSEX, parameterNumber + 108, value)
    parameterMap.send(deviceId, PT_SYSEX, parameterNumber + 108)
end

If you are into lua, parameterMap.send is a great function to experiment with. Would be happy to hear other ideas to use it.

1 Like

Nice find. Thanks for posting. I’m not far enough into my lua to make use of it but I appreciate the community spirit.

2 Likes

yes, the parameterMap is the hearth of Electra in terms of handling parameters. It distributes all changes automatically and consistently, allowing the user’s Lua script to be simpler.

1 Like

If you do a parameterMap.set(), does that trigger a MIDI message for that param, or is MIDI only generated when you do a parameterMap.send() ? Also - .send() only causes the specific MIDI message to be generated or all parameters get sent?

What I’m trying to do (and it may be the fault of the receiving device) is to adjust the start or end point of a sample while it’s being triggered and I want to make sure the start and end values never equal or cross each other.

To do that, I call a LUA function that check the value of whatever is being moved and if it gets close to the other parameter, the other parameter is shifted away. I’m doing this by updating the parameterMap for the value being adjusted and (possibly) for the other parameter using parameterMap.set() and then using parameterMap.send(). But it appears I’m getting multiple MIDI messages for a parameter change or something.

Just confused really and haven’t had any quality time to sit down with a MIDI monitor and see what’s being transmitted. In the past I was using parameterMap.set() to fill in values from a sysex dump and then just allowing the controls to transmit MIDI as they normally do. I think I’m causing headaches by ignoring what the controls are doing and writing/using parameterMap set() and send()

Would this all work if the controls were virtual and I just used parameterMap set() and send()?

A paramerMap.set() does not trigger the MIDI message. You indeed need the parameterMap.send to generate that specific MIDI message. Others aren’t sent.

How are you changing the first value? If you are changing that one already via a control, the control itself will trigger the MIDI message. For that control you do not need to update the parameterMap yourself. You shoud only apply the .set and .send to the control that needs to be changed indirectly…

And yes, I think making all controls virtual could also do the trick, because then none of them would send MIDI messages on their own.

At least that’s my understanding of parameterMap so far. I’m learning every day :slight_smile:

Is parameterMap.send still available? I cannot find documentation for it but I did find a post reporting that it was not callable (because it was nil) which makes me think that it was removed at some point.

There was a change made in Lua API. It addressed what was discussed earlier in this thread. Before one had to usually call both set() and send(). This was replaced with set() that sets and sends the message. That guarantees that the data in the parameterMap is identical with the data sent to the devices. The change was introduced with the upgrade from 2.x firmware to 3.x firmware.

I see. Thanks for clearing that up. It wasn’t clear form the docs whether parameterMap.set would actually send messages too.

  1. What happens I interact with a control that is assigned to a parameter and has a Virtual message configured? No MIDI Message and a callback to parameterMap.onChange?
  2. What would be a recommended way to send all messages in the parameter map that are recorded for a given device? I.E. if I would want to programatically reset the device to the same state as what is displayed on the screen of the E1 (which could be 0 or anything else)

Yes, that is correct. No message sent out, but onChange() triggered.

I would recommend myself to add a new function(s) to the Lua API :slight_smile: It is easy to do in the firmware. Currently, you would need to keep the values in your own data store and use set() to send all device values.

2 Likes

I would recommend myself to add a new function(s) to the Lua API

That would be really nice!

2 Likes