Toggle two SysEx strings

Home Forums General Using Ctrlr Toggle two SysEx strings

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #70144
    Pulse505
    Participant
      • Topics: 1
      • Replies: 2
      • Total: 3

      Hi everyone,

      I couldn’t find it anywhere on the forums so I will post my question here.

      Is there a simple way to make a toggle button for two SysEx strings.

      I want it to be like this
      on(1) = F0 41 12 3A 12 70 01 09 01 05 F7
      off(0) = F0 41 12 3A 12 70 01 09 00 06 F7

      Is this possible whitout LUA?

      Kind regards

      #70145
      Possemo
      Participant
        • Topics: 14
        • Replies: 638
        • Total: 652
        • ★★★

        Hi Pulse,

        to my knowledge this is not possible without Lua, but with Lua it is a dead easy task. I will post the code this evening when I’m at home.

        • This reply was modified 7 years, 5 months ago by Possemo.
        #70153
        goodweather
        Participant
          • Topics: 45
          • Replies: 550
          • Total: 595
          • ★★★

          Hi Poss, was chatting with Pulse and proposed him to post this question on the forum as I thought that maybe it is possible to use the sysex Midi properties of the component for that. I now how to get the value of the button in the sysex string (explained by Atom in his Getting started doc) but don’t think it is possible to make a calculation on one byte (second to last byte would be 06 – button value).

          Hi Pulse, here is the code and instructions I spoke in our chat…

          – Check my Step by Step guide for some introduction to Lua and some references
          – Open your panel then open Lua editor (in Panel menu)
          – Create a method isPanelReady()

          --
          -- Check if the panel is not busy to load or receiving a program
          --
          isPanelReady = function()
          
          	if panel:getBootstrapState() == false and panel:getProgramState() == false then
          		return (true)
          	else
          		return (false)
          	end
          
          end
          

          – Save and compile
          – Create a method Mute_OnChange with luaModulatorValueChange selected in the Initialize from template combo

          --
          -- Called when a modulator value changes
          -- @mod   http://ctrlr.org/api/class_ctrlr_modulator.html
          -- @value    new numeric value of the modulator
          --
          Mute_OnChange = function(--[[ CtrlrModulator --]] mod, --[[ number --]] value, --[[ number --]] source)
          
          	-- No action if the panel is in bootstrap or program states
          	if not isPanelReady() then
          		return
          	end
          
          	if value==1 then
          		-- Mute ON
          		msg = CtrlrMidiMessage({0xF0, 0x41, 0x12, 0x3A, 0x12, 0x70, 0x01, 0x09, 0x01, 0x05, 0xF7})
          	else
          		-- Mute OFF
          		msg = CtrlrMidiMessage({0xF0, 0x41, 0x12, 0x3A, 0x12, 0x70, 0x01, 0x09, 0x00, 0x06, 0xF7})
          	end
          	panel:sendMidiMessageNow(msg)
          
          end
          

          – Save and compile
          – Select your toggle and select the Mute_OnChange method in the property Called when the modulator value change

          Should work fine 🙂
          Good luck!

          #70154
          Possemo
          Participant
            • Topics: 14
            • Replies: 638
            • Total: 652
            • ★★★

            Hi Goodie, sorry Pulse I was too tired yesterday. I wanted to give you the code now but goodweather was faster. I would have done it the same way, I maybe would have shortended the script to the max like this:

            Mute_OnChange = function(mod, value)
            
             if value==1 then
              -- Mute ON
              panel:sendMidiMessageNow(CtrlrMidiMessage("F0 41 12 3A 12 70 01 09 01 05 F7"))
             else
              -- Mute OFF
              panel:sendMidiMessageNow(CtrlrMidiMessage("F0 41 12 3A 12 70 01 09 00 06 F7"))
             end
            end

            I only insert checks like isPanelReady() and getBootstrapState() when I run into problems. But it surely is not a bad thing to do it as a preventive measure.

            • This reply was modified 7 years, 5 months ago by Possemo.
            #70175
            goodweather
            Participant
              • Topics: 45
              • Replies: 550
              • Total: 595
              • ★★★

              Well, I’m putting isPanelReady in all _OnChange and _OnClick methods otherwise you get soon or later issues…
              Also, I’m avoiding putting too many functions in functions even if it works perfectly. More a visual matter and more for code readability.

              Now, to shorten even further the code, you can just have everything in one line in fact…

              Mute_OnChange = function(mod, value)
              
              panel:sendMidiMessageNow(CtrlrMidiMessage(string.format("F0 41 12 3A 12 70 01 09 %.2x %.2x F7", value, 6-value)))
              
              end

              Have a nice w-e 🙂

              #70176
              Pulse505
              Participant
                • Topics: 1
                • Replies: 2
                • Total: 3

                Thanks for the help guys!

                I will have a lot of reading to do now. Let’s get into that LUA. I have 17 different buttons with this functionality to make for my panel 🙂

                Kind regards

                #70183
                Possemo
                Participant
                  • Topics: 14
                  • Replies: 638
                  • Total: 652
                  • ★★★

                  Hi Goodie, now that’s really short! Very smart, I like short code.

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

                    😉

                    #70248
                    Pulse505
                    Participant
                      • Topics: 1
                      • Replies: 2
                      • Total: 3

                      Hey Possemo,

                      Your code seems to be working very nicely. I don’t know why goodweathers code isn’t working for me but none the less the button is working! 😀

                      Thanks a lot for the help!

                      Kind regards

                      • This reply was modified 7 years, 4 months ago by Pulse505.
                      • This reply was modified 7 years, 4 months ago by Pulse505.
                      • This reply was modified 7 years, 4 months ago by Pulse505.
                      #117152
                      higgy
                      Participant
                        • Topics: 9
                        • Replies: 11
                        • Total: 20

                        Is there a simple way to make a toggle button for two SysEx strings.
                        I want it to be like this
                        on(1) = F0 41 12 3A 12 70 01 09 01 05 F7
                        off(0) = F0 41 12 3A 12 70 01 09 00 06 F7
                        Is this possible whitout LUA?

                        the question is old but maybe someone else will have the same question.
                        Answer is yes, use msb/lsb in uiButton:

                        sysex: F0 41 12 3A 12 70 01 09 ms ls F7 (ms = msb, ls=lsb)

                        button content : value = ms*16 + ls
                        OFF = 6 (= 0x06 = 0*16 + 6)
                        ON = 21 (= 0x15 = 1*16 + 5)

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

                          Is there a simple way to make a toggle button for two SysEx strings.
                          I want it to be like this
                          on(1) = F0 41 12 3A 12 70 01 09 01 05 F7
                          off(0) = F0 41 12 3A 12 70 01 09 00 06 F7
                          Is this possible whitout LUA?

                          the question is old but maybe someone else will have the same question.
                          Answer is yes, use msb/lsb in uiButton:

                          sysex: F0 41 12 3A 12 70 01 09 ms ls F7 (ms = msb, ls=lsb)

                          button content : value = ms*16 + ls
                          OFF = 6 (= 0x06 = 0*16 + 6)
                          ON = 21 (= 0x15 = 1*16 + 5)

                          Very nice! Didn’t know that!

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

                            Yes indeed! Very good proposal and a new thing I didn’t know 🙂

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