Hey Thanks a lot. I am doing some testing.
- Value send test
We put the filter freq [36] on Value 20 and clear the monitor
We spin back to 0 quickly.
The display shows 10 now…
I count all the arrow down bytes… And see only 10…
So does the Eone send only 10? Is the Mirage not so old in the brain after all?
We put the filter freq [36] on Value 32 and clear the monitor
We spin back to 0 quickly.
The display shows 12 now…
Hmm the webapp debug logs are too short so i re-did this test using the console app.
And got again 12 on the display … so there is some consistency in the behavior.
Counting the bytes from the debug log we get 22 down arrows and 2 up, so 32- 20 down = 12…
Counting the sysex bytes I got the same.
Testing with this template: Electra One App
And here is the lua code
tmrPeriod = 50
timer.setPeriod(tmrPeriod)
timer.disable()
mirageDeviceId = 9
-- set to an impossible value to force mainWorker() to process first touched control
previousParameterNumber = -1
-- holds the value and direction (up or down) for each encoder
-- this is what the timer function uses to send to the Mirage
lastValue = {}
lastDirection = {}
-- holds the current value of each encoder as a user changes different controls
-- when a user comes back to a control, we know the current value to use in the next calculations
curEncValue = {}
oldValue = 0
maxBytes = 5
upArrow= 14
downArrow = 15
-- temporary texts to make reading debug statements easier
dbgTxt = {}
dbgTxt[14] = " Up"
dbgTxt[15] = " Down"
parameterSelect = 12
valueSelect = 13
endCommand = 127
-- which control is currently being changed
currentControl = 0
function timer.onTick()
if (currentControl ~= 0) then
local av = math.abs(lastValue[currentControl])
local ad = lastDirection[currentControl]
print("currentControl = " .. currentControl)
if ( av > 5 ) then
print(" *** Sending 5 arrowBytes, direction is" .. dbgTxt[ad])
lastValue[currentControl] = av - 5
sysexMsg = { 15, 1, 1, ad, ad, ad, ad, ad, endCommand }
midi.sendSysex(PORT_1, sysexMsg)
elseif ( av < 5 ) and ( av > 0) then
print (" *** Sending remaining bytes " .. av .. dbgTxt[ad])
sysexMsg = {15, 1, 1}
for i = 1,av do
sysexMsg[3+i] = ad
end
-- note that the variable i does not exist after the for loop so we cannot use it here
sysexMsg[4+av] = endCommand
midi.sendSysex(PORT_1, sysexMsg)
-- finished sending bytes, zero out the value so we do not send extra bytes if called again
lastValue[currentControl] = 0
currentControl = 0
else
-- catch an edge case
-- somehow we get called for the current control, but with no change in value
print ("Sending nothing - Edge case")
-- lastValue[currentControl] = 0
currentControl = 0
end
end
end
function mainWorker(ValueObject, Value)
local message = ValueObject:getMessage()
local currentParameterNumber = message:getParameterNumber ()
local curValue = message:getValue()
-- worker function called, save off the parameter number
currentControl = currentParameterNumber
if ( currentParameterNumber ~= previousParameterNumber ) then
-- do not have the timer running in case it catches us with partially filled in data
timer.disable()
-- we store the current value as the previous for the next time
previousParameterNumber = currentParameterNumber
-- common way to separate the tens digit and the ones digit
local byte1st = math.floor(currentParameterNumber / 10)
local byte2nd = currentParameterNumber % 10
sysexMsg = { 15, 1, 1, parameterSelect, byte1st, byte2nd, valueSelect, endCommand }
midi.sendSysex(PORT_1, sysexMsg)
-- NOTE - this assumes your controls have a default value of 0
-- if they start with a default of 64 or something else, different code needs to go here
-- get the last value for this control
oldValue = (curEncValue[previousParameterNumber] or 0)
timer.enable()
end
-- we need to keep track of the last value for each encoder
-- there is probably a better way to pull this from the control
-- so we do not have to keep storing it
curEncValue[currentParameterNumber] = curValue
if ( currentParameterNumber == previousParameterNumber ) then
-- figure out how much the encoder has changed from last time to this time
-- note that the value can be positive or negative at this point
local delta = curValue - oldValue
-- save off the current value
oldValue = curValue
-- declare a local variable and set it to something
local arrowDirection = upArrow
-- the default is upArrow (positive) so only do things for negative or zero cases
if ( delta == 0 ) then
print("nothing to do")
return
elseif ( delta < 0 ) then
arrowDirection = downArrow
end
-- for this parameter, save off the last value sent and the direction
lastValue[currentParameterNumber] = (lastValue[currentParameterNumber] or 0) + delta
lastDirection[currentParameterNumber] = arrowDirection
end
end
- Parameter response messages:
Filter freq parameter [36] hex [24]
we send 1 arrow up so value is 1
F0h 0Fh 01h 01h 0Eh 7Fh F7h
Response from the Mirage:
F0h 0Fh 01h 0Dh 00h 24h 02h 00h F7h
we send 1 more arrow up so the value on the panel and eone is 2
Response from the Mirage:
F0h 0Fh 01h 0Dh 00h 24h 04h 00h F7h
So the internal range is 00 … 198 and we have to divide the value by 2 to get the front panel value.
Header Parametermessage keyboardhalf 4bits and program parameternumber in hex value LS / MS nybble the end
F0h 0Fh 01h
0Dh
00h
24h
04h 00h
F7h