position of data in sysex received

Home Forums General Programming position of data in sysex received

Viewing 20 posts - 1 through 20 (of 59 total)
  • Author
    Posts
  • #117105
    EnzoF04
    Participant
      • Topics: 17
      • Replies: 102
      • Total: 119
      • ★★

      Hi all,

      I receive this message from my synth:

      RAW:[240 001 005 038 012 000 000 000 000 000 000 000 000 009 001 007 000 000 013 009 002 011 000 006 008 003 000 000 003 008 015 007 001 001 002 001 247]
      

      formatting is as described in the first attachment, data is in second and my analysis in third attachment. But the data is not corresponding with what I see on the synthesizer’s display. What am I assuming wrong?

      I am aware of the fact that some parameters are spanned over several bytes. Can anyone explain this clearly? I don’t get this and I’m not that experienced with programming / hex / dec / binary conversion. Many thanks!

      Thanks for all help. When I have the da

      Attachments:
      You must be logged in to view attached files.
      #117117
      lecleto
      Participant
        • Topics: 10
        • Replies: 34
        • Total: 44

        Hello! First thing in my opnion to understand better is configure your midi monitor to see the size of message received in Hexa form.

        The message always will star with F0 and will end with F7. The 19 before F7 is a checksum.

        The point is understand what byte is the start of your parameters.

        You will see as a machine!

        In this example the parameters comes after 00 08 20 00.

        [22:18:25:000730]: Size:[ 45] RAW:[f0 41 10 46 12 00 08 20 00 4e 65 77 20 41 67 65 20 56 6f 78 20 01 05 7f 0c 36 00 7f 52 00 00 00 00 76 40 3e 02 00 00 00 00 00 5d 19 f7]

        #117118
        EnzoF04
        Participant
          • Topics: 17
          • Replies: 102
          • Total: 119
          • ★★

          Thanks for your reply!

          How do you know this?

          In this example the parameters comes after 00 08 20 00.

          I’m trying to refer the received data in the synth but I cannot get a grip on it. When i start with byte 09 and try to relate the received data in that byte to what is in the synth for that program (patch) then I’m confused.

          How do I read the received data? Some parameters are spanned over more than one byte, but how?
          Do I need to read the received data backwards, starting at the end?

          EDIT: I convert the received bytes to string for output in console, see attachment 3.
          EDIT: I’m messing with bits and bytes. That’s where I’m wrong, as far as I know. But how….?

          Thanks for helping out!

          • This reply was modified 4 years, 1 month ago by EnzoF04.
          Attachments:
          You must be logged in to view attached files.
          #117129
          lecleto
          Participant
            • Topics: 10
            • Replies: 34
            • Total: 44

            Hello Enzo!!

            This information 00 08 20 00 comes from map of memory. In this case my Roland Synth JV-880.

            • This reply was modified 4 years, 1 month ago by lecleto.
            Attachments:
            You must be logged in to view attached files.
            #117132
            lecleto
            Participant
              • Topics: 10
              • Replies: 34
              • Total: 44

              Hello Enzo!!

              This information 00 08 20 00 comes from map of memory. In this case my Roland Synth JV-880.
              You can see by this graph below that you are working on temporary patch wich adress is 00 08 20 00.
              This adress define where you are working.
              To understand your message first of all try to change only one parameter (On-Off Switch) and analyze the incoming message. In many cases will be used more than one byte to set a value of modulador. This will be described on manual.
              For Roland Syhths this information of the sequence of bytes and values comes at the end of owner manual.
              See the attached files.
              Once a time that you understand one byte the others will be consequence.
              I´m just trying to explain what I do to “read and understand” my sysex messages to create a panel for JV-880.
              I hope that can be usefull!

              • This reply was modified 4 years, 1 month ago by lecleto.
              Attachments:
              You must be logged in to view attached files.
              #117140
              EnzoF04
              Participant
                • Topics: 17
                • Replies: 102
                • Total: 119
                • ★★

                Hi Lecleto!

                Thanks for your reply. I’m creating an Excel sheet where I can ‘cluster’ the bits used for a parameter so I get a good reference ‘where’ data is stored. I do this by pushing and pulling between bits (binary) and hexadecimal and decimal. I show you in the attached image. When I have an idea what bits are representing which parameter, I try to put them in corresponding variables in decimal format.

                #117141
                lecleto
                Participant
                  • Topics: 10
                  • Replies: 34
                  • Total: 44

                  My first step to create my panel was the same!
                  An excel sheet with each parameter of synth and your respective sysex message. This certanly will help you to take a global view of synth!
                  Have a good work!!

                  #117142
                  EnzoF04
                  Participant
                    • Topics: 17
                    • Replies: 102
                    • Total: 119
                    • ★★

                    This helps me to get the data less abstract and I can pin point where a parameter is sent.

                    Thanks for your input!

                    Attachments:
                    You must be logged in to view attached files.
                    #117145
                    dnaldoog
                    Participant
                      • Topics: 4
                      • Replies: 480
                      • Total: 484
                      • ★★

                      Hi Enzo,

                      Can you set each parameter starting from Osc Coarse A0 to ZB (all 16 bytes) to its Max value and post the sysex message?

                      #117151
                      EnzoF04
                      Participant
                        • Topics: 17
                        • Replies: 102
                        • Total: 119
                        • ★★

                        Hello Dnaldoog, here is program 44, which I saved with all parameters set to full. I’ve added in my Excel sheet all front panel parameter numbers and the minimum and maximum values. It’s obvious what resolution a 1 bit, a 4 bit, a 5 bit, a 6 bit and a 7 bit parameter have.

                        The sysex data is 37 bytes; 4 as header (syxex, sci id, sixtrak id, program number). Then 32 bytes of program data and an EOX byte.

                        The manual says:

                        Data is 16 bytes of program data, sent as 32 four-bit nibbles, right justified, LS nibble sent first.

                        RAW:[f0 01 05 2c 00 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0a f7]

                        The last byte before the f7 is 10 because the last two bits are left empty.

                        • This reply was modified 4 years, 1 month ago by EnzoF04.
                        • This reply was modified 4 years, 1 month ago by EnzoF04.
                        #117156
                        EnzoF04
                        Participant
                          • Topics: 17
                          • Replies: 102
                          • Total: 119
                          • ★★

                          Getting very excited about your post. I can read what you do and try to understand. I’m hyper motivated to continue with your suggestion. I’m trying to proceed but my time is limited for now. Have to be patient but I’ll keep you updated and work in between commitments.

                          #117158
                          EnzoF04
                          Participant
                            • Topics: 17
                            • Replies: 102
                            • Total: 119
                            • ★★

                            We’re calling variable ‘m’ in the third line but never declared ‘m’. Do I have to tell what ‘m’ holds or what type it is?

                            local t={}
                            mbTemp32Byte=MemoryBlock()
                            mbTemp32Byte:append(m:getData():getRange(4, 32))
                            m16=MemoryBlock()
                            assert(mbTemp32Byte:getSize()==32) -- development code can be deleted
                            for n=0,mbTemp32Byte:getSize()-1,2 do
                            local msb=bit.lshift(mbTemp32Byte:getByte(n+1),4)
                            local lsb=mbTemp32Byte:getByte(n)
                            table.insert(t,msb+lsb)
                            end

                            I changed m to mBlock16.

                            • This reply was modified 4 years, 1 month ago by EnzoF04.
                            • This reply was modified 4 years, 1 month ago by EnzoF04.
                            • This reply was modified 4 years, 1 month ago by EnzoF04.
                            Attachments:
                            You must be logged in to view attached files.
                            #117162
                            EnzoF04
                            Participant
                              • Topics: 17
                              • Replies: 102
                              • Total: 119
                              • ★★

                              forget my question, got it! ‘m’ is the received midi message!

                              #117164
                              dnaldoog
                              Participant
                                • Topics: 4
                                • Replies: 480
                                • Total: 484
                                • ★★

                                Hi Enzo,

                                So ‘m’ would be the midi data received from the panel (from the synthesizer) so you could pass it as a parameter to a function, so in your panel you might have (called when a Panel receives a MIDI message)

                                
                                myMidi = function(--[[ CtrlrMidiMessage --]] midi)
                                run(midi)
                                end
                                

                                and all the code posted above could be included in the function run(m)

                                run=function(m)
                                local t={}
                                mbTemp32Byte=MemoryBlock()
                                mbTemp32Byte:append(m:getData():getRange(4, 32))
                                m16=MemoryBlock() ...
                                ...
                                ...
                                end -- function
                                

                                P.S.
                                Oh! I see you got it :)

                                #117167
                                dnaldoog
                                Participant
                                  • Topics: 4
                                  • Replies: 480
                                  • Total: 484
                                  • ★★

                                  My original post seems to have disappeared!???

                                  Here it is again this time in a function:

                                  –m=F0 01 05 26 [[->0C 00 00 00 00 00 00 00 00 09 01 07 00 00 0D 09 02 0B 00 06 08 03 00 00 03 08 0F 07 01 01 02 01<-]] F7 -- incoming midi message of 32 bytes of data

                                  
                                  function run(m)
                                  local t={}
                                  mbTemp32Byte=MemoryBlock()
                                  mbTemp32Byte:append(m:getData():getRange(4, 32))
                                  m16=MemoryBlock()
                                  if mbTemp32Byte:getSize()==32 then
                                  --assert(mbTemp32Byte:getSize()==32) -- development code can be deleted
                                  for n=0,mbTemp32Byte:getSize()-1,2 do
                                  local msb=bit.lshift(mbTemp32Byte:getByte(n+1),4)
                                  local lsb=mbTemp32Byte:getByte(n)
                                  table.insert(t,msb+lsb)
                                  end
                                  
                                  m16:createFromTable(t)
                                  console(String(m16:toHexString(1))) -- let's see what we got
                                  panel:getLabel("debug"):setText(m16:toHexString(1))
                                  
                                  modulators={
                                  ["COARSE FREQUENCY"]={byte={0},position={0x3f},lshift={0},rshift={0}},
                                  ["FINE FREQUENCY"]={byte={0,1},position={0xC0,0x07},lshift={0,2},rshift={6,0}},
                                  ["GLIDE RATE"]={byte={1},position={0x78},lshift={0},rshift={3}},
                                  ["ENVELOPE AMOUNT"]={byte={1,2},position={0x80,0x07},lshift={0,1},rshift={7,0}},
                                  --... to all 37 ?? of them
                                  }
                                  console('---------------')
                                  for k in pairs (modulators) do
                                  n=0
                                  for j,v in ipairs (modulators[k].byte) do
                                  if j == 1 then
                                  n=n+bit.rshift(bit.band(m16:getByte(v),modulators[k].position[j]),modulators[k].rshift[j])
                                  console("right shift "..k.." by "..modulators[k].rshift[j])
                                  else
                                  console("left shift "..k.." by "..modulators[k].lshift[j])
                                  n=n+bit.lshift(bit.band(m16:getByte(v),modulators[k].position[j]),modulators[k].lshift[j])
                                  end
                                  end
                                  console(String("n "..n))
                                  --panel:getModulatorByName(k)getComponent():setValue(n,true)
                                  end
                                  end -- is 32 bytes coming in
                                  end -- method
                                  
                                  
                                  • This reply was modified 4 years, 1 month ago by dnaldoog. Reason: avoid BBCode [i] clash change iterator to j
                                  • This reply was modified 4 years, 1 month ago by dnaldoog. Reason: added rshift
                                  • This reply was modified 4 years, 1 month ago by dnaldoog. Reason: added left shift
                                  #117173
                                  EnzoF04
                                  Participant
                                    • Topics: 17
                                    • Replies: 102
                                    • Total: 119
                                    • ★★

                                    Ok, I’m getting closer! Am I right that this:

                                    modulators={
                                    ["COARSE FREQUENCY"]={byte={0},position={0x3f}},
                                    ["FINE FREQUENCY"]={byte={0,1},position={0xC0,0x07}},
                                    ["GLIDE RATE"]={byte={1},position={0x78}},
                                    ["ENVELOPE AMOUNT"]={byte={1,2},position={0x80,0x07}},
                                    --... to all 37 ?? of them
                                    }

                                    is generating a variable / table / array of pairs and putting all bits corresponding to the parameter into the array / variable? so ‘coarse frequency’ is paired to position which has the 6 digit binary representing the coarse frequency in the program?

                                    Then: this:

                                    for k in pairs (modulators) do
                                    local n=0
                                    for i,v in ipairs (modulators[k].byte) do
                                    n=n+bit.band(m16:getByte(v),modulators[k].position)
                                    end
                                    console(String("n "..n))
                                    panel:getModulatorByName(k)getComponent():setValue(n,true)
                                    end

                                    We are executing a ‘for… do’ for ‘k’ times (the amount of pairs in ‘modulators’.
                                    Create a variable ‘n’ with value ‘0’.
                                    The next code starting ‘for i,v in ipairs…. till [k].position) end’ is not clear to me.
                                    console(string(‘n…..) is putting the data in variable ‘n’ to console for check?
                                    pane.:getModulator… is putting the extracted values to the panel components?

                                    The last part gives me the attached error.

                                    • This reply was modified 4 years, 1 month ago by EnzoF04.
                                    Attachments:
                                    You must be logged in to view attached files.
                                    #117177
                                    dnaldoog
                                    Participant
                                      • Topics: 4
                                      • Replies: 480
                                      • Total: 484
                                      • ★★

                                      Hi Enzo,

                                      Away from computer right now, but try [k].position [ i ]

                                      It’s in the original post but this forum strips the square brackets i square brackets code from the post. How frustrating!

                                      Reading a bit further I discover that [i] is BBCode for italics so an unfortunate ambiguous situation. I have now changed the iterator in the original code example to [j]
                                      ———————————————————————–
                                      regarding previous questions:
                                      Yes ‘modulators’ is an associative table of all your modulators in ctrlr. The table lists named ‘byte’ refer to which byte contains data for that modulator and ‘position’ (should really be called ‘mask’) shows the position of the data in that byte.

                                      You can filter out data you don’t need by running an AND bit calculation on the values.

                                      For example if you have a value 0111 1111 in a byte = 127 but only want the first four bytes you run 127 AND 15 = 15 0000 1111 – that is how you find the byte value in each of 16 bytes, but because the values span different bytes we need to keep a record of which bytes to mask and where to mask, hence ‘byte’, ‘position’ – they are looped over and the sum ‘n’ returned or written to the modulator k – the console code is just debugging –

                                      Or another example 0x57 = decimal 87
                                      That’s 5 in the first msb position 0101
                                      That’s 7 in the second lsb position 0111
                                      run 87 AND 15 in lua bit.band(0x57,0x0f) and you will get 0111 (7)

                                      Well it’s all a stab in the dark – I am probably missing something crucial or obvious, but if you could send a sysex message with all values set to maximum, I could probably test it, otherwise it’s really just a guess right now.

                                      #117181
                                      dnaldoog
                                      Participant
                                        • Topics: 4
                                        • Replies: 480
                                        • Total: 484
                                        • ★★

                                        But wait there’s more!

                                        I think (and at this stage it’s more like a thought experiment) we need to add extra right and left shifting to the split byte values! The plot thickens. Again I have put the necessary shifts into a lookup table ‘modulators’, but there’s probably a cleverer way of doing the bit shifting and masking calculations I would suppose.

                                        #117185
                                        EnzoF04
                                        Participant
                                          • Topics: 17
                                          • Replies: 102
                                          • Total: 119
                                          • ★★

                                          Thanks for your explanation! I can really appreciate your input, you get me closer. Your shortening of code is helping me develop procedural thinking! I’ll try to achieve progress tonight! I’ll keep you updated!

                                          #117187
                                          EnzoF04
                                          Participant
                                            • Topics: 17
                                            • Replies: 102
                                            • Total: 119
                                            • ★★

                                            Trying to get my head around:
                                            n=n+bit.rshift(bit.band(mBlock16:getByte(v),modulators[k].position[j]),modulators[k].rshift[j])

                                            Perhaps we need to put the bit.rshift data into a variable because i get the error ‘Attempt to index field ‘rshift’ (a nil value)? Or do I miss an operand/incomplete syntax?

                                            Attachments:
                                            You must be logged in to view attached files.
                                          Viewing 20 posts - 1 through 20 (of 59 total)
                                          • The forum ‘Programming’ is closed to new topics and replies.
                                          There is currently 0 users and 52 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