Hi, I wanted to know if there is a simple way to have the fader spring back to its default value over the course of half a second or so without using a canvas widget.
Cheers
Hi, I wanted to know if there is a simple way to have the fader spring back to its default value over the course of half a second or so without using a canvas widget.
Cheers
As far as I know, there is no option to control the spring speed in a built-in slider widget.
Any ideas for how to achieve this with scripting?
Ok, got it to work.
Put this in the fader's onTouch
prop:
if (event.type == "stop") {
const range = getProp(this, "range")
const min = range.min
const max = range.max
const interval = 1000 / (max - min)
const speed = 3
setInterval(() => {
set(this, get(this) - speed, {script: false})
if (get(this) <= min) clearInterval()
}, interval)
}
interval
is the time that makes going from max to min last one second, if speed
is 1.
Play with speed
(this is actually how many steps will be subtracted from the current value each time the setInterval runs). Higher values mean faster movement.
Awesome, I'm trying to use this with a pitch bend slider. Currently this springs to 0, but I'd like to be able to set it to the center value, in this case 8192. This seems more complex as it needs to go in both directions.
Ok, there you go:
if (event.type == "stop") {
const range = getProp(this, "range")
const min = range.min
const max = range.max
const interval = Math.floor(1000 / (max - min))
const speed = 100
const origin = getProp(this, "origin")
setInterval(() => {
if (get(this) > origin) {
set(this, get(this) - speed, {script: false})
if (get(this) <= origin) clearInterval()
} else {
set(this, get(this) + speed, {script: false})
if (get(this) >= origin) clearInterval()
}
}, interval)
}
Hmm perhaps I have something set wrong, but it seems the fader has strange behavior now. It now springs to max value but if the position is above the center, the fader jumps down before moving to the max value.
How did you set the fader's range(max, min) and origin props?
You're missing the origin one. Set it to 8192.
Awesome, thank you. I also realized I had to turn "spring" off for this to work.
Very cool. I have a question, what does the parameter "origin" do? I noticed if I changed the const origin line to this, it seems to work the same. What was the reasoning to use origin over default?
const origin = getProp(this, "default")
I just saw this Glad you figure it.
The fader needs this to know where is the origin to draw the gauge. So, it's better having the origin defined, instead of the default. The default value matters when loading the session and when using double tap (if it's enabled). But in this case, you can leave it empty and only set origin
to 8192.
Great, thank you so much!
One more issue, how come I'm getting this error when I move the fader?
Oh, missing preArgs in the OSC section. Set it to 1, meaning the pitchend will be sent over channel 1.
Yes! I had it there before must have removed. Thank you again for all the help on this one!