HISE Logo Forum
    • Categories
    • Register
    • Login

    Start timer based on the values of the buttons in an array

    Scheduled Pinned Locked Moved Scripting
    13 Posts 3 Posters 93 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Oli UllmannO
      Oli Ullmann
      last edited by

      Hello everyone!

      I have an array with several buttons. If ALL buttons have the value 0, the timer should be stopped.

      If at least one of the buttons has a value greater than 0, the timer should be started.

      Simple task but I can't figure it out right now. Does anyone have any ideas?

      PS. I could of course implement it in a large if-query, but that would be very awkward...

      Many thanks
      Oli

      A 1 Reply Last reply Reply Quote 0
      • A
        aaronventure @Oli Ullmann
        last edited by

        @Oli-Ullmann value change broadcaster that has a listener which loops through all these buttons.

        If you have the references in an array,use that. If not, you can get it using a filter with Content.getComponents().

        The code is simply
        For (i in buttonArray)
        If (i.getValue()! = 0)
        Return

        StopTimer

        So if they're all 0, return won't be called and it'll stop the timer. If any of them isn't, the function won't get to stopTimer

        Sry for formatting, phone.

        d.healeyD 1 Reply Last reply Reply Quote 0
        • d.healeyD
          d.healey @aaronventure
          last edited by

          @aaronventure What about if (myArr.contains(1))? No need for a loop then.

          Libre Wave - Freedom respecting instruments and effects
          My Patreon - HISE tutorials
          YouTube Channel - Public HISE tutorials

          Oli UllmannO A 2 Replies Last reply Reply Quote 0
          • Oli UllmannO
            Oli Ullmann @d.healey
            last edited by

            @aaronventure
            Good idea, thank you very much! :-) I'll try that.

            @d-healey
            Did you see that I was talking about the value of the buttons? I don't know how to apply your suggestion to buttons...

            d.healeyD 1 Reply Last reply Reply Quote 0
            • d.healeyD
              d.healey @Oli Ullmann
              last edited by

              @Oli-Ullmann Ah sorry I misread that. I thought you were storing the button values in an array.

              Libre Wave - Freedom respecting instruments and effects
              My Patreon - HISE tutorials
              YouTube Channel - Public HISE tutorials

              Oli UllmannO 2 Replies Last reply Reply Quote 1
              • Oli UllmannO
                Oli Ullmann @d.healey
                last edited by

                @d-healey
                Ah ok. :-)

                1 Reply Last reply Reply Quote 0
                • Oli UllmannO
                  Oli Ullmann @d.healey
                  last edited by

                  @d-healey
                  But another question:

                  If I use getAllComponents, is there a way to select all components except the components with a specific name?

                  In my case, I want to select all components except the components that have “UI” in their name. Do you know if this is possible?

                  d.healeyD 1 Reply Last reply Reply Quote 0
                  • d.healeyD
                    d.healey @Oli Ullmann
                    last edited by

                    @Oli-Ullmann It uses regex so it might be possible - ChatGPT could possibly help but might require some tweaks to its output because HISE regex is none standard

                    Libre Wave - Freedom respecting instruments and effects
                    My Patreon - HISE tutorials
                    YouTube Channel - Public HISE tutorials

                    Oli UllmannO 2 Replies Last reply Reply Quote 1
                    • Oli UllmannO
                      Oli Ullmann @d.healey
                      last edited by

                      @d-healey
                      Ok, thank you! :-)

                      1 Reply Last reply Reply Quote 0
                      • Oli UllmannO
                        Oli Ullmann @d.healey
                        last edited by

                        @d-healey
                        Thank you, that worked.
                        For the “UI” example, the code is as follows:

                        Content.getAllComponents(“^(?!.*UI).*$”);
                        
                        d.healeyD 1 Reply Last reply Reply Quote 3
                        • d.healeyD
                          d.healey @Oli Ullmann
                          last edited by d.healey

                          @Oli-Ullmann Good to know, I might include that in a video.

                          Should also work with getAllModulators, getAllEffects, etc.

                          Libre Wave - Freedom respecting instruments and effects
                          My Patreon - HISE tutorials
                          YouTube Channel - Public HISE tutorials

                          Oli UllmannO 1 Reply Last reply Reply Quote 2
                          • Oli UllmannO
                            Oli Ullmann @d.healey
                            last edited by

                            @d-healey
                            Yes, that's a great topic for a video! If I had known this earlier, it would have saved me a lot of time and programming effort.

                            1 Reply Last reply Reply Quote 0
                            • A
                              aaronventure @d.healey
                              last edited by

                              This post is deleted!
                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post

                              57

                              Online

                              1.7k

                              Users

                              11.7k

                              Topics

                              101.8k

                              Posts