Start pattern with a slider in a specific position

Hello !

I’m using a slider in a pattern that returns a log variable between 0 and 10.

export function sliderManualEnergy(n){
  manualEnergy = exp(logmin + (logmax-logmin)*n);

Is it possible to have the slider and its associated value start at a very specific position (manualEnergy=1 for example) whenever i start the pattern ?
At the moment the slider is always at the maximum (n=1) when i start the pattern.

Thank you !

Hey! So, a funny thing is that the initial UI position for a slider is full-right, IE a value of 1.0.

However, if you set a variable in the slider handler, it’s never set until the slider-change handler is called at least once (you move the slider). After that point, the pattern saves a copy of the last known slider value, and it will be re-initialized whenever the pattern is launched, say from the pattern list or by re-editing it. You can observe this with the vars watcher:

Monosnap Desk 2 2023-09-16 15-41-48

So try setting your sliders once after you create them, and see if that helps.

@wizard - do you think this could be enhanced to call the handler with a value of 1 on initial load if there’s no saved value for a UI Slider control? I notice it often when downloading patterns from the library. One option would be to start including UI Control values in .epes, but a potentially quicker improvement would be to just call the handler once on load with something other than a null value. If the UI shows 1.0, it makes sense to me to call it with a 1.0. I know you might have other things in the backlog for 2-way binding.

1 Like

Ah yes, i didn’t notice it kept the last value. That’s good enough for me, and actually better to “save” the best preset. Thank you !

1 Like