Fix AudioBuffer constructor calls in Web Audio basic concepts - #45701
Conversation
|
Preview URLs (1 page) (comment last updated: 2026-09-15 23:13:40) |
wbamberg
left a comment
There was a problem hiding this comment.
Thanks for your PR!
I think it would be better to remove the context creation calls, as these code samples seem from the context to be just about creating the buffer. In a code sample for creating the buffer, creating the context looks odd.
When the example says:
If you use this call above, you will get a stereo buffer with two channels that, when played back on an AudioContext
...I read "this call" as referring to the code sample, which just creates the buffer, then using it in an audio context is a separate operation.
The samples are about constructing a buffer; creating a context there is unrelated to the call the surrounding prose describes.
|
Good point — done. Both samples now just create the buffer; the prose still mentions playing it back on an |
wbamberg
left a comment
There was a problem hiding this comment.
👍 thank you for the fix!
Description
The two
AudioBufferexamples on "Basic concepts behind Web Audio API" called the constructor with anAudioContextas the first argument:That signature comes from an early draft of the spec. The current constructor takes only an options dictionary:
new AudioBuffer(options). This PR removes thecontextargument from both examples.Motivation
Anyone who copies the examples hits a problem right away:
Expected 1 arguments, but got 2.AudioContextgets read as the options dictionary. It has nolengthmember, so the constructor throws aTypeError.Additional details
Related issues and pull requests
Follow-up to #36562, which removed deprecated
AudioBufferoptions elsewhere but didn't change this page.