HISE Logo Forum
    • Categories
    • Register
    • Login

    Button value at start

    Scheduled Pinned Locked Moved General Questions
    12 Posts 3 Posters 486 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.
    • JayJ
      Jay @alepan
      last edited by

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

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

      Joansi Villalona

      A 1 Reply Last reply Reply Quote 0
      • A
        alepan @Jay
        last edited by

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

        JayJ 1 Reply Last reply Reply Quote 0
        • JayJ
          Jay @alepan
          last edited by

          @alepan Did you load the instrument before hand?

          Joansi Villalona

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

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

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

            A 1 Reply Last reply Reply Quote 2
            • A
              alepan @d.healey
              last edited by

              @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)?

              1 Reply Last reply Reply Quote 0
              • A
                alepan @Jay
                last edited by

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

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

                  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.

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

                  A 1 Reply Last reply Reply Quote 2
                  • A
                    alepan @d.healey
                    last edited by

                    @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?)

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

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

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

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

                        @d-healey Thanks a lot!

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

                        23

                        Online

                        1.8k

                        Users

                        12.0k

                        Topics

                        104.7k

                        Posts