how to handle more then one received midi messages?

Home Forums General Programming how to handle more then one received midi messages?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #6608
    SWB
    Participant
      • Topics: 35
      • Replies: 157
      • Total: 192
      • ★★

      When I send a program change to my device it responds with sending a bunch of midi messages. Of these messages I only interested in two specific messages, the ones that contain program numbers. I have attached a screen print of the incoming messages and highlighted the bytes I’m interested in. What is the Lua script for this? As usually any help much appreciated!

      Attachments:
      You must be logged in to view attached files.
      #6621
      Llamatron
      Participant
        • Topics: 7
        • Replies: 27
        • Total: 34

        Here is how I convert midi received in the function to lua data in the data variable, then assign the first byte to a variable called b:
        data = midiMessage:getLuaData()
        b = data:getByte(0)

        Then you have to make conditional statements with if … then … end according to the desired logic. If it can help you thoses messages you want to get are program change messages: Cx, where x is an hexadecimal between 0 and F that indicates the midi channel between 1 and 16.

        #6622
        SWB
        Participant
          • Topics: 35
          • Replies: 157
          • Total: 192
          • ★★

          That is indeed a way to get data contained in a midi message, but doesn’t solve my issue. Thanks anyway!

          I further analyzed the “problem” and it can be solved if I can dynamically change (using a loop) the midi channel called midi input channel (from device) of the panel. But when the code loops I need also to be sure that Ctrlr still has the incoming midi messages from the other midi channels in memory, otherwise looping is of no use. You can see in the attached screen print from the midi  input monitor of Ctrlr (in my first message of this thread) that it receives midi messages from three channels,  channel 1, 2 and 3 (or c0, c1 and c2).  So the Lua script needs access to the midi data of those three channels.

          So the question boiles down to this: how can I dynamically change the midi input channel (from device) in a Lua script and does Ctrlr ‘remember’ incoming midi messages from several channels?

          #6625
          zeoka
          Participant
            • Topics: 73
            • Replies: 466
            • Total: 539
            • ★★★

            panelMidiInputChannelDevice=”1″ in utility

            euh… panel:GetPanelProperty?():SetMidiChannel??: (“panelMidiInputChannelDevice”,  2?)

            Hard to find myself the exact command 😮

            But you could type the proper command in LUA at each steps of your sript

            May be a post with

            some type of components, type of request , type of data could help to create script quickly

            oh may be you could create an  hidden modulator especially for help in  your script :

            link it to panel property and integrate it in your script….or link directly target modulators

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

            #6626
            Llamatron
            Participant
              • Topics: 7
              • Replies: 27
              • Total: 34

              Setting the input channel to “All channels” wouldn’t work for what you want to do?

              #6627
              SWB
              Participant
                • Topics: 35
                • Replies: 157
                • Total: 192
                • ★★

                Yes, that did the trick! As usually the most simple approach works the best. Thanks!

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