Sysex and Msb/Lsb – too hard for me (noob)

Home Forums General Programming Sysex and Msb/Lsb – too hard for me (noob)

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #117514
    jmarco
    Participant
      • Topics: 9
      • Replies: 22
      • Total: 31

      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.
      #117517
      dnaldoog
      Participant
        • Topics: 4
        • Replies: 480
        • Total: 484
        • ★★

        Hi 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+112

        So 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.
        #117546
        jmarco
        Participant
          • Topics: 9
          • Replies: 22
          • Total: 31

          Hello.

          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.
          #117548
          dnaldoog
          Participant
            • Topics: 4
            • Replies: 480
            • Total: 484
            • ★★

            Hi 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
            
            #117549
            jmarco
            Participant
              • Topics: 9
              • Replies: 22
              • Total: 31

              Hello, again. Yes, I,ve changed that value, but without success!

              Well, I’ll keep trying. Thanks for this code, I will take a closer look.

              Lua is a nice language to learn in quarentine.

              Here is my panel:

              Korg N1


              Thanks for this!

              • This reply was modified 4 years ago by jmarco.
              #117567
              dnaldoog
              Participant
                • Topics: 4
                • Replies: 480
                • Total: 484
                • ★★

                The 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.
                #117577
                jmarco
                Participant
                  • Topics: 9
                  • Replies: 22
                  • Total: 31

                  Thank 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
                  end

                  GREAT, 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.
                  #117596
                  dnaldoog
                  Participant
                    • Topics: 4
                    • Replies: 480
                    • Total: 484
                    • ★★


                    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]

                    • This reply was modified 4 years ago by dnaldoog.
                    • This reply was modified 4 years ago by dnaldoog.
                    Attachments:
                    You must be logged in to view attached files.
                    #117617
                    jmarco
                    Participant
                      • Topics: 9
                      • Replies: 22
                      • Total: 31

                      Thanks a lot. I seems very good this Ctrlr.

                      Let me jump into it!

                    Viewing 9 posts - 1 through 9 (of 9 total)
                    • The forum ‘Programming’ is closed to new topics and replies.
                    There is currently 0 users and 78 guests online
                    No users are currently active
                    Forum Statistics
                    Threads: 2,495, Posts: 17,374, Members: 77,605
                    Most users ever online was 12 on January 22, 2019 3:47 pm
                    Ctrlr