HISE Logo Forum
    • Categories
    • Register
    • Login

    Change the slider name and value placement

    Scheduled Pinned Locked Moved Newbie League
    41 Posts 6 Posters 3.7k 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.
    • M
      Mickolos
      last edited by

      Thanks everyone for your input but none of those new suggestions are working for me. Obviously because I'm doing it wrong.

      There was a lot of different recommendations and any combination of them seems to break the code from affecting the knobs. As a noob, I'm not sure where and what to place everything...

      Heres what I got which compiles okay but does nothing to the knob

      .------- PS: I don't know how to make all the code appear in the black box so it overflows at the top and bottom on this page------


      Content.makeFrontInterface(1000, 1000);

      const comps = Content.getAllComponents("^.(Knob|Button).$");

      const ValueLAF = Content.createLocalLookAndFeel();

      ValueLAF.registerFunction("drawRotarySlider", function(g, obj)
      {
      g.setColour(Colours.white);
      g.setFont("Arial", 20);

      var area = obj.area;
      g.drawAlignedText(obj.valueAsText(obj.value, 0), [0, 0, area[2], area[3] - VALUE_Y_POS], "centred");
      
      
      
      var a = obj.area;
      	
      	// Knob Background Colour
      	g.setColour (obj.bgColour);
      	g.fillEllipse(a);
      	
      	// Knob Inner Colour (Item 1)
      	g.setColour(obj.itemColour1);
      	g.fillEllipse ([5, 5, a[2] - 10, a[3] -10]);
      	
      	//Knob Marker Position
      	var start = 2.5;
      	var end = start * 2 * obj.valueNormalized - start;
      	g.rotate (end, [a[2] / 2, a[3] / 2]);
      	
      	// Knob Marker Colour
      	g.setColour(obj.itemColour2);
      	g.fillRoundedRectangle([a[2] / 2 - 5 / 2, 3, 5, 11], 2.5);
      

      });

      for (i = 0; i < knobs.length; i++)
      {
      knobs[i].setLocalLookAndFeel(knb_LAF);
      }

      Oli UllmannO rglidesR dannytaurusD 4 Replies Last reply Reply Quote 0
      • Oli UllmannO
        Oli Ullmann @Mickolos
        last edited by

        @Mickolos

        I don't know what exactly you are trying to achieve but this code is now working:

        HiseSnippet 1247.3ocsV0sa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HyDD5qrXypG7o0rxK8RdNAkhNBl5UinY6aK495lP502r0FJqKgtIWFBAQUlVbOLqEWZC.DCLxWXqKAbQFvme5C50c1mnHSMCXQvKinwJlNXr1mdILcJsyYA68oICUxQFYy5jAd6dc50yb3ue9NSl68eXmD0Dcp4AFAQQLeeNc58jbiM+KnE2ndP8ul16e7e9h+9c+wyixOYEghHWmePax3f.10lQhPcbThBvVmHXRIx56reMb80mFPFyU3jgfc3LwPn4kzH+ULe0f415zcFPYgCT4oft4bEXhlzeLmnVbLm9A.YLzwT9YK54GBHVmjG2eFy9pdmy99Tg3ir6xTdCtcLtxsfQnT4+CLl8hguw9ff.nayb.tlc62rrOO3dbOzcSwDgGQfpCnVw93wQ8f9edTv6vDBNXbaqUzW1R2WUuWmA5AsbMa9W3SFSW8dqLltSYB0kdwx25kdEU+ljuzPAvjv7lsBviGg83a4tIbef8VOuEM0MTr1xpX8kUwMWVEarrJ9SKqhasrJ179UT+B1ViUxnzqMHzQcOvzK0x5.AAp.MUqn+CnJNxYI
        
        1 Reply Last reply Reply Quote 0
        • rglidesR
          rglides @Mickolos
          last edited by

          @Mickolos You could export a snippet, it would be a lot easier - In HISE go to Export, Export as HISE Snippet and then in here click the </> in the menu above where you write a message, then replace the ... with the copied hise snippet. You can paste any code with the same method, but a snippet would make it easy to take a look

          1 Reply Last reply Reply Quote 0
          • dannytaurusD
            dannytaurus @Mickolos
            last edited by

            @Mickolos You're missing the * in your regex.

            Instead of
            const comps = Content.getAllComponents("^.(Knob|Button).$");
            use
            const comps = Content.getAllComponents("^.*(Knob|Button).*$");

            The dot is looking for exactly one character. The * modifies that to look for any number of characters, including zero.

            The way you had it will only match components that have exactly one character before the word and one character after the word, like 1Knob1 or ZButtonZ.

            If in doubt, use a regex tester like regex101.com. Put the regex in the top text field then add some example component names including wrong ones, to see which ones the regex matches.

            The next image shows that the only ones matched by your original regex are the last two.

            CleanShot 2025-06-10 at 10.01.11@2x.png

            The next image shows that with the extra * in the regex, ALL the names are matched.

            CleanShot 2025-06-10 at 10.02.52@2x.png

            Meat Beats: https://meatbeats.com
            Klippr Video: https://klippr.video

            M 1 Reply Last reply Reply Quote 1
            • dannytaurusD
              dannytaurus @Mickolos
              last edited by dannytaurus

              @Mickolos Other than the incorrect regex, your code seems have a couple of other problems:

              1. You put all knobs into 'comps' but then later loop through 'knobs', which is not defined in your code.
              2. You create a look and feel called 'ValueLAF', then later assign one called 'knb_LAF', which is not defined in your code.

              I realise these might be copy/paste inconsistencies and your code is actually correct. But just wanted to point it out.

              Meat Beats: https://meatbeats.com
              Klippr Video: https://klippr.video

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

                The problem is you are trying to use code without understanding it, what you end up with is Frankencode which is little bits and pieces copy and pasted together.

                Start by not touching copy/paste. Instead write out your code from scratch, and only write things that you understand, if you don't understand something, look it up, or ask here for an explanation.

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

                M 1 Reply Last reply Reply Quote 1
                • M
                  Mickolos @dannytaurus
                  last edited by

                  @dannytaurus Thank you.

                  1 Reply Last reply Reply Quote 0
                  • M
                    Mickolos @d.healey
                    last edited by

                    @d-healey Yup that's basically what I said. And what I'm doing.

                    The problem with your suggestion is whether I type or copy I still do not understand it right now. Hence why I'm asking for advice here. I have manage to solve problems already but the only thing that is helping me with this seeing the code recommendations here from everyone, which then allows me understand what went wrong or what new functions are possible.

                    Remember I am not a developer but I want to learn, I am digesting your videos, forum posts and dev glossary, but I do not know what the possible functions are, what functions are outdated (the that global style I started with from your video), etc. Some information to what I'm trying to do is just not out there at least in a way I can search or find or understand it.

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

                      @Mickolos said in Change the slider name and value placement:

                      I still do not understand it right now.

                      Lets go through the code you don't understand a bit at a time, rather than dumping a big example on you and letting you try to wade through it.

                      Which part of your original code you posted (the stuff from my video) do you feel most confident with?

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

                      M 1 Reply Last reply Reply Quote 0
                      • M
                        Mickolos @d.healey
                        last edited by

                        Thanks @d-healey I really feel like I'm wasting everyone's time at this point so don't feel obligated, and no rush. But I still very much appreciate the offer.

                        Here's rglides suggestion which worked. In green is what I loosely understand, I red is what I don't.Screenshot 2025-06-10 at 12.20.50 PM.png

                        Here's the updated version with rglides suggestions for allowing knob values to have decimals and to style all knobs globally. None of these updates I really understand fully.
                        Screenshot 2025-06-10 at 12.39.38 PM.png

                        Here's dannytarus recommendation to target all knobs:
                        Screenshot 2025-06-10 at 12.20.59 PM.png

                        ...
                        In summary

                        1. I want to target all knobs so I don't have to duplicate code.
                        2. I want to show knob value with decimals. (This is not an issue of the slider properties, as I've matched it with other knobs that show the full character amount).

                        I know there is a combined negative effect of code I added to the original which I did not account for but can't figure out what it is.

                        PS: I don't know what a snippet is and how to use it.

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

                          @Mickolos said in Change the slider name and value placement:

                          I really feel like I'm wasting everyone's time at this point

                          Not at all, this is the purpose of the forum :)

                          @Mickolos said in Change the slider name and value placement:

                          I don't know what a snippet is and how to use it.

                          A snippet is a snapshot of your HISE project - it's presented as a piece of text - that anyone can copy and open in HISE. You can create one from the Export menu in HISE and you can import one from the File menu.

                          ValueLaf is the name of a variable - a variable is a place where we can store a value, and we give it a name so we can identify it and use it in other parts of the script. It's a good idea to give them a meaningful name. The const part indicates it's a constant variable, that means the value cannot be changed later.

                          // Some other examples of variables
                          const name = "David";
                          const age = 38;
                          
                          Console.print(name); // This will print the value stored in the "name" variable
                          Console.print(age); // This will print the value stored in the "age" variable
                          

                          In this case ValueLaf is storing a look and feel object - and object is a collection of data and functions.

                          ValueLaf.registerFunction assigns a specific look and feel function to the local laf object stored in ValueLaf

                          function(g, obj) this is creating the look and feel function - a function is block of code that does a task, in this case it will draw the knob. The laf function has two bits of data we can use which are g and obj. Both of these are objects provided automatically by HISE.

                          g is a graphics object and gives us access to all of the functions in the Graphics section of HISE script - type Graphics into the API browser in HISE to see all the functions available.

                          obj contains properties that are specific to the component you are drawing - different components have different properties available. To view the contents of obj you can write Console.print(trace(obj)); within the laf function. This will output the contents of obj to the Console. You can remove this once you are finished with it.

                          To access a property in obj, you write obj. followed by the name of the property. For example to access the knob's text, you can write obj.text.

                          Knob1.setLocalLookAndFeel(ValueLaf) assigns the look and feel object stored in ValueLaf to the knob - basically it tells the knob to use the laf you've created.

                          const var knobs = Content.getAllComponents("Knob"); - This is getting more advanced. Master one knob first, get it to look the way you want. Then come back and we'll talk about applying it to multiple components.

                          I recommend you read everything in this section of the docs.

                          And especially this.

                          My scripting101 video might also be helpful to you.

                          Then go and write your laf function (from scratch, no copy/paste) and apply it to one knob - make a new project for this that you can just play around in.

                          Once you've done it, or you've got stuck, post a snippet of where you are up to. When you post the snippet use code tags so that it's formatted nicely on the forum.

                          f0d0fafc-84ac-4812-bd49-3de65ac2e50c-image.png This button on the toolbar will add code tags for you.

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

                          M 1 Reply Last reply Reply Quote 4
                          • M
                            Mickolos @d.healey
                            last edited by

                            @d-healey This is gold mate. I'll get cracking on it on hopefully have something good to show ya, thanks :-)

                            1 Reply Last reply Reply Quote 1
                            • M
                              Mickolos
                              last edited by

                              Thanks guys, finally got my head around it 😀

                              @rglides and @Oli-Ullmann
                              Sorry I didn't know how to use snippets before but after loading them they thought me everything I needed to know to figure out what I was doing wrong and comparing them with each other was a huge leap forward in my understanding of what does what.

                              @dannytaurus Thank you for your detailed input. This helped clarify some things and understand the other guys suggestions better. I'll defo check out regex101 too, thanks for the suggestion.

                              @d-healey Thanks for all your advice and patience, it really helped improve my understanding.

                              Thanks again everyone! 🤘

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

                              12

                              Online

                              1.8k

                              Users

                              11.9k

                              Topics

                              103.9k

                              Posts