You can use a separate variable and store the incoming value there and then decide when to actually update the parameter map.
Yeah, for now, I settled with a similar workaround - a pot-value-hashmap that’ll be set and checked before setting the parameterMap. Look like this:
PotValues =
{
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
}
-- this function is called when the DAW plugin changes a value and wants to inform the E1 about that change
function OnPluginParameterChanged(value)
-- extract paramValue and paramId from value, irrelevant for this topic
-- determine ID of knob, paramId is always a multiple of the active control set
local activeControlSet = pages.getActiveControlSet()
local knobId = (paramId / activeControlSet) + 1
if PotValues[knobId] == value then
--print("Received value already set. Not setting parameter map to prevent feedback loop!")
return
end
-- set PotValues hashmap to plugin value of current knobId
PotValues[knobId] = paramValue
-- finally, set parameterMap
parameterMap.set(1, PT_VIRTUAL, paramId, value)
end
-- this function is called when the user twists a knob on the E1
function OnPotTwist (valueObject, value)
local parameterNumber = valueObject:getMessage():getParameterNumber()
local activeControlSet = pages.getActiveControlSet()
local knobId = (parameterNumber / activeControlSet) + 1
if PotValues[knobId] == value then
--print("Knob value already set. Not sending out message!")
return
end
-- set PotValues hashmap to value currently set on the E1 to prevent feedback loop
PotValues[knobId] = value
-- send MIDI message to DAW
end
There are other things to consider for breaking up such feedback loops:
- in OnPluginParameterChanged, check if the associated pot is touched and ignore incoming values (user is currently in control of the parameter via a physical knob and no one should overwrite that)
- in the DAW control plugin, detect touched pot states and send the current plugin’s parameter value on untouch if the plugin’s value is different than the last incoming value from the E1
You can use direct midi messages called from functions associated with controls.
So setting a control to send 14bit MIDI messages will make it not send out a 14bit MIDI message when receiving it?
You might also want to look at the parameterMap.onChange() functionality because inside there you can see where the change request is coming from (MIDI, internal code, or an E1 control)
Interesting! So the control would still call a Lua function but that function would be empty. The code sending out the message would reside in parameterMap.OnChange() instead but only react to INTERNAL (E1 knobs?) and ignore LUA and MIDI.