-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add HTMLMediaElement.preservesPitch #3881
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will push a commit adding the skeleton for the missing pieces of this PR.
|
||
<dd> | ||
|
||
<p>Can be set to false to have the <span>media resource</span>'s audio pitch change up or down correspondingly to the <code data-x="dom-media-playbackRate">playbackRate</code> instead of using pitch-preserving algorithms. This is useful for aesthetic and performance reasons. Default: true.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this is the definition for web developers, the green box that you see here:
https://html.spec.whatwg.org/multipage/media.html#playing-the-media-resource
Here, I suggest following the structure of the ended/playbackRate attributes, with one "Returns true if ... The default value is true." statement and a separate "Can be set, to change ...".
@haywirez, thanks for sending the PR! I've left some comments, hopefully that is enough for you to continue with this. When the spec text is done, a corresponding PR in web-platform-tests will also be needed. Unfortunately, since this concerns the audio output, that isn't directly testable. However, we will have to decide whether the pitch adjustment should affect https://webaudio.github.io/web-audio-api/#mediaelementaudiosourcenode or not, and that can be tested. Checking how that behaves in Firefox and Safari would be a good start. |
Thanks, appreciate the help! |
Finally got around pushing some changes 🎉 |
d4fb870
to
44ee700
Compare
The problem with Participation here is that you're not a public member of the haywirez-org GitHub organization (and someone will need to verify your organization still I think). |
Thanks - should I squash the commits to make the log simpler as well? |
There's no need for that, we typically squash when landing on master. (If you want some control over the eventual commit message it helps to leave it in a comment so that whoever merges can take it into account.) |
@foolip continuing, I think the pitch adjustment should affect |
44ee700
to
c2adab3
Compare
Force pushed to reauthor commit with correct e-mail address |
That sounds reasonable. Have you tested what Firefox and Safari do? |
I discovered that changing the I'm trying to put together a codepen so I can demonstrate easier, but meanwhile you can try this or a similar code in the browser console while on the correct domain (CORS issues otherwise...)
|
That's interesting, and I guess it would make sense for either both of Have you tested Edge and Safari? |
Slapped together a quick ridiculous test page: As far as I can tell: Safari (12.0 macOS): only plays a small fragment, then mutes playback altogether (no matter the settings). Edge (41.16299.371.0 Win10): only plays back when playbackRate is 1, if it's anything else, sound immediately gets muted Firefox (60.0.2/62.0.2 Win10, 62.0.2 macOS): changing playbackRate has no effect whatsoever Chrome (69.0.3497.100 macOS): playbackRate works properly, but there's no preservesPitch control... Weird. |
Relevant, the Web Audio API spec's editor's draft clearly states:
|
Not sure what to do next here |
@haywirez, thanks for that testing and finding the relevant part of the Web Audio API spec. Given the mix of results and that there's no consistency in behavior, I think aiming for what the Web Audio spec asks for is the most reasonable path. That should mean that we can add tests that verify that the pitch changes depending on the use of If that does not seem like a good use of time, what I'd suggest is that we file an issue on web-platform-tests to test that aspect, and link to it in each browser bug created for this PR, asking the vendors to create tests when they implement this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo wrapping, which I can fix up. |
Thanks! Definitely up for writing the tests. I'll probably need some guidance, bit unclear how to test these. I'll look into it tomorrow |
Here are some resources to get started: |
@tguilbert-google is adding tests for this in https://chromium-review.googlesource.com/c/chromium/src/+/2259375. @tguilbert-google would you also be willing to revive this spec change (as a new PR) so that we can land spec and tests together? |
Sorry, strike that. @haywirez started this PR, no need to create a new one if we can iterate on this one. |
Funny, I started a similar test in my fork but my sine wave + zero-crossing rate detector approach didn't work accurately enough and I ran out of time. Before that I was also trying one based on the FFT analyzer — looks like the chromium test case is similar, happy that the team got it done ✌️ |
It looks like the tests are ready. I'm going to rebase this and merge! |
Hmm, @haywirez, can you check "allow edits from maintainers" on this PR? |
Weird... maybe it doesn't exist for very old PRs. I guess I'll close this one and re-create it (with you as the committer still, of course!) |
Thanks for all the extra effort! 😄 |
See isaacs/github#1681 and https://git.luolix.topmunity/t/how-can-we-enable-allow-edits-from-maintainers-by-default/2847/8. It's a missing feature for forks from organizations. |
Would appreciate some comments on how to improve. Ideally the standard should also point out that changes to the
playbackRate
andpreservesPitch
need to be handled continuously and not interrupt playback (e.g. firefox has the correct behavior, safari not...). Thank you 🙏/acknowledgements.html ( diff )
/media.html ( diff )