HISE Logo Forum
    • Categories
    • Register
    • Login

    the value on the label

    Scheduled Pinned Locked Moved Scripting
    14 Posts 3 Posters 2.4k 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.
    • Christoph HartC
      Christoph Hart
      last edited by

      Can you post your code? You've probably made a mistake when replacing the name.

      1 Reply Last reply Reply Quote 0
      • alexaudio10A
        alexaudio10
        last edited by

        yes, of course!

        ~~Content.makeFrontInterface(150, 150);

        const var volKnob = Content.addKnob("volKnob", 16, 26);

        inline function onKnobControl(component, value)
        {
        local v = Engine.doubleToString(value, 2); // 2 digits

        // set the tooltip of the knob to the value
        component.set("tooltip", v);
            // set the text of the label
        volLabel.set("text", v);
        

        };

        volKnob.setControlCallback(onKnobControl);

        const var volLabel = Content.addLabel("volLabel", 28, 105);
        // [JSON volLabel]
        Content.setPropertiesFromJSON("Label", {
        "saveInPreset": false,
        "editable": false,
        "multiline": false
        });
        // [/JSON volLabel]

        //!

        const var widthKnob = Content.addKnob("widthKnob", 16, 26);

        inline function onKnobControl(component, value)
        {
        local v = Engine.doubleToString(value, 2); // 2 digits

        // set the tooltip of the knob to the value
        component.set("tooltip", v);
            // set the text of the label
        widthLabel.set("text", v);
        

        };

        wdithKnob.setControlCallback(onKnobControl);

        const var widthLabel = Content.addLabel("widthLabel", 28, 105);
        // [JSON widthLabel]
        Content.setPropertiesFromJSON("widthLabel", {
        "saveInPreset": false,
        "editable": false,
        "multiline": false
        });
        // [/JSON widthLabel]~~

        Breakingpoint no.1 was hit !

        1 Reply Last reply Reply Quote 0
        • alexaudio10A
          alexaudio10
          last edited by

          Do I write it correctly?

          I have misery to enter a script on your forum!

          1 Reply Last reply Reply Quote 0
          • Christoph HartC
            Christoph Hart
            last edited by Christoph Hart

            This forum uses Markdown syntax so in order to write a code example with Javascript Syntax highlighting, wrap your script code inside a three fence block like this:

            ```javascript
            // Code goes here
            ```
            

            Now back to your actual problem: The only issue I see with your script is that you're using the same coordinates for both knobs so the second one masks the first one:

            const var knobName = Content.createKnob("knobName", x-position, y-position);
            

            And you've got a typo here:

            wdithKnob.setControlCallback(onKnobControl);
            

            Also your error message suggests that you've accidently created a breakpoint by clicking on the left gutter of the code editor. This will abort the script execution at the given line and store all current variables which is useful for debugging, but in your case, rather annoying :)

            Either click on the red circle with the 1 on it or Shift-Click on any line number to remove all breakpoints.

            1 Reply Last reply Reply Quote 0
            • alexaudio10A
              alexaudio10
              last edited by

              Hello,

              Thank you for your reply. It's great, everything works, and most importantly, I understood. :)

              The only trick I can not understand is that as soon as I put my label that displays the value of my button, it destroys my link with the effect.

              Ex: I have a volume button that has a link to a "simple gain" effect module ... Everything works great, it is a -12 and 12 because that's what I need .

              As soon as I put the label that displays the value, it destroys the link, and "simple gain" no longer works with the GUI. Is this normal?

              Here is an example of a script I have to perform...

              Content.makeFrontInterface(640,480);
              
              const var background = Content.addImage("background", 690, 23);
              // [JSON background]
              Content.setPropertiesFromJSON("background", {
                "width": 65,
                "height": 67,
                "fileName": "{PROJECT_FOLDER}Background.png"
              });
              // [/JSON background]
              
              const var vol = Content.addKnob("vol", 0, 14);
              
              // [JSON vol]
              Content.setPropertiesFromJSON("vol", {
                "text": "Volume",
                "width": 45,
                "height": 39,
                "min": -12,
                "max": 12,
                "suffix": "db",
                "filmstripImage": "{PROJECT_FOLDER}m4003.png",
                "numStrips": "31"
              });
              // [/JSON vol]
              
              inline function onvolControl(component, value)
              
              
              {
              local v = Engine.doubleToString(value, 2); // 2 digits
              
                  // set the text of the label
              volLabel.set("text", v);
              };
              
              vol.setControlCallback(onvolControl);
              
              const var volLabel = Content.addLabel("volLabel", 0, 54);
              // [JSON volLabel]
              Content.setPropertiesFromJSON("volLabel", {
                "text": "0.00",
                "width": 134,
                "height": 15,
                "multiline": 0
              });
              // [/JSON volLabel]
              
              //!
              
              1 Reply Last reply Reply Quote 0
              • Dominik MayerD
                Dominik Mayer
                last edited by

                Hey Alex,

                i think thats because your custom onvolControl callback now overrides the onControl callback that was added by the ConnecttoModule command.
                You can now add something like this SimpleGain.setAttribute(SimpleGain.Gain, value); to your custom Callback. (you can see your legacy code at the onControl TAB / and by the way clean up :))

                Oh, and dont forget to declare the SimpleGain via const var SimpleGain = Synth.getEffect("Simple Gain"); in your init script ..

                Greetings,
                d

                1 Reply Last reply Reply Quote 0
                • Christoph HartC
                  Christoph Hart
                  last edited by

                  Yes, Dominik is right basically, you have three ways of interacting with the controls you define:

                  1. Via a custom callback (your onVolControl function).
                  2. Via the "catch-all" onControl callback (which I consider a bit deprecated because the first one enforces a better encapsulation). As soon as you define a custom callback, the onControl callback will not be triggered anymore for the respective control.
                  3. For simple connections to modules, just set the processorId and parameterId properties of a control and they will just forward the value to the connected module. This works only for simple connections, as soon as you want to control multiple modules, update another UI element (which would be the case in your example), or calculate something, you'll have to resort to 1. or 2.
                  1 Reply Last reply Reply Quote 0
                  • alexaudio10A
                    alexaudio10
                    last edited by

                    Thank you for your help. I do not understand yet but I think I have a good track to continue.

                    I'll keep you informed!

                    Alex

                    1 Reply Last reply Reply Quote 0
                    • alexaudio10A
                      alexaudio10
                      last edited by

                      In fact, it was already written in my code, but it does not work anymore.

                      const var vol = Content.addKnob("vol", 0, 14);
                      
                      // [JSON vol]
                      Content.setPropertiesFromJSON("vol", {
                        "text": "Volume",
                        "width": 45,
                        "height": 39,
                        "min": -12,
                        "max": 12,
                        "suffix": "db",
                        "filmstripImage": "{PROJECT_FOLDER}m4003.png",
                        "numStrips": "31"
                      });
                      // [/JSON vol]
                      
                      inline function onvolControl(component, value)
                      
                      {
                      local v = Engine.doubleToString(value, 2); // 2 digits
                      
                          // set the text of the label
                      volLabel.set("text", v);
                      };
                      
                      vol.setControlCallback(onvolControl);
                      
                      
                      const var SimpleGain = Synth.getEffect("Simple Gain");
                      
                      const var volLabel = Content.addLabel("volLabel", 0, 54);
                      // [JSON volLabel]
                      Content.setPropertiesFromJSON("volLabel", {
                        "text": "0.00",
                        "width": 134,
                        "height": 15,
                        "multiline": 0
                      });
                      // [/JSON volLabel]
                      

                      And OnControl

                      function onControl(number, value)
                      {
                      	
                      
                      	
                      
                          
                      		switch(number)
                      	{
                      		case vol:
                      		{
                      			SimpleGain.setAttribute(SimpleGain.Gain, value);
                      			
                      		}
                      	};
                      };
                      }
                      
                      
                      1 Reply Last reply Reply Quote 0
                      • Christoph HartC
                        Christoph Hart
                        last edited by Christoph Hart

                        Yes, this behaviour is expected, as stated before: as soon as you define a custom control callback (which you're doing with the line vol.setControlCallback(onvolControl);, you're not triggering the onControl callback anymore for this particular UI element, which contains the logic that changes the SimpleGain module.

                        The reason for this is performance: you usually only need one of both methods, mixing both only leads to duplicate script execution (and control callbacks can be used within a time-critical context when automated).

                        This can be solved by copying the line SimpleGain.setAttribute(SimpleGain.Gain, value) to the body of the onvolControl function (and delete everything else from the onControl callback).

                        1 Reply Last reply Reply Quote 0
                        • alexaudio10A
                          alexaudio10
                          last edited by

                          Its WORK! Big Thanks !

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

                          17

                          Online

                          1.7k

                          Users

                          11.9k

                          Topics

                          103.6k

                          Posts