HISE Logo Forum
    • Categories
    • Register
    • Login

    Using "obj"

    Scheduled Pinned Locked Moved Scripting
    7 Posts 2 Posters 132 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.
    • VirtualVirginV
      VirtualVirgin
      last edited by

      When I search on "obj" in the Docs I don't get any hits.
      I have only picked up so far what to do with it in context (obj.value, obj.over etc.).
      Does "obj" itself return the component ID? Or do I have to do anything special to get it?
      I am doing some LAF right now and I'm trying to make conditions based on the component ID.

      You can listen to my orchestral mockups here:
      https://www.virtualvirgin.net/

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

        @VirtualVirgin obj is just the name we give to the object that is passed to a laf function, but it could have any name, so you won't find it in the docs.

        The contents of obj varies between different laf functions, to find out what it contains in the function you're in you can use Console.print(trace(obj));

        You should generally use local laf, so you can assign a separate laf to each component, so you don't need to do things based on the component ID. You can also share a single local laf between multiple components and use the properties of each component within the laf - again avoiding the need to filter based on the ID. But there are some occasions when knowing the ID can be useful.

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

        VirtualVirginV 2 Replies Last reply Reply Quote 0
        • VirtualVirginV
          VirtualVirgin @d.healey
          last edited by VirtualVirgin

          @d-healey Thanks :)

          I'm using it to color keys on a keyboard based on a range, so I need the ID of each button (key) component to see if it is in range. The component reference definitions are stored inside an array, so I've got this now:

          if(keyboard0.indexOf(obj) >= rangeMin && keyboard0.indexOf(obj) <= rangeMax)
          

          "keyboard0" is an array of the keys indexed in order (0-127).

          All of the button keys share the same LAF.

          Currently, rangeMin and rangeMax are set to 0/127, but this is not returning "true" and hence does not seem to return the component ID.

          You can listen to my orchestral mockups here:
          https://www.virtualvirgin.net/

          1 Reply Last reply Reply Quote 0
          • VirtualVirginV
            VirtualVirgin @d.healey
            last edited by VirtualVirgin

            @d-healey
            Ok, so I'm noticing that this method of making script definitions does not get the user ID name into the array, just HISE encoded Object ID:

            Screenshot 2024-12-09 at 2.43.56 PM.png

            It doesn't respond to searching for the user ID.

            If I print the obj.id from the LAF, it is giving me the user ID name, not the encoded Object ID:

            Screenshot 2024-12-09 at 2.48.06 PM.png

            So is there a way to convert the user ID name to the HISE encoded one?

            I think the mismatch is causing my range conditions to return a false.

            You can listen to my orchestral mockups here:
            https://www.virtualvirgin.net/

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

              @VirtualVirgin said in Using "obj":

              user ID name to the HISE encoded one?

              I'm not sure what you're referring to here. But looking at the bit of script you posted:

              Content.getComponent() will get a reference to the specified component, in the form of a ScriptObject. If you want to view the ID of one of those components you can use myComponent.getId(); or in your example keyboard0[3].getId();

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

              VirtualVirginV 1 Reply Last reply Reply Quote 0
              • VirtualVirginV
                VirtualVirgin @d.healey
                last edited by

                @d-healey
                I was referring to the difference between the user name for the ID and the one HISE creates "Object 0x58dca420" or whatever it comes up with.
                Up until this point I thought putting the script variable definitions in the array was storing the ID name at the indexes, but apparently not.
                To solve here I just pushed a new array specifically for the ID names and now it works to match the names with an index, and thus satisfies the condition above and returning "true".

                Thanks for the help :)

                You can listen to my orchestral mockups here:
                https://www.virtualvirgin.net/

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

                  @VirtualVirgin said in Using "obj":

                  I was referring to the difference between the user name for the ID and the one HISE creates "Object 0x58dca420" or whatever it comes up with.

                  Console.print will only display text. When you pass it something that isn't text it will display what it is, Object, Array, etc. In the case of objects it also prints some hex numbers which I'm not entirely sure what they are, perhaps a memory address, either way the information is not useful to us.

                  d6c2f95c-c442-4e86-b8fd-ca466ccca12f-image.png

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

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post

                  24

                  Online

                  1.8k

                  Users

                  12.1k

                  Topics

                  105.0k

                  Posts