Closed Bug 1214239 Opened 6 years ago Closed 6 years ago

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

Categories

(Core :: Web Audio, defect, P2)

41 Branch
x86_64
macOS
defect

Tracking

()

RESOLVED FIXED
mozilla45
Tracking Status
firefox45 --- fixed

People

(Reporter: jyk2048, Assigned: dminor)

References

Details

Attachments

(1 file, 1 obsolete file)

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.
OS: Unspecified → Mac OS X
Hardware: Unspecified → x86_64
Component: Untriaged → Web Audio
Product: Firefox → Core
Blocks: 1100349
Status: UNCONFIRMED → NEW
Rank: 25
Ever confirmed: true
Priority: -- → P2
Attached patch Apply gain when pan == 0.0f (obsolete) — Splinter Review
Assignee: nobody → dminor
Status: NEW → ASSIGNED
Attachment #8676910 - Flags: review?(padenot)
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)
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)
Attachment #8678290 - Flags: review?(padenot) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/e5e91219c8a170204f7c1351939f449b7917479e
Bug 1214239 - [Web Audio] StereoPannerNode ignores input gain when pan is 0 r=padenot
https://hg.mozilla.org/mozilla-central/rev/e5e91219c8a1
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
You need to log in before you can comment on or make changes to this bug.