parameterMap & Devices

Today I tried to adapt the LFO example Preset to my needs. Unfortunately, I am again struggling with the logic behind “parameterMap”.

I am working with the following example function:

function startLFO(valueObject, value)
    -- ________________________________________________________
    if value == 0 then return end
faderValue = 0
timer.enable()
timer.setBpm(120 * 8)
function timer.onTick ()
parameterMap.set(1, PT_CC7, 2, faderValue)
faderValue = math.fmod(faderValue + 1, 13)
end   
end

Activating the Pad, that is assigned to the function it starts, no matter if there is another control available in this preset. I added a dial by decision before adding the pad so that it gets the control ID 1.

The manual says:
parameterMap.set(deviceId, type, parameterNumber, midiValue)

I tried to select a different device from the editor menu but nothing else than 1 works. As soon as I change the control ID of the dial it also stops working. Even though I added another control with the related ID. I’m sorry again, but I can’t get the logic behind it even though I read a lot in the documentation as well as the LUA API.

My goal would be using it like this …

a) the ability to send i.e. CC data directly to different MIDI devices (different MIDI channels within one preset)
b) remotely controlling an E1 control with a certain ID that controls one or more parameters simultaneously (maybe even SysEx)

You will have to provide more detail to render this understandable. Perhaps add a link to the preset where this code is in.

1 Like

I really appreciate your answer. Thank you so much.

However, if it’s so complex that the entire preset needs to be considered, I’d like to see if I can manage without that feature for now. The preset already contains a relatively large amount of Lua code.

My interpretation of the Device ID—apparently too simplistic—led me to believe I could simply change it and send the LFO result to a different destination than ID 1 (at least for the part after a)).

Perhaps I’ll come back to this later. Thanks again.

it basically works that way. The only issue is that you probably have not created controls linked to the devices you want to use.

let me explain:

the parameterMap is a database of all (midi) values for each combination of “device-messageType-parameterNumber“ used in the preset.

if you have a preset that has one Fader that sends CC# 1 to device 1, there will be one entry in the parameterMap.

If you have two faders, say CC #1 on device 1 and CC 2 on device 1, there will be two entries in the parameterMap.

The same counts for CC #1 on device 1 and CC #1 on device 2. They will be represented by two entries in the parameterMap.

If you have two faders in the preset and they both refer to CC #1 on device 1, there will be only one entry in the parameterMap. ie. they share that entry.

The parameterMap is optimized to locate parameter values quickly and it maintains a map of all controls values associated with each entry. This is the main logic behind the E1’s value updates. All input types (MIDI, knobs, LCD touch, remote knobs) eventually result in an update of a particular value in the parameterMap. Once that value is updated, Electra will automatically update all associated controls, trigger functions, formatters, send messages out.

Having said this, it means that in order to have an entry in the parameterMap, there must be a control with a value and message in the preset.

If you create say four dials:

  • dial1 → device Id 1, CC # 2
  • dial2 → device Id 2, CC # 2
  • dial3 → device Id 3, CC # 2
  • dial4 → device Id 4, CC # 2

then changing the deviceId in this Lua function call will address different control:

parameterMap.set(deviceId, PT_CC7, 2, faderValue)

TL;DR you are almost there, you use miss the controls in the preset I guess.

a few notes:

  1. change your code to:
function startLFO(valueObject, value)
    -- ________________________________________________________
  if value == 0 then return end
  faderValue = 0
  timer.enable()
  timer.setBpm(120 * 8) 
end

function timer.onTick ()
  parameterMap.set(1, PT_CC7, 2, faderValue)
  faderValue = math.fmod(faderValue + 1, 13)
end  

so that you do not have the timer function nested in the startLFO callback

  1. you can find the device id in the Device Editor:

or in the JSON:

  1. Since yesterday, there is a new version of the Debugger in the editor. There is still a lot to do, but it already provides some handy functionality. eg. you can print current state of the parameterMap by clicking the “Map” button:

    I will eventually change this to a structured list with the control names and all. For now, it is a simple dump to the logger window.

4 Likes

Hello @martin Thank you so so much for all these information. I greatly appreciate your answer and sharing all the details.

I only wish I could check this immediately. But unfortunately my current schedule doesn’t allow me to work based on it today or during the weekend. But at least next week I will take a deep look into it and provide a feedback about my results.

Thanks again so much! :heart:

1 Like

Hi @martin,

Thanks again a lot for your help.

I did indeed have two knobs with different device IDs. The problem was the CC value. I suspected that the LFO only needed a matching device ID, since the target control sends the MIDI data itself. Therefore, the device ID AND parameter type must match. Sorry for the inconvenience!

I’ve just tested this in my preset and can now automatically ramp up a virtual controller that controls two parameters simultaneously. Of course, this was only made possible with the help of Gemini and your assistance. Thanks again!

2 Likes