New issue
Advanced search Search tips

Issue 861681 link

Starred by 1 user

Issue metadata

Status: Verified
Owner:
Closed: Sep 11
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Bug



Sign in to add a comment

AudioWorklet outputChannelCount ignored when numberOfInputs and numberOfOutputs are 1

Reported by mossblaser@gmail.com, Jul 9

Issue description

UserAgent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0

Steps to reproduce the problem:
Using the attached example:

1. Extract the attached zip and host locally (e.g. with python3 -m http.server)
2. Visit 'bug.html' and open the JS console
3. This page creates a number of audio worklets with various combinations of numberOfInputs and numberOfOutputs and prints out the actual and expected channel counts resulting from these options.
4. Observe that for the two broken test cases (where numberOfInputs = numberOfOutputs = 1) the output channel count always matches the input channel count, ignoring the outputChannelCount option.

Various test cases are included in the attached sample which show that this bug doesn't occur when either numberOfInputs or numberOfOutputs has been specified.

What is the expected behavior?
The outputChannelCount option, when present, should be honoured regardless of numberOfInputs and numberOfOutputs.

What went wrong?
Instead, if-and-only-if numberOfInputs = numberOfOutputs = 1, the outputChannelCount option is ignored when it is provided.

Section 1.33.3.3.2 of the WebAudioAPI specification (https://webaudio.github.io/web-audio-api/#configuring-channels-with-audioworkletnodeoptions)  specifies various behaviours for selection of the output channel count. Specifically it states:

> With a combination of numberOfInputs, numberOfOutputs, and outputChannelCount, various channel configurations can be achieved.
> 
> numberOfInputs = 0, numberOfOutputs = 0
> 
>     NotSupportedError MUST be thrown by the constructor.
> 
> numberOfInputs = 1, numberOfOutputs = 1
> 
>     If outputChannelCount is unspecified, the output channel count will match computedNumberOfChannels from the input.
> 
> All other cases
> 
>     If outputChannelCount is unspecified, it will be mono for all outputs.

I believe this section may have been misinterpreted (and/or possibly that the specification itself is poorly worded in this instance). Specifically, it seems that in Chrome if both numberOfInputs and numberOfOutputs are '1', computedNumberOfChannels is used as the output channel count even when outputChannelCount has been specified.

Did this work before? N/A 

Does this work in other browsers? Yes

Chrome version: 67.0.3396.99 (Official Build) (64-bit)  Channel: stable
OS Version: Ubuntu 16.04
Flash Version:
 
outputChannelCountBug.zip
1.1 KB Download
Labels: Needs-Triage-M67
Status: Untriaged (was: Unconfirmed)
The spec is clearly under-specified because we have the case of numberOfInputs = numberOfOutputs = 1 so the second item is applicable.  But outputChannelCount is specified, but that item doesn't say what to do in this case.

I'll file an issue with the spec to get this clarified.

Not sure hos this works in other browsers because right now no other browser implements AudioWorklets. :-)

Thanks for looking into this!

For those following along, the issue has been logged as:

https://github.com/WebAudio/web-audio-api/issues/1686

> Not sure hos this works in other browsers because right now no other browser implements AudioWorklets. :-)

Hah, sorry about that. That would be a failing of my use of the bug reporting wizard.
Talked to hongchan@ about this (who wrote most of the AudioWorklet spec) and he thinks the intent is always to use the computed channels when inputs = outputs = 1.


Do you know what the rationale for this choice might be? While defaulting to the computed channel count when no other outputChannelCount is provided is clearly a very useful feature, it seems like not allowing this to be overridden is an artificial limitation.

As a concrete example of an application this restriction might present consider custom up-mixing/down-mixing logic implemented within an AudioWorklet.

There are obviously potential workarounds such as adding a dummy output/input or using channel splitters/mergers but this doesn't seem ideal.

Thanks rtoy@ and hongchan@ for your help!
Status: Available (was: Untriaged)
Owner: hongchan@chromium.org
Status: Assigned (was: Available)
We'll have to discuss this, but it seems reasonable to let outputChannelCount override the computed count.  I don't really remember the full rationale, but we definitely wanted an AudioWorklet to be able to emulate the behavior of a Gain node.
I guess we have the mutual agreement now:
https://github.com/WebAudio/web-audio-api/issues/1686#issuecomment-404285949

I will fix this when we merge the spec PR.
Status: Started (was: Assigned)
PR is merged and we're ready to do this.
Project Member

Comment 12 by bugdroid1@chromium.org, Sep 11

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/b9a938fe9706bdeb853e768b30917be01dba47dd

commit b9a938fe9706bdeb853e768b30917be01dba47dd
Author: Hongchan Choi <hongchan@chromium.org>
Date: Tue Sep 11 19:09:21 2018

Honor given outputChannelCount for AudioWorkletNodeOptions

When both input and output are 1 in AudioWorkletNode, it ignores
the output channel count specified by user. Fix this incorrect behavior
so the specified channel count can be honored properly.

See also: https://webaudio.github.io/web-audio-api/#configuring-channels-with-audioworkletnodeoptions

Bug:  861681 
Test: webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-output-channel-count.https.html
Change-Id: Ie5cc7f3a5a2b48c67cdf39e93bde8477bfedae89
Reviewed-on: https://chromium-review.googlesource.com/1216072
Commit-Queue: Hongchan Choi <hongchan@chromium.org>
Reviewed-by: Raymond Toy <rtoy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590432}
[add] https://crrev.com/b9a938fe9706bdeb853e768b30917be01dba47dd/third_party/WebKit/LayoutTests/external/wpt/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-output-channel-count.https.html
[add] https://crrev.com/b9a938fe9706bdeb853e768b30917be01dba47dd/third_party/WebKit/LayoutTests/external/wpt/webaudio/the-audio-api/the-audioworklet-interface/processors/channel-count-processor.js
[modify] https://crrev.com/b9a938fe9706bdeb853e768b30917be01dba47dd/third_party/blink/renderer/modules/webaudio/audio_worklet_node.cc
[modify] https://crrev.com/b9a938fe9706bdeb853e768b30917be01dba47dd/third_party/blink/renderer/modules/webaudio/audio_worklet_node.h

Status: Verified (was: Started)

Sign in to add a comment