HISE Logo Forum
    • Categories
    • Register
    • Login

    Label to show current expansion

    Scheduled Pinned Locked Moved General Questions
    expanionslabelobject name
    7 Posts 2 Posters 159 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.
    • R
      rzrsharpeprod
      last edited by

      I am trying to create a label to show the currently selected expansion but I can only get it to show the object name not the actual name of the expansion.

      I have used this code to do the same for the preset name and it works fine

      Content.getComponent("PresetName").set("text", Engine.getCurrentUserPresetName());
      

      but when I use this code for the expansion name using this (ExpName is just the label)

      Content.getComponent("ExpName").set("text", expHandler.getCurrentExpansion());
      

      I get the object name instead as well as a warning in the console saying

      ! You must specify the unique component name, not the object itself
      

      How can I get the expansion text name and then apply that to the label please?

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

        @rzrsharpeprod get current expansion returns an expansion object not a text string. You need to get the properties of this object which contains the name.

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

        R 1 Reply Last reply Reply Quote 1
        • R
          rzrsharpeprod @d.healey
          last edited by

          @d-healey

          The array that contains the expansion names is called expansionNames in my project
          What do I need to put after this part to call the expansionNames current name please?

          Content.getComponent("ExpName").set("text",
          

          I looked through the API and am struggling to see what I need to use.
          I have tried

          Content.getComponent("ExpName").set("text", expansionsNames.push(p.Name));
          

          and

          Content.getComponent("ExpName").set("text", expansionsNames.getProperties().Name);
          

          but am getting errors as it clearly isn't right. I can usually find examples or something to help me figure out the syntax but I am struggling when it comes to expansions as there doesn't seem to be too much out there other than your 2 tutorials and a little in the API.

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

            @rzrsharpeprod

            const currentExpansion = expHandler.getCurrentExpansion(); // Returns an Expansion object - so you can use any functions that are listed under Expansion in the API.
            
            const expansionProperties = currentExpansion.getProperties();
            
            const expansionName = expansionProperties.Name;
            

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

            R 1 Reply Last reply Reply Quote 1
            • R
              rzrsharpeprod @d.healey
              last edited by

              @d-healey said in Label to show current expansion:

              expansionProperties.Name;

              By changing these to const vars and having them above the code to populate the label, I can get it to work but it only works for the initial expansion. It doesn't change when I switch expansions unless I recompile.

              I have done this as you suggested

              const var currentExpansion = expHandler.getCurrentExpansion(); 
              const var expansionProperties = currentExpansion.getProperties();
              const var expansionName = expansionProperties.Name;
              

              and this is in the else clause of my label populate script

              Content.getComponent("ExpName").set("text", expansionProperties.Name);
              

              but it doesn't change without recompiling. What am I missing?

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

                @rzrsharpeprod You don't have to use const, I was just using it for the example. Use the appropriate variable type for the code you're working on. You will want to update the name when the expansion is changed presumably, so put the code in that part of your script.

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

                R 1 Reply Last reply Reply Quote 1
                • R
                  rzrsharpeprod @d.healey
                  last edited by

                  @d-healey Got it working, thankyou.

                  Obviously it has to go in the part of the code where the change happens...for whatever reason that basic concept had escaped me. Thanks again

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

                  53

                  Online

                  1.7k

                  Users

                  11.7k

                  Topics

                  102.2k

                  Posts