Skip to content

Commit cc2b681

Browse files
committed
Fix various issues with the descriptions for the spatial audio plugin
1 parent 09e9653 commit cc2b681

File tree

2 files changed

+39
-36
lines changed

2 files changed

+39
-36
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,11 @@ Unload and destroy all currently loaded Howl objects. This will immediately stop
327327

328328
### Options
329329
#### orientation `Array` `[1, 0, 0]`
330-
Sets the direction the audio source is pointing in the 3D cartesian coordinate space. Depending on how direction the sound is, based on the `cone` attributes, a sound pointing away from the listener can be quiet or silent.
330+
Sets the direction the audio source is pointing in the 3D cartesian coordinate space. Depending on how directional the sound is, based on the `cone` attributes, a sound pointing away from the listener can be quiet or silent.
331331
#### stereo `Number` `null`
332332
Sets the stereo panning value of the audio source for this sound or group. This makes it easy to setup left/right panning with a value of `-1.0` being far left and a value of `1.0` being far right.
333333
#### pos `Array` `null`
334-
Sets the 3D spatial position of the audio source for this sound or group. Setting any value higher than `1.0` will begin to decrease the volume of the sound as it moves further away.
334+
Sets the 3D spatial position of the audio source for this sound or group relative to the global listener.
335335
#### pannerAttr `Object`
336336
Sets the panner node's attributes for a sound or group of sounds. See the `pannerAttr` method for all available options.
337337
#### onstereo `Function`
@@ -349,30 +349,30 @@ Get/set the stereo panning of the audio source for this sound or all in the grou
349349
* **id**: `Number` `optional` The sound ID. If none is passed, all in group will be updated.
350350

351351
#### pos(x, y, z, [id])
352-
Get/set the 3D spatial position of the audio source for this sound or group. Setting any value higher than `1.0` will begin to decrease the volume of the sound as it moves further away.
353-
* **x**: `Number` The x-position of the audio from `-1000.0` to `1000.0`.
354-
* **y**: `Number` The y-position of the audio from `-1000.0` to `1000.0`.
355-
* **z**: `Number` The z-position of the audio from `-1000.0` to `1000.0`.
352+
Get/set the 3D spatial position of the audio source for this sound or group relative to the global listener.
353+
* **x**: `Number` The x-position of the audio source.
354+
* **y**: `Number` The y-position of the audio source.
355+
* **z**: `Number` The z-position of the audio source.
356356
* **id**: `Number` `optional` The sound ID. If none is passed, all in group will be updated.
357357

358358
#### orientation(x, y, z, [id])
359-
Get/set the direction the audio source is pointing in the 3D cartesian coordinate space. Depending on the direction of the sound, based on the `cone` attributes, a sound pointing away from the listener can be quiet or silent.
359+
Get/set the direction the audio source is pointing in the 3D cartesian coordinate space. Depending on how directional the sound is, based on the `cone` attributes, a sound pointing away from the listener can be quiet or silent.
360360
* **x**: `Number` The x-orientation of the source.
361361
* **y**: `Number` The y-orientation of the source.
362362
* **z**: `Number` The z-orientation of the source.
363363
* **id**: `Number` `optional` The sound ID. If none is passed, all in group will be updated.
364364

365365
#### pannerAttr(o, [id])
366-
Get/set the panner node's attributes for a sound or group of sounds. This method can optionall take 0, 1 or 2 arguments.
366+
Get/set the panner node's attributes for a sound or group of sounds.
367367
* **o**: `Object` All values to update.
368-
* **coneInnerAngle** `360` There will be no volume reduction inside this angle.
369-
* **coneOuterAngle** `360` The volume will be reduced to a constant value of `coneOuterGain` outside this angle.
370-
* **coneOuterGain** `0` The amount of volume reduction outside of `coneOuterAngle`.
371-
* **distanceModel** `inverse` Determines algorithm to use to reduce volume as audio moves away from listener. Can be `linear`, `inverse` or `exponential.
372-
* **maxDistance** `10000` Volume won't reduce between source/listener beyond this distance.
368+
* **coneInnerAngle** `360` A parameter for directional audio sources, this is an angle, in degrees, inside of which there will be no volume reduction.
369+
* **coneOuterAngle** `360` A parameter for directional audio sources, this is an angle, in degrees, outside of which the volume will be reduced to a constant value of `coneOuterGain`.
370+
* **coneOuterGain** `0` A parameter for directional audio sources, this is the gain outside of the `coneOuterAngle`. It is a linear value in the range `[0, 1]`.
371+
* **distanceModel** `inverse` Determines algorithm used to reduce volume as audio moves away from listener. Can be `linear`, `inverse` or `exponential. You can find the implementations of each in the [spec](https://webaudio.github.io/web-audio-api/#idl-def-DistanceModelType).
372+
* **maxDistance** `10000` The maximum distance between source and listener, after which the volume will not be reduced any further.
373+
* **refDistance** `1` A reference distance for reducing volume as source moves further from the listener. This is simply a variable of the distance model and has a different effect depending on which model is used and the scale of your coordinates. Generally, volume will be equal to 1 at this distance.
374+
* **rolloffFactor** `1` How quickly the volume reduces as source moves from listener. This is simply a variable of the distance model and can be in the range of `[0, 1]` with `linear` and `[0, ∞]` with `inverse` and `exponential`.
373375
* **panningModel** `HRTF` Determines which spatialization algorithm is used to position audio. Can be `HRTF` or `equalpower`.
374-
* **refDistance** `1` A reference distance for reducing volume as the source moves away from the listener.
375-
* **rolloffFactor** `1` How quickly the volume reduces as source moves from listener.
376376
* **id**: `Number` `optional` The sound ID. If none is passed, all in group will be updated.
377377

378378

src/plugins/howler.spatial.js

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,10 @@
228228
};
229229

230230
/**
231-
* Get/set the 3D spatial position of the audio source for this sound or
232-
* all in the group. The most common usage is to set the 'x' position for
233-
* left/right panning. Setting any value higher than 1.0 will begin to
234-
* decrease the volume of the sound as it moves further away.
235-
* @param {Number} x The x-position of the audio from -1000.0 to 1000.0.
236-
* @param {Number} y The y-position of the audio from -1000.0 to 1000.0.
237-
* @param {Number} z The z-position of the audio from -1000.0 to 1000.0.
231+
* Get/set the 3D spatial position of the audio source for this sound or group relative to the global listener.
232+
* @param {Number} x The x-position of the audio source.
233+
* @param {Number} y The y-position of the audio source.
234+
* @param {Number} z The z-position of the audio source.
238235
* @param {Number} id (optional) The sound ID. If none is passed, all in group will be updated.
239236
* @return {Howl/Array} Returns self or the current 3D spatial position: [x, y, z].
240237
*/
@@ -388,18 +385,24 @@
388385
* pannerAttr(o, id) -> Set's the values of passed sound id.
389386
*
390387
* Attributes:
391-
* coneInnerAngle - (360 by default) There will be no volume reduction inside this angle.
392-
* coneOuterAngle - (360 by default) The volume will be reduced to a constant value of
393-
* `coneOuterGain` outside this angle.
394-
* coneOuterGain - (0 by default) The amount of volume reduction outside of `coneOuterAngle`.
395-
* distanceModel - ('inverse' by default) Determines algorithm to use to reduce volume as audio moves
396-
* away from listener. Can be `linear`, `inverse` or `exponential`.
397-
* maxDistance - (10000 by default) Volume won't reduce between source/listener beyond this distance.
388+
* coneInnerAngle - (360 by default) A parameter for directional audio sources, this is an angle, in degrees,
389+
* inside of which there will be no volume reduction.
390+
* coneOuterAngle - (360 by default) A parameter for directional audio sources, this is an angle, in degrees,
391+
* outside of which the volume will be reduced to a constant value of `coneOuterGain`.
392+
* coneOuterGain - (0 by default) A parameter for directional audio sources, this is the gain outside of the
393+
* `coneOuterAngle`. It is a linear value in the range `[0, 1]`.
394+
* distanceModel - ('inverse' by default) Determines algorithm used to reduce volume as audio moves away from
395+
* listener. Can be `linear`, `inverse` or `exponential.
396+
* maxDistance - (10000 by default) The maximum distance between source and listener, after which the volume
397+
* will not be reduced any further.
398+
* refDistance - (1 by default) A reference distance for reducing volume as source moves further from the listener.
399+
* This is simply a variable of the distance model and has a different effect depending on which model
400+
* is used and the scale of your coordinates. Generally, volume will be equal to 1 at this distance.
401+
* rolloffFactor - (1 by default) How quickly the volume reduces as source moves from listener. This is simply a
402+
* variable of the distance model and can be in the range of `[0, 1]` with `linear` and `[0, ∞]`
403+
* with `inverse` and `exponential`.
398404
* panningModel - ('HRTF' by default) Determines which spatialization algorithm is used to position audio.
399405
* Can be `HRTF` or `equalpower`.
400-
* refDistance - (1 by default) A reference distance for reducing volume as the source
401-
* moves away from the listener.
402-
* rolloffFactor - (1 by default) How quickly the volume reduces as source moves from listener.
403406
*
404407
* @return {Howl/Object} Returns self or current panner attributes.
405408
*/
@@ -429,9 +432,9 @@
429432
coneOuterGain: typeof o.coneOuterGain !== 'undefined' ? o.coneOuterGain : self._coneOuterGain,
430433
distanceModel: typeof o.distanceModel !== 'undefined' ? o.distanceModel : self._distanceModel,
431434
maxDistance: typeof o.maxDistance !== 'undefined' ? o.maxDistance : self._maxDistance,
432-
panningModel: typeof o.panningModel !== 'undefined' ? o.panningModel : self._panningModel,
433435
refDistance: typeof o.refDistance !== 'undefined' ? o.refDistance : self._refDistance,
434436
rolloffFactor: typeof o.rolloffFactor !== 'undefined' ? o.rolloffFactor : self._rolloffFactor
437+
panningModel: typeof o.panningModel !== 'undefined' ? o.panningModel : self._panningModel,
435438
};
436439
}
437440
} else {
@@ -458,9 +461,9 @@
458461
coneOuterGain: typeof o.coneOuterGain !== 'undefined' ? o.coneOuterGain : pa.coneOuterGain,
459462
distanceModel: typeof o.distanceModel !== 'undefined' ? o.distanceModel : pa.distanceModel,
460463
maxDistance: typeof o.maxDistance !== 'undefined' ? o.maxDistance : pa.maxDistance,
461-
panningModel: typeof o.panningModel !== 'undefined' ? o.panningModel : pa.panningModel,
462464
refDistance: typeof o.refDistance !== 'undefined' ? o.refDistance : pa.refDistance,
463465
rolloffFactor: typeof o.rolloffFactor !== 'undefined' ? o.rolloffFactor : pa.rolloffFactor
466+
panningModel: typeof o.panningModel !== 'undefined' ? o.panningModel : pa.panningModel,
464467
};
465468

466469
// Update the panner values or create a new panner if none exists.
@@ -471,9 +474,9 @@
471474
panner.coneOuterGain = pa.coneOuterGain;
472475
panner.distanceModel = pa.distanceModel;
473476
panner.maxDistance = pa.maxDistance;
474-
panner.panningModel = pa.panningModel;
475477
panner.refDistance = pa.refDistance;
476478
panner.rolloffFactor = pa.rolloffFactor;
479+
panner.panningModel = pa.panningModel;
477480
} else {
478481
// Make sure we have a position to setup the node with.
479482
if (!sound._pos) {
@@ -559,9 +562,9 @@
559562
sound._panner.coneOuterGain = sound._pannerAttr.coneOuterGain;
560563
sound._panner.distanceModel = sound._pannerAttr.distanceModel;
561564
sound._panner.maxDistance = sound._pannerAttr.maxDistance;
562-
sound._panner.panningModel = sound._pannerAttr.panningModel;
563565
sound._panner.refDistance = sound._pannerAttr.refDistance;
564566
sound._panner.rolloffFactor = sound._pannerAttr.rolloffFactor;
567+
sound._panner.panningModel = sound._pannerAttr.panningModel;
565568
sound._panner.setPosition(sound._pos[0], sound._pos[1], sound._pos[2]);
566569
sound._panner.setOrientation(sound._orientation[0], sound._orientation[1], sound._orientation[2]);
567570
} else {

0 commit comments

Comments
 (0)