Setting an Inteface value from container



  • ..so I want to read an incoming MIDI number - check it against an array and display the name of the articulation in the interface.

    In the script processor of the Master(top most) container I already have a script called "Interface", so I've added another called Script Processor1

    ..and added these lines of code:

    function onNoteOn()
    {
        
    	var found_acoustic_articulation;
    	var acoustic_name_map = [0,12,14,16,17,19,21,23,24,26,28,29,31,33,35,36,38,40,41,43,45,47,48,50,52,53,55,57,59,60,62,64,65,67,69,0,72,74,76,77,79,81,83];
    	found_acoustic_articulation = acoustic_name_map.indexOf(Message.getNoteNumber());
    	Console.print("at pos:" + found_acoustic_articulation);
    	// Content.getComponent("Articulations_ACOUSTIC").setValue(found_acoustic_articulation);
    }
    

    So as we can see from the last line I want the widget in the overall interface (called : articulations_ACOUSTIC) to change its value based on the midi note coming in...

    But... HISE cant find it.

    How do I reference a widget in the overall interface (and change its value) ?

    Or alternatively what do I type in the on init of the main interface to get some action undertaken on note on? I surely cant use the on note call back in the main interface - it never fires.



  • Why don't you put that code in your main interface script?

    Think you edited the post after I posted or I didn't read your post properly 😛

    Yes the on note in the main interface does fire.

    HiseSnippet 652.3ocsUssaSCCF1tsdhVNHlDO.Q6pNowTJrMPZWvX8.pBVWEYLwcSdNtqVywNxwYPEhWSdN3M.9cR1RKjMsfD9p7e3K4ye+GxTilwSRzFDt8IKh4H7iHAKT148mSEJz3AH7SHGQSrbiWtqCWDSSR3gHLt46bNvsagxN+7MGRkTEiW5BgNUKX7OHhD1RuSO38BobDMjehHZor24fwLspuVpSA9zj3ihorKoWvmPco0ffvqMLTX0l.K0xSfbNTGtHXt9Kp77OUjHNWxcF8PAvKJ2Mp+bgLb5020DDB2ZZ4MuY9M+YjiDgha7Wp.OMKfWIhk0.biUoTqUnTuaiRizxP2K3VnGdI50JmdqSBXFQrsLhiaOjLVAEmYTP1WlV44hv+fzWCInraGQujOx.F2.n6d99a4squ+l6OKUwrBsxSqlns7iUc2ry25z1CN.9DsjucrQnrc2XNWJ0ar49c9dm+DzrY4nVMj66azRI2TUTWGf4Nf0UkFcN2rk2UTYJ+57.QYUUes6mpyx0hkRTqFqD1ii4E1k0kdUTWPEhI7zmFOfZotRUgOHuXtwJbzAOfeEz2mW3ZSFvStzpigN++ppB8V5vTI0tZCmaxpH.HGqTYckOUhvtX4IuZzE5WYWXk216IcWmLUXYyqluMpfufp8+luEyzOlLb1LNyVR1VjQe9ec.tFT4i5TqPcwQTqQ7UDlLIMJ.Vqw3.STJtD9PDbCWGUtsuy1oLAbUXlwufSQvdNabQvdWGDEQYF8Yr7AE2ViGj4A3jJagYaXyMX60CkM7jy6HXU1YLlSHdNv7pQ7hZi3k0FwN0Fwt0Fwd0FwqpMhWeGHb+23soVcT9XA3X5vr0FX7PEE5px5.Q+FLEdAMB
    


  • Wow this is SOOO frustrating - now the on note is firing in the main interface,....but I had to reload the entire project to make it do it.



  • @d-healey thanks anyway.



  • In all my projects I defer the callbacks in the interface script and do all real-time stuff in sub scripts. I was working on a project yesterday that used key switching, which is obviously real-time, so I put it in a sub-script. However I wanted the keyswitch to update the GUI.

    My solution was to have a global variable called articulationID and whenever a keyswitch was pressed the sub-script would update this variable with a number that referenced the selected articulation. In the interface script's onNote callback I put a simple check to see if the value of the global variable had changed and if it has I update the GUI appropriately.



  • @d-healey Yes I'm begining to think Globals are the way to go for a lot of things...



  • @Lindon Not necessarily. I generally try to avoid them because it can make scripts trickier to debug and maintain at a later date.

    My keyswitches for example work by enabling/disabling samplers using MIDI muters so instead of using a global variable I could have checked the state of the muters. But for this particular use case I applied a kind of Occam's razor approach and decided a global was right.



  • @d-healey yes I think there are cases (and I have one) where this is the way to go... now I've tried this but I cant seem to get my container to recognise my Global variable, here's what I've done:

    in my Interface on Init I said:

    var triggerNote;

    in my control call back I say:

    inline function onArticulations_TRIGGER_ELECTRICControl(component, value)
    {
    	triggerNote = -99;
    	Console.print("set up:" + triggerNote);
    };
    

    and this prints to the Console nicely...

    in my containers on note call back I say:

    function onNoteOn()
    {
    	Console.print(triggerNote);
    }
    
    

    and I get this error message:

    Script Processor_TRIGGER:! onNoteOn() - Line 3, column 15: API call with undefined parameter 0

    • so triggerNote is undefined for my on note container call back - how do I reference globals then?

    Do I need to referece my Interface script somehow? Im mystifid as usual. How can something as simple as global variables be this hard?



  • D*mn it! I hate people who ask questions without first searching the forum...

    https://forum.hise.audio/topic/15/fr-global-variables-scripting-api/8

    Still, yet another undocumented feature...to add to Christoph's list ☺



  • @Lindon I think it is documented in the blog posts



  • @d-healey yeah because blog-posts = documentation☺


Log in to reply
 

6
Online

502
Users

1.8k
Topics

13.6k
Posts