Bug 75119

Summary: MediaElementAudioSourceNode should support multi-channel > stereo
Product: WebKit Reporter: Chris Rogers <crogers>
Component: Web AudioAssignee: Wei James (wistoch) <james.wei>
Status: RESOLVED FIXED    
Severity: Normal CC: crogers, eric.carlson, feature-media-reviews, james.wei, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Chris Rogers 2011-12-22 13:27:53 PST
Both up and down mixing paths for multi-channel > stereo need to be added into AudioBus::processWithGainFrom(), etc.
And then the checks in AudioBufferSourceNode and MediaElementAudioSourceNode need to be removed.

We should have layout tests (at least for AudioBufferSourceNode)
Comment 1 Wei James (wistoch) 2011-12-29 17:45:49 PST
(In reply to comment #0)
> Both up and down mixing paths for multi-channel > stereo need to be added into AudioBus::processWithGainFrom(), etc.
> And then the checks in AudioBufferSourceNode and MediaElementAudioSourceNode need to be removed.
> 
> We should have layout tests (at least for AudioBufferSourceNode)

roger, I'm interested in this feature implementation. 

If this task is not urgent and not so complicated for a newbie, can I have a try for it? thanks
Comment 2 Wei James (wistoch) 2011-12-29 17:46:11 PST
for 5.1 to stereo downmixing, there is no algorithm in https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#UpMix-section, which algorithm should I use? thanks
Comment 3 Chris Rogers 2012-01-03 16:05:09 PST
Hi James, thanks for offering to do this.  I think it's something you could probably tackle.  But we'll have to first sort out the details of your other vsmul() optimizations in that same part of the code.  If you see my latest comment there, I think we should maybe simplify the denormal handling:

https://bugs.webkit.org/show_bug.cgi?id=75334

As far as the 5.1 to stereo case, the only question is the exact scaling factors (constant multipliers), so you can prepare a patch with close to the exact code (except the numeric values) and we can sort that out later.
Comment 4 Wei James (wistoch) 2012-01-03 17:18:06 PST
(In reply to comment #3)
> Hi James, thanks for offering to do this.  I think it's something you could probably tackle.  But we'll have to first sort out the details of your other vsmul() optimizations in that same part of the code.  If you see my latest comment there, I think we should maybe simplify the denormal handling:
> 
> https://bugs.webkit.org/show_bug.cgi?id=75334
> 
> As far as the 5.1 to stereo case, the only question is the exact scaling factors (constant multipliers), so you can prepare a patch with close to the exact code (except the numeric values) and we can sort that out later.

roger, thanks for the guidance. I will work on #75334 firstly. 

for up and down mixing, for source and destination, we both have 5 options: mono, stereo, quad, 5.0, 5.1.  Current we only have 3 options: mono->mono, mono->stereo, stereo->stereo. 

do we need to support all channel up and down mixing(that is all 25 options)?
Comment 5 Chris Rogers 2012-01-03 17:49:19 PST
(In reply to comment #4)
> (In reply to comment #3)
> > Hi James, thanks for offering to do this.  I think it's something you could probably tackle.  But we'll have to first sort out the details of your other vsmul() optimizations in that same part of the code.  If you see my latest comment there, I think we should maybe simplify the denormal handling:
> > 
> > https://bugs.webkit.org/show_bug.cgi?id=75334
> > 
> > As far as the 5.1 to stereo case, the only question is the exact scaling factors (constant multipliers), so you can prepare a patch with close to the exact code (except the numeric values) and we can sort that out later.
> 
> roger, thanks for the guidance. I will work on #75334 firstly. 
> 
> for up and down mixing, for source and destination, we both have 5 options: mono, stereo, quad, 5.0, 5.1.  Current we only have 3 options: mono->mono, mono->stereo, stereo->stereo. 
> 
> do we need to support all channel up and down mixing(that is all 25 options)?

We don't have to support all of them to start with.  After all we only currently support a few of them, so anything is an improvement.  Quad (4-channels) we can probably skip for now (and get to it later).  Also, the most important are the up-mixing options (as opposed to down-mixing).  For up-mixing to a number of channels which isn't known as having a specific channel layout such as 3 channels (which isn't 1,2,4,6 - for mono,stereo,quad,5.1) , the default up-mix should just be to copy/sum the channels into the first available channels, and then just ignore (or zero) the remaining channels.

For example, if up-mixing stereo to 3 channels:
channel0 -> channel0
channel1 -> channel1
ignore/silence -> channel2

This type of up-mix may also be interesting for 1,2,4,6, but we don't have to worry about that for now.
Comment 6 Wei James (wistoch) 2012-05-17 19:06:14 PDT
Created attachment 142608 [details]
Patch
Comment 7 Chris Rogers 2012-05-17 19:30:41 PDT
Comment on attachment 142608 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=142608&action=review

Thanks James! - looks good with nit

> Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.cpp:71
> +        if (!numberOfChannels || numberOfChannels > AudioContext::maxNumberOfChannels() \

style nit: Please remove continuation character '\' and leave everything on one long line
Comment 8 Wei James (wistoch) 2012-05-17 19:56:18 PDT
Created attachment 142618 [details]
Patch
Comment 9 Wei James (wistoch) 2012-05-17 19:59:18 PDT
Comment on attachment 142608 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=142608&action=review

>> Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.cpp:71
>> +        if (!numberOfChannels || numberOfChannels > AudioContext::maxNumberOfChannels() \
> 
> style nit: Please remove continuation character '\' and leave everything on one long line

fixed. thanks. Just back from chromium coding style. :)
Comment 10 WebKit Review Bot 2012-05-17 21:56:23 PDT
Comment on attachment 142618 [details]
Patch

Clearing flags on attachment: 142618

Committed r117541: <http://trac.webkit.org/changeset/117541>
Comment 11 WebKit Review Bot 2012-05-17 21:56:28 PDT
All reviewed patches have been landed.  Closing bug.
Comment 12 Eric Seidel (no email) 2012-05-21 15:23:28 PDT
Comment on attachment 142608 [details]
Patch

Cleared review? from obsolete attachment 142608 [details] so that this bug does not appear in http://webkit.org/pending-review.  If you would like this patch reviewed, please attach it to a new bug (or re-open this bug before marking it for review again).