Bug 21223 - Mandate a useful accepted sampling rate ranges for buffers created through AudioContext.createBuffer
Mandate a useful accepted sampling rate ranges for buffers created through Au...
Status: ASSIGNED
Product: AudioWG
Classification: Unclassified
Component: Web Audio API
unspecified
PC All
: P2 normal
: TBD
Assigned To: Ehsan Akhgari [:ehsan]
public-audio
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-03-08 16:55 UTC by Ehsan Akhgari [:ehsan]
Modified: 2013-03-14 16:45 UTC (History)
3 users (show)

See Also:


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

Note You need to log in before you can comment on or make changes to this bug.
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.