Replies: 10 comments 3 replies
-
What synth is it and why are you adding two bytes' values together then multiplying by 16? If it's KORG are you trying to combine MSB, LSB values? Sometimes KORG has a setup where MSB represents the 8th byte of subsequent 7 bytes in a message. |
Beta Was this translation helpful? Give feedback.
-
hey thank you, I thought byte 6 goes to 0f and changes byte 5 to 1 so 16(dec)=01 00. |
Beta Was this translation helpful? Give feedback.
-
I am guessing you are trying to convert two bytes into a single value. Those bytes look like they are 4 bit nibbles - probably true on an old machine like that. Here is an example panel 4 bit nibble Korg Poly 800_1_0.zip Your code would be altered to something like: for _, param in ipairs(parameters1) do local msb = midi:getData():getByte(param[1]) local lsb = midi:getData():getByte(param[1] + 1) local sum1 = combine4n(msb, lsb) panel:getComponent(param[2]):setValue(sum1, true) -- or false? end function combine4n(a, b) -- convert two 4 bit nibbles to a single integer local m = bit.lshift(a, 4) return m + b end --f parameters1 = { {5, "gl11"}, {7, "gl12"} } |
Beta Was this translation helpful? Give feedback.
-
To send MIDI sysex back to the Korg, something like: function create4n(n) -- convert integer into two 4 bit nibbles local bv = BigInteger(tonumber(n)) return bv:getBitRangeAsInt(4, 4), bv:getBitRangeAsInt(0, 4) end local ms,ls=create4n(panel:getComponent("gl11"):getValue()) local ms1,ls1=create4n(panel:getComponent("gl12"):getValue()) local midiout=MemoryBlock(string.format("f0 42 21 08 0A %.2x %.2x %.2x %.2x f7",ms,ls,ms1,ls1)) panel:sendMidiMessageNow(CtrlrMidiMessage(midiout:toHexString(1))) |
Beta Was this translation helpful? Give feedback.
-
Hey thank you for your help. I indeed used the bitshift funkction before and it worked for the paramaters like cutoff...
|
Beta Was this translation helpful? Give feedback.
-
The code you are showing me is midi received. What code are you using for changing modulators :: "when I change gl11 from 0 to 1 it shows 16 2 =32 3=48" ? I don't understand what you mean by "16 2 =32 3=48" Also you have two functions with the same code ~ DRY.
You should generally keep your functions global for re-use elsewhere (potentially) in the program unless you have a good reason for not doing so. Some advanced lua coding gets into what you are doing but it’s usually not the way to go. Also the condition if s == 262 then elseif s <= 262 then end means if s==262 only the first condition will be met so the second elseif should be if the condition < 262 only changes two modulators why not keep it simpler? it's much more readable. elseif s < 262 then local msb1 = midi:getData():getByte(5) local lsb1 = midi:getData():getByte(6) local sum1 = combine4n(msb1, lsb1) panel:getComponent(gl11):setValue(sum1, true) msb1 = midi:getData():getByte(7) lsb1 = midi:getData():getByte(8) sum1 = combine4n(msb1, lsb1) panel:getComponent(gl12):setValue(sum1, true) end |
Beta Was this translation helpful? Give feedback.
-
But what is gl12 supposed to show? And what does gl11 show. Would need to see the incoming dump and what you expect vs what you are getting because for example 03 00 does equal 48 |
Beta Was this translation helpful? Give feedback.
-
gl12 should show 3 in this example because its not 03 00 its 00 03 receives msg = f0 42 21 08 00 00 00 00 gl12(modvalue) = 0 receives msg = f0 42 21 08 00 0f 00 00 gl12(modvalue) = 15 |
Beta Was this translation helpful? Give feedback.
-
[06:02:05:000595]: RAW:[f0 42 21 08 00 01 00 00 00 00 00 00 00 01 00 01 00 03 00 00 00 01 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 01 00 00 00 00 00 00 00 00 03 0f 00 00 03 0f 00 00 00 00 00 0f 00 00 02 07 00 05 00 01 00 00 00 01 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 00 01 00 01 f7] |
Beta Was this translation helpful? Give feedback.
-
It seems to work fine for me : see attached panel. It looks like you need to alter byte 4 and 5 for gl12 |
Beta Was this translation helpful? Give feedback.
-
f0 42 21 08 ms ls ms ls ..... f7
msb lsb structur of received msg is:
00 00
00 01
00 02
...
00 0f
01 00
01 01
I want to represent byte 5 and 6 in modulator gl11 and byte 7 and 8 in Modulator gl12
It works kind of but when I reach value 15 it start by 0 again. Can´t find a solution. Thanks for your help
Beta Was this translation helpful? Give feedback.
All reactions