Home › Forums › General › Programming › Sysex and Msb/Lsb – too hard for me (noob)
- This topic has 8 replies, 2 voices, and was last updated 4 years ago by jmarco.
-
AuthorPosts
-
March 26, 2020 at 5:03 am #117514
Hello.
…
How can I program a knob with an arpeggio speed for N1. I keep not understanding MSB / LSB and how to use it…
…
I’m new to this, but I’m loving it!
…
I let a tech page with this Korg information. Arpeggio speed is on the page 17, almost in the end.
If you could make me a Sysex F0…. f7, I would be very happy. MAybe I could understand that once and for ever.
…
https://drive.google.com/file/d/1q0I4XCGeD-247miizuJ4eKypIgInF1xG/view?usp=sharing
…
Thanks a lot.
…
João Marco- This topic was modified 4 years ago by jmarco.
March 27, 2020 at 2:01 am #117517Hi João,
I attach a panel which shows how to do it in Ctrlr without lua.
Because the arpeggiator has a value above 128 the sysex value sent needs to be split into two bytes MS LS in the Ctrlr interface message. That is Most Significant Byte MSB and Least Significant Byte LSB.f0 42 yy 4c 08 11 00 LS MS f7
yy means channel.
MIDI values are 7 bit 0111 1111 7F = 127 – that’s the limit for one byte; you can only send values from 0-127 with one byte, so because the arpeggiater goes to 240 – you need to send two bytes.
One LSB byte represents values up to 128 0-127: eg for 240 that is 240-128=112
The MSB is another byte recording how many 128s to add to the value. eg for 240 that is 1*128+112So if you dial in 200 as a value, it’s over 128 so 200-128=72 so your LSB will be 0x48 (hex) 0100 1000 – your MSB is 128 1000 0000. Add 0100 1000 + 1000 0000 and you get 1100 1000 C8 = 200. But it has to be sent in two byte messages.
I don’t have the machine, but I am guessing:
F0 42 04 4C 08 11 48 01 f7 (it looks like the Korg sends LSB first 0x48 and MSB second 0x01). O4 is channel 5
Regards,
Attachments:
You must be logged in to view attached files.March 28, 2020 at 2:35 pm #117546Hello.
…
I really like your lua code, but where is it for me to read it? I cannot find it…
…
By the way it doesn’t work. I’ve changed the 04 for 34, as in the korg manual – thanks for let me know that about yy. Can you look again. 🙂 I’m looking for an answer for two days now…
…
Thanks a lot for your help. I really appreciate it.
…
You can take a look at my work – I’ve upload it for the panel subforum. Hope you like it.- This reply was modified 4 years ago by jmarco.
March 28, 2020 at 3:15 pm #117548Hi João,
Well the code there is a bit of a wild guess. I see so channel is 0x30 + n – sorry about that. That would make the correct sysex
F0 42 34 4C 08 11 48 01 f7
Can you confirm this?
What/Where is the panel subforum? Can you link to it?
If you changed the 04 for 34 I guess you found it in the sysex message field
A lua function would look like:
-- -- Called when a modulator value changes -- @mod http://ctrlr.org/api/class_ctrlr_modulator.html -- @value new numeric value of the modulator -- luaGeneratedSysexExample = function(--[[ CtrlrModulator --]] mod, --[[ number --]] value, --[[ number --]] source) local channelOut=panel:getProperty("panelMidiOutputChannelDevice") local lsb=value local msb=0 if value > 127 then lsb=value-128 msb=1 end sysex_string=string.format("F0 42 %.2x 4C 08 11 00 %.2X %.2x F7",0x30+(channelOut-1),lsb,msb) panel:sendMidiMessageNow(CtrlrMidiMessage(sysex_string)) end -- function
March 28, 2020 at 9:10 pm #117549March 30, 2020 at 4:09 am #117567The value 11 is decimal ! – it needs to be 0x0B in the message!
Try the following panel. There are two possibilities as I see it:
I think Korg calculates MSB different to the system I suggested above (which works for Yamaha)
Attachments:
You must be logged in to view attached files.March 30, 2020 at 7:00 pm #117577Thank you. It’s a great mini method.
…
Not working… 🙁
…
Maybe it’something to do with edit parameter change / part parameter change?
…
I can make it work in the list attached to number 7 Arp. Switch, but no more… and I don’t have a clue why.
…
EDIT:
It’s Working!!
F0 42 %.2x 4C 08 0b 00 %.2X %.2x F7
…
You send it as b0. GREAT!And also “1” not “128” in the end:
elseif name == “v2” then
lsb,msb=value,0
if value > 127 then
lsb=value-128
msb=1
endGREAT, GREAT!
Thanks a LOT
…- This reply was modified 4 years ago by jmarco.
- This reply was modified 4 years ago by jmarco.
- This reply was modified 4 years ago by jmarco.
Attachments:
You must be logged in to view attached files.March 31, 2020 at 3:26 am #117596
Great to hear!So the original was correct except for the 11 which should have been
0b
not B0 of course!!!Here is another panel demonstrating four ways I know of splitting the byte into two values.
[1] in Ctrlr
f0 42 yy 4c 08 0B 00 LS MS f7
in lua:
-- [2] local bv=BigInteger(value) local lsb=bv:getBitRangeAsInt(0,7) -- position of lsb local msb=bv:getBitRangeAsInt(7,7) -- position of msb --[3] local lsb,msb=value,0 if value > 127 then lsb=value-128 msb=1 end --[4] local lsb=bit.band(value,127) local msb=bit.rshift(value,7)
Ignore panel version 3, use version 4 – panel 3 contains unnecessary code for method [4]
Attachments:
You must be logged in to view attached files.April 1, 2020 at 9:44 am #117617Thanks a lot. I seems very good this Ctrlr.
…
Let me jump into it! -
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.