Button value at start



  • Hi all, I am stuck with a very simple problem...
    I'm making an instrument in which two buttons load different "setups" of the instrument, one is a playable cello, the other one is a phrase-based instrument. Each "setup" has a combobox which selects different sounds and some keyswitches changing either the articulation or the rootkey of the phrases.
    What I would like to do is having the instrument set with button "Instrument" already selected and passing its "on" value when I load the instrument, so that it can be played immediately. At the moment I have to push the button to activate it, even if I have set its default value to 1 via script.
    What am I doing wrong?
    Here's the snippet:

    HiseSnippet 4750.3oc6c07aajjcuojaaQJKaMJFIKVryhNJSBnmQiVRpu2Y2n1RhzVYjrnEk83ENFba0rHYupY28zcSYowv.dSxjYVDDjiAyM+mPts6dH.B4uf.jKatMIAHHA4xbImSdUU8GU+EYSpOr8LR.jlcU0qpeuOpW8pW0c6pl5xHKKcStLY26XCDWlqyW6XM61q2VRQiayM3xLAeMYkJJBqiTU04V6XCIKKTCtLYF8t3ljI6U3H+8MqtljpjlLxuHNtGoqHi1RoihseoUE+XEU0JRMP6ozgo0yKtort155p5cA3LJeANCI4CjZgtuDtYivyk4pkanXqaVyVxFYwk4Jqo233Zs0elFs8ORwRYeUD9hhb0fNhVbEc0FXDiKka81JpMp5x1VbbYtVUegvnTgvs32VoghW49BiIIUH3SAq7HyH8BdEYgWgzCuLLv6JT38NfJwTwv1uFL1FmeSMajYSIPEvBKZa4F4gSvutNzBM6Y6Hc.phIbgGE4WYtByHr3xEt8GMQtIx8i9Q0j5XnhLslQvh7qNRFVBRZMD5n2nqJxRXWTSjIBz2VSjCzaV1BGJYJrI7CytcfAQ3mJPrjlsEx1oyxOse0SiGHe5p11TxB503HxotPTfUDa2EfeQVhBn2xOseiRh5Rog5RgnlJR1VxXKEKa736yW9H2o57tRz6ppuujJU9IAlIBltRvv.CqlL0UUCyatTRQl.Syl1cPVWuy956qejemGQ8Ty9XUDzutFCPOCTYnqAWP0PjVP5Ruql0BAUpXi5XM8Lg3+Y+E5JZ4m9OWa5a6BixOHA.rk9ypef19IN7N0GUa0SpbpODU2SomDQqNDM.vYj3ka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nYggflEGBZVZHnY4dRCNTj6z0VuC0QLTP0xTi2LLOENb++KEzf2C
    


  • bump...
    Anyone? 🙂



  • @alepan all you have to do is put one on default value

    Screen Shot 2020-02-13 at 9.24.45 AM.png



  • @Jay Hi Jay, I tried that, but unfortunately it doesn't work... every time I hit compile, I have to push the "cello" button to have HISE produce sound...



  • @alepan Did you load the instrument before hand?



  • Console.print() is your friend.

    inline function onPhrasesButton(component, value)
    {
        Console.print("phrases");
        
        MidiMuter1.setAttribute(MidiMuter1.ignoreButton, 1);
        MidiMuter2.setAttribute(MidiMuter2.ignoreButton, 0);
        if (value)
        {
            for (i = 0; i < ks_phrase.length; i++)
            {
                Engine.setKeyColour(ks_phrase[i], Colours.withAlpha(Colours.red, 0.5));
            }
        }
        
        else
        {
        for (i = 0; i < ks_phrase.length; i++)
            {
                Engine.setKeyColour(ks_phrase[i], Colours.withAlpha(Colours.white, 0.0));
            }
        }
    }
    
    
    inline function onInstrumentButton(component, value)
    {
        
        Console.print("instrument");
        
        MidiMuter1.setAttribute(MidiMuter1.ignoreButton, 0);
        MidiMuter2.setAttribute(MidiMuter2.ignoreButton, 1);
        if (value)
        {
            for (i = 0; i < ks_inst.length; i++)
            {
                Engine.setKeyColour(ks_inst[i], Colours.withAlpha(Colours.red, 0.5));
            }
        }
    }
    


  • @d-healey said in Button value at start:

    Console.print("instrument");

    Sorry Dave, still not very clear to me (I'm a real noob...)
    I inserted the two Console.print commands and it prints the two words in the console as soon as I hit compile, which makes me think that both buttons are active so the software doesn't know that one button has to be in "pressed" state and the other has to be off...
    How can I check the value of the buttons? I tried Console.print(Phrases.btn) but it gives me an error. I think it wants a string but I need to check the value of the button.
    In case they both start active, how can I pass value = 1 to one button and value = 0 to the other button at start? (if this is the correct way to go)?



  • @Jay Well, I thought that loading the project would load everything... what do you mean by loading the instrument? The samplemaps?



  • When you run your instrument (or hit compile) the script will run the on init callback. After that callback completes it will run the on control callback of every control that has saveInPreset set to true - this will restore the value of those controls and overwrite any value changes you made in on init.

    As you can see by using Console.print() the instrument button's callback fires before the phrase button's callback. This means this code will always run after the instrument button's code on first load.

        MidiMuter1.setAttribute(MidiMuter1.ignoreButton, 1);
        MidiMuter2.setAttribute(MidiMuter2.ignoreButton, 0);
    

    So you need to swap the order of the buttons in the component list to get the instrument button to run after the phrase button.



  • @d-healey Aaaahhhh... it really was a simple problem... Sorry to bother you, but I can't understand how to use the Console.print command to retrieve the value of these buttons...

    Console.print(Phrases); -> gives me an error
    Console.print("Phrases"); -> prints Phrases
    Console.print(Phrases_btn); -> gives me 0x17149e20 (an index?)



  • @alepan Console.print(variableName.getValue());



  • @d-healey Thanks a lot!


Log in to reply
 

10
Online

601
Users

2.4k
Topics

18.4k
Posts