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

Issue with "Web Audio playbackRate explained": (Note: pitch of the audio track does not change, for video only) #3783

Closed
mattgilbertnet opened this issue Apr 2, 2021 · 5 comments
Labels
Content:Guide Guide docs Content:WebAPI Web API docs effort: small This task is a small effort. good first issue A good issue for newcomers to get started with. help wanted If you know something about this topic, we would love your help!

Comments

@mattgilbertnet
Copy link

MDN URL: https://developer.mozilla.org/en-US/docs/Web/Guide/Audio_and_video_delivery/WebAudio_playbackRate_explained

What information was incorrect, unhelpful, or incomplete?

One of the notes says "The pitch of the audio track does not change when playBackRate is altered." This is true for video elements, like the example provided. However, it's not true for audio elements, like this example.

Ideally, links to examples of both types would be provided, along with a more detailed note.

Specific section or headline?

Notes

What did you expect to see?

The pitch of the audio track changes when playBackRate is altered for audio elements, but not for video elements.

Did you test this? If so, how?

I compared the relationship between pitch and playback rate with these two examples:

MDN Content page report details
@CreaTorAlexander
Copy link
Contributor

I can update this 👍

@mattgilbertnet
Copy link
Author

It's possible that this is dependent on the audio format of the video file, but I'm not sure.

@sideshowbarker sideshowbarker added Content:Learn Learning area docs Content:WebAPI Web API docs help wanted If you know something about this topic, we would love your help! labels Jun 6, 2021
@github-actions github-actions bot added the idle label Dec 9, 2021
@sideshowbarker sideshowbarker added effort: small This task is a small effort. good first issue A good issue for newcomers to get started with. labels Dec 10, 2021
MrBrain295 added a commit to MrBrain295/content that referenced this issue Mar 16, 2022
@MrBrain295 MrBrain295 mentioned this issue Mar 16, 2022
3 tasks
@wbamberg
Copy link
Collaborator

I think this is not correct.

The spec is clear that the <audio>and <video> elements should (by default) preserve the pitch when playbackRate is changed: https://html.spec.whatwg.org/multipage/media.html#dom-media-playbackrate . There's no suggestion that it should be different for audio and for video, or that the format should make a difference.

I think what's happening with the example quoted: https://mdn.github.io/webaudio-examples/decode-audio-data/ is that this example isn't using the HTMLMediaElement interface (which is the relevant interface described in https://developer.mozilla.org/en-US/docs/Web/Guide/Audio_and_video_delivery/WebAudio_playbackRate_explained). It's using the AudioBufferSourceNode interface, which says nothing about pitch preserving.

If I use the same audio file in an <audio> element, I can adjust playbackRate and preserve pitch: https://codepen.io/willbamberg/pen/JjMRbbQ?editors=1111.

One real issue is that https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/playbackRate says:

The pitch of the audio is corrected by default and is the same for every speed. Some browsers implement the non-standard HTMLMediaElement.preservesPitch property to control this.

It looks like preservesPitch() is now standard (not supported in Firefox, but it is in Chrome) and probably deserves a page. (More info: https://bugzilla.mozilla.org/show_bug.cgi?id=1652950).

Maybe we should file a separate issue for that though?

@github-actions github-actions bot removed the idle label Mar 21, 2022
@wbamberg
Copy link
Collaborator

It turns out that we have BCD for preservesPitch, which makes things easier: https://github.com/mdn/browser-compat-data/blob/2a845c8742b274407cad0011cfd836dddd04061d/api/HTMLMediaElement.json#L2664.

@wbamberg
Copy link
Collaborator

It looks like preservesPitch() is now standard (not supported in Firefox, but it is in Chrome) and probably deserves a page. (More info: https://bugzilla.mozilla.org/show_bug.cgi?id=1652950).

Maybe we should file a separate issue for that though?

I filed #14183 to add this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:Guide Guide docs Content:WebAPI Web API docs effort: small This task is a small effort. good first issue A good issue for newcomers to get started with. help wanted If you know something about this topic, we would love your help!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants