Button value at start
-
bump...
Anyone? :) -
@alepan all you have to do is put one on default value
-
@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 theon control
callback of every control that hassaveInPreset
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!