Closed Bug 875277 Opened 11 years ago Closed 11 years ago

Implement WaveShaperNode.oversample

Categories

(Core :: Web Audio, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla26
Tracking Status
firefox25 --- affected
firefox26 --- fixed

People

(Reporter: ehsan.akhgari, Assigned: jwwang)

References

(Blocks 1 open bug)

Details

(Keywords: dev-doc-complete)

Attachments

(2 files, 6 obsolete files)

      No description provided.
Mass moving Web Audio bugs to the Web Audio component.  Filter on duckityduck.
Component: Video/Audio → Web Audio
The idea is to use libspeex for up/down sampling per chunk. However, speex_resampler_process_float() gives weird outputs in Resampler::UpSample/DownSample. Is there anything missing to use libspeex correctly?
Flags: needinfo?(jmvalin)
Pass 1 for channel count to _init and 0 for channel number in _process_float because the channels are already individual streams.
Actually, please ignore comment 3, sorry.
Attached patch Part1 - add webidl enums (obsolete) — Splinter Review
Attachment #782479 - Flags: review?(ehsan)
Attachment #782480 - Flags: review?(ehsan)
Attachment #782481 - Flags: review?(ehsan)
Attachment #782479 - Flags: review?(ehsan) → review+
Comment on attachment 782480 [details] [diff] [review]
Part2 - add up/down samplers from Blink

Review of attachment 782480 [details] [diff] [review]:
-----------------------------------------------------------------

Why should we not use libspeex here?  I don't think this is the right thing to do.
Attachment #782480 - Flags: review?(ehsan) → review-
Attachment #782481 - Flags: review?(ehsan)
Attachment #780297 - Attachment is obsolete: true
Attachment #782480 - Attachment is obsolete: true
Attachment #782481 - Attachment is obsolete: true
Attachment #782972 - Flags: review?(ehsan)
Attachment #782972 - Attachment description: implement based on libspeex → Part2 - implement based on libspeex
Comment on attachment 782972 [details] [diff] [review]
Part2 - implement based on libspeex

Review of attachment 782972 [details] [diff] [review]:
-----------------------------------------------------------------

Looks great, thanks!

::: content/media/webaudio/WaveShaperNode.cpp
@@ +67,5 @@
> +  void Reset(uint32_t aChannels, uint32_t aSampleRate, OverSampleType aType)
> +  {
> +    if (aChannels == mChannels
> +        && aSampleRate == mSampleRate
> +        && aType == mType)

Nit: please put the ands at the end of lines.  Also, please wrap if's in curly brackets.

@@ +90,5 @@
> +    mDownSampler = speex_resampler_init(aChannels,
> +                                        aSampleRate * ValueOf(aType),
> +                                        aSampleRate,
> +                                        SPEEX_RESAMPLER_QUALITY_DEFAULT,
> +                                        nullptr);

Hmm, I think it would be slightly better to lazily allocate the resamplers, since I believe in most cases we will only end up using one of them.

@@ +104,5 @@
> +    MOZ_ASSERT(mBuffer.Length() == outSamples);
> +
> +    speex_resampler_process_float(mUpSampler, aChannel,
> +                                  aInputData, &inSamples,
> +                                  outputData, &outSamples);

After this line, please MOZ_ASSERT(inSamples == WEBAUDIO_BLOCK_SIZE && outSamples == WEBAUDIO_BLOCK_SIZE * aBlocks);.  Same in DownSample() below.

@@ +139,5 @@
> +  OverSampleType mType;
> +  SpeexResamplerState* mUpSampler;
> +  SpeexResamplerState* mDownSampler;
> +  uint32_t mChannels;
> +  uint32_t mSampleRate;

Nit: please use TrackRate as the type of the sample rate here and in the above functions.  (TrackRate is int32_t.)
Attachment #782972 - Flags: review?(ehsan) → review+
Assignee: nobody → jwwang
Comment on attachment 782972 [details] [diff] [review]
Part2 - implement based on libspeex

Review of attachment 782972 [details] [diff] [review]:
-----------------------------------------------------------------

::: content/media/webaudio/WaveShaperNode.cpp
@@ +90,5 @@
> +    mDownSampler = speex_resampler_init(aChannels,
> +                                        aSampleRate * ValueOf(aType),
> +                                        aSampleRate,
> +                                        SPEEX_RESAMPLER_QUALITY_DEFAULT,
> +                                        nullptr);

I don't get it. Do you mean we will only use either upsampler or downsampler in most cases? I think we will need both of them to complete the process (upsample -> apply curve -> downsample).
(In reply to jwwang from comment #11)
> Comment on attachment 782972 [details] [diff] [review]
> Part2 - implement based on libspeex
> 
> Review of attachment 782972 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: content/media/webaudio/WaveShaperNode.cpp
> @@ +90,5 @@
> > +    mDownSampler = speex_resampler_init(aChannels,
> > +                                        aSampleRate * ValueOf(aType),
> > +                                        aSampleRate,
> > +                                        SPEEX_RESAMPLER_QUALITY_DEFAULT,
> > +                                        nullptr);
> 
> I don't get it. Do you mean we will only use either upsampler or downsampler
> in most cases? I think we will need both of them to complete the process
> (upsample -> apply curve -> downsample).

No, sorry, this comment was a mistake of mine, and I meant to remove it before submitting the review!  Please ignore it.
Attachment #782972 - Attachment is obsolete: true
Attachment #785583 - Flags: review+
Keywords: checkin-needed
"OverSampleType mType;" is missing from WaveShaperNode.h after merge and results in build fail. Does the merge fail?
Maybe. Please make sure your patches apply against m-c tip and rebase as necessary.
Attachment #782479 - Attachment is obsolete: true
Attachment #786152 - Flags: review+
Attachment #785583 - Attachment is obsolete: true
Attachment #786153 - Flags: review+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/802ef003bb08
https://hg.mozilla.org/mozilla-central/rev/1406e31167e2
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla26
Comment on attachment 786152 [details] [diff] [review]
Part1 - add webidl enums

This is needed for Web Audio in Firefox 25.
Attachment #786152 - Flags: approval-mozilla-aurora?
checkin-needed for Aurora, a=webaudio.
Keywords: checkin-needed
Attachment #786152 - Flags: approval-mozilla-aurora?
Clear the needinfo
Flags: needinfo?(jmvalin)
Depends on: 912474
No longer depends on: 912474
Depends on: 921695
Blocks: 865251
Blocks: 961932
Flags: in-testsuite?
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: