HISE Logo Forum
    • Categories
    • Register
    • Login

    About labels -> get value

    Scheduled Pinned Locked Moved Scripting
    labelgetvalue
    5 Posts 4 Posters 1.6k 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.
    • Dark BoubouD
      Dark Boubou
      last edited by Dark Boubou

      Hey :) I did a long break :D
      Well I have an interrogation.
      I have a knob (Midi channel selecter), and next to, a label displaying the value selected by that knob.
      But... the problem is that I don't know how about linking the value as the text.
      I did this but of course it doesn't work:

      // [JSON MIDIDisplay]
      Content.setPropertiesFromJSON("MIDIDisplay", {
        "text": ScriptLabel.getValue(MidiChan)   override
        "width": 99,
        "height": 34,
        "fontName": "Digital-7 Mono",
        "fontSize": 21,
        "multiline": false
      });
      // [/JSON MIDIDisplay]
      

      Well I don't understand that 'override' and even without it it doesnt' work :)

      Perhaps should I do an OnControl function?
      Thanks,
      D.B.

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

        That override is a glitch from the automatic API creation (I have to remove this). However, getValue() has no arguments.

        But most importantly, the value for ScriptLabel - if that's your knob then kudos to your variable naming :) - can't be accessed during the onInit callback. For all UI controls that don't have the saveInPreset property set to false, the values will be handled in this order at compiling / recompiling:

        1. Save the value (if recompiling)
        2. Compile the script (run the onInit callback and parse all other callback). Because the old controls are deleted and replaced with new ones, the new controls don't have access to the previous values during this stage.
        3. Restore the values from step 1 or the ones saved in the preset (if not recompiling). Also the onControl callback will be executed for each control, which is the place to handle the value (you need to implement this here anyway for value changes caused by automation or human interaction).

        TLDR: Use the onControl callback as you've guessed and call MidiDisplay.set("text", ScriptLabel.getValue());. Also set saveInPreset for the Label to false (since it does not contain a real value but just displays the value from another control).

        1 Reply Last reply Reply Quote 1
        • Dominik MayerD
          Dominik Mayer
          last edited by Dominik Mayer

          Content.makeFrontInterface(300, 200);
          
          const var MIDIDisplay = Content.addKnob("MIDIDisplay", 0, 0);
          // [JSON Knob]
          Content.setPropertiesFromJSON("MIDIDisplay", {
            "text": "MidiChannel",
            "min": 1,
            "max": 16,
            "mode": "Discrete",
            "stepSize": 1,
            "middlePosition": 8
          });
          // [/JSON Knob]
          
          inline function onMIDIDisplayControl(component, value)
          {
          	Label.set("text", MIDIDisplay.getValue());
          };
          MIDIDisplay.setControlCallback(onMIDIDisplayControl);
          
          
          const var Label = Content.addLabel("Label", 30, 50);
          // [JSON Label]
          Content.setPropertiesFromJSON("Label", {
            "editable": false,
            "saveInPreset": false
          });
          // [/JSON Label]
          
          1 Reply Last reply Reply Quote 1
          • Dark BoubouD
            Dark Boubou
            last edited by

            Nice!
            And one more question:
            If I use a personnal font stored in my computer, will it saves the font while exporting?
            Should I put the font file somewhere in the Project Folder?

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

              The font goes in the images folder. You need to use the loadFont command in your front interface script to include it with the instrument. Make sure you own the license to use the font or that it is royalty free or similar :)

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

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

              22

              Online

              1.7k

              Users

              11.8k

              Topics

              102.4k

              Posts