how to send program change with LUA

Home Forums General Programming how to send program change with LUA

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #121240
    drno
    Participant
      • Topics: 1
      • Replies: 1
      • Total: 2

      hi i’m newbie to LUA,
      I want to send the following midi sequence:
      0xB8, 0x00, 0x7F, 0xB8, 0x20, 0x00, 0xC8, 0x05

      which is basically a bank change and a program change
      CC 0 MSB
      CC 32 LSB
      Patch Change Program_number

      where the variables are:
      MSB, LSB and Program_number

      the function written in Lua only sends the first 3 bytes, does anyone know why and can help me?

      patchKick = function(–[[ CtrlrModulator –]] mod, –[[ number –]] value, –[[ number –]] source)

      if value==0 then
      m = CtrlrMidiMessage({0xB8, 0x00, 0x7F, 0xB8, 0x20, 0x00, 0xC8, 0x05}) — PATCH
      panel:sendMidiMessageNow(m) — SENDS
      end

      end

      #121244
      BAUS
      Participant
        • Topics: 2
        • Replies: 22
        • Total: 24

        Hi drno,

        Welcome….learning LUA is fun!

        Looking at your sysex table there is 1 thing I notice: it does not open with 0x0F and end with 0xF7

        In sysex 0F declares the beginning of a sysex message and F7 declares the end of it.

        Best regards,

        BAUS

        • This reply was modified 3 years, 2 months ago by BAUS. Reason: typo

        Updating a 25 year old Editor

        #121248
        Tedjuh
        Participant
          • Topics: 9
          • Replies: 97
          • Total: 106
          • ★★

          I think Baus means 0XF0 instead of 0x0F 🙂

          The first 3 bytes are the MSB if I’m correct. So I guess you need to shoot another two CtrlrMidiMessages for the LSB and the Program Change. Like this:

          msb = CtrlrMidiMessage(0xB8, 0x00, 0x7F)
          lsb = CtrlrMidiMessage(0xB8, 0x20, 0x00)
          pc = CtrlrMidiMessage(0xC8, 0x05)

          panel:sendMidiMessageNow(msb)
          panel:sendMidiMessageNow(lsb)
          panel:sendMidiMessageNow(pc)

          There are probably better ways to do this..

          If you want to send them in one message in sysex format, you need what Baus says. But you need to know the right format for your synth as well. Example, for my synth (Roland SH-201) it’s: F0 41 10 00 00 16 12 01 00 00 00 MSB LSB ProgramChange 00 F7. Where MSB, LSB, ProgramChange are the values of 7F, 00, 05 of your example. But I need to know for which synth you are developing a panel to help you any further with that.

          #121249
          samoht
          Participant
            • Topics: 1
            • Replies: 54
            • Total: 55

            Hi all,

            Not sure what you are intending to do.

            0xB initiates a control change message, so I guess 0xB8= control change on channel 8 followed by 2 data bytes (one with a controller number and one with a value);
            So the first 6 bytes of your message seem to represent 2 control change messages each of 3 bytes.

            0xC initiates a program change message, so I guess your seventh byte 0xC8 is a program change on channel 8 followed by one data byte 0x05 containing the program number.

            These three messages are not of the sysex type (initiated by 0xF0 and ending with 0xF7).

            I don’t think you need lua to send these control change and program change messages in Ctrlr, but others on this forum are more experienced about the subtlities of this types of messages in ctrlr.

            • This reply was modified 3 years, 2 months ago by samoht.
            • This reply was modified 3 years, 2 months ago by samoht.
            #121250
            samoht
            Participant
              • Topics: 1
              • Replies: 54
              • Total: 55

              the function written in Lua only sends the first 3 bytes, does anyone know why and can help me?

              I guess because your synth is reading the first byte 0xB8 and recognizes a control change message. Your synths brain is made to think that a control change message consists of 3 bytes, the first byte containing the identification of the message with channel, the second containing the cc number, the thirth a value. So the brain of your synth is made to be not aware of the following bytes in order not to confuse the message, already complete.

              • This reply was modified 3 years, 2 months ago by samoht.
              • This reply was modified 3 years, 2 months ago by samoht.
              #121251
              drno
              Participant
                • Topics: 1
                • Replies: 1
                • Total: 2

                thank you all for the smart responses.
                the device is a Yamaha DJX II keyboard.
                I have solved the bank change and patch, sent three separate messages one for the MSB, one for the LSB and one for the program change.
                thank you very much to all.

              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 36 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