-
Notifications
You must be signed in to change notification settings - Fork 167
cancelScheduledValues with setValueCurveAtTime #2071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Wouldn't it be possible to use |
Yes, The alternative that would work is to use the same time for |
Author of the StackOverflow question here. From the cancelScheduledValues() spec:
My interpretation of the bolded part is that
const start = ctx.currentTime
gain.gain.setValueCurveAtTime(curve1, start, 1)
setTimeout(() => {
const cancelTime = ctx.currentTime // both `0` and `start` are clamped to ctx.currentTime according to the spec
gain.gain.cancelScheduledValues(cancelTime)
gain.gain.setValueCurveAtTime(curve2, ctx.currentTime, 1)
}, 100) Current browser behaviour for the above codeFirefox v68Throws Operation is not supported when Chrome v77Any value less than Edge v42All values |
Oh, you are right about the bold part of the spec. I missed that on my initial read. I think that means However, I'm not sure what should happen if the |
Teleconf: @rtoy to come up with a proposal on how this works. Probably will remove the setCurve if the cancel time lies between the start and duration of the setCurve. Not a problem for setTarget where you can always schedule something after a setTarget. |
I think we need to consider what it means to be an "active automation". My interpretation is that at the time
At time 0.3, we call But if we changed the example to
the output is a constant 1 up to time 0.5 and then becomes a constant 0. For If |
The behavior in the first snippet from #2071 (comment) isn't specified any where that I can find. I don't want to specify that now, so I'm not going to add anything about that for But I will make it explicit that if the cancel time is in the middle of the curve, the entire curve event is removed. |
If the cancelTime overlaps the setValueCurveAtTime event, remove the event too.
Describe the issue
Consider the following bit of code:
The second call to
setValueCurveAtTime
will throw an error because it overlaps the first. BasicallycancelScheduledValues
didn't remove the firstsetValueCurveAtTime
.A strict reading of the spec says this is the correct behavior because the event time of the first setValueCurve is
time + 0.1
, which is before the cancel time oftime + 0.2
. Hence it isn't removed.The result is that you can't actually remove a
setValueCurve
; you have to wait until after thesetValueCurve
has ended before scheduling anything else.The spec is pretty clear on what the behavior is, but I think we do really want to be able to remove the
setValueCurve
event if it ends some time after the cancel time.setTargetAtTime
kind of has the same issue, but you can always schedule events after it without errors, so perhaps we don't need to do anything here for that.Where Is It
See cancelScheduledValues
Also see StackOverflow question on this.
The text was updated successfully, but these errors were encountered: