How to prevent incoming MIDI CC from changing Parameter Map values?

Hi,
I’m making a LUA script to handle incoming MIDI CC messages and Parameter Map.
I want to prevent CC messages from changing Parameter Map value of the control bound to that CC#, in certain situation.
Is it possible?

Initially I was thinking using MIDI callbacks to achieve this. But now, from my understanding,
MIDI callback functions do not override the default behavior, but add an additional hook procedure preserving the default behavior. So the Parameter Map value seems to be always changed by MIDI CC even if I implement the midi.onControlChange().

I use parameterMap.onChange().
One of the parameters is origin.

You can check the origin and if it is MIDI, simply return.

Most of my presets use something like

If origin ~= INTERNAL then return end.

But you can also use the valueObjects parameter to get the control ID and/or parameter number, etc and decide based on all those what to do

Thanks for the comment!

I may have been misunderstanding…
I’ve been thinking that when parameterMap.onChange() is called, the Parameter Map value is already changed.
I’ll try your method!

You may be right – I use PT_VIRTUAL for just about all my controls and as a result the onChange() callback is where I manage all the special cases.
If you’re using a standard PT_CC7 control you’re probably correct - the data has already updated the parameterMap and you’ll have to do something else to handle this exception.

using the PT_VIRTUAL is the way to go. The reason for that is that the parameter map is the main data/event distribution hub in the Electra One firmware. All the function / formatter calls, MIDI messaging is triggered upon changing the data in the parameter map.

@oldgearguy , @martin ,
Thank you for clarifying guys!
I now understand the difference of the behaviors between PT_VIRTUAL and PT_CC7.
I’ll try!

1 Like

I have created a preset with PT_VIRTUAL control and implemented midi.onControlChange() to connect MIDI CC value to parameter value.
It’s working as I expected. Thanks!

But a new problem has occurred…
When I add quite a few controls (e.g. 384) on my preset, my E1 gets frozen after receiving consecutive MIDI CC messages for several seconds.
I checked the log messages in E1 app, but it doesn’t say anything about the error.

My E1 is :
MK1
Hardware revision 2.10
Firmware version v3.5.4

Preset contents :

  • 12 PT_VIRTUAL faders per MIDI channel
  • All 2 ports and 16 channels are used
  • So, there are 2 * 16 * 12 = 384 faders in my preset

About the received MIDI CC message :

  • Destination : PORT_1, Channel 1, CC# 1 only
  • Message frequency : 64 messages per second

My LUA code is very simple as below.
Strangely, if I comment out the function parameterMap.onChange(), it doesn’t get frozen.
Is there any fault in my code?

function preset.onLoad()
end

function midi.onControlChange(midiInput, channel, controllerNumber, value)
    parameterMap.set(1, PT_VIRTUAL, controllerNumber, value)
end

-- It doesn't freeze if this function is commented out
function parameterMap.onChange(valueObjects, origin, midiValue)
end

I also attach my preset.
Very sorry for bothering you but could you please check these?

384 virtual params.epr (98.8 KB)

1 Like

I will take a look at it over the weekend.