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



  • 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 ☺



  • @LeeC

    Hey, you made it? 🙂 Because I looking for solution 😛



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



  • @d-healey
    Ah true legend man 🙌



  • @arminh Not yet.
    Hopefully David can lead us through this tunnel 🤞



  • This post is deleted!


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



  • @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!



  • 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);
    


  • @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"



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



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



  • 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.


 

5
Online

427
Users

1.5k
Topics

10.7k
Posts