Sampler Gain - Slider bug?
-
I'm either missing something or there's a bug - when I apply a slider to a Sampler gain value, if the slider is set to Decibel, the control doesn't work and sets the Sampler gain value to -100db. I'm just using the component editor. What am I missing? I can't use a simple gain, as the sampler is in a synthesizer group and it looks like that isn't an option.
-
@paper_lung The sampler uses a different range. There is an engine function that can do the conversion for you.
-
@d-healey Thanks. Am I looking for Engine.getGainFactorForDecibels? Do you have any examples of how this works?
-
@paper_lung That's the one. Pass in the decibel value (your slider value) and it will give you a gain factor value, which is what the sampler's gain uses.
If this is a user controllable slider on your interface it's usually better to connect it to a simple gain effect instead of directly to the sampler's gain. This is because the sampler's gain doesn't have any smoothing so if you move the slider quickly while audio is playing you will sometimes hear audio artifacts.
-
@d-healey Cool thanks, that's worked, but as you say - there's audio artefacts. I might have to use script fx instead, in that case, as simple gain doesn't seem to be available in synthesizer grouped instruments
-
@paper_lung In a synth group you could add a CC modulator and connect your slider to its DefaultValue knob. You'll need to write a function to convert the decibel value to a range of 0-127 (ChatGPT can help with this).
-
@paper_lung drop a snippet.