webaudio panner node using inverse distance model impacted by maxDistance
Reported by
p...@sketchfab.com,
May 3 2017
|
||||||
Issue descriptionUserAgent: 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
,
May 3 2017
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.
,
May 4 2017
I made a hopefully reproducable jsbin of it: http://jsbin.com/sezena/edit?html,js,output
,
May 4 2017
at maxDistance = 1 I get a glitch then no sound at maxDistance = 10000 I get the sound
,
May 4 2017
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
,
May 4 2017
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.
,
May 4 2017
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.
,
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 ?
,
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.)
,
May 6 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/c8faec73855c122f94f00c54549ee6542da59e9b commit c8faec73855c122f94f00c54549ee6542da59e9b Author: rtoy <rtoy@chromium.org> Date: Sat May 06 00:14:41 2017 Correctly clamp in distance formulas The clamping of the distance formulas was incorrect. Implement clamping according to the spec. BUG= 718069 TEST=panner-distance-clamping.html Review-Url: https://codereview.chromium.org/2859143004 Cr-Commit-Position: refs/heads/master@{#469824} [modify] https://crrev.com/c8faec73855c122f94f00c54549ee6542da59e9b/third_party/WebKit/LayoutTests/webaudio/Panner/panner-distance-clamping.html [modify] https://crrev.com/c8faec73855c122f94f00c54549ee6542da59e9b/third_party/WebKit/LayoutTests/webaudio/resources/panner-formulas.js [modify] https://crrev.com/c8faec73855c122f94f00c54549ee6542da59e9b/third_party/WebKit/Source/platform/audio/Distance.cpp
,
May 8 2017
,
May 9 2017
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 |
||||||
Comment 1 by rbyers@chromium.org
, May 3 2017