New issue
Advanced search Search tips

Issue 718069 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: May 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

webaudio panner node using inverse distance model impacted by maxDistance

Reported by p...@sketchfab.com, May 3 2017

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.96 Safari/537.36

Steps to reproduce the problem:
1. make a scene in 3D webaudio with panner node with a panner.refDistance > panner.maxDistance, and distance algorithm is "inverse" (and HRTF)
2. you get no sound  (and/or horribly distorted sound)

What is the expected behavior?
maxDistance value should have no effect on sound gain in that distance model

What went wrong?
maxDistance is used and lead to either no sound or distorted sound.

Did this work before? N/A 

Does this work in other browsers? Yes

Chrome version: 58.0.3029.96  Channel: stable
OS Version: 10.0
Flash Version: 

attached is the minimal js repro case pseudo code
 
maxdistance.bug.js
752 bytes View Download
Cc: rtoy@chromium.org

Comment 2 by rtoy@chromium.org, May 3 2017

Labels: Needs-Feedback
Thanks for the report.

Your repro case seems wrong.  Your graph, as you say, looks like sound -> panner -> gain -> destination.

But you set the gain of the gainNode to 0.

Please provide another test case.  Or correct the following, which was based on your repro case:

let context = new AudioContext();
let panner = new PannerNode(context, {
  maxDistance: 1,
  panningModel: "HRTF",
  rolloffFactor: 1,
  coneInnerAngle: 360,
  coneOuterAngle: 0,
  coneOuterGain: 0
});

panner.setPosition(0,0,0);
panner.refDistance = 6697.47512;

let gain = new GainNode(context);
let s = new OscillatorNode(context);

s.connect(gain).connect(panner).connect(context.destination);
context.listener.setPosition( 17763, 25650, 11887 );

I hear a sound.

Comment 3 by p...@sketchfab.com, May 4 2017

I made a hopefully reproducable jsbin of it: http://jsbin.com/sezena/edit?html,js,output

Comment 4 by p...@sketchfab.com, May 4 2017

at maxDistance = 1 I get a glitch then no sound
at maxDistance = 10000 I get the sound

Project Member

Comment 5 by sheriffbot@chromium.org, May 4 2017

Labels: -Needs-Feedback
Thank you for providing more feedback. Adding requester "rtoy@chromium.org" to the cc list and removing "Needs-Feedback" label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Comment 6 by rtoy@chromium.org, May 4 2017

Status: Available (was: Unconfirmed)
Thanks for the repro case. I don't get the same results as you, but there's something definitely wrong.  With maxDistance = 1, I hear audio, but it's totally distorted.

Comment 7 by rtoy@chromium.org, May 4 2017

Owner: rtoy@chromium.org
Status: Started (was: Available)
Ok, there are a couple of issues here. First, the actual distance was clamped between 0 and maxDistance. That, as you say, is incorrect for the inverse distance model.  And then, since maxDistance = 1, the inverse distance formula did not compute max(distance, refDistance), so the resulting gain was huge (6697.48).  This causes the distortion.

Comment 8 by p...@sketchfab.com, May 5 2017

Great, thanks for the progress report.

If I am to overcome this in current build, does just always making sure maxDistance > refDistance fixes it ?
like always setting "maxDistance = refDistance * 1e5;" each time I change refDistance ?

Comment 9 by rtoy@chromium.org, May 5 2017

Yes, making sure maxDistance > refDistance is enough. I don't know your actual use case, so I can't say if maxDistance = 1e5 * refDistance is right.

However, you said you change refDistance.  I'm curious what the use case for that is.  Could you explain why you need to change refDistance? (It sounds like you change it a lot, instead of just once and keeping it fixed.)
Project Member

Comment 10 by bugdroid1@chromium.org, May 6 2017

Comment 11 by rtoy@chromium.org, May 8 2017

Status: Fixed (was: Started)
Thanks a lot for the fix!

RefDistance is for 3D sound positioning/range editing in an "editor".
not changing in the "viewer" ;)

Sign in to add a comment