This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 21223 - Mandate a useful accepted sampling rate ranges for buffers created through AudioContext.createBuffer
Summary: Mandate a useful accepted sampling rate ranges for buffers created through Au...
Status: CLOSED WONTFIX
Alias: None
Product: AudioWG
Classification: Unclassified
Component: Web Audio API (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: TBD
Assignee: Ehsan Akhgari [:ehsan]
QA Contact: public-audio
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-08 16:55 UTC by Ehsan Akhgari [:ehsan]
Modified: 2014-10-28 17:17 UTC (History)
3 users (show)

See Also:


Attachments
Patch (1.53 KB, patch)
2013-03-13 15:07 UTC, Ehsan Akhgari [:ehsan]
Details
Patch (1.83 KB, patch)
2013-03-13 15:08 UTC, Ehsan Akhgari [:ehsan]
Details

Description Ehsan Akhgari [:ehsan] 2013-03-08 16:55:21 UTC
Currently, the spec just suggests that implementations should at least accept sampling rate ranges of 22050-96000.  I think it would be better to mandate this range as opposed to just suggest it, since otherwise it would be possible to write code which works in one UA and not the other.

Also, sampling rates outside of this range probably don't make much sense anyway.
Comment 1 Ehsan Akhgari [:ehsan] 2013-03-08 16:57:11 UTC
Paul Adenot brought up a very good point in <https://bugzilla.mozilla.org/show_bug.cgi?id=849230#c1>.  We should consider setting the minimum sample rate value to 8000Hz.
Comment 2 Ehsan Akhgari [:ehsan] 2013-03-08 16:59:45 UTC
Also, the spec doesn't specify what needs to happen if the sample rate is not accepted, as usual. ;)  WebKit throws DOM_SYNTAX_ERR, I'm going to modify Gecko to do the same.  We should spec this.
Comment 3 Ralph Giles 2013-03-08 21:20:20 UTC
96 kHz is an odd limit, considering the fad for material at 192 kHz. I think the allowed range should be either 8-48 kHz or 8-192 kHz.
Comment 4 Chris Rogers 2013-03-08 21:33:37 UTC
(In reply to comment #3)
> 96 kHz is an odd limit, considering the fad for material at 192 kHz. I think
> the allowed range should be either 8-48 kHz or 8-192 kHz.

8-192 KHz sounds good to me
Comment 5 Ehsan Akhgari [:ehsan] 2013-03-08 21:39:09 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > 96 kHz is an odd limit, considering the fad for material at 192 kHz. I think
> > the allowed range should be either 8-48 kHz or 8-192 kHz.
> 
> 8-192 KHz sounds good to me

Sounds good to me too!
Comment 6 Marat Tanalin | tanalin.com 2013-03-10 16:37:32 UTC
"At least" should not be confused with "limited to". These are totally different things.

Current spec says "must", not "should":

"An implementation must support sample-rates in at least the range 22050 to 96000."
(https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#dfn-sampleRate_2)

That does require that the range of sample rates must be supported, but does not prevent implementations from supporting more wide range if they want / need / are able to.

There is no sense to _limit_ sample-rate range unless there are corresponding technical limitations in a specific implementation. This is completely out of the spec scope.
Comment 7 Olivier Thereaux 2013-03-11 11:43:28 UTC
The spec currently says two things:
* An implementation must support sample-rates in at least the range 22050 to 96000.
* An exception will be thrown if the numberOfChannels or sampleRate are out-of-bounds


Looking at the discussion so far, I think the spec should say something like:

* implementations MUST support sampling rate ranges of 8-192 KHz. sampling rates beyond this range MAY be supported.
* [in The createBuffer method ] An exception MUST be thrown if sampleRate is out of bounds.

is DOM_SYNTAX_ERR the best exception though?
Comment 8 Ehsan Akhgari [:ehsan] 2013-03-11 15:12:34 UTC
(In reply to comment #7)
> The spec currently says two things:
> * An implementation must support sample-rates in at least the range 22050 to
> 96000.
> * An exception will be thrown if the numberOfChannels or sampleRate are
> out-of-bounds
> 
> 
> Looking at the discussion so far, I think the spec should say something like:
> 
> * implementations MUST support sampling rate ranges of 8-192 KHz. sampling
> rates beyond this range MAY be supported.
> * [in The createBuffer method ] An exception MUST be thrown if sampleRate is
> out of bounds.

That sounds fine.

> is DOM_SYNTAX_ERR the best exception though?

Not really.  The best exception for this kind of error would be INDEX_SIZE_ERR, I think, since that is supposed to be used for out of range arguments <http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-17189187>.
Comment 9 Olivier Thereaux 2013-03-13 14:50:31 UTC
Seeing as we seem to have consensus on the solution, I am setting the issue as ASSIGNED (to CRogers - although others are welcome to send a patch to the source of the spec in dvcs.w3.org).
Comment 10 Ehsan Akhgari [:ehsan] 2013-03-13 15:07:04 UTC
Created attachment 1336 [details]
Patch

Does this look good?
Comment 11 Ehsan Akhgari [:ehsan] 2013-03-13 15:08:44 UTC
Created attachment 1337 [details]
Patch

Actually this is probably better!
Comment 12 Olivier Thereaux 2013-03-14 16:45:19 UTC
(In reply to comment #11)
> Created attachment 1337 [details]
> Patch
> 
> Actually this is probably better!

Ehsan, we discussed this - good to go, please push to the repo.
Comment 13 Olivier Thereaux 2014-10-28 17:14:42 UTC
Web Audio API issues have been migrated to Github. 
See https://github.com/WebAudio/web-audio-api/issues
Comment 14 Olivier Thereaux 2014-10-28 17:17:39 UTC
Closing. See https://github.com/WebAudio/web-audio-api/issues for up to date list of issues for the Web Audio API.