I’ve been trying to access a control during a midi callback function. I need to find the parameter id number so I can use parameterMap.set (). I tried using the following which didn’t work:
local control = controls.get(targetControlId)
local message = control:getMessage()
local paramID = message:getParameterNumber()
I then used the following which did work but it is confusing.
local control = controls.get(targetControlId)
local value = control:getValue():getValue()
parameterNumber = control:getValue():getMessage():getParameterNumber()
I then refactored the code to this:
local control = controls.get(targetControlId)
local valueObject = control:getValue() -- I want to better understand this line
local message = valueObject:getMessage()
local paramID = message:getParameterNumber()
parameterMap.set(1, PT_VIRTUAL, paramID, fourteenBitValue)
I think I am misunderstanding how json works and I often get confused by what I need to get and how best to get it. I know a common routine to acces the value of the control is something like this and I feel this all makes sense.
function process_active_fx(valueObject, value)
local control = valueObject:getControl()
local onVal = valueObject:getMessage():getValue()
local onVal = 6 - value
parameterMap.set (deviceId, PT_CC7, 126,onVal );
end
However that changes when you need to use control = controls.get(id) because there is no value object. I feel that the language used on the call to valueObject = control:getValue() should be changed to valueObject = control:getValueObject() The reason I think this makes sense is that there are other calls made to getValue where you are specifically getting a value rather than the object. I’m sorry if I am being confusing. Really all I am looking for is a straightforward way to get and set things and I am simply sharing my challenges in accessing the parameterNumber programmatically in order to use parameterMap.set(). I’ll take any insight. Maybe there is a way to make it easier for users or explain the methods on how to access the various json levels. That’s not to say I am complaining because I really love this device and all the capabilities it offers. I think most of my difficulties come from a lack of understanding how these calls relate to json.