Setting a value of a volume knob...
-
HI all,
first post here, i must admit that i started some days ago with Hise and so i'm a pure beginner, i made some Kontakt Instrument/scripts but stopped 2, 3 years ago and i forgot a lot about scripting in Kontakt! :)
I have a Sample Player and a bypass button to switch the layer OFF and a volume knob.Both works fine, i can switch the sample player with the knob on/off and i can change the volume of the player.
But, i want, that the old level of the volume knob when i switch the bypass button on.
It works when i set the volume by hand, for example:
const var a = -100 //level down
const var b = 0 //old levelWhen i switch the button on/off, the volume has the levels from a or b. But when i try to read the actual volume from the slider, it isn't working.
Any ideas?
When i look in the array of the knob, i can see the right volume but why it isn't working when i send it to the sample player?
Engine.getGainFactorForDecibels(b));
When i use const var b = VolumeSlider it isn't working.
Hm...
-
This post is deleted! -
Avoid setting the volume of the sampler directly as this can cause audio artifacts if it is done while audio is playing back, also you have to mess around with the gain factor conversion thing.
Instead add a Simple Gain effect to your sampler and control its Gain parameter. This is a smoothed value so it avoids the artifact issue I mentioned, and the value is set in decibels so no conversion needed.
-
Thank you, David, of course i added a "Simple gain" because i read somewhere else, that it's getting problems when i bypass the sampler... But thank you for the reminder, David.
-
Ok. Thank you guys for your help, it's working fine...
But, i have another little question, when i store a value in a array, how can i update the value in the array...
Sometimes i have to change the value so i need to update it, when i use
arr.clear();
i got an error...
Sorry for my newbie questions...
Frank
-
const myArr = [1, 2, 3]; // This creates a new array myArr[0] = 10; // This sets the first element of the array to 10 Console.print(trace(myArr)); // [10, 2, 3]
-
@Xenox-AFL
If you want to set the value of a button/slider/component in an array you have to do something like this:array[0].setValue();