@martin , I’m actually having a series of unexpected behaviour, of which I can’t tell which ones are by design and which aren’t. They all feel like the memory allocation is going haywire. It’s become a long message , sorry about that.
The issue above is found in preset “Kingkorg v0”
Just look at the orange controls, the other ones don’t count. ‘Cutoff stuck12’ is not changing its bytes according to the device’s channel, while the others, having the same code, do change along…
But the weird behaviour started before that : I’ll try to give 4 observations in chronological order below
1 . Memory question for preset “NewIgnis Notes transmittor V3”
In this preset there is a user function “assignActive” I call very often, which is meant to populate various arrays with values of those midi channels the E1 needs to respond to when a MidiCC, NoteOn NoteOff and the likes are received.
However I found that when I call this function with the very first control (which has parameter number 1001), the value of the function itself " function assignActive (valueObject, value)" and the value of “local activeValue=parameterMap.get (deviceId, PT_VIRTUAL, 1001)” are different. It’s like the ‘value’ does contains the new value reached by the control, whereas requesting the same value with parameterMap (into variable ‘activeValue’), is giving me the value the control was in before I moved it. So the paramterMap contains a buffered value from before changing it, while invoking the control function. Is that by design?
I worked my way around this by assigning parameter numbers carefully, so I could split them in a pageGroup (for instance 1000) and a midichannel (for instance 01), and depending from where the function was called, I’m using either the value from the function itself, or the value via the parameterMap, as shown below, where I look for both function value and activeValue:
– this updates the active tables ------------------------------------------------------- ACTIVE TABLES
> function assignActive (valueObject, value)
local message = valueObject:getMessage()
> local channel = tonumber(message:getParameterNumber()) % 100
local pageGroup = tonumber(message:getParameterNumber())-channel
print("pageGroup = "…pageGroup)
> local activeValue=parameterMap.get (deviceId, PT_VIRTUAL, 1000+channel )
local assignValue=parameterMap.get (deviceId, PT_VIRTUAL, 2000+channel)
local pbValue=parameterMap.get (deviceId, PT_VIRTUAL, 3000+channel)
local atValue=parameterMap.get (deviceId, PT_VIRTUAL, 3100+channel)
local voicesValue=parameterMap.get (deviceId, PT_VIRTUAL, 5000+channel)
- ParameterMap is not initialised
When further developing this preset into the current draft version “Clone of NewIgnis Notes transmittor V4”, I wanted to have more control over the velocity sensitivity (amount ànd inversion) when receiving a noteOn.The values of how to convert velocity per channel are maintained with the 16 controls on the 2nd half of page 9, where I’ve given them parameterNumbers 9101-9116. I kind of expected that I could simply read those parametes when setting the variable velSens in the script, but that didn’t work: the parameterMap seemed not to be filled with the default settings of the controls when starting the preset. These controls had to be tweaked before the value makes it into the parameterMap which is not my intention… So I created an initialisation code to read in all default values from those 16 controls and then use these to set the parameterMap of those same controls myself. Is that by design?
for i= 1,16 do – initializing
local control = controls.get ((9-1)*36+18+i)
local value= control:getValue (“default”)
local default= value:getDefault ()
parameterMap.set (deviceId, PT_VIRTUAL, 9100+i, default)
- Visualisation bug
When further developing this preset into the current draft version “Clone of NewIgnis Notes transmittor V4”, I wanted to color all the controls as of page 2 in RED, if the corresponding midi channel in page 1 was not yet active. Because of the previous initialisation challenge, I settled for now coloring them all red, with a user function called applyColor (colourValue, channelNumber). That works. But when I call off the same function applyColor via controls 1-16 (each one has control function assignActive, which in turns calls applyColor ) of page 1, it does some weird stuff: apart from what it was supposed to do (coloring controls BLUE, WHITE or RED), it also changes the type, color and name of the controls 19-34 of page 1. It’s clearly some kind of bug, because whenever I change focus on page 1, these ill-represented controls are again replaced by the original controls I configured in there.
function applyColor (value,channel)
local color = BLUE
if channel < 1 or channel > 16 then return end
if value ==0 then
elseif math.floor((channel-1)/4) == 0 or math.floor((channel-1)/4) == 2 then
color = WHITE
controls.get ( 36+channel):setColor (color)
controls.get ( 54+channel):setColor (color)
controls.get ( 72+channel):setColor (color)
controls.get ( 90+channel):setColor (color)
controls.get (108+channel):setColor (color)
controls.get (216+channel):setColor (color)
controls.get (234+channel):setColor (color)
controls.get (252+channel):setColor (color)
controls.get (288+channel):setColor (color)
controls.get (306+channel):setColor (color)
controls.get (324+channel):setColor (color)
controls.get (342+channel):setColor (color)
- E1 freezing
I haven’t gone beyond this stage anymore with that preset, because of this apparent last bug. However, I notice that during use but also on startup the Electra 1 sometimes freezes, which I hadn’t had before. Only way to resolve is disconnect its power.