Skip to content

Commit da1d778

Browse files
authored
update docs for Panner3d (#217)
* update docs for Panner3d * panner3d docs: add links to distance model and panning model
1 parent d893159 commit da1d778

File tree

1 file changed

+56
-27
lines changed

1 file changed

+56
-27
lines changed

src/panner3d.js

Lines changed: 56 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,40 @@ define(function (require) {
55
var Effect = require('effect');
66

77
/**
8-
* Spatializer is a class that can construct both a Spatial Panner
9-
* and a Spatial Listener. The panner is based on the
10-
* Web Audio Spatial Panner Node
11-
* https://www.w3.org/TR/webaudio/#the-spatializernode-interface
8+
* Panner3D is based on the <a title="Web Audio Panner docs" href=
9+
* "https://developer.mozilla.org/en-US/docs/Web/API/PannerNode">
10+
* Web Audio Spatial Panner Node</a>.
1211
* This panner is a spatial processing node that allows audio to be positioned
13-
* and oriented in 3D space.
12+
* and oriented in 3D space.
1413
*
15-
* The Listener modifies the properties of the Audio Context Listener.
16-
* Both objects types use the same methods. The default is a spatial panner.
14+
* The position is relative to an <a title="Web Audio Listener docs" href=
15+
* "https://developer.mozilla.org/en-US/docs/Web/API/AudioListener">
16+
* Audio Context Listener</a>, which can be accessed
17+
* by <code>p5.soundOut.audiocontext.listener</code>
1718
*
18-
* <code>p5.Panner3D</code> - Constructs a Spatial Panner<br/>
19-
* <code>p5.Listener3D</code> - Constructs a Spatial Listener<br/>
2019
*
21-
* @class Spatializer
20+
* @class p5.Panner3D
2221
* @constructor
23-
* @return {Object} p5.Panner3D Object
24-
*
25-
* @property {Web Audio Node} spatializer Web Audio Spatial Panning Node
26-
* @property {AudioParam} spatializer.panningModel "equal power" or "HRTF"
27-
* @pproperty {AudioParam} spatializer.distanceModel "linear", "inverse", or "exponential"
2822
*/
2923
p5.Panner3D = function() {
3024
Effect.call(this);
25+
26+
/**
27+
* <a title="Web Audio Panner docs" href=
28+
* "https://developer.mozilla.org/en-US/docs/Web/API/PannerNode">
29+
* Web Audio Spatial Panner Node</a>
30+
*
31+
* Properties include
32+
* - <a title="w3 spec for Panning Model"
33+
* href="https://www.w3.org/TR/webaudio/#idl-def-PanningModelType"
34+
* >panningModel</a>: "equal power" or "HRTF"
35+
* - <a title="w3 spec for Distance Model"
36+
* href="https://www.w3.org/TR/webaudio/#idl-def-DistanceModelType"
37+
* >distanceModel</a>: "linear", "inverse", or "exponential"
38+
*
39+
* @property {Web Audio Node} panner
40+
*
41+
*/
3142
this.panner = this.ac.createPanner();
3243
this.panner.panningModel = 'HRTF';
3344
this.panner.distanceModel = 'linear';
@@ -36,10 +47,12 @@ define(function (require) {
3647
};
3748

3849
p5.Panner3D.prototype = Object.create(Effect.prototype);
39-
50+
4051

4152
/**
4253
* Connect an audio sorce
54+
*
55+
* @method process
4356
* @param {Object} src Input source
4457
*/
4558
p5.Panner3D.prototype.process = function(src) {
@@ -57,15 +70,23 @@ define(function (require) {
5770
this.positionX(xVal,time);
5871
this.positionY(yVal,time);
5972
this.positionZ(zVal,time);
60-
return [this.panner.positionX.value,
73+
return [this.panner.positionX.value,
6174
this.panner.positionY.value,
6275
this.panner.positionZ.value];
6376
};
6477

6578
/**
6679
* Getter and setter methods for position coordinates
6780
* @method positionX
81+
* @return {Number} updated coordinate value
82+
*/
83+
/**
84+
* Getter and setter methods for position coordinates
6885
* @method positionY
86+
* @return {Number} updated coordinate value
87+
*/
88+
/**
89+
* Getter and setter methods for position coordinates
6990
* @method positionZ
7091
* @return {Number} updated coordinate value
7192
*/
@@ -116,17 +137,25 @@ define(function (require) {
116137
this.orientX(xVal,time);
117138
this.orientY(yVal,time);
118139
this.orientZ(zVal,time);
119-
return [this.panner.orientationX.value,
140+
return [this.panner.orientationX.value,
120141
this.panner.orientationY.value,
121142
this.panner.orientationZ.value];
122143
};
123144

124145
/**
125146
* Getter and setter methods for orient coordinates
126-
* @method positionX
127-
* @method positionY
128-
* @method positionZ
129-
* @return {Number} [updated coordinate value]
147+
* @method orientX
148+
* @return {Number} updated coordinate value
149+
*/
150+
/**
151+
* Getter and setter methods for orient coordinates
152+
* @method orientY
153+
* @return {Number} updated coordinate value
154+
*/
155+
/**
156+
* Getter and setter methods for orient coordinates
157+
* @method orientZ
158+
* @return {Number} updated coordinate value
130159
*/
131160
p5.Panner3D.prototype.orientX = function(xVal, time) {
132161
var t = time || 0;
@@ -166,7 +195,7 @@ define(function (require) {
166195
* Set the rolloff factor and max distance
167196
* @method setFalloff
168197
* @param {Number} [maxDistance]
169-
* @param {Number} [rolloffFactor]
198+
* @param {Number} [rolloffFactor]
170199
*/
171200
p5.Panner3D.prototype.setFalloff = function(maxDistance, rolloffFactor) {
172201
this.maxDist(maxDistance);
@@ -175,8 +204,8 @@ define(function (require) {
175204
/**
176205
* Maxium distance between the source and the listener
177206
* @method maxDist
178-
* @param {Number} maxDistance
179-
* @return {Number} updated value
207+
* @param {Number} maxDistance
208+
* @return {Number} updated value
180209
*/
181210
p5.Panner3D.prototype.maxDist = function(maxDistance){
182211
if (typeof maxDistance === 'number') {
@@ -188,8 +217,8 @@ define(function (require) {
188217
/**
189218
* How quickly the volume is reduced as the source moves away from the listener
190219
* @method rollof
191-
* @param {Number} rolloffFactor
192-
* @return {Number} updated value
220+
* @param {Number} rolloffFactor
221+
* @return {Number} updated value
193222
*/
194223
p5.Panner3D.prototype.rolloff = function(rolloffFactor){
195224
if (typeof rolloffFactor === 'number') {

0 commit comments

Comments
 (0)