W3C home > Mailing lists > Public > public-audio@w3.org > July to September 2012

Re: Thoughts about the AudioPanner

From: Chris Rogers <crogers@google.com>
Date: Thu, 2 Aug 2012 12:10:41 -0700
Message-ID: <CA+EzO0mSP5Y7CRXkbKnCViZ3snLFpPfMu-iigL2TrkFBi0KKSg@mail.gmail.com>
To: Chris Wilson <cwilso@google.com>
Cc: Peter van der Noord <peterdunord@gmail.com>, public-audio@w3.org
On Thu, Aug 2, 2012 at 10:00 AM, Chris Wilson <cwilso@google.com> wrote:

> "Panning" - as in stereo panning - isn't a clear-cut in a 5.1 surround
> sound system.  If you really do just want to control volume level, you
> could (via splitter/gain nodes/merger), but you'll miss the aural placement.
>
> The current AudioPanner is actually quite easy to use as just a simple
> stereo panner - in fact, I have a slide about that in my I/O talk on Web
> Audio: http://webaudio-io2012.appspot.com/#40:
>
> var panner = audioContext.createPanner();
>
> // default to straight ahead
> panner.setPosition(0.0, 1.0, 0.0);
>
>    ...
> // remember, 0.0 is straight ahead: negative=left, positive=right
> panner.setPosition( newPanningPosition, 1.0, 0.0 );
>

Hi Chris, I'm going to jump in here.  Actually Peter is right about this
one.  Your technique using "newPanningPosition" does *not* actually achieve
equal-power panning because the distance from the listener is changing, and
the changing distance changes the attenuation.  In order to get equal-power
panning you need to move around a circle at an equal distance from the
listener.  You can see the nitty-gritty details in the spec here:
https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#Spatialization-section


I think this code will get you real equal-power panning for more musical
applications:
var x = Math.sin(0.5*Math.PI * panPosition);
var z = -Math.cos(0.5*Math.PI * panPosition);
panner.panningModel = webkitAudioPannerNode.EQUALPOWER;
panner.setPosition(x, 0, z);

So Peter's point is well taken.  The parametric control is via cartesian
coordinates which is perfect for games and is taken directly from OpenAL.
 Other game audio APIs also use this approach, so it's well accepted in the
industry.  For music, it's not as convenient.  To make this more inviting
for music, one flexible approach would be to expose the "azimuth" (and
"elevation") (both of which are explained in the specification) as writable
AudioParams.  That way the panner can be controlled in either way.



>
> On Thu, Aug 2, 2012 at 2:37 AM, Peter van der Noord <peterdunord@gmail.com
> > wrote:
>
>> I wanted to use the panner, but was a little overwhelmed by the options
>> that the AudioPannerNode has. Two thoughts:
>>
>> - I am only looking for a panner, and i'm expecting a node that has just
>> one property: a param that i can set from -1 to 1 or something like that
>> (and maybe an algorithm to choose from). The current AudioPanner can
>> probably be set up to do that, but it's not very inviting to say the least.
>> I could create a node that does what i want, but i think a native module
>> that simply does panning is a basic tool that a lot of users would expect.
>>
>> - I think the name of the AudioPannerNode is misleading. It doesn't do
>> panning, it does spatialization. I'd suggest renaming it to
>> AudioSpatializerNode (and add an AudioPannerNode that that does panning)
>>
>>
>> Peter
>>
>
>
Received on Thursday, 2 August 2012 19:11:12 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 2 August 2012 19:11:13 GMT