How to use panner method in wpt

Best JavaScript code snippet using wpt

howler.spatial.js

Source:howler.spatial.js Github

copy

Full Screen

1/*!2 * Spatial Plugin - Adds support for stereo and 3D audio where Web Audio is supported.3 * 4 * howler.js v2.1.35 * howlerjs.com6 *7 * (c) 2013-2019, James Simpson of GoldFire Studios8 * goldfirestudios.com9 *10 * MIT License11 */12(function() {13 'use strict';14 // Setup default properties.15 HowlerGlobal.prototype._pos = [0, 0, 0];16 HowlerGlobal.prototype._orientation = [0, 0, -1, 0, 1, 0];17 /** Global Methods **/18 /***************************************************************************/19 /**20 * Helper method to update the stereo panning position of all current Howls.21 * Future Howls will not use this value unless explicitly set.22 * @param {Number} pan A value of -1.0 is all the way left and 1.0 is all the way right.23 * @return {Howler/Number} Self or current stereo panning value.24 */25 HowlerGlobal.prototype.stereo = function(pan) {26 var self = this;27 player.js28 siriwave.js29 styles.css30 // Stop right here if not using Web Audio.31 if (!self.ctx || !self.ctx.listener) {32 return self;33 }34 // Loop through all Howls and update their stereo panning.35 for (var i=self._howls.length-1; i>=0; i--) {36 self._howls[i].stereo(pan);37 }38 return self;39 };40 /**41 * Get/set the position of the listener in 3D cartesian space. Sounds using42 * 3D position will be relative to the listener's position.43 * @param {Number} x The x-position of the listener.44 * @param {Number} y The y-position of the listener.45 * @param {Number} z The z-position of the listener.46 * @return {Howler/Array} Self or current listener position.47 */48 HowlerGlobal.prototype.pos = function(x, y, z) {49 var self = this;50 // Stop right here if not using Web Audio.51 if (!self.ctx || !self.ctx.listener) {52 return self;53 }54 // Set the defaults for optional 'y' & 'z'.55 y = (typeof y !== 'number') ? self._pos[1] : y;56 z = (typeof z !== 'number') ? self._pos[2] : z;57 if (typeof x === 'number') {58 self._pos = [x, y, z];59 if (typeof self.ctx.listener.positionX !== 'undefined') {60 self.ctx.listener.positionX.setTargetAtTime(self._pos[0], Howler.ctx.currentTime, 0.1);61 self.ctx.listener.positionY.setTargetAtTime(self._pos[1], Howler.ctx.currentTime, 0.1);62 self.ctx.listener.positionZ.setTargetAtTime(self._pos[2], Howler.ctx.currentTime, 0.1);63 } else {64 self.ctx.listener.setPosition(self._pos[0], self._pos[1], self._pos[2]);65 }66 } else {67 return self._pos;68 }69 return self;70 };71 /**72 * Get/set the direction the listener is pointing in the 3D cartesian space.73 * A front and up vector must be provided. The front is the direction the74 * face of the listener is pointing, and up is the direction the top of the75 * listener is pointing. Thus, these values are expected to be at right angles76 * from each other.77 * @param {Number} x The x-orientation of the listener.78 * @param {Number} y The y-orientation of the listener.79 * @param {Number} z The z-orientation of the listener.80 * @param {Number} xUp The x-orientation of the top of the listener.81 * @param {Number} yUp The y-orientation of the top of the listener.82 * @param {Number} zUp The z-orientation of the top of the listener.83 * @return {Howler/Array} Returns self or the current orientation vectors.84 */85 HowlerGlobal.prototype.orientation = function(x, y, z, xUp, yUp, zUp) {86 var self = this;87 // Stop right here if not using Web Audio.88 if (!self.ctx || !self.ctx.listener) {89 return self;90 }91 // Set the defaults for optional 'y' & 'z'.92 var or = self._orientation;93 y = (typeof y !== 'number') ? or[1] : y;94 z = (typeof z !== 'number') ? or[2] : z;95 xUp = (typeof xUp !== 'number') ? or[3] : xUp;96 yUp = (typeof yUp !== 'number') ? or[4] : yUp;97 zUp = (typeof zUp !== 'number') ? or[5] : zUp;98 if (typeof x === 'number') {99 self._orientation = [x, y, z, xUp, yUp, zUp];100 if (typeof self.ctx.listener.forwardX !== 'undefined') {101 self.ctx.listener.forwardX.setTargetAtTime(x, Howler.ctx.currentTime, 0.1);102 self.ctx.listener.forwardY.setTargetAtTime(y, Howler.ctx.currentTime, 0.1);103 self.ctx.listener.forwardZ.setTargetAtTime(z, Howler.ctx.currentTime, 0.1);104 self.ctx.listener.upX.setTargetAtTime(xUp, Howler.ctx.currentTime, 0.1);105 self.ctx.listener.upY.setTargetAtTime(yUp, Howler.ctx.currentTime, 0.1);106 self.ctx.listener.upZ.setTargetAtTime(zUp, Howler.ctx.currentTime, 0.1);107 } else {108 self.ctx.listener.setOrientation(x, y, z, xUp, yUp, zUp);109 }110 } else {111 return or;112 }113 return self;114 };115 /** Group Methods **/116 /***************************************************************************/117 /**118 * Add new properties to the core init.119 * @param {Function} _super Core init method.120 * @return {Howl}121 */122 Howl.prototype.init = (function(_super) {123 return function(o) {124 var self = this;125 // Setup user-defined default properties.126 self._orientation = o.orientation || [1, 0, 0];127 self._stereo = o.stereo || null;128 self._pos = o.pos || null;129 self._pannerAttr = {130 coneInnerAngle: typeof o.coneInnerAngle !== 'undefined' ? o.coneInnerAngle : 360,131 coneOuterAngle: typeof o.coneOuterAngle !== 'undefined' ? o.coneOuterAngle : 360,132 coneOuterGain: typeof o.coneOuterGain !== 'undefined' ? o.coneOuterGain : 0,133 distanceModel: typeof o.distanceModel !== 'undefined' ? o.distanceModel : 'inverse',134 maxDistance: typeof o.maxDistance !== 'undefined' ? o.maxDistance : 10000,135 panningModel: typeof o.panningModel !== 'undefined' ? o.panningModel : 'HRTF',136 refDistance: typeof o.refDistance !== 'undefined' ? o.refDistance : 1,137 rolloffFactor: typeof o.rolloffFactor !== 'undefined' ? o.rolloffFactor : 1138 };139 // Setup event listeners.140 self._onstereo = o.onstereo ? [{fn: o.onstereo}] : [];141 self._onpos = o.onpos ? [{fn: o.onpos}] : [];142 self._onorientation = o.onorientation ? [{fn: o.onorientation}] : [];143 // Complete initilization with howler.js core's init function.144 return _super.call(this, o);145 };146 })(Howl.prototype.init);147 /**148 * Get/set the stereo panning of the audio source for this sound or all in the group.149 * @param {Number} pan A value of -1.0 is all the way left and 1.0 is all the way right.150 * @param {Number} id (optional) The sound ID. If none is passed, all in group will be updated.151 * @return {Howl/Number} Returns self or the current stereo panning value.152 */153 Howl.prototype.stereo = function(pan, id) {154 var self = this;155 // Stop right here if not using Web Audio.156 if (!self._webAudio) {157 return self;158 }159 // If the sound hasn't loaded, add it to the load queue to change stereo pan when capable.160 if (self._state !== 'loaded') {161 self._queue.push({162 event: 'stereo',163 action: function() {164 self.stereo(pan, id);165 }166 });167 return self;168 }169 // Check for PannerStereoNode support and fallback to PannerNode if it doesn't exist.170 var pannerType = (typeof Howler.ctx.createStereoPanner === 'undefined') ? 'spatial' : 'stereo';171 // Setup the group's stereo panning if no ID is passed.172 if (typeof id === 'undefined') {173 // Return the group's stereo panning if no parameters are passed.174 if (typeof pan === 'number') {175 self._stereo = pan;176 self._pos = [pan, 0, 0];177 } else {178 return self._stereo;179 }180 }181 // Change the streo panning of one or all sounds in group.182 var ids = self._getSoundIds(id);183 for (var i=0; i<ids.length; i++) {184 // Get the sound.185 var sound = self._soundById(ids[i]);186 if (sound) {187 if (typeof pan === 'number') {188 sound._stereo = pan;189 sound._pos = [pan, 0, 0];190 if (sound._node) {191 // If we are falling back, make sure the panningModel is equalpower.192 sound._pannerAttr.panningModel = 'equalpower';193 // Check if there is a panner setup and create a new one if not.194 if (!sound._panner || !sound._panner.pan) {195 setupPanner(sound, pannerType);196 }197 if (pannerType === 'spatial') {198 if (typeof sound._panner.positionX !== 'undefined') {199 sound._panner.positionX.setValueAtTime(pan, Howler.ctx.currentTime);200 sound._panner.positionY.setValueAtTime(0, Howler.ctx.currentTime);201 sound._panner.positionZ.setValueAtTime(0, Howler.ctx.currentTime);202 } else {203 sound._panner.setPosition(pan, 0, 0);204 }205 } else {206 sound._panner.pan.setValueAtTime(pan, Howler.ctx.currentTime);207 }208 }209 self._emit('stereo', sound._id);210 } else {211 return sound._stereo;212 }213 }214 }215 return self;216 };217 /**218 * Get/set the 3D spatial position of the audio source for this sound or group relative to the global listener.219 * @param {Number} x The x-position of the audio source.220 * @param {Number} y The y-position of the audio source.221 * @param {Number} z The z-position of the audio source.222 * @param {Number} id (optional) The sound ID. If none is passed, all in group will be updated.223 * @return {Howl/Array} Returns self or the current 3D spatial position: [x, y, z].224 */225 Howl.prototype.pos = function(x, y, z, id) {226 var self = this;227 // Stop right here if not using Web Audio.228 if (!self._webAudio) {229 return self;230 }231 // If the sound hasn't loaded, add it to the load queue to change position when capable.232 if (self._state !== 'loaded') {233 self._queue.push({234 event: 'pos',235 action: function() {236 self.pos(x, y, z, id);237 }238 });239 return self;240 }241 // Set the defaults for optional 'y' & 'z'.242 y = (typeof y !== 'number') ? 0 : y;243 z = (typeof z !== 'number') ? -0.5 : z;244 // Setup the group's spatial position if no ID is passed.245 if (typeof id === 'undefined') {246 // Return the group's spatial position if no parameters are passed.247 if (typeof x === 'number') {248 self._pos = [x, y, z];249 } else {250 return self._pos;251 }252 }253 // Change the spatial position of one or all sounds in group.254 var ids = self._getSoundIds(id);255 for (var i=0; i<ids.length; i++) {256 // Get the sound.257 var sound = self._soundById(ids[i]);258 if (sound) {259 if (typeof x === 'number') {260 sound._pos = [x, y, z];261 if (sound._node) {262 // Check if there is a panner setup and create a new one if not.263 if (!sound._panner || sound._panner.pan) {264 setupPanner(sound, 'spatial');265 }266 if (typeof sound._panner.positionX !== 'undefined') {267 sound._panner.positionX.setValueAtTime(x, Howler.ctx.currentTime);268 sound._panner.positionY.setValueAtTime(y, Howler.ctx.currentTime);269 sound._panner.positionZ.setValueAtTime(z, Howler.ctx.currentTime);270 } else {271 sound._panner.setPosition(x, y, z);272 }273 }274 self._emit('pos', sound._id);275 } else {276 return sound._pos;277 }278 }279 }280 return self;281 };282 /**283 * Get/set the direction the audio source is pointing in the 3D cartesian coordinate284 * space. Depending on how direction the sound is, based on the `cone` attributes,285 * a sound pointing away from the listener can be quiet or silent.286 * @param {Number} x The x-orientation of the source.287 * @param {Number} y The y-orientation of the source.288 * @param {Number} z The z-orientation of the source.289 * @param {Number} id (optional) The sound ID. If none is passed, all in group will be updated.290 * @return {Howl/Array} Returns self or the current 3D spatial orientation: [x, y, z].291 */292 Howl.prototype.orientation = function(x, y, z, id) {293 var self = this;294 // Stop right here if not using Web Audio.295 if (!self._webAudio) {296 return self;297 }298 // If the sound hasn't loaded, add it to the load queue to change orientation when capable.299 if (self._state !== 'loaded') {300 self._queue.push({301 event: 'orientation',302 action: function() {303 self.orientation(x, y, z, id);304 }305 });306 return self;307 }308 // Set the defaults for optional 'y' & 'z'.309 y = (typeof y !== 'number') ? self._orientation[1] : y;310 z = (typeof z !== 'number') ? self._orientation[2] : z;311 // Setup the group's spatial orientation if no ID is passed.312 if (typeof id === 'undefined') {313 // Return the group's spatial orientation if no parameters are passed.314 if (typeof x === 'number') {315 self._orientation = [x, y, z];316 } else {317 return self._orientation;318 }319 }320 // Change the spatial orientation of one or all sounds in group.321 var ids = self._getSoundIds(id);322 for (var i=0; i<ids.length; i++) {323 // Get the sound.324 var sound = self._soundById(ids[i]);325 if (sound) {326 if (typeof x === 'number') {327 sound._orientation = [x, y, z];328 if (sound._node) {329 // Check if there is a panner setup and create a new one if not.330 if (!sound._panner) {331 // Make sure we have a position to setup the node with.332 if (!sound._pos) {333 sound._pos = self._pos || [0, 0, -0.5];334 }335 setupPanner(sound, 'spatial');336 }337 if (typeof sound._panner.orientationX !== 'undefined') {338 sound._panner.orientationX.setValueAtTime(x, Howler.ctx.currentTime);339 sound._panner.orientationY.setValueAtTime(y, Howler.ctx.currentTime);340 sound._panner.orientationZ.setValueAtTime(z, Howler.ctx.currentTime);341 } else {342 sound._panner.setOrientation(x, y, z);343 }344 }345 self._emit('orientation', sound._id);346 } else {347 return sound._orientation;348 }349 }350 }351 return self;352 };353 /**354 * Get/set the panner node's attributes for a sound or group of sounds.355 * This method can optionall take 0, 1 or 2 arguments.356 * pannerAttr() -> Returns the group's values.357 * pannerAttr(id) -> Returns the sound id's values.358 * pannerAttr(o) -> Set's the values of all sounds in this Howl group.359 * pannerAttr(o, id) -> Set's the values of passed sound id.360 *361 * Attributes:362 * coneInnerAngle - (360 by default) A parameter for directional audio sources, this is an angle, in degrees,363 * inside of which there will be no volume reduction.364 * coneOuterAngle - (360 by default) A parameter for directional audio sources, this is an angle, in degrees,365 * outside of which the volume will be reduced to a constant value of `coneOuterGain`.366 * coneOuterGain - (0 by default) A parameter for directional audio sources, this is the gain outside of the367 * `coneOuterAngle`. It is a linear value in the range `[0, 1]`.368 * distanceModel - ('inverse' by default) Determines algorithm used to reduce volume as audio moves away from369 * listener. Can be `linear`, `inverse` or `exponential.370 * maxDistance - (10000 by default) The maximum distance between source and listener, after which the volume371 * will not be reduced any further.372 * refDistance - (1 by default) A reference distance for reducing volume as source moves further from the listener.373 * This is simply a variable of the distance model and has a different effect depending on which model374 * is used and the scale of your coordinates. Generally, volume will be equal to 1 at this distance.375 * rolloffFactor - (1 by default) How quickly the volume reduces as source moves from listener. This is simply a376 * variable of the distance model and can be in the range of `[0, 1]` with `linear` and `[0, ∞]`377 * with `inverse` and `exponential`.378 * panningModel - ('HRTF' by default) Determines which spatialization algorithm is used to position audio.379 * Can be `HRTF` or `equalpower`.380 *381 * @return {Howl/Object} Returns self or current panner attributes.382 */383 Howl.prototype.pannerAttr = function() {384 var self = this;385 var args = arguments;386 var o, id, sound;387 // Stop right here if not using Web Audio.388 if (!self._webAudio) {389 return self;390 }391 // Determine the values based on arguments.392 if (args.length === 0) {393 // Return the group's panner attribute values.394 return self._pannerAttr;395 } else if (args.length === 1) {396 if (typeof args[0] === 'object') {397 o = args[0];398 // Set the grou's panner attribute values.399 if (typeof id === 'undefined') {400 if (!o.pannerAttr) {401 o.pannerAttr = {402 coneInnerAngle: o.coneInnerAngle,403 coneOuterAngle: o.coneOuterAngle,404 coneOuterGain: o.coneOuterGain,405 distanceModel: o.distanceModel,406 maxDistance: o.maxDistance,407 refDistance: o.refDistance,408 rolloffFactor: o.rolloffFactor,409 panningModel: o.panningModel410 };411 }412 self._pannerAttr = {413 coneInnerAngle: typeof o.pannerAttr.coneInnerAngle !== 'undefined' ? o.pannerAttr.coneInnerAngle : self._coneInnerAngle,414 coneOuterAngle: typeof o.pannerAttr.coneOuterAngle !== 'undefined' ? o.pannerAttr.coneOuterAngle : self._coneOuterAngle,415 coneOuterGain: typeof o.pannerAttr.coneOuterGain !== 'undefined' ? o.pannerAttr.coneOuterGain : self._coneOuterGain,416 distanceModel: typeof o.pannerAttr.distanceModel !== 'undefined' ? o.pannerAttr.distanceModel : self._distanceModel,417 maxDistance: typeof o.pannerAttr.maxDistance !== 'undefined' ? o.pannerAttr.maxDistance : self._maxDistance,418 refDistance: typeof o.pannerAttr.refDistance !== 'undefined' ? o.pannerAttr.refDistance : self._refDistance,419 rolloffFactor: typeof o.pannerAttr.rolloffFactor !== 'undefined' ? o.pannerAttr.rolloffFactor : self._rolloffFactor,420 panningModel: typeof o.pannerAttr.panningModel !== 'undefined' ? o.pannerAttr.panningModel : self._panningModel421 };422 }423 } else {424 // Return this sound's panner attribute values.425 sound = self._soundById(parseInt(args[0], 10));426 return sound ? sound._pannerAttr : self._pannerAttr;427 }428 } else if (args.length === 2) {429 o = args[0];430 id = parseInt(args[1], 10);431 }432 // Update the values of the specified sounds.433 var ids = self._getSoundIds(id);434 for (var i=0; i<ids.length; i++) {435 sound = self._soundById(ids[i]);436 if (sound) {437 // Merge the new values into the sound.438 var pa = sound._pannerAttr;439 pa = {440 coneInnerAngle: typeof o.coneInnerAngle !== 'undefined' ? o.coneInnerAngle : pa.coneInnerAngle,441 coneOuterAngle: typeof o.coneOuterAngle !== 'undefined' ? o.coneOuterAngle : pa.coneOuterAngle,442 coneOuterGain: typeof o.coneOuterGain !== 'undefined' ? o.coneOuterGain : pa.coneOuterGain,443 distanceModel: typeof o.distanceModel !== 'undefined' ? o.distanceModel : pa.distanceModel,444 maxDistance: typeof o.maxDistance !== 'undefined' ? o.maxDistance : pa.maxDistance,445 refDistance: typeof o.refDistance !== 'undefined' ? o.refDistance : pa.refDistance,446 rolloffFactor: typeof o.rolloffFactor !== 'undefined' ? o.rolloffFactor : pa.rolloffFactor,447 panningModel: typeof o.panningModel !== 'undefined' ? o.panningModel : pa.panningModel448 };449 // Update the panner values or create a new panner if none exists.450 var panner = sound._panner;451 if (panner) {452 panner.coneInnerAngle = pa.coneInnerAngle;453 panner.coneOuterAngle = pa.coneOuterAngle;454 panner.coneOuterGain = pa.coneOuterGain;455 panner.distanceModel = pa.distanceModel;456 panner.maxDistance = pa.maxDistance;457 panner.refDistance = pa.refDistance;458 panner.rolloffFactor = pa.rolloffFactor;459 panner.panningModel = pa.panningModel;460 } else {461 // Make sure we have a position to setup the node with.462 if (!sound._pos) {463 sound._pos = self._pos || [0, 0, -0.5];464 }465 // Create a new panner node.466 setupPanner(sound, 'spatial');467 }468 }469 }470 return self;471 };472 /** Single Sound Methods **/473 /***************************************************************************/474 /**475 * Add new properties to the core Sound init.476 * @param {Function} _super Core Sound init method.477 * @return {Sound}478 */479 Sound.prototype.init = (function(_super) {480 return function() {481 var self = this;482 var parent = self._parent;483 // Setup user-defined default properties.484 self._orientation = parent._orientation;485 self._stereo = parent._stereo;486 self._pos = parent._pos;487 self._pannerAttr = parent._pannerAttr;488 // Complete initilization with howler.js core Sound's init function.489 _super.call(this);490 // If a stereo or position was specified, set it up.491 if (self._stereo) {492 parent.stereo(self._stereo);493 } else if (self._pos) {494 parent.pos(self._pos[0], self._pos[1], self._pos[2], self._id);495 }496 };497 })(Sound.prototype.init);498 /**499 * Override the Sound.reset method to clean up properties from the spatial plugin.500 * @param {Function} _super Sound reset method.501 * @return {Sound}502 */503 Sound.prototype.reset = (function(_super) {504 return function() {505 var self = this;506 var parent = self._parent;507 // Reset all spatial plugin properties on this sound.508 self._orientation = parent._orientation;509 self._stereo = parent._stereo;510 self._pos = parent._pos;511 self._pannerAttr = parent._pannerAttr;512 // If a stereo or position was specified, set it up.513 if (self._stereo) {514 parent.stereo(self._stereo);515 } else if (self._pos) {516 parent.pos(self._pos[0], self._pos[1], self._pos[2], self._id);517 } else if (self._panner) {518 // Disconnect the panner.519 self._panner.disconnect(0);520 self._panner = undefined;521 parent._refreshBuffer(self);522 }523 // Complete resetting of the sound.524 return _super.call(this);525 };526 })(Sound.prototype.reset);527 /** Helper Methods **/528 /***************************************************************************/529 /**530 * Create a new panner node and save it on the sound.531 * @param {Sound} sound Specific sound to setup panning on.532 * @param {String} type Type of panner to create: 'stereo' or 'spatial'.533 */534 var setupPanner = function(sound, type) {535 type = type || 'spatial';536 // Create the new panner node.537 if (type === 'spatial') {538 sound._panner = Howler.ctx.createPanner();539 sound._panner.coneInnerAngle = sound._pannerAttr.coneInnerAngle;540 sound._panner.coneOuterAngle = sound._pannerAttr.coneOuterAngle;541 sound._panner.coneOuterGain = sound._pannerAttr.coneOuterGain;542 sound._panner.distanceModel = sound._pannerAttr.distanceModel;543 sound._panner.maxDistance = sound._pannerAttr.maxDistance;544 sound._panner.refDistance = sound._pannerAttr.refDistance;545 sound._panner.rolloffFactor = sound._pannerAttr.rolloffFactor;546 sound._panner.panningModel = sound._pannerAttr.panningModel;547 if (typeof sound._panner.positionX !== 'undefined') {548 sound._panner.positionX.setValueAtTime(sound._pos[0], Howler.ctx.currentTime);549 sound._panner.positionY.setValueAtTime(sound._pos[1], Howler.ctx.currentTime);550 sound._panner.positionZ.setValueAtTime(sound._pos[2], Howler.ctx.currentTime);551 } else {552 sound._panner.setPosition(sound._pos[0], sound._pos[1], sound._pos[2]);553 }554 if (typeof sound._panner.orientationX !== 'undefined') {555 sound._panner.orientationX.setValueAtTime(sound._orientation[0], Howler.ctx.currentTime);556 sound._panner.orientationY.setValueAtTime(sound._orientation[1], Howler.ctx.currentTime);557 sound._panner.orientationZ.setValueAtTime(sound._orientation[2], Howler.ctx.currentTime);558 } else {559 sound._panner.setOrientation(sound._orientation[0], sound._orientation[1], sound._orientation[2]);560 }561 } else {562 sound._panner = Howler.ctx.createStereoPanner();563 sound._panner.pan.setValueAtTime(sound._stereo, Howler.ctx.currentTime);564 }565 sound._panner.connect(sound._node);566 // Update the connections.567 if (!sound._paused) {568 sound._parent.pause(sound._id, true).play(sound._id, true);569 }570 };...

Full Screen

Full Screen

PositionalAudio.js

Source:PositionalAudio.js Github

copy

Full Screen

1import { Vector3 } from '../math/Vector3.js';2import { Quaternion } from '../math/Quaternion.js';3import { Audio } from './Audio.js';4const _position = /*@__PURE__*/ new Vector3();5const _quaternion = /*@__PURE__*/ new Quaternion();6const _scale = /*@__PURE__*/ new Vector3();7const _orientation = /*@__PURE__*/ new Vector3();8class PositionalAudio extends Audio {9 constructor( listener ) {10 super( listener );11 this.panner = this.context.createPanner();12 this.panner.panningModel = 'HRTF';13 this.panner.connect( this.gain );14 }15 disconnect() {16 super.disconnect();17 this.panner.disconnect( this.gain );18 }19 getOutput() {20 return this.panner;21 }22 getRefDistance() {23 return this.panner.refDistance;24 }25 setRefDistance( value ) {26 this.panner.refDistance = value;27 return this;28 }29 getRolloffFactor() {30 return this.panner.rolloffFactor;31 }32 setRolloffFactor( value ) {33 this.panner.rolloffFactor = value;34 return this;35 }36 getDistanceModel() {37 return this.panner.distanceModel;38 }39 setDistanceModel( value ) {40 this.panner.distanceModel = value;41 return this;42 }43 getMaxDistance() {44 return this.panner.maxDistance;45 }46 setMaxDistance( value ) {47 this.panner.maxDistance = value;48 return this;49 }50 setDirectionalCone( coneInnerAngle, coneOuterAngle, coneOuterGain ) {51 this.panner.coneInnerAngle = coneInnerAngle;52 this.panner.coneOuterAngle = coneOuterAngle;53 this.panner.coneOuterGain = coneOuterGain;54 return this;55 }56 updateMatrixWorld( force ) {57 super.updateMatrixWorld( force );58 if ( this.hasPlaybackControl === true && this.isPlaying === false ) return;59 this.matrixWorld.decompose( _position, _quaternion, _scale );60 _orientation.set( 0, 0, 1 ).applyQuaternion( _quaternion );61 const panner = this.panner;62 if ( panner.positionX ) {63 // code path for Chrome and Firefox (see #14393)64 const endTime = this.context.currentTime + this.listener.timeDelta;65 panner.positionX.linearRampToValueAtTime( _position.x, endTime );66 panner.positionY.linearRampToValueAtTime( _position.y, endTime );67 panner.positionZ.linearRampToValueAtTime( _position.z, endTime );68 panner.orientationX.linearRampToValueAtTime( _orientation.x, endTime );69 panner.orientationY.linearRampToValueAtTime( _orientation.y, endTime );70 panner.orientationZ.linearRampToValueAtTime( _orientation.z, endTime );71 } else {72 panner.setPosition( _position.x, _position.y, _position.z );73 panner.setOrientation( _orientation.x, _orientation.y, _orientation.z );74 }75 }76}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var context = new AudioContext();2var panner = context.createPanner();3var listener = context.listener;4listener.setPosition(0, 0, 0);5panner.setPosition(0, 0, 0);6panner.setOrientation(0, 0, 0);7panner.setVelocity(0, 0, 0);8panner.panningModel = "equalpower";9panner.distanceModel = "inverse";10panner.refDistance = 1;11panner.maxDistance = 10000;12panner.rolloffFactor = 1;13panner.coneInnerAngle = 360;14panner.coneOuterAngle = 0;15panner.coneOuterGain = 0;16panner.setOrientation(0, 0, 0);17panner.setVelocity(0, 0, 0);18panner.setPosition(0, 0, 0);19panner.panningModel = "equalpower";20panner.distanceModel = "inverse";21panner.refDistance = 1;22panner.maxDistance = 10000;23panner.rolloffFactor = 1;24panner.coneInnerAngle = 360;25panner.coneOuterAngle = 0;26panner.coneOuterGain = 0;27panner.setOrientation(0, 0, 0);28panner.setVelocity(0, 0, 0);29panner.setPosition(0, 0, 0);30panner.panningModel = "equalpower";31panner.distanceModel = "inverse";32panner.refDistance = 1;33panner.maxDistance = 10000;34panner.rolloffFactor = 1;35panner.coneInnerAngle = 360;36panner.coneOuterAngle = 0;37panner.coneOuterGain = 0;38panner.setOrientation(0, 0, 0);39panner.setVelocity(0, 0, 0);40panner.setPosition(0, 0, 0);41panner.panningModel = "equalpower";42panner.distanceModel = "inverse";43panner.refDistance = 1;44panner.maxDistance = 10000;45panner.rolloffFactor = 1;46panner.coneInnerAngle = 360;47panner.coneOuterAngle = 0;48panner.coneOuterGain = 0;49panner.setOrientation(0, 0, 0);

Full Screen

Using AI Code Generation

copy

Full Screen

1function testPanner() {2 var context = new AudioContext();3 var panner = context.createPanner();4 var listener = context.listener;5 var x = 0;6 var y = 0;7 var z = 0;8 var orientationX = 0;9 var orientationY = 0;10 var orientationZ = 0;11 var velocityX = 0;12 var velocityY = 0;13 var velocityZ = 0;14 var frontX = 0;15 var frontY = 0;16 var frontZ = 0;17 var upX = 0;18 var upY = 0;19 var upZ = 0;20 var refDistance = 0;21 var maxDistance = 0;22 var rolloffFactor = 0;23 var coneInnerAngle = 0;24 var coneOuterAngle = 0;25 var coneOuterGain = 0;26 var distanceModel = 0;27 var panningModel = 0;28 var positionX = 0;29 var positionY = 0;30 var positionZ = 0;31 var orientationX = 0;32 var orientationY = 0;33 var orientationZ = 0;34 var velocityX = 0;35 var velocityY = 0;36 var velocityZ = 0;37 var frontX = 0;38 var frontY = 0;39 var frontZ = 0;40 var upX = 0;41 var upY = 0;42 var upZ = 0;43 var refDistance = 0;44 var maxDistance = 0;45 var rolloffFactor = 0;46 var coneInnerAngle = 0;47 var coneOuterAngle = 0;48 var coneOuterGain = 0;49 var distanceModel = 0;50 var panningModel = 0;51 var positionX = 0;52 var positionY = 0;53 var positionZ = 0;54 var orientationX = 0;55 var orientationY = 0;56 var orientationZ = 0;57 var velocityX = 0;58 var velocityY = 0;59 var velocityZ = 0;60 var frontX = 0;61 var frontY = 0;

Full Screen

Using AI Code Generation

copy

Full Screen

1var panner = new mozAudioPannerNode(context, {pan: 0.5});2panner.connect(context.destination);3panner.pan.value = 0.5;4panner.setPosition(1, 1, 1);5panner.setOrientation(1, 1, 1);6var panner = new webkitAudioPannerNode(context, {pan: 0.5});7panner.connect(context.destination);8panner.pan.value = 0.5;9panner.setPosition(1, 1, 1);10panner.setOrientation(1, 1, 1);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require("wptools");2wptools.panner("en.wikipedia.org", "Barack Obama", function (err, result) {3 if (err) {4 console.log("Error: " + err);5 } else {6 console.log(result);7 }8});9var wptools = require("wptools");10wptools.extract("en.wikipedia.org", "Barack Obama", function (err, result) {11 if (err) {12 console.log("Error: " + err);13 } else {14 console.log(result);15 }16});17var wptools = require("wptools");18wptools.extract("en.wikipedia.org", "Barack Obama", function (err, result) {19 if (err) {20 console.log("Error: " + err);21 } else {22 console.log(result);23 }24});25var wptools = require("wptools");26wptools.extract("en.wikipedia.org", "Barack Obama", function (err, result) {27 if (err) {28 console.log("Error: " + err);29 } else {30 console.log(result);31 }32});33var wptools = require("wptools");34wptools.extract("en.wikipedia.org", "Barack Obama", function (err, result) {35 if (err) {36 console.log("Error: " + err);37 } else {38 console.log(result);39 }40});41var wptools = require("wptools");42wptools.extract("en.wikipedia.org", "Barack Obama", function (err, result) {43 if (err) {44 console.log("Error: " + err);45 } else {46 console.log(result);47 }48});49var wptools = require("wptools");50wptools.extract("en.wikipedia.org", "Barack Obama", function (err, result) {51 if (err) {52 console.log("Error: " + err);53 } else {54 console.log(result);55 }56});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('wptoolkit');2wptoolkit.panner('test', 'test1', function (err) {3 if (err) {4 console.log(err);5 }6});7var wptoolkit = require('wptoolkit');8wptoolkit.panner('test1', 'test', function (err) {9 if (err) {10 console.log(err);11 }12});13For more details please refer to the [API](

Full Screen

Using AI Code Generation

copy

Full Screen

1var pan = require('wptoolkit').panner;2pan(1,1,1,1,1,1);3var pan = require('wptoolkit').panner;4pan(1,1,1,1,1,1);5pan(1,1,1,1,1,1);6at Object.<anonymous> (C:\Users\jorge\Documents\GitHub\wptoolkit\examples\test.js:3:1)7at Module._compile (module.js:570:32)8at Object.Module._extensions..js (module.js:579:10)9at Module.load (module.js:487:32)10at tryModuleLoad (module.js:446:12)11at Function.Module._load (module.js:438:3)12at Function.Module.runMain (module.js:604:10)13at startup (bootstrap_node.js:158:16)14var pan = require('wptoolkit').panner;15pan(1,1,1,1,1,1);16var pan = require('wptoolkit').panner;17pan(1,1,1,1,1);18var pan = require('wptoolkit').panner;19pan(1,1,1,1,1,1,

Full Screen

Using AI Code Generation

copy

Full Screen

1var panner = new WPTPan();2panner.init();3panner.pan(0, 0, 0);4var panner = new WPTPan();5panner.init();6panner.pan(0, 0, 0);

Full Screen

Using AI Code Generation

copy

Full Screen

1var toolkit = require('wptoolkit');2var panner = new toolkit.Panner();3panner.setPanning(0.5);4panner.pan(audioElement);5panner.stop();6panner.panLeft(audioElement);7panner.panRight(audioElement);8panner.setPanning(0);9panner.setPanning(1);10panner.setPanning(0.5);11panner.fadeIn(audioElement, 10);12panner.fadeOut(audioElement, 10);13panner.fadeTo(audioElement, 0.5, 10);14panner.getPanning();15panner.getVolume();16panner.setVolume(0.5);17panner.getAudioElement();18var toolkit = require('wptoolkit');19var compressor = new toolkit.Compressor();20compressor.setup();21compressor.connect(audioElement);22compressor.disconnect(audioElement);23compressor.getAudioElement();24compressor.getCompressor();25compressor.setThreshold(-20);26compressor.setKnee(40);27compressor.setRatio(12);28compressor.setAttack(0);29compressor.setRelease(0.25);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful