the value on the label
-
Hello,
I started developing a project that I have been using for a long time. Record piano samples that I wanted to put in Kontakt, but my choice turned to Hise because I thought it was really well done.
I actually lack knowledge in development, but I manage rather well and I'm made quite far anyway.
There is one thing I block, in fact, I want the label to display the value when the knob changes position. Is it feasible with Hise?
Thanks for answering.
If you find that it's a beginner's question, can you at least point me to a website where I could understand the operation.
P.S. Sorry for my bad English, I really do my best to communicate with you.
At pleasure
-
Hi Alex,
you can change the label text using it's
text
property in the control callback of the knob. You might also want to checkout the TooltipPanel, which automatically shows information when you hover over a control:const var Knob = Content.addKnob("Knob", 16, 26); inline function onKnobControl(component, value) { local v = Engine.doubleToString(value, 2); // 2 digits // set the tooltip of the knob to the value component.set("tooltip", v); // set the text of the label Label.set("text", v); }; Knob.setControlCallback(onKnobControl); const var Label = Content.addLabel("Label", 28, 105); // [JSON Label] Content.setPropertiesFromJSON("Label", { "saveInPreset": false, "editable": false, "multiline": false }); // [/JSON Label] // Adds a tooltip that appears when you hover over the knob const var TooltipPanel = Content.addFloatingTile("TooltipPanel", 10, 134); // [JSON TooltipPanel] Content.setPropertiesFromJSON("TooltipPanel", { "width": 237, "height": 24 }); // [/JSON TooltipPanel] TooltipPanel.setContentData({ "Type": "TooltipPanel"}); ``
-
Hello,
Thank you very much for rewriting me. I am beginning to understand the functioning, in fact, I think I expressed myself badly.
My problem is that as soon as I change the image of the button, the values are lost.
Your code solves the problem anyway, thanks. However, when I try to copy the code (changing the name) it does not work anymore.
I do not need tooltips, I use them for something else.
Thanks
Alex
-
Can you post your code? You've probably made a mistake when replacing the name.
-
yes, of course!
~~Content.makeFrontInterface(150, 150);
const var volKnob = Content.addKnob("volKnob", 16, 26);
inline function onKnobControl(component, value)
{
local v = Engine.doubleToString(value, 2); // 2 digits// set the tooltip of the knob to the value component.set("tooltip", v); // set the text of the label volLabel.set("text", v);
};
volKnob.setControlCallback(onKnobControl);
const var volLabel = Content.addLabel("volLabel", 28, 105);
// [JSON volLabel]
Content.setPropertiesFromJSON("Label", {
"saveInPreset": false,
"editable": false,
"multiline": false
});
// [/JSON volLabel]//!
const var widthKnob = Content.addKnob("widthKnob", 16, 26);
inline function onKnobControl(component, value)
{
local v = Engine.doubleToString(value, 2); // 2 digits// set the tooltip of the knob to the value component.set("tooltip", v); // set the text of the label widthLabel.set("text", v);
};
wdithKnob.setControlCallback(onKnobControl);
const var widthLabel = Content.addLabel("widthLabel", 28, 105);
// [JSON widthLabel]
Content.setPropertiesFromJSON("widthLabel", {
"saveInPreset": false,
"editable": false,
"multiline": false
});
// [/JSON widthLabel]~~Breakingpoint no.1 was hit !
-
Do I write it correctly?
I have misery to enter a script on your forum!
-
This forum uses Markdown syntax so in order to write a code example with Javascript Syntax highlighting, wrap your script code inside a three fence block like this:
```javascript // Code goes here ```
Now back to your actual problem: The only issue I see with your script is that you're using the same coordinates for both knobs so the second one masks the first one:
const var knobName = Content.createKnob("knobName", x-position, y-position);
And you've got a typo here:
wdithKnob.setControlCallback(onKnobControl);
Also your error message suggests that you've accidently created a breakpoint by clicking on the left gutter of the code editor. This will abort the script execution at the given line and store all current variables which is useful for debugging, but in your case, rather annoying :)
Either click on the red circle with the
1
on it or Shift-Click on any line number to remove all breakpoints. -
Hello,
Thank you for your reply. It's great, everything works, and most importantly, I understood. :)
The only trick I can not understand is that as soon as I put my label that displays the value of my button, it destroys my link with the effect.
Ex: I have a volume button that has a link to a "simple gain" effect module ... Everything works great, it is a -12 and 12 because that's what I need .
As soon as I put the label that displays the value, it destroys the link, and "simple gain" no longer works with the GUI. Is this normal?
Here is an example of a script I have to perform...
Content.makeFrontInterface(640,480); const var background = Content.addImage("background", 690, 23); // [JSON background] Content.setPropertiesFromJSON("background", { "width": 65, "height": 67, "fileName": "{PROJECT_FOLDER}Background.png" }); // [/JSON background] const var vol = Content.addKnob("vol", 0, 14); // [JSON vol] Content.setPropertiesFromJSON("vol", { "text": "Volume", "width": 45, "height": 39, "min": -12, "max": 12, "suffix": "db", "filmstripImage": "{PROJECT_FOLDER}m4003.png", "numStrips": "31" }); // [/JSON vol] inline function onvolControl(component, value) { local v = Engine.doubleToString(value, 2); // 2 digits // set the text of the label volLabel.set("text", v); }; vol.setControlCallback(onvolControl); const var volLabel = Content.addLabel("volLabel", 0, 54); // [JSON volLabel] Content.setPropertiesFromJSON("volLabel", { "text": "0.00", "width": 134, "height": 15, "multiline": 0 }); // [/JSON volLabel] //!
-
Hey Alex,
i think thats because your custom onvolControl callback now overrides the onControl callback that was added by the ConnecttoModule command.
You can now add something like thisSimpleGain.setAttribute(SimpleGain.Gain, value);
to your custom Callback. (you can see your legacy code at the onControl TAB / and by the way clean up :))Oh, and dont forget to declare the SimpleGain via
const var SimpleGain = Synth.getEffect("Simple Gain");
in your init script ..Greetings,
d -
Yes, Dominik is right basically, you have three ways of interacting with the controls you define:
- Via a custom callback (your
onVolControl
function). - Via the "catch-all"
onControl
callback (which I consider a bit deprecated because the first one enforces a better encapsulation). As soon as you define a custom callback, theonControl
callback will not be triggered anymore for the respective control. - For simple connections to modules, just set the
processorId
andparameterId
properties of a control and they will just forward the value to the connected module. This works only for simple connections, as soon as you want to control multiple modules, update another UI element (which would be the case in your example), or calculate something, you'll have to resort to 1. or 2.
- Via a custom callback (your
-
Thank you for your help. I do not understand yet but I think I have a good track to continue.
I'll keep you informed!
Alex
-
In fact, it was already written in my code, but it does not work anymore.
const var vol = Content.addKnob("vol", 0, 14); // [JSON vol] Content.setPropertiesFromJSON("vol", { "text": "Volume", "width": 45, "height": 39, "min": -12, "max": 12, "suffix": "db", "filmstripImage": "{PROJECT_FOLDER}m4003.png", "numStrips": "31" }); // [/JSON vol] inline function onvolControl(component, value) { local v = Engine.doubleToString(value, 2); // 2 digits // set the text of the label volLabel.set("text", v); }; vol.setControlCallback(onvolControl); const var SimpleGain = Synth.getEffect("Simple Gain"); const var volLabel = Content.addLabel("volLabel", 0, 54); // [JSON volLabel] Content.setPropertiesFromJSON("volLabel", { "text": "0.00", "width": 134, "height": 15, "multiline": 0 }); // [/JSON volLabel]
And OnControl
function onControl(number, value) { switch(number) { case vol: { SimpleGain.setAttribute(SimpleGain.Gain, value); } }; }; }
-
Yes, this behaviour is expected, as stated before: as soon as you define a custom control callback (which you're doing with the line
vol.setControlCallback(onvolControl);
, you're not triggering theonControl
callback anymore for this particular UI element, which contains the logic that changes the SimpleGain module.The reason for this is performance: you usually only need one of both methods, mixing both only leads to duplicate script execution (and control callbacks can be used within a time-critical context when automated).
This can be solved by copying the line
SimpleGain.setAttribute(SimpleGain.Gain, value)
to the body of theonvolControl
function (and delete everything else from theonControl
callback). -
Its WORK! Big Thanks !