[Web Audio] StereoPannerNode ignores input gain when pan is 0

RESOLVED FIXED in Firefox 45

Status

()

Core
Web Audio
P2
normal
Rank:
25
RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: jyk2048, Assigned: dminor)

Tracking

41 Branch
mozilla45
x86_64
Mac OS X
Points:
---

Firefox Tracking Flags

(firefox45 fixed)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

3 years ago
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36

Steps to reproduce:

The problem can be observed using the following JSFiddle:

https://jsfiddle.net/s_c_g/1arrbfcw/

For reference, here's the JSFiddle source:

var context = new (window.AudioContext || window.webkitAudioContext)();
var source = context.createOscillator();
var gain = context.createGain();
var pan = context.createStereoPanner();
source.connect(gain);
gain.connect(pan);
pan.connect(context.destination);
gain.gain.value = 0.01;
//pan.pan.value = 0.01;
source.start(0);

I've tested this using 41.0.1 and 42.0b5, including with a new profile. Steps to reproduce are to open Firefox, paste the JSFiddle URL into the URL bar, and press enter.


Actual results:

The tone (generated by an oscillator node) plays at full volume.


Expected results:

As there is a gain node with gain set to 0.01, the tone should be quiet rather than loud. If the commented-out line is uncommented, the tone is quiet as expected. As such, it appears the incorrect behavior only occurs when pan is 0. Looking at the source code for StereoPannerNode, it looks like aInput.mVolume isn't factored in in the special-case path for pan = 0, which seems like it could be the cause of the issue.
(Reporter)

Updated

3 years ago
OS: Unspecified → Mac OS X
Hardware: Unspecified → x86_64
Component: Untriaged → Web Audio
Product: Firefox → Core
Blocks: 1100349

Updated

3 years ago
Status: UNCONFIRMED → NEW
Rank: 25
Ever confirmed: true
Priority: -- → P2
(Assignee)

Comment 1

3 years ago
Created attachment 8676910 [details] [diff] [review]
Apply gain when pan == 0.0f
Assignee: nobody → dminor
Status: NEW → ASSIGNED
Attachment #8676910 - Flags: review?(padenot)

Updated

3 years ago
Attachment #8676910 - Attachment is patch: true
Comment on attachment 8676910 [details] [diff] [review]
Apply gain when pan == 0.0f

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

::: dom/media/webaudio/StereoPannerNode.cpp
@@ -102,5 @@
> -      AllocateAudioBlock(2, aOutput);
> -      const float* input = static_cast<const float*>(aInput.mChannelData[0]);
> -      for (uint32_t channel = 0; channel < 2; channel++) {
> -        float* output = aOutput->ChannelFloatsForWrite(channel);
> -        PodCopy(output, input, WEBAUDIO_BLOCK_SIZE);

Can we not just use AudioBlockCopyChannelWithScale here ?
Attachment #8676910 - Flags: review?(padenot)
(Assignee)

Comment 3

3 years ago
Created attachment 8678290 [details] [diff] [review]
Apply gain when pan == 0.0f

I've restored the UpmixToStereoIfNeeded method which is what I think you were asking for here.
Attachment #8676910 - Attachment is obsolete: true
Attachment #8678290 - Flags: review?(padenot)

Updated

3 years ago
Attachment #8678290 - Flags: review?(padenot) → review+
(Assignee)

Comment 5

3 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/e5e91219c8a170204f7c1351939f449b7917479e
Bug 1214239 - [Web Audio] StereoPannerNode ignores input gain when pan is 0 r=padenot

Comment 6

3 years ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/e5e91219c8a1
Status: ASSIGNED → RESOLVED
Last Resolved: 3 years ago
status-firefox45: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
You need to log in before you can comment on or make changes to this bug.