• Products
    • Isadora
    • Get It
    • ADD-ONS
    • IzzyCast
    • Get It
  • Forum
  • Help
  • Werkstatt
  • Newsletter
  • Impressum
  • Dsgvo
  • Press
  • Isadora
  • Get It
  • ADD-ONS
  • IzzyCast
  • Get It
  • Press
  • Dsgvo
  • Impressum

Navigation

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Tags

    16bit over midi LSB/MSB

    How To... ?
    2
    4
    620
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • fubbi
      fubbi last edited by

      Hello


      I am working with a MIDI to SERVO controller and need some help understanding the concept of MSB/LSB and 16bit math

      This controller can take a coarse and a fine value broadcast over 2 MIDI channels. The only information I can find is pertaining to DMX. 

      I am unsure how this scales to MIDI. I need 0-127 and I am wondering if I should just swap 256 for 127 in the code below, or does that mess up the math?

      Thanks for any advice!

      Fubbi

      _________________________________

      Here is what I know so far:

      In order to make a "high res" input in Isadora I have come to the following conclusions by studying the coarse/fine behavior of DMX fixture control:

      • Coarse is the MSB (Most Significant Bit) and Fine is the LSB (Least Significant Bit)

      • 16 bit is equal to 65535

      • For DMX the LSB is input % 256 (modulo)

      • For DMX the MSB is floor(input/256)

      I concocted the following javascript to scale and split a 16bit value to LSB/MSB

      // iz_output 1 "LSB"

      // iz_output 2 "MSB"

      function main()

      {

      var input = arguments[0];   // input 1 [0-65535]

          var n = Math.trunc(input); // float to integer, maybe redundant

      var LSB = n % 256; // for dmx this is how LSB is calculated

      var MSB = Math.floor(n/256);  // for dmx this is how MSB is calculated

      return [LSB, MSB]

      }

      Mac M2 Ultra, 64gb — Berlin

      1 Reply Last reply Reply Quote 0
      • fubbi
        fubbi last edited by fubbi

        Update:

        Actually, it's supposed to be 14 bit (16384?) for midi, so now I am really curious if I am on the right track

        Since each controller message has only a 7-bit value field, many MIDI devices utilize some controllers in pairs to achieve a full 14-bit resolution. These can be thought of as the “coarse” adjustment for the most significant 7-bits (MSB), and the “fine” adjustment for the least significant 7-bits (LSB). 

        Mac M2 Ultra, 64gb — Berlin

        Juriaan 1 Reply Last reply Reply Quote 0
        • Juriaan
          Juriaan Tech Staff @fubbi last edited by

          @fubbi

          If the code of DMX is the following (and you know this is correct)

          // iz_output 1 "LSB"

          // iz_output 2 "MSB"

          function main()

          {

          var input = arguments[0];   // input 1 [0-65535]

              var n = Math.trunc(input); // float to integer, maybe redundant

          var LSB = n % 256; // for dmx this is how LSB is calculated

          var MSB = Math.floor(n/256);  // for dmx this is how MSB is calculated

          return [LSB, MSB]

          }


          DMX is 512 channels, 256 is exactly .5 of 512. So I would personally think that if it expects 14 Bit MIDI that we should divide by 0.5 * 16384 = 8192

          Isadora 3.1.1, Dell XPS 17 9710, Windows 10
          Interactive Performance Designer, Freelance Artist, Scenographer, Lighting Designer, TroikaTronix Community moderator
          Always in for chatting about interaction in space / performance design. Drop me an email at hello@juriaan.me

          fubbi 1 Reply Last reply Reply Quote 0
          • fubbi
            fubbi @Juriaan last edited by

            @juriaan said:

            DMX is 512 channels, 256 is exactly .5 of 512. So I would personally think that if it expects 14 Bit MIDI that we should divide by 0.5 * 16384 = 8192

             Hi Jurian, thanks for jumping in. But divide where? I am not sure what you mean. The size of the incoming number could be relatively arbitrary as the servos will just stop moving outside their scope. I changed my script from 256 to 127 and I get pretty consistent movement from 0 to 16384.

            Now if it really makes the movement so much more high res is another question. I have come to believe that it really only matters if you need to make very precisely positioned stops.

            Cheers

            Mac M2 Ultra, 64gb — Berlin

            1 Reply Last reply Reply Quote 0
            • First post
              Last post