panel MIDI channel change

Home Forums General Panels, Components, Macros panel MIDI channel change

Viewing 20 posts - 1 through 20 (of 26 total)
  • Author
    Posts
  • #71772
    human fly
    Participant
      • Topics: 124
      • Replies: 1070
      • Total: 1194
      • β˜…β˜…β˜…β˜…

      *awesome* πŸ™‚ that’s neat:
      just made a combo to see if i could get it to address
      Panel MIDI Channel out by linking it to a Panel Property
      -yes, it works, for MIDI CC anyway.

      what i would like to do now, is to be able to select
      the main MIDI channel on a a device with 4 parts, where
      2,3,4 channel numbers follow consecutively. so you select
      ie: main channel as 1, and the others are automatically
      sending out on 2,3, and 4 ( or as main channel number+1,+2,+3)

      would this be a lua: ‘when modulator value changes’?
      there is a parameter:’override panel MIDI channel’ :
      can that and the following parameter ‘midi channel’
      be accessed via lua?

      #71778
      Puppeteer
      Participant
        • Topics: 16
        • Replies: 185
        • Total: 201
        • β˜…β˜…

        Yes. When the MidiCh modulator value changes.

        I’d do it something like this. Use Mch2-4 for your consecutive channels. You may need some logic in there to deal with the case where Mch is set to 13 or higher, as Mch 4 would end up as Ch 17 in that case.

        SetMch = function(–[[ CtrlrModulator –]] mod, –[[ number –]] value)
        — ch = panel:getModulatorByName(“MidiCh”):getModulatorValue()
        ch = value
        cntch = value + 1
        Mch = 176 + ch — 176 == b0
        Mch2 = 177 + ch
        Mch3 = 178 + ch
        Mch4 = 179 + ch

        — Change all of the MIDI sliders. This changes channel for the panel as a whole.
        panel:setPropertyInt(“panelMidiOutputChannelDevice”, cntch)

        — Reset Last Modulator. This is specific to the panel I was making and can be
        — ignored. I used this for MIDI data compression of some custom MIDI messages.
        LastModulator = “None”

        — This works for an individual controller
        — panel:getModulatorByName(“Vol”):getMidiMessage(0):setPropertyString(“midiMessageChannel”, tostring(cntch))

        — Refresh the panel
        redraw = panel:getPanelEditor():getCanvas()
        redraw:repaint()

        end

        The Puppeteer
        http://godlike.com.au

        #71781
        human fly
        Participant
          • Topics: 124
          • Replies: 1070
          • Total: 1194
          • β˜…β˜…β˜…β˜…

          thanks – but i’m having some trouble interpreting that.
          realise i need to approach something more basic first.

          all i’ve done so far is change the overall MidiChannel.
          changing the channel of all objects on a given tab will
          be the issue.

          i really need to become more conversant with the basic
          concepts first, i can see that. function, variable, value,
          syntax (meaning/familiarisation/recognition) –

          i need to set this up as a simple demo panel first, just
          controlling some combo values, maybe. get the midi side
          working after.

          #71785
          human fly
          Participant
            • Topics: 124
            • Replies: 1070
            • Total: 1194
            • β˜…β˜…β˜…β˜…

            OK, i have made something that will compile.
            but it doesn’t do anything.
            i am not sure what to use from what you’ve shown above.
            i’ve just started bodging something: i’ve called master midi
            MidiCh, and the others MidiCh2,3,4
            i’ve got no ifs and thens here though.


            — Called when a modulator value changes
            — @mod http://ctrlr.org/api/class_ctrlr_modulator.html
            — @value new numeric value of the modulator

            SetMch = function(mod, value)

            ch = panel:getModulatorByName(“MidiCh”):getModulatorValue()
            MidiChB = panel:getModulatorByName(“MidiChB”):getModulatorValue()
            MidiChC = panel:getModulatorByName(“MidiChC”):getModulatorValue()
            MidiChD = panel:getModulatorByName(“MidiChD”):getModulatorValue()

            ch = value
            cntch = value + 1
            MidiCh = 176 + ch – 176 == b0
            MidiChB = 177 + ch
            MidiChC = 178 + ch
            MidiChD = 179 + ch
            end

            #71786
            human fly
            Participant
              • Topics: 124
              • Replies: 1070
              • Total: 1194
              • β˜…β˜…β˜…β˜…

              this compiles but then fails at line 12 when tested:
              (if
              MChA:getModulatorValue() (newValue, ch) then)

              lol i don’t know what i’m doing ! haven’t got anything
              to control the other combos yet.
              —————————————————————————

              SetMch = function (value)

              MChA = panel:getModulatorByName(“MidiCh”):getModulatorValue()
              MChB = panel:getModulatorByName(“MidiChB”):getModulatorValue()
              MChC = panel:getModulatorByName(“MidiChC”):getModulatorValue()
              MChD = panel:getModulatorByName(“MidiChD”):getModulatorValue()

              ch = value

              if
              MChA:getModulatorValue() (newValue, ch) then

              MChB:setModulatorValue() (newValue, ch + 1)
              MChC:setModulatorValue() (newValue, ch + 2)
              MChD:setModulatorValue() (newValue, ch + 3)
              end
              end

              #71787
              proton
              Participant
                • Topics: 19
                • Replies: 94
                • Total: 113
                • β˜…β˜…

                MChA = panel:getModulatorByName(β€œMidiCh”):getModulatorValue()

                you assign a value (a number in that case) to a variable MChA

                later on you are trying to getModulatorValue from this variable (from a number):

                MChA:getModulatorValue()

                this makes no sense.
                you could create a variable for your modulator like this:

                MChA = panel:getModulatorByName(β€œMidiCh”) and use it later to getValue like this: MChA:getValue()

                If you don’t know what are you doing (as stated in the post above) you should take the time to check some Lua tutorials on YouTube and then we will be happy to help. We’ve all been there and it take some time but it will eventually be very clear to you. Keep the faith man! πŸ˜‰

                Cheers!

                #71789
                human fly
                Participant
                  • Topics: 124
                  • Replies: 1070
                  • Total: 1194
                  • β˜…β˜…β˜…β˜…

                  “MChA = panel:getModulatorByName(β€œMidiCh”):getModulatorValue()

                  you assign a value (a number in that case) to a variable MChA”

                  oh? i thought it was ..’fetch its value’ so that it is available
                  for the rest.

                  “later on you are trying to getModulatorValue from this variable (from a number):

                  MChA:getModulatorValue()

                  this makes no sense.”
                  is MChA a ‘number’ now? don’t understand! lol

                  ‘you could create a variable for your modulator like this:

                  MChA = panel:getModulatorByName(β€œMidiCh”) and use it later to getValue like this: MChA:getValue()’

                  that’s what i thought i was doing.

                  #71790
                  human fly
                  Participant
                    • Topics: 124
                    • Replies: 1070
                    • Total: 1194
                    • β˜…β˜…β˜…β˜…

                    #71791
                    human fly
                    Participant
                      • Topics: 124
                      • Replies: 1070
                      • Total: 1194
                      • β˜…β˜…β˜…β˜…

                      – – –

                      #71792
                      human fly
                      Participant
                        • Topics: 124
                        • Replies: 1070
                        • Total: 1194
                        • β˜…β˜…β˜…β˜…

                        – – –

                        #71793
                        human fly
                        Participant
                          • Topics: 124
                          • Replies: 1070
                          • Total: 1194
                          • β˜…β˜…β˜…β˜…

                          this one eventually gets to some detail stuff, eg:
                          on difference between ‘=’ and ‘==’ … i’ll watch
                          this one…

                          #71794
                          proton
                          Participant
                            • Topics: 19
                            • Replies: 94
                            • Total: 113
                            • β˜…β˜…

                            Hi human fly!

                            don’t give up!

                            If you are looking for shortcuts and an easy and quick solution for implementing your ideas just hire a programmer, this is what they do all day long. If you really want to LEARN about programming in Lua and about implementing this knowledge in Ctrlr you need to get your hands dirty: check a lot of videos about the boring stuff like variables, tables, syntax etc., read the Lua manual maybe, read the available great articles on the JUCE website and foremost analyze tons of panels from the great bunch of Ctrlr users that are all available to you in the download section. Ask questions on this forum and you will see the light in the tunnel pretty quickly.
                            If on the other hand you don’t feel like investing your precious time into this whole boring stuff – hire a programmer or don’t wonder that scripts do not work. There is no middle ground really. Don’t expect from Atom Lua tutorials just because he chose Lua for extending Ctrlrs possibilities. You don’t need to use Lua at all to use Ctrlr. If you need more advanced features there comes the Lua and it is your responsibility to get prepared for it and not Atoms. This dude spent years developing this for all of us and he is never pleased reading comments from users that expect stuff to happen after just watching few YT videos. I mean it in a very positive way, please don’t get me wrong. Most of us have been there. It can be frustrating at times but this is just a small language that consists of few rules that YOU need to learn in order to be able use it. Please don’t expect other users to write the script for you – this isn’t the right attitude not only here but also among other programmers and languages. Make an effort and write something with tons of errors and people will help you for sure anyways. Saying that this is all unclear to you and you don’t really need this anyways is not the best start to get help from others. Learn the basics about stuff like [[ () = and ==, functions, variables and all those other building blocks and you will see much more clear the logic in how Lua is working inside Ctrlr. You are right that sometimes same things are done slightly different by different programmers and there is nothing wrong about it. Just learn one correct way of calling functions/methods first and don’t bother too much if you see someone else doing it some other way. People here have various backgrounds and are scripting in different fashions but believe me, once you get your basics straight you will be able to understand all of it. There is just no real shortcut for this process.
                            Learn every day, ask questions, stay positive and you will get anywhere you want with Ctrlr!
                            Cheers!

                            #71795
                            human fly
                            Participant
                              • Topics: 124
                              • Replies: 1070
                              • Total: 1194
                              • β˜…β˜…β˜…β˜…

                              okay, thanks for taking the time to a/read (cz i don’t know if people are
                              stumbling this by chance, or if it is an ongoing conversation, and i am careful
                              not to post for *nothing* and harass you guys with thin air – right? >premise#Uno) and b/ taking the time to write a reply.

                              tbh, i think this forum could have a sticky with a topic with decent links
                              to the most useful vids and reading matter. what i watched, i did find some
                              of the basics, and it is useful to see it being done in real time.

                              #71796
                              human fly
                              Participant
                                • Topics: 124
                                • Replies: 1070
                                • Total: 1194
                                • β˜…β˜…β˜…β˜…

                                here’s a better vid:

                                #71797
                                human fly
                                Participant
                                  • Topics: 124
                                  • Replies: 1070
                                  • Total: 1194
                                  • β˜…β˜…β˜…β˜…

                                  LOOK: i’m not a total lost cause, you’ll be proud of me :p
                                  i just optimised something a little bit that i know works.
                                  wish i’d done it first to save all the re-naming…anyway:

                                  version1 (‘bodge-it version’): (this is a view choice between
                                  2 options)

                                  PCM2Bank_showChoice_Pt1 = function(mod, value)

                                  if
                                  panel:getModulatorByName(“Partial2_PCM Part1”):getValue() == 0 then

                                  panel:getModulatorByName(“PCM1_P2 Part1”):getComponent():setVisible(true)
                                  panel:getModulatorByName(“PCM2_P2 Part1”):getComponent():setVisible(false)
                                  elseif
                                  panel:getModulatorByName(“Partial2_PCM Part1”):getValue() == 1 then

                                  panel:getModulatorByName(“PCM1_P2 Part1”):getComponent():setVisible(true)
                                  panel:getModulatorByName(“PCM2_P2 Part1”):getComponent():setVisible(false)
                                  elseif
                                  panel:getModulatorByName(“Partial2_PCM Part1”):getValue() == 2 then

                                  panel:getModulatorByName(“PCM1_P2 Part1”):getComponent():setVisible(false)
                                  panel:getModulatorByName(“PCM2_P2 Part1”):getComponent():setVisible(true)
                                  elseif
                                  panel:getModulatorByName(“Partial2_PCM Part1”):getValue() == 3 then

                                  panel:getModulatorByName(“PCM1_P2 Part1”):getComponent():setVisible(false)
                                  panel:getModulatorByName(“PCM2_P2 Part1”):getComponent():setVisible(true)
                                  end
                                  end

                                  WORKING.

                                  *new* V.2, smart way:(this one is re-usable with minimum
                                  renaming)

                                  PCM1Bank_showChoice_Pt1B = function(mod, value)

                                  bankSel = panel:getModulatorByName(“Partial1_PCM Part1”):getValue()
                                  pcm1 = panel:getModulatorByName(“PCM1_P1 Part1”)
                                  pcm2 = panel:getModulatorByName(“PCM2_P1 Part1”)

                                  if
                                  bankSel == 0 then

                                  pcm1:getComponent():setVisible(true)
                                  pcm2:getComponent():setVisible(false)
                                  elseif
                                  bankSel == 1 then

                                  pcm1:getComponent():setVisible(true)
                                  pcm2:getComponent():setVisible(false)
                                  elseif
                                  bankSel == 2 then

                                  pcm1:getComponent():setVisible(false)
                                  pcm2:getComponent():setVisible(true)
                                  elseif
                                  bankSel == 3 then

                                  pcm1:getComponent():setVisible(false)
                                  pcm2:getComponent():setVisible(true)
                                  end
                                  end

                                  *WORKING*

                                  NOW! the odd thing here is that ‘==’ works, but ‘=’ does not.
                                  so that’s a ‘comparative’ ‘==’

                                  (thinks)>if i put bankSel:getValue() would i be able to use ‘=’ ?
                                  ie: i would be dealing with a value?

                                  note: i have not had to use anything like ‘local’ for
                                  bankSel, pcm1 and pcm2 at the top of the 2nd version.
                                  (soz, i’m still forgetting what is called what: value/string/
                                  operator/component/etc.)

                                  (figured i should go back to a point where i know what’s going
                                  on)

                                  #71798
                                  human fly
                                  Participant
                                    • Topics: 124
                                    • Replies: 1070
                                    • Total: 1194
                                    • β˜…β˜…β˜…β˜…

                                    (double post)

                                    #71799
                                    human fly
                                    Participant
                                      • Topics: 124
                                      • Replies: 1070
                                      • Total: 1194
                                      • β˜…β˜…β˜…β˜…

                                      in fact, there is currently a problem with both of those setVisible() Luas:
                                      they do work, but they both also load with both options showing, overlaid.

                                      this is cleared as soon as a selection is made.

                                      somehow, it needs to check the ‘structure’ value on load/startup.
                                      is this where one uses something like redraw/repaint? (i don’t know
                                      that function yet, or what it is for)

                                      #71800
                                      human fly
                                      Participant
                                        • Topics: 124
                                        • Replies: 1070
                                        • Total: 1194
                                        • β˜…β˜…β˜…β˜…

                                        can’t ‘hire a programmer’, man.. i have to figure out
                                        how to do the simple things i need, or there’s no point
                                        in this. !! c’mon, that’s cheating.. but i do glimpse
                                        how far this goes, and i don’t think i’ll be going there!

                                        right now, i just want to learn to do straightforward
                                        things, like show/hide stuff, switch things on or off
                                        depending on selections, and depending on what the
                                        device involved needs.

                                        later maybe, more involved stuff like retrieving data
                                        and updating panel controls from data requests – but
                                        that’s some way off at this point, haven’t looked into
                                        it yet.(same with any notion of a patch librarian)
                                        i’m really just a novice trying to finish a first panel
                                        adequately. i needed a specific lua for that, if you
                                        remember the ‘partial onoff’ method, because of the way
                                        that device works. similarly, i’m using some ‘setVisible’
                                        methods because it makes sense to show options available
                                        depending on the main parameter’s selection.(hope that
                                        makes sense) – if i can get that loading properly, i’m
                                        happy: ‘version’ done.

                                        #71801
                                        human fly
                                        Participant
                                          • Topics: 124
                                          • Replies: 1070
                                          • Total: 1194
                                          • β˜…β˜…β˜…β˜…

                                          – – –

                                          #71815
                                          human fly
                                          Participant
                                            • Topics: 124
                                            • Replies: 1070
                                            • Total: 1194
                                            • β˜…β˜…β˜…β˜…

                                            okay, fresh start, then, at this point: rtfm
                                            (this is, of course, in Goodweather’s manual.pdf)

                                            http://www.lua.org/home.html

                                            http://www.lua.org/manual/5.3/
                                            (these actually don’t cast much light, in terms of
                                            direct use in Ctrlr – you’re right: learn from examples
                                            from other users)
                                            viz: in my little world, getting a first thing working
                                            is what motivates me to find out how the rest of it works πŸ˜‰

                                            here’s a simple one i just did to get back to basics a bit:
                                            a button to show/hide an item. can you show me alternative,
                                            maybe shorter, ways to do this? >
                                            (i’m still poking around in the dark here; still don’t know
                                            what i must specify in brackets after ‘function’..so i’ll
                                            go off and do a bit of reading..)

                                            setVisible2 = function(mod, value)

                                            button = panel:getModulatorByName(“big button”):getValue()
                                            item = panel:getModulatorByName(“Partial1_Wave Part1”)

                                            if
                                            button == 0 then
                                            item:getComponent():setVisible(false)
                                            elseif
                                            button == 1 then
                                            item:getComponent():setVisible(true)
                                            end
                                            end

                                            • This reply was modified 6 years, 11 months ago by human fly.
                                          Viewing 20 posts - 1 through 20 (of 26 total)
                                          • The forum ‘Panels, Components, Macros’ is closed to new topics and replies.
                                          There is currently 0 users and 54 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