-
Notifications
You must be signed in to change notification settings - Fork 166
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
When exactly does stop(time) stop? #2452
Comments
When start, stop, and duration are whole numbers of frames, my expectation is Re the boundaries for non-aligned times, I've aimed to avoid the situation In the same way that an ABSN output sample at My expectation is that we should aim to centre the band-limited impulse for a This is simple enough when start time is frame aligned. The band-limited When the start time is not frame aligned, the sample from the buffer can be "A starting offset, which can expressed with sub-sample precision" implies For consistency with start time, an aligned stop time would describe the |
Sorry, I'm thoroughly confused. How does a band-limited impulse come into play here? For the start time, I think rounding the time to the nearest frame is wrong. It should "start" exactly where I say so that the frame just before the start time must be 0 and the frame after the start time is not. We implemented this approach for Chrome's AudioParam's and it fixed a huge number of issues. Previously AudioParams would round to the nearest frame, but it's much easier to reason about if params started exactly where the time said. See also #915 |
Consider
Assume The samples in the buffer are there to represent a continuous function. For subsample accuracy in start time, the zeroth sample in the buffer will be When generating the ABSN output, the continuous signal represented by the What is counter-intuitive is that this is not like trimming off the leading My point was that rounding the start time to the nearest output frame would |
Thanks for the detailed explanation. I understand what you're saying. However, your argument kind of assumes the ABSN is bandlimited (because you are bandlimiting the step function). But that's not a requirement for an ABSN. My expectation is that with epsilon > 0, then at time |
The output of ABSN is band-limited because it has a finite sample rate. (e.g. it cannot precisely represent a sub-sample start time.) But it is not really the step function that I was choosing to band-limit. I found https://www.psaudio.com/article/cardinal-sinc/ a helpful resource. |
I still stand by my original comments in https://github.com/WebAudio/web-audio-api/issues/1749#issue-360102561. If an ABSN has 44100 samples in it and the sample rate is 44100, the So if a stop time lies on an exact frame boundary, the value of at that frame should be 0. If this is not the case, consider an ABSN with 50000 samples. I call |
Teleconf: not important enough to do for v1. Move to v.next. |
I made a quick test and it looks like Chrome and Firefox already do what @rtoy said in the last comment. const offlineAudioContext = new OfflineAudioContext({ length: 88200, sampleRate: 44100 });
const constantSourceNode = new ConstantSourceNode(offlineAudioContext);
constantSourceNode.start(0);
constantSourceNode.stop(1);
constantSourceNode.connect(offlineAudioContext.destination);
offlineAudioContext
.startRendering()
.then((renderedBuffer) => {
console.log(Array.from(renderedBuffer.getChannelData(0)).slice(44099, 44101));
// This will log [ 1, 0 ].
}); |
TPAC 2020: Based on https://github.com/WebAudio/web-audio-api-v2/issues/38#issuecomment-642793385, both Chrome and Firefox interpret |
Virtual F2F 2021: https://github.com/WebAudio/web-audio-api-v2/issues/38#issuecomment-713729212 still holds. Now that V1 is basically done, we can start updating the text with these changes. |
Consider you have an offline context with sample rate
F
and with an ABSN scheduled to stop at timet
. Where exactly does the ABSN stop?If
F*t
lies between sample frames, it's pretty clear that the last non-zero output happens at the frame just less thanF*t
, i.e,floor(F*t)
. But what happens ifF*t
is exactly on a frame boundary? The spec doesn't really say, but I think the output value at that frame must be 0.Doing it this way makes
stop
consistent with ABSN duration, I think. If the ABSN has a durationd
, the number of frames isF*d
, which is a whole number of frames, so the output is zero at frameF*d
. If we didstop(d)
as defined above, then this would be exactly equivalent to letting the ABSN run without calling stop.The text was updated successfully, but these errors were encountered: