SOLVED: Display Sysex String in Console

Home Forums General Programming SOLVED: Display Sysex String in Console

Tagged: ,

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #73318
    Puppeteer
    Participant
      • Topics: 16
      • Replies: 185
      • Total: 201
      • ★★

      Just wanted to post a little code for something I’ve been wanting to do for bug testing and development.

      How to post a sysex string to the console, so we can see what’s going on?

      My methodology – I have a table of hex values that I manipulate, and periodically convert it to a MIDI Message and send it to the synth.

      Here’s the code for the function to display the table to the console.

      function sysexToString(--[[ CtrlrMidiMessage --]] midi)
      	-- Expects userdata Table of Hex
      
      local midiString = ""
      
      	for i= 1, table.getn(midi) do
      		midiString = midiString .. string.format("%02x", midi) .. " "
      	end --for
      return midiString
      end

      It’s called from a method like this

      testConsoleMethod = function(--[[ CtrlrModulator --]] mod, --[[ number --]] value, --[[ number --]] source)
      console (String("Control Mode Enabled"))
      console (String(sysexToString(midiBuffer)))
      end

      The initial value of midiBuffer (so you can see the formatting used)

      midiBuffer = {0xf0,0x00,0x00,0x2f,0x03,0x02,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x0c,0x00,0x00,0x00,0x00,0x0b,0x02,0x06,0x02,0x0f,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x0f,0x00,0x00,0x09,0x0c,0x00,0x00,0x00,0x00,0x08,0x08,0x00,0x00,0x02,0x0c,0x01,0x07,0x0f,0x07,0xf7}

      To convert this table to a Midi Message that you can send, use
      midiBufferMessage = CtrlrMidiMessage(midiBuffer)

      Hope this helps you guys in the future

      • This topic was modified 6 years, 5 months ago by Puppeteer.
      • This topic was modified 6 years, 5 months ago by Puppeteer. Reason: Added Code Tags

      The Puppeteer
      http://godlike.com.au

      #73321
      human fly
      Participant
        • Topics: 124
        • Replies: 1070
        • Total: 1194
        • ★★★★

        nice. could you clarify what you’ve got in the midi buffer there?
        -or is that just some specimen values?

        also this: for i= 1, table.getn(midi) do
        is that ‘the table’? all you need?
        still hazy/not very good/uncertain using those forms.

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

          You can just do it this way:

          
          myMidiReceived = function(--[[ CtrlrMidiMessage --]] midi)
          console(midi:getLuaData():toHexString(1))
          end
          

          #73416
          Puppeteer
          Participant
            • Topics: 16
            • Replies: 185
            • Total: 201
            • ★★

            Human Fly,

            MidiNuffer contains the hex values for a dump from a Roland Jupiter 8. Just consider them specimen values though. I update this Midi Buffer from the panel and send the Buffer to the Jupiter to update the edit buffer.

            The Puppeteer
            http://godlike.com.au

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