Multiple bytes dumping into 1 parameter help

Home Forums General Programming Multiple bytes dumping into 1 parameter help

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #69425
    memorysplice
    Participant
      • Topics: 14
      • Replies: 59
      • Total: 73

      I am able to get a sysex dump using this method

      Known working method

      but I have a parameter that requires 4 separate bytes from the sysex dump that has a total of 0 – 16384 parameter possibilities. How do I utilize the method above to dump to my panel?

      I have included a picture of the sysex spec in regards to the parameter in question.

      Attachments:
      You must be logged in to view attached files.
      #69427
      goodweather
      Participant
        • Topics: 45
        • Replies: 550
        • Total: 595
        • ★★★

        Hi,
        if you know the offset of your parameter, then you can use one getRange() or 4 getByte().
        You have your sysex dump in a memoryblock, let’s say mbDump.
        The first byte is at offset 0. If your parameter is for example at offset 30, you will do:

        byte1 = mbDump:getByte(30) -- 0000aaaa
        byte2 = mbDump:getByte(31) -- 0000bbbb
        byte3 = mbDump:getByte(32) -- 0000cccc
        byte4 = mbDump:getByte(33) -- 0000dddd

        Then you need to assemble those 4 bytes to form the number:

        • dddd= 0 to 8
        • cccc= 16 to 128
        • bbbb= 256 to 2048
        • aaaa= 4096 to 16384 (the first a should always be 0 if 16384 is the max)

        So, the following formula should work:
        wave_number = byte4 + byte3*16 + byte2*256 + byte1*4096
        Test: 16384 = 0100 0000 0000 0000 = 4*4096 Yes!

        Note that you need to check the order of the bytes (is aaaa the first one or the last one) but the solution above gives you the general principle.

        Good luck 🙂

        #69428
        memorysplice
        Participant
          • Topics: 14
          • Replies: 59
          • Total: 73

          Goodweather I appreciate your quick response. Unfortunately I do not understand how to utilize your solution with the method that I am using. Can you please provide a more indepth example?

          #69429
          goodweather
          Participant
            • Topics: 45
            • Replies: 550
            • Total: 595
            • ★★★

            Well…
            In the midiMessageReceived method described by dasfaker, you can see you are loading a memory block called PatchDataLoaded (or programData if your data is in some extract of it).
            Just replace mbDump in what I have written by PatchDataLoaded

            The byte extraction and wave_number calculation can be put within dasfaker’s AssignValues() method. Assign the wave_number to one of your modulator if this is what you want to do…

            #69430
            memorysplice
            Participant
              • Topics: 14
              • Replies: 59
              • Total: 73

              Thank you very much will be trying out soon. 🙂

            Viewing 5 posts - 1 through 5 (of 5 total)
            • The forum ‘Programming’ is closed to new topics and replies.
            There is currently 0 users and 108 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