Saturday 15 January 2011

javascript - How to understand the relationships between "distance" methods of the Web Audio API panner node -



javascript - How to understand the relationships between "distance" methods of the Web Audio API panner node -

i'm trying understand , improve mental image of relationship between next methods

listener.setposition(x,y,z); panner.setposition(x,y,z);

from here on out describe think know , few people tell me i'm wrong , right me.

now @ basic imagine sphere both of these "positions" occupying same place in middle. in way @ panner.setposition , listener.setposition() both physical "things" within our hypothetical sphere.

now when alter coordinates of 1 move in relation other.

so 1 point of confusion this. i've come understand coordinates of these 2 methods not particular value, unlike x value 1 , -1 determine range 0 in middle, z index seem have value, if give positive value "push sound farther away" (or more point - attenuate it). 0 close , 200 far example. value ?

partial answer:

the reason 1 -1 hard right/left because z set 0 hence there 0 space between listener , "sound source" represented panner node. still unclear "value" z index is.

the other questions have:

1.

if have hypothetical "world" imaginary person moving closer or farther away sound source, should programme listeners z coordinate or should programme panners z coordinate. reason i'm asking because in example panner programmed , listener stays in same place ui suggest listener moving toward sound source. guess question more best practice seems either work.

2. when run sound through default panner node literally sounds different ( more muffled , "dense", if 2 instances of same sound file playing simultaneously or highs getting cancelled out). assume since case there culmination of "settings" programmer expected know remedy this. i'm interested in knowing whatever that is.

if side side illustration below 2 jsfiddle examples. 1 uses panner node , 1 not. open both of them , play files side side while listening in headphones, difference subtle noticeable.

jsfiddle panner node

jsfiddle without panner node

0 close , 200 far example. value this?

i think numbers arbitrary units. section on distancemodel gives formulae calculating alter in gain based on distance between source , listener.

also spec mentions "pannernode scales/multiplies input sound signal distancegain"

for answers question:

q1. - should programme listeners z coordinate or should programme panners z coordinate

it depends on application. api designed have single listener per audiocontext. can create multiple audiosources pannernode attached each of them. can envision bunch of loudspeakers (audiosources) can position in 3d space, (listener) can move around. in such case depending on whether want sources move respect each other or not, may or may not want listener move.

q2. - sounds different ( more muffled , "dense")

i not sure this. have not encountered before. give example/demo?

based on trying various panning models, seems muffled sound result of using hrtf panning model. hrtf impulse responses not have flat frequency response , colour audio. can utilize equalpower panning model instead.

be warned though lot of these things gonna alter in upcoming alter of webaudio. can read more here https://github.com/webaudio/web-audio-api/issues/372

javascript html5-audio web-audio

No comments:

Post a Comment