Mouse Down Events and Toggle Buttons

Home Forums General Using Ctrlr Mouse Down Events and Toggle Buttons

Viewing 19 posts - 21 through 39 (of 39 total)
  • Author
    Posts
  • #100440
    FOLKDISCO
    Participant
      • Topics: 2
      • Replies: 18
      • Total: 20

      Thank you so much Possemo.
      Your buttons work great.
      Just looking at your coding, using modulatorCustomIndex to set the button output note.
      I am happy with a fixed midi channel from the onMouseDown() function.
      I might use two functions to cover channel 15 and 16, rather than using one panel midi channel.
      See below.
      Anyway, your use of radio group works great.
      Playtime is happy with different inputs, but I have seen before that Ableton seemed to have a problem when a note on wasn’t terminated by a note off.
      Maybe something else in the setup was messing with things, I don’t know, but notes were disappearing.
      You used Aftertouch rather than note on for the buttons…
      Any reason for this?

      I might in the future look into pressing one scene button, and this sending just one midi note, but also setting the equivalent radio group buttons for all the tracks.
      Currently, pressing a scene button leaves all the other buttons untouched.

      goodweather, thanks again for your help.
      Yeah I had figured out string.sub(), Lua itself actually has pretty good documentation, so it’s easy enough to work out what you’re doing.
      But Possemo’s use of modulatorCustomIndex works fine and I suspect it’s faster and more efficient so I’ll probably use that.
      I had just got stuck on midi out.
      Basically, I was just working on CTRLR before I connected to anything, and component midi always appeared in monitor so I just kept wondering why the Lua midi wasn’t there…
      D’oh!
      With no set output, component midi appears in the monitor, but Lua midi doesn’t.
      Just one of those CTRLR quirks.

      Thinking through my overall approach to channels and midi control.
      Do I need to use two channels, 15 and 16 to cover all the options?
      Or do I go one channel using 0-9, 10-19, etc to cover all the buttons?
      Will I ever want more than 10 buttons per group/track?
      Perhaps.
      I do want consistent midi now, so different future versions of my controller work with different songs made now and in the future without having to learn new controllers in my DAW, etc.
      So for example, if I have one panel with just some scene buttons and a few rotaries, these should match up so everything still lines up on a different panel with hundreds of buttons and rotaries.
      Just wondering how quickly I can put together a panel with this using PHP.
      Let’s see…
      Probably sleep now and try it tomorrow.
      It is interesting that CTRLR has been envisaged from the start as creating panels to control specific devices.
      I was just looking for a ridiculous number of buttons and controllers, and nothing seemed to fit the bill.
      CTRLR is quirky and complicated but it’s just ridiculously flexible, and I’m really grateful to everyone involved in putting it together.

      • This reply was modified 5 years, 1 month ago by FOLKDISCO.
      #100454
      FOLKDISCO
      Participant
        • Topics: 2
        • Replies: 18
        • Total: 20

        Is there any way to set a radio group by just setting one value or modulator value?
        Rather than setting all values for the whole group?

        I can see how to set a modulator on or off with panel:getModulatorByName(“ModulatorName”):setModulatorValue(1, false, false, false)
        But this does not affect the rest of the modulators in the radio group.

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

          AFAIK there is no way to affect all buttons in a radio group. It is just a loose link between buttons.

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

            I confirm.
            Buttons grouped in a radio group are handled on and off only manually.
            If you set the value of one of the button by Lua then you need to handle the others as well via Lua
            But this is piece of cake when you have a smart naming of your buttons.
            You can create a loop on the button name that you put in a variable that you use within panel:getModulatorByName()
            And you need only 1 method that you set to all buttons.
            Button1, Button2….Button16

            sName= L(comp:getOwner():getName())
            --set all OFF
            for i=1, 16 do
            panel:getModulatorByName("Button"..i):setValue(0, true)
            end
            -- set current ON and send msg
            panel:getModulatorByName(sName):setValue(1, true)

            Didn’t verify the code but should be something like that
            You can also make it even smarter by introducing your radio group number as part of the button number
            If you build your panel by a script and not manually, this should not be any issue.

            Use setValue(your_value, true) if you don’t need the other params of setModulatorValue().

            #100514
            FOLKDISCO
            Participant
              • Topics: 2
              • Replies: 18
              • Total: 20

              Already did this last night.
              All buttons now named b-0-0, b-0-1… b-2-0, etc now.
              Buttons send out midi note on c15 0-9 for track 1, c15 0x10-0x19 for track 2, c16 0x0-0x9.
              Scene buttons send out 0x40-0x49.
              This leaves some space at the end of the tracks and clips for future expansion, if I need it.
              Not sure if I will need more, but if I do, leaving space means I won’t have to reassign all the midi in Reaper.
              Have separate methods for mouse down on channel 15, channel 16 (same as 16), and scenes.

              mouseDown15 = function(comp, event)
              
                  -- get the Note from the Custom Name
                  local NoteNr = comp:getOwner():getProperty("modulatorCustomName")
              
                  -- send the NoteOn event
              	panel:sendMidiMessageNow(CtrlrMidiMessage("9e"..NoteNr.."40"))
              
                  -- reset the Button colour
                  comp:setValue(0,false)
              
              end

              mouseDown() functions use getProperty(“modulatorCustomName”) instead of getPropertyInt(“modulatorCustomIndex”), because I might as well store and read hex, rather than read integers and then have to convert this into hex every time for CtrlrMidiMessage().

              When it came to the scenes, in retrospect this actually freed up modulatorCustomIndex for scene numbers so that pressing a scene button can reset and set relevant button on/off colours.
              Of course this doesn’t send out any extra midi, but it’s massively useful to know where you are with the scenes and clips currently playing.

              scenic16 = function(comp, event)
              
                  -- get the Note from the Custom Name
                  local NoteNr = comp:getOwner():getProperty("modulatorCustomName")
              
                  -- send the NoteOn event
              	panel:sendMidiMessageNow(CtrlrMidiMessage("9f"..NoteNr.."40"))
              
                  -- reset the Button colour
                  comp:setValue(0,false)
              
              	local scene= comp:getOwner():getPropertyInt("modulatorCustomIndex")
              	local t={0,0,0,0,0,0,0,0,0,0,0,0}
              	local i=1
              	local j=1
              	t[0]=0
              	t[scene]=1
              	for i=0, 8 do
              		for j=0, 9 do
              			n="b-"..i.."-"..j
              			panel:getModulatorByName(n):setModulatorValue(t[j], false, false, false)
              		end
              	end
              end

              I was a bit more paranoid about making variables local with the scene button Lua, as it will take longer to run.
              I created a fully functioning panel with buttons then deleted all except one of the buttons and rotaries.
              I use a php script to build all the XML script (buttons and rotaries) into a textarea box.
              Save, then open the panel in a text editor, delete the one modulator and paste in the text from the PHP textarea.
              Not sure if this saved time or made it all ridiculously more complicated for myself!
              But it does mean that I can build new versions of my panel automatically, rather than having to edit and resize 100 buttons and 60 rotaries manually.
              Just want to actually use the thing now.
              Cheers again for your help, goodweather and Possemo.
              Not just specifically on this thread, but I also found useful stuff from both of you on other threads.
              The rotaries work left/right, because I have my tablet in portrait mode, but work it in landscape mode.
              This is to maximise screen usage/screen wastage, both on CTRLR and windows taskbar etc.
              When I run Reaper/Playtime on my laptop, I use rtpMIDI over wifi tablet -> laptop.
              When I run Reaper/Playtime on my tablet, I use Loopbe to route back midi.
              Going forward, I was thinking I might make the last set of buttons for each track a simple on/off toggle, not in the radio groups, for a midi mute function on all tracks.
              I think this might be more useful than an extra clip on each track.
              Really quite happy how this turned out.
              Take a look, I think it’s pretty cool.

              • This reply was modified 5 years, 1 month ago by FOLKDISCO.
              • This reply was modified 5 years, 1 month ago by FOLKDISCO.
              • This reply was modified 5 years, 1 month ago by FOLKDISCO.
              Attachments:
              You must be logged in to view attached files.
              #100558
              goodweather
              Participant
                • Topics: 45
                • Replies: 550
                • Total: 595
                • ★★★

                Glad we could help!
                I’m personally only using variables (tables, memory blocks) to store data related to modulators because this is probably the safest (but probably also not the easiest).
                ModulatorCustomIndex/Name are good alternatives but due to the lack of documentation of Ctrlr you are unsure if this is completely free to use (probably) or not.

                Have fun!

                #100567
                FOLKDISCO
                Participant
                  • Topics: 2
                  • Replies: 18
                  • Total: 20

                  It certainly makes A LOT of sense to have a free variable on components, for users to pass variables.
                  From their name I would be surprised if Atom didn’t put these here for this purpose.
                  If I was you I would use it.
                  There was a point where I was thinking, “hold on, do I need 100 methods here?”
                  Then making hacks/workarounds like passing variables through component name until Possemo pointed me in the direction of ModulatorCustomIndex/Name.
                  Writing Lua is fine, because Lua is documented, but even if you have had decades of writing code, writing Lua code in CTRLR is really difficult, because nothing is documented.
                  You search in the forum, but obviously the forum is chaotic and disorganised because it’s a forum!
                  We could really do with documentation.
                  Maybe a wiki with all the CTRLR functions, passed variables.
                  Maybe a couple of examples if people can do that.
                  I think Atom gave us all CTRLR for nothing, so I’m not going to go asking him to document the thing.
                  I am probably over the difficult hump now, but it’s a steep hill at first.

                  • This reply was modified 5 years, 1 month ago by FOLKDISCO.
                  #100600
                  goodweather
                  Participant
                    • Topics: 45
                    • Replies: 550
                    • Total: 595
                    • ★★★

                    As I said, different ways to achieve the same result. You choose the one you feel the most confortable with and you remain open to new stuff.
                    I have already documented quite many things in my Step by Step Guide 2.0 (but not published due to still many “holes”) maybe I can add a reference part.
                    You find a lot in the github of Ctrlr and this is where I’m looking to many things
                    Then you have the panels people have made which are also a good source

                    Have fun!

                    #100963
                    FOLKDISCO
                    Participant
                      • Topics: 2
                      • Replies: 18
                      • Total: 20

                      Actually… Rethink!
                      I am going to scrap a lot of the above, and just work with static uiLabel.
                      At a basic level, I am fighting problems resulting from mouse up behaviour, and it is impossible to turn this off.
                      Probably simpler to just use statics, creat my own radio groups, and set colours on mouse down using:
                      panel:getModulatorByName(“static1”):getComponent():setPropertyString(“uiLabelBgColour”,”ff0000ff”)
                      The basic problem I had isn’t CTRLR, it’s the touch screen.
                      I can set mouse down behaviours but mouse up is so inconsistent.
                      It works literally about 2/3 of the time, unless I am being really careful, and you don’t do that in performance situations.
                      Pretty sure I know what I’m doing now.
                      On the plus side, uiLabels actually are physically looking nicer.

                      • This reply was modified 5 years, 1 month ago by FOLKDISCO.
                      #100970
                      Possemo
                      Participant
                        • Topics: 14
                        • Replies: 638
                        • Total: 652
                        • ★★★

                        I wanted to warn you about the ctrlr uibutton. It can be buggy at times – it depends on what you want to do with it. Also, radiogroup does not always work as expected. Btw. I used the uicustomcomponent for my isomorphic keyboard (for touchscreens):

                        Isomorphic Keyboard

                        It does work nicely on my Surfacebook. I was surprised myself how well the mouse-up and mouse-down events are working on the uicustomcomponent. It is the only component who provides both mouse events.

                        • This reply was modified 5 years, 1 month ago by Possemo.
                        #101150
                        FOLKDISCO
                        Participant
                          • Topics: 2
                          • Replies: 18
                          • Total: 20

                          uicustomcomponent supports mouse down and up?
                          Maybe I should have used uicustomcomponent, but all the buttons needed some lua anyway.
                          Here’s the full panel, everything working, sending out midi.
                          I used global variables 0-15 for current clip.
                          19 for the mute/stop toggle button, which changes the function of the s/m buttons.
                          20-35 for the mutes.
                          Obviously only using up to 8 and 28 currently, but there is plenty of space for expansion.
                          Also double clicking the mute/stop button this clears the scenes and clips.
                          All buttons send out note on except mutes which send out CC 0 or 7f, matching the rotaries.
                          Think it responds really nicely, and looks a lot nicer using uiLabels than ctrlr buttons.
                          Buttons have some strange colour effects I couldn’t work out how to turn off.
                          When I save as an exe, a small part of the panel is chopped off at the bottom.
                          What’s going on there?
                          Cheers again for your help.
                          And your iso keyboard looks lovely.

                          • This reply was modified 5 years, 1 month ago by FOLKDISCO.
                          Attachments:
                          You must be logged in to view attached files.
                          #101454
                          Possemo
                          Participant
                            • Topics: 14
                            • Replies: 638
                            • Total: 652
                            • ★★★

                            cropped off bottom: a know bug. Add 24 pixels to the property uiPanelCanvasRectangle – e.g. when you want the panel to be 800×600 you put this in the property-field: 0 0 800 624

                            #101462
                            FOLKDISCO
                            Participant
                              • Topics: 2
                              • Replies: 18
                              • Total: 20

                              I saved my panel, and it didn’t save the Lua methods!
                              So it was working 100% in CTRLR, kept saving different versions, and now they don’t work because the methods have gone AWOL.
                              Why would it do that?
                              Lesson learned, I will be more paranoid in future, but I now need to rewrite 2 methods.
                              Everything saved fine previously, including methods.
                              I am on version 5.4.29, because that loads lots, lots faster, than 5.5.2 and I don’t have the correct dlls for version 6.
                              And thanks for your reply about the 24 pixels.

                              • This reply was modified 5 years, 1 month ago by FOLKDISCO.
                              #101497
                              FOLKDISCO
                              Participant
                                • Topics: 2
                                • Replies: 18
                                • Total: 20

                                Two panels written, exported, etc.
                                Feel a bit daft for uploading a useless panel.
                                Oh well.
                                Cheers again.
                                Definitely getting faster at doing this stuff.
                                To start with, you just look at CTRLR and think. “….. WHAAAAT?”
                                Then you look at Lua methods and go “….. WHAAAAT?”
                                It all gets easier.
                                Just need to know the basics of programming.

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

                                  For developing panels I would use the recommended version here: http://ctrlr.org/nightly/Ctrlr-5.3.201.exe
                                  It is far from being bug-free but “forgetting” the Lua methods never happened to me. I guess everyone that made panels with Ctrlr experienced some serious setbacks due to nasty bugs. If you are developing with Ctrlr you have to live with it. Making a version tree helps a lot. Save as many steps as possible. When you look at the version numbers of my panels, e.g. “Matrix1000_1_230” it started at v 0.1 and ended at v 1.230

                                  • This reply was modified 5 years, 1 month ago by Possemo.
                                  • This reply was modified 5 years, 1 month ago by Possemo.
                                  #102137
                                  FOLKDISCO
                                  Participant
                                    • Topics: 2
                                    • Replies: 18
                                    • Total: 20

                                    That’s what got me. I always save important docs, songs, etc, regularly as filename 001, filename 002, etc with a round 10 number sometimes for significant steps. What got me was that I saved the thing in lots of versions, but from a certain point forward, none of the saves had my Lua methods. I have a program called “agent ransack”, a file search thing so I did a full computer search for panels containing “string.sub”, sorted by date. Only took an hour to re-write the last two methods and other enhancements, not too bad.
                                    I historically lost important stuff, so I’m pretty anal about saving lots of versions of everything.
                                    It is the one program on my whole computer where I have more than two versions…. *SIX* different versions installed in different folders.
                                    In your humble opinion, is Ctrlr-5.3.201.exe better than Ctrlr 5.4.29?
                                    Also, almost all the different versions seem on the face of it to be exactly the same as each other!
                                    The only big differences seem to be that Ctrlr-5.5.2.exe took ages to load, and I didn’t have all the dlls for v6.x. Need to run CTRLR on a w10 x32 windows tablet, with so much space, so don’t want to install extra dlls if possible.

                                    I just plumped for the latest version which loaded speedily.
                                    You say “For developing panels I would use the recommended version here: Ctrlr-5.3.201.exe”
                                    Is there a different better version for running panels more efficiently? I found there’s quite a big CPU hit spinning rotaries on my old laptop.

                                    • This reply was modified 5 years ago by FOLKDISCO.
                                    • This reply was modified 5 years ago by FOLKDISCO.
                                    #102148
                                    goodweather
                                    Participant
                                      • Topics: 45
                                      • Replies: 550
                                      • Total: 595
                                      • ★★★

                                      As we mentioned several times, the Ctrlr versions to use to avoid issues is 5.3.201 for PC and 5.3.198 for Mac.
                                      They are not perfect and have some bugs but they are stable and provide good results.
                                      I’m using Ctrlr almost every day and have seldom issues.
                                      I never had any issue with disappearing methods and I’m using a lot of methods in my panels.

                                      If you are using another version of Ctrlr, you need to accept the inconveniences, crashes, etc…
                                      It will not help to complaint I’m afraid.

                                      And in general, if you find some bugs then it is good to report them in the Development – Issue tracker part of this site.

                                      So, recommendation is exactly as Possemo mentioned: don’t use any other version than 5.3.201

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

                                        I said “for developing” beause almost any build will do if you are just using a panel. Most bugs are showing up when you are editing panels. As you said, the newest version will load much faster. Therefore I would suggest using the newest version for building instances of your panel. That is – for a standalone instance, plugin is not able to make instances yet.

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

                                          With the remark that I found that some code in my panels was not working in newer versions (don’t remember what exactly, sorry) and thus that newer versions are not fully backward compatible with 5.3.201.

                                          But now you gave me some gently push to check what was not working anymore 😉
                                          Thanks Possemo!

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