Specifying a unique midi message for each slider value?

Home Forums General Using Ctrlr Specifying a unique midi message for each slider value?

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #764
    Dunbar
    Participant
      • Topics: 3
      • Replies: 4
      • Total: 7

      Hi all,

      Is it possible to specify a unique midi message for each value of a modulator/slider. For example:

      Value 0 = f0 42 30 55 42 k0 k1 12 00 00 00 00 00 f7
      Value 1 = f0 42 30 55 42 k0 k1 12 00 2e 0f 05 00 f7
      Value 2 = f0 42 30 55 42 k0 k1 12 00 5c 1e 0a 00 f7
      Value 3 = f0 42 30 55 42 k0 k1 12 00 0a 2e 0f 00 f7

      Value 24 = f0 42 30 55 42 k0 k1 12 00 51 70 7a 00 f7
      Value 25 = f0 42 30 55 42 k0 k1 12 00 00 00 00 01 f7
      Value 26 = f0 42 30 55 42 k0 k1 12 00 2e 0f 05 01 f7
      Value 27 = f0 42 30 55 42 k0 k1 12 00 5c 1e 0a 01 f7

      etc… up to value 127 (or 100 in the example I’m using).

      The reason I ask is because the hardware I’m trying to control (Korg Oasys PCI) has odd interval changes that makes the standard sequential variables unusable. Does a feature to directly specify the midi message for each value of a slider exist?

      #4965
      msepsis
      Participant
        • Topics: 219
        • Replies: 732
        • Total: 951
        • ★★★

        You can pretty much do anything you want with lua.
        Here youd just put a script on the modulator that sends these values. Youd put in the script a line that gets the value of your modulator and assigns it a variable name.
        Then youd want to write some if/ifelse statements that would send the desired sysex depending on the value of the variable created above.

        Monstrum Media | Music, Sound & Software Design, Chicago / San Francisco listen

        #4966
        atom
        Keymaster
          • Topics: 159
          • Replies: 2945
          • Total: 3104
          • ★★★★★

          You can used a Fixed slider to specify custom numeric values for each state of the slider, the same goes for buttons and combos.

          #4967
          Dunbar
          Participant
            • Topics: 3
            • Replies: 4
            • Total: 7

            Thanks for the responses, the help is much appreciated.

            "msepsis":2cijil2t wrote:
            You can pretty much do anything you want with lua.
            Here youd just put a script on the modulator…[/quote:2cijil2t]

            So, in other words, I have to learn the LUA programming/scripting language?

            "atom":2cijil2t wrote:
            You can used a Fixed slider to specify custom numeric values for each state of the slider, the same goes for buttons and combos.[/quote:2cijil2t]

            Er… the slider just spits out the midi message defined in the midi section of the editor, same as a normal slider. Where do I "…specify custom numeric values…"?

            <img decoding=” title=”Confused” />

            #4968
            Dunbar
            Participant
              • Topics: 3
              • Replies: 4
              • Total: 7

              A forum search revealed the answer: the slider content box!

              It’s a shame the slider content box can’t spit out an entire sysex string, it appears to be limited to one numeric value for every modulator value. I’m sure I can come up with an inelegant solution for all four variables in the sysex string… <img decoding=” title=”Wink” />

              Thanks for pointing me in the right direction.

              <img decoding=” title=”Smile” />

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

                Dunbar,

                I have exactly the same “problem”. Did you come up with a solution? I have just started to make a panel for the Proteus-1 and already I encountered the need for unique sysex messages, in my case for de Pan-control. In the real world the values go from -7 to +7, but when studying the sysex string for these values they require for the positive values a different set of strings then for the negative values. Any input much appreciated.

                If I need to use Lua to solve this, then can you or someone point me to a (small?) tutorial how to start with Lua in Ctrlr in the first place, because I have no clue!

                #5286
                msepsis
                Participant
                  • Topics: 219
                  • Replies: 732
                  • Total: 951
                  • ★★★

                  Hey guys, there really is no Lua for ctrlr tutorial besides the example panels included with the ctrlr installer and of course the panel DDB. I put together a list of frequently used functions here just the other day which should help you out. Hecticc’s follow-up there regarding sending sysex messages pretty much gives you what you should need to get this done.

                  If your combobox needs to send sysex commands that are unique per value or range of values I’d recommend going about it like this:

                  set your combobox’s midi message to “none”, and give the combo contents field the range of values it should display (not a value it should send).. something like
                  very negative = 0
                  negative = 1
                  positive = 2
                  very positive = 3

                  etc. First part is what the combobox displays, the = 1 part just gives a value to the selection for us to reference next.

                  Add a script to the combobox, name it what you want, then open the script in the Lua editor. This is all done under a modulator’s “called when modulator value changes” section on the far right.

                  So in Lua what you want to do is
                  first get the value of the combobox, then based on the value, send the appropriate sysex message.

                  assuming the unique name of the combobox in question is “yourComboBox”:


                  --this is a comment, anything prefixed w/ double dashes is ignored by the interpreter.

                  --get the combo's value:
                  comboValue = panel:getModulatorByName(“yourComboBox”):getModulatorValue()

                  --send appropriate sysex based on combo's value:

                  if comboValue == 0 then
                  mySysex1 = CtrlrMidiMessage({0xF0, 0x3E, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xF7})
                  panel:sendMidiMessageNow(mySysex1)

                  elseif comboValue == 1 then
                  mySysex1 = CtrlrMidiMessage({0xF0, 0x3E, 0x0e, 0x00, 0x01, 0x00, 0x00, 0x7F, 0xF7})
                  panel:sendMidiMessageNow(mySysex2)

                  elseif comboValue == 2 then
                  mySysex1 = CtrlrMidiMessage({0xF0, 0x3E, 0x0e, 0x00, 0x02, 0x00, 0x00, 0x7F, 0xF7})
                  panel:sendMidiMessageNow(mySysex3)

                  elseif comboValue == 3 then
                  mySysex1 = CtrlrMidiMessage({0xF0, 0x3E, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x7F, 0xF7})
                  panel:sendMidiMessageNow(mySysex4)

                  end

                  i totally made up those sysex values, replace with what you need. There are other more elegant ways to do this but this method, at least to me reads fairly logically for beginners.

                  Basically any time you want to trigger a lua script it usually happens when a modulator’s value changes. In Lua you’re usually getting values of some modulator then setting some other value of some other modulator based on a variety of conditions. The Lua documentation is my fav place to go for reference. Definately worth looking over if you get stuck. Doesn’t hurt to read the first few chapters if you’re just getting started.

                  Monstrum Media | Music, Sound & Software Design, Chicago / San Francisco listen

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

                    Hi msepsis,

                    This is just what I needed, especially your remark about when a script is triggered! I theory I did know what to do, using scripting with Lua and I did download a few panels. Studying the scripts made me aware of the possibilities, but also of the complexity of things, especially for beginners. I will study the recommended documentation and try to get and read a book about how to program with Lua. Thanks a lot and I will let you know how I fared.

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

                      Well, with the excellent help of msepsis I made my first working method and as always things are much simpler when you know how to do it! (Of course one has to have some programming experience to understand the workings of a particular piece of code.)

                      I will explain what I needed and how I made this (very simple) method/script with Lua. I hope this will help someone who also is wondering about how to integrate Ctrlr and Lua ;-):

                      I needed a slider with values going from -7 to +7, with the value 0 being a bit special. This slider sets the pan-value of a certain preset (in this case for my Proteus-1 from Emu). On the panel I picked (right click mouse) from the slider option an ‘uiSlider’ and did set the type to ‘LinearHorizontal’ (choose from Slider Style in the ‘component’ part of the right panel of Ctrlr). I also did set the Minimum value to -7 and the Maximum value to 7 and Interval to 1. The Visible name is ‘pan’ and the Name [unique] is ‘PanSlider”. This last name is the name to be used in the method. Then in the Modulator part of the right panel I choose ‘Called when the modulator value changes’, clicked on the ‘+’ sign and added the name for my method, in this case ‘PanMethod’. In the MIDI part I did set the MIDI message type to ‘none’. Then I selected (click on the ‘\’ sign) the PanMethod and the Lua editor window opened. I typed the following Lua code in this window (the first 5 lines of code were already there):


                      — Called when a modulator value changes

                      PanMethod = function(modulator, newValue)

                      panValue = panel:getModulatorByName(“PanSlider”):getModulatorValue()

                      –send appropriate sysex based on slider value:

                      if panValue < 0 then
                      mySysex = CtrlrMidiMessage({0xF0, 0x18, 0x04, 0x00, 0x03, 0x02, 0x02, panValue+128, 0x7F, 0xF7})
                      panel:sendMidiMessageNow(mySysex)

                      elseif panValue == 0 then
                      mySysex = CtrlrMidiMessage({0xF0, 0x18, 0x04, 0x00, 0x03, 0x02, 0x02, 0x78, 0x7F, 0xF7})
                      panel:sendMidiMessageNow(mySysex)

                      elseif panValue > 0 then
                      mySysex = CtrlrMidiMessage({0xF0, 0x18, 0x04, 0x00, 0x03, 0x02, 0x02, panValue, 0x00, 0xF7})
                      panel:sendMidiMessageNow(mySysex)

                      end
                      end

                      and saved the method. Now, when moving the slider, the appropriate pan-value is send to the Proteus-1!

                      Besides the quite easy way of coding, I discovered to my surprise that I could p[ut just decimal values in the sysex string (and even a simple formula) and still the sysex data are understand by the receiving device!

                      I’m on a Mac (10.7.5) and I have also at the same time Windows running on this machine. This is handy, because the help file for the Ctrlr Lua classes only opens on a windows machine. Now I understand how things work this help file is necessary when programming/scripting with Lua for Ctrlr.

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

                        I forgot to mention that for the pan values -1 to -7 I needed different sysex messages then for the pan values form +1 to +7 and also the value ‘0’ needed its own sysex string.

                      Viewing 10 posts - 1 through 10 (of 10 total)
                      • The forum ‘Using Ctrlr’ 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