Skip to content
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

Fix #915 The case for sample-accurate start() #1024

Closed
wants to merge 3 commits into from

Conversation

mdjp
Copy link
Member

@mdjp mdjp commented Oct 4, 2016

WG should we explicitly statethat this is not quantised to samples?
eg.
It is in the same time coordinate system as the AudioContext's currentTime attribute.

attribute is converted to an exact sample frame offset within the
buffer by multiplying by the buffer's sample rate and rounding to
the nearest integer value. Thus its behavior is independent of
the value of the <a href=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part about the behavior with respect to the playbackRate is important and should be left in, here and below.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me review this again. i was under the impression that we were not quantising to the closest sample. I might have got my wires crossed with this one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, you are right; not quantizing to the closest sample. But we need to still say that where loopStart and loopEnd in the AudioBuffer is independent of the playbackRate. I think people were (previously) wondering if the playbackRate affected loopStart and loopEnd. If I set them, and then set playbackRate to 2, what gets looped? This section says you'll get the original region looped twice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seconding @rtoy's observation that we have to specify that the loop points (though now unquantized) are defined in terms of the buffer's sample rate, not the computed playback rate.

If loop points were evaluated in terms of computed playback rate, the behavior with a modulated playback rate would be chaotic and unpredictable.

@rtoy
Copy link
Member

rtoy commented Oct 4, 2016

This seems tricky. I'm not sure what the best way to deal with this would be. Removing the rounding to the sample frame is certainly right, but I'm not sure if we need to say anything more.

Perhaps a diagram that illustrates how time and sampling interact would be appropriate. That would also help explain how time in AudioParams work too. (This is not to say you need to draw this diagram for this PR.)

For the oscillator case, I think it's pretty clear. Let s(t) be the basic waveform of the oscillator. If you have osc.start(ts), and t0 <= ts < t1, where t0, and t1 are the sample points closest to ts, the output value at t0 is 0. The output value at t1, must be s(t1-ts), which is typically not 0.

I think the same holds for an ABSN. You have to interpolate between the samples of the buffer. Thus, the output at time t1 is not exactly equal to the first sample of the AudioBuffer. It can be a linear interpolation between 0 and s(0), where s(n) are the samples in the AudioBuffer.

Once we have this, I think it's pretty clear how loopStart and loopEnd behave. (Even if it is actually hard to describe the exact behavior.)

attribute is converted to an exact sample frame offset within the
buffer by multiplying by the buffer's sample rate and rounding to
the nearest integer value. Thus its behavior is independent of
the value of the <a href=
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seconding @rtoy's observation that we have to specify that the loop points (though now unquantized) are defined in terms of the buffer's sample rate, not the computed playback rate.

If loop points were evaluated in terms of computed playback rate, the behavior with a modulated playback rate would be chaotic and unpredictable.

@joeberkovitz
Copy link
Contributor

@mdjp I think @rtoy's feedback is valid - do you think we can wrap this up this week?

@joeberkovitz
Copy link
Contributor

@mdjp is this ready to merge?

@joeberkovitz
Copy link
Contributor

@mdjp and I just talked and agree it makes sense to wait until #95 is closed, then this becomes a trivial change to the Oscillator and other schedulable nodes other than ABSN.

@joeberkovitz joeberkovitz assigned joeberkovitz and unassigned mdjp Mar 30, 2017
@joeberkovitz
Copy link
Contributor

We agreed to close this w/o merging since it's superseded by #1155 which fixes #95. A new PR will be created for the general case of AudioSchedulableSourceNodes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants