HISE Logo Forum
    • Categories
    • Register
    • Login

    Linking a preset Name to a Labels text - Any ideas?

    Scheduled Pinned Locked Moved General Questions
    19 Posts 5 Posters 1.2k 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.
    • d.healeyD
      d.healey
      last edited by d.healey

      You're living in HISE v1 world :p

      Rarely should you need the setPropertiesFromJSON() function. Just setup your GUI in the interface designer and right click on widgets in the widgets list to get a variable reference for them that you can paste into your code. None of this Content.addLabel() stuff is required on a main interface script.

      Now to the preset name thingy.

      HISE doesn't load any preset when the plugin is first initialized. So Engine.getCurrentUserPresetName(); isn't going to work in the init callback. It's also important that you set the label's saveInPreset property to false.

      Now to get the name of the current preset when changing presets.

      After the on init callback completes, the control callback of each GUI widget is triggered (assuming the widget isn't assigned to a control through the interface designer's property ID system). Inside a callback for one of your widgets (I use my hidden sample map drop down menu) you need to put some code that will change the label's text.

      Something like this

      if(Engine.getCurrentUserPresetName() == "")
          Content.getComponent("lblPreset").set("text", "My Super Preset");
      else
          Content.getComponent("lblPreset").set("text", Engine.getCurrentUserPresetName());
      

      What this code does is check if there is a preset name from Engine.getCurrentUserPresetName()- this is important because, remember, when the instrument first opens this function will return "" as no preset is loaded by default. So inside here we manually set the label's text to whatever we want the "default" preset to be. In my example I've set it to My Super Preset but you should set it to whatever you want the default preset to be.

      Then the else part will fire whenever a user selects a preset from the preset browser.

      Before you export your project as a plugin to give to the end user you need to load your default preset from the preset browser and resave the project.

      There are loads of forum posts on this subject already.

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

      L 1 Reply Last reply Reply Quote 1
      • L
        LeeC @d.healey
        last edited by LeeC

        Thanks @d-healey.

        Ok so that all makes a lot of sense and the "You're living in HISE v1 world" quote made me chuckle.

        The only thing that I'm not 100% clear on is where to place the example code you've laid out.
        So can I place this inside any callback written in my code like the one below?

        inline function onhideShowControl(number, value)
        {
                panel1.showControl(value); 
        }
        
        hideShow.setControlCallback(onhideShowControl);
        

        If so how would this be placed & structured in order for it to work?

        Sorry for all the newbie questions.

        Appreciate all the patience and feedback man ☺

        A 1 Reply Last reply Reply Quote 0
        • A
          arminh @LeeC
          last edited by

          @LeeC

          Hey, you made it? :) Because I looking for solution :P

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

            I'm uploading a video tutorial for this now....

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

            L 1 Reply Last reply Reply Quote 0
            • L
              LeeC @d.healey
              last edited by

              @d-healey
              Ah true legend man 🙌

              1 Reply Last reply Reply Quote 0
              • L
                LeeC @arminh
                last edited by

                @arminh Not yet.
                Hopefully David can lead us through this tunnel :crossed_fingers:

                1 Reply Last reply Reply Quote 0
                • A
                  arminh
                  last edited by

                  This post is deleted!
                  1 Reply Last reply Reply Quote 0
                  • d.healeyD
                    d.healey
                    last edited by

                    You'll have to wait 10 minutes or so for the high q version to finish processing.

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

                    L 1 Reply Last reply Reply Quote 5
                    • L
                      LeeC @d.healey
                      last edited by LeeC

                      @d-healey
                      Wow that video was crystal clear.

                      Learnt a lot about how callbacks work in HISE and the 'Save in Preset' or not to 'Save in Preset' stuff was golden - definitely wouldn't have discovered this myself.

                      All working now so thanks.

                      Your tutorials are second to none ☺
                      Truly appreciate the insight man!

                      1 Reply Last reply Reply Quote 1
                      • A
                        arminh
                        last edited by

                        Thank you! You're master!

                        Btw, im trying to push sampleMapList to label but now I have all samplemaps

                        const var sampleList = Sampler.getSampleMapList();
                        const var sampleArrayString = sampleList.join("\n")
                        Console.print(sampleArrayString);
                        const var Label1 = Content.getComponent("Label1");
                        Label1.set("text", sampleArrayString);
                        
                        d.healeyD 1 Reply Last reply Reply Quote 0
                        • d.healeyD
                          d.healey @arminh
                          last edited by

                          @arminh .join() takes all the elements in an array and connects them in a string.

                          For example [1, 2, 3, 4, 5].join("/n"); would become "1/n2/n3/n4/n5/n"

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

                          A 1 Reply Last reply Reply Quote 0
                          • A
                            arminh @d.healey
                            last edited by

                            @d-healey so there is some method to pick current sample map name?

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

                              @arminh The sample maps are in an array. So just use the index of the sample map you want. sampleMapList[index];

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

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

                                so there is some method to pick current sample map name?

                                Yes, there is Sampler.getCurrentSampleMapId()

                                Great video, Dave - there is also another advantage of loading the user preset you show before saving and that is that it keeps the Git commit history as clean as possible (otherwise it would be scattered with meaningless value changes).

                                The only thing I'd like to add to this is that it's a weird design decision to make a knob responsible for displaying the user preset name - for the sake of demonstration in this video it's certainly sufficient, but if people try to replicate this in their real projects it gets a bit messy.

                                The cleanest solution is using a timer and query the name periodically:

                                const var presetUpdater = Engine.createTimerObject();
                                
                                presetUpdater.setTimerCallback(function()
                                {
                                    var text = Label1.get("text");
                                    var preset = Engine.getCurrentUserPresetName();
                                    
                                    if(preset == "")
                                        preset = "Gerald");
                                        
                                    // Check if it has changed before updating the text
                                    // in order to save a bit CPU.
                                    if(text != preset)
                                        Label1.set("text", preset);
                                });
                                
                                // Check this 5 times per second.
                                presetUpdater.startTimer(200);
                                

                                Normally, polling is not the smartest way of communication - the cleanest solution would be a callback onUserPresetChange() that you can use, but for this simple use case it is fine.

                                1 Reply Last reply Reply Quote 3
                                • lalalandsynthL
                                  lalalandsynth
                                  last edited by lalalandsynth

                                  @d-healey Going through this tutorial and I keep getting warning at the else line.
                                  "Found 'else' when expecting a statement"

                                  const var presetLabel = Content.getComponent("presetLabel");
                                  
                                  
                                  inline function onsliderInputControl(component, value)
                                  { 
                                        
                                      if (Engine.getCurrentUserPresetName() == "");
                                            Content.getComponent("presetLabel").set("text", "Preset 1");
                                        else
                                            Content.getComponent("presetLabel").set("text", Engine.getCurrentUserPresetName());
                                        
                                  };
                                      
                                  Content.getComponent("sliderInput"),setControlCallback(onsliderInputControl);
                                  

                                  https://lalalandaudio.com/

                                  https://lalalandsynth.com/

                                  https://www.facebook.com/lalalandsynth

                                  https://www.facebook.com/lalalandsynth

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

                                    The semicolon at the end of the if line will terminate the branch.

                                    This is the pitfall of omitting braces for branches, but it reduces the clutter.

                                    1 Reply Last reply Reply Quote 1
                                    • lalalandsynthL
                                      lalalandsynth
                                      last edited by lalalandsynth

                                      @Christoph-Hart Thanks !

                                      But you would suggest using the timer right or has anything changed in Hise since that post ?

                                      As for using that knob , is that then supposed to be hidden , not sure what its purpose is .

                                      https://lalalandaudio.com/

                                      https://lalalandsynth.com/

                                      https://www.facebook.com/lalalandsynth

                                      https://www.facebook.com/lalalandsynth

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

                                      24

                                      Online

                                      1.7k

                                      Users

                                      11.8k

                                      Topics

                                      102.7k

                                      Posts