Closed Bug 1171436 Opened 9 years ago Closed 9 years ago

Support at least 8192 elements for PeriodicWave

Categories

(Core :: Web Audio, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla45
Tracking Status
firefox45 --- fixed

People

(Reporter: padenot, Assigned: dminor)

Details

(Whiteboard: [spec])

Attachments

(1 file)

Spec change: https://github.com/WebAudio/web-audio-api/pull/538/commits, discussion: https://github.com/WebAudio/web-audio-api/issues/386

We also need to perform the optimization where we only allocate and compute partials that make sense for the context's sample rate.
Rank: 25
Priority: -- → P2
Whiteboard: [spec]
(In reply to Paul Adenot (:padenot) (at TPAC, slow reviews) from comment #0)
> Spec change: https://github.com/WebAudio/web-audio-api/pull/538/commits,
> discussion: https://github.com/WebAudio/web-audio-api/issues/386
> 
> We also need to perform the optimization where we only allocate and compute
> partials that make sense for the context's sample rate.

Hi Paul, I'd be interested in working on this. For the optimization mentioned, is the idea to choose an appropriate fft size based upon the context's sample rate, or is it something more involved? Thanks!
Flags: needinfo?(padenot)
(In reply to Dan Minor [:dminor] from comment #1)
> Hi Paul, I'd be interested in working on this. For the optimization
> mentioned, is the idea to choose an appropriate fft size based upon the
> context's sample rate, or is it something more involved? Thanks!

Yep, the idea is that you only need to generate partials that make sense considering the Nyquist frequency. So for example when you have a sample rate of 44.1kHz, you don't want to generate partials at more than 44.1 / 2 = 22.05kHz.
Flags: needinfo?(padenot)
The tricky part is that, when createBandLimitedTables() is called, we don't know what the fundamental frequency will be, and so we don't know which partials will be above Nyquist.

Part of the full optimization solution would be to create the tables lazily, when required, at which point the fundamental is known, but I'm guessing that might be quite a redesign.

Perhaps simpler (and probably a good thing to do anyway even if the lazy-creation approach will be added later) would be to make m_periodicWaveSize a function of numberOfComponents.

The linear interpolation currently in use means that m_periodicWaveSize >> numberOfComponents is required to render higher components reasonably, which we don't necessarily achieve right now.  Cubic interpolation would provide much better rendering with much smaller m_periodicWaveSize, but that need not be addressed for this bug.
Thanks for the suggestions!
Assignee: nobody → dminor
Bug 1171436 - support at least 8192 elements for PeriodicWave r?padenot

This increases the maximum PeriodicWave size to 8192 and adds an optimization
to use 8192 elements only in the case where we receive more than 4096
components. In accordance with the spec, a maximum number of components is no
longer enforced.
Attachment #8683813 - Flags: review?(padenot)
Status: NEW → ASSIGNED
Comment on attachment 8683813 [details]
MozReview Request: Bug 1171436 - support at least 8192 elements for PeriodicWave r=padenot

https://reviewboard.mozilla.org/r/24435/#review22007

Thanks. Can you file a bug for the rest of Karl's suggestions ?

::: dom/media/webaudio/blink/PeriodicWave.cpp:104
(Diff revision 1)
> +    m_numberOfRanges=(unsigned)(3.0f*logf(m_periodicWaveSize)/logf(2.0f));

Spaces around `=`.

::: dom/media/webaudio/test/test_periodicWave.html:40
(Diff revision 1)
> -    ac.createPeriodicWave(new Float32Array(4097), new Float32Array(4097));
> +  ac.createPeriodicWave(new Float32Array(4097), new Float32Array(4097));

You can add an `expectNoException` call here.
Attachment #8683813 - Flags: review?(padenot) → review+
Comment on attachment 8683813 [details]
MozReview Request: Bug 1171436 - support at least 8192 elements for PeriodicWave r=padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/24435/diff/1-2/
Attachment #8683813 - Attachment description: MozReview Request: Bug 1171436 - support at least 8192 elements for PeriodicWave r?padenot → MozReview Request: Bug 1171436 - support at least 8192 elements for PeriodicWave r=padenot
Comment on attachment 8683813 [details]
MozReview Request: Bug 1171436 - support at least 8192 elements for PeriodicWave r=padenot

Sorry to ask for a re-review, but I realized this morning I had an off by one error that would result in 4096 being rounded up to 8192.
Attachment #8683813 - Flags: review+ → review?(padenot)
Comment on attachment 8683813 [details]
MozReview Request: Bug 1171436 - support at least 8192 elements for PeriodicWave r=padenot

https://reviewboard.mozilla.org/r/24435/#review22041
Attachment #8683813 - Flags: review?(padenot) → review+
https://hg.mozilla.org/mozilla-central/rev/378ce498787c
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: