Closed Bug 1002513 Opened 7 years ago Closed 6 years ago

WebAudio linear distance model not clamping


(Core :: Web Audio, defect, P2)




Tracking Status
firefox41 --- fixed


(Reporter: davidgaleano, Assigned: padenot)




(3 files)

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:28.0) Gecko/20100101 Firefox/28.0 (Beta/Release)
Build ID: 20140410211200

Steps to reproduce:

Create PannerNode.
Set node distanceModel property to "linear".
Set node maxDistance property to 100.
Set node position 200 units away from the listener position.
Connect node to the context destination.
Play a sound buffer connected to the PannerNode.

Actual results:

Sound is played at full volume.

Expected results:

Once the PannerNode distance to the listener is bigger than maxDistance the sound volume should be clamped to zero.
OS: Linux → All
QA Whiteboard: [bugday-20140505]
Component: Untriaged → Web Audio
Product: Firefox → Core
Blocks: 849918
Ever confirmed: true
Priority: -- → P2
I'll propose a change to the spec, this is clearly the right thing to do in any
Attachment #8548955 - Flags: review?(karlt)
Assignee: nobody → padenot
Comment on attachment 8548955 [details] [diff] [review]
Clamp gain to zero in PannerNode to avoid inverting the phase when the distance is greater than maxDistance. r=

Yes, "after [maxDistance] the volume will not be reduced any further", but coneOuterGain can be negative, even if that doesn't seem so useful.

What would you think about doing this in ComputeDistanceGain() or LinearGainFunction() so that this takes effect for equal power panning also?
Flags: needinfo?(padenot)
Attachment #8548955 - Flags: review?(karlt)

my team and me are currently developing a browsergame and have the same issue with the linear distance model. Can somebody tell me, when this bug will be fixed? Currently, we are going to recommend our users to use Chrome, because the spatial sound effects of the game don't work in Firefox.

Dunno, I can probably fix what needs to be fixed and land it.
Flags: needinfo?(padenot)
Well, it would be great, if we can achieve an equivalent behavior of the linear distance model in comparison to Chrome. David described the problem perfectly.

When the distance between listener and pannerNode is greater than maxDistance, the volume should be zero.
That's better indeed. Added a test to make sure.
Attachment #8612867 - Flags: review?(karlt)
Hi Paul,

that's great! How can i test the fix with by demo application ( At stage six, there is a sample for spatial audio effects. 

Do i need to build a dev-version of Firefox on my local machine or can i use a specific update-channel to get the recent fixes?

I've sent this patch to our CI system, and triggered builds for all desktop platform (not being sure what you use), so you don't have to build it yourself.

You'll be able to find binaries here [0] (choose the right directory for your platform, and look for a zip. Unzip it and simply run it, after having closed other firefox process). It takes some time to build, though, they should be available in less than 6 hours from now (sometimes, our build farm is overloaded and it takes some time to schedule a build).

Depending on whether Karl thinks my patch is correct or not, it'll probably land in Firefox Nightly [1] early next week, and then will ride the releases (developer edition, beta, release).

Hi Paul,

i've tested your build (firefox-41.0a1.en-US.mac.dmg) on my iMac (OSX 10.10.3). In my opinion, the linear distance model works correctly now! My mentioned test case sounds fine, analogous to Chrome!

Thanks for that fix! I'll keep tracking this patch, until it lands in production.

Attachment #8612867 - Flags: review?(karlt) → review+
Closed: 6 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla41
You need to log in before you can comment on or make changes to this bug.