mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 16:48:00 +00:00
new class PanVol. combined Pan and Vol
useful for making stereo mixer-type things
This commit is contained in:
parent
7e09fc6931
commit
f1593c1a29
1 changed files with 57 additions and 0 deletions
57
Tone/component/PanVol.js
Normal file
57
Tone/component/PanVol.js
Normal file
|
@ -0,0 +1,57 @@
|
|||
define(["Tone/core/Tone", "Tone/component/Panner", "Tone/source/Source"], function(Tone){
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* @class A Panner and volume in one
|
||||
*
|
||||
* @extends {Tone}
|
||||
* @constructor
|
||||
*/
|
||||
Tone.PanVol = function(pan, volume){
|
||||
/**
|
||||
* the panning node
|
||||
* @type {Tone.Panner}
|
||||
*/
|
||||
this.pan = this.input = new Tone.Panner(pan);
|
||||
|
||||
/**
|
||||
* the volume node
|
||||
* @type {GainNode}
|
||||
*/
|
||||
this.vol = this.output = this.context.createGain();
|
||||
|
||||
//connections
|
||||
this.pan.connect(this.vol);
|
||||
this.setVolume(this.defaultArg(volume, 0));
|
||||
};
|
||||
|
||||
Tone.extend(Tone.PanVol);
|
||||
|
||||
/**
|
||||
* borrows the source's set volume
|
||||
* @function
|
||||
*/
|
||||
Tone.PanVol.prototype.setVolume = Tone.Source.prototype.setVolume;
|
||||
|
||||
/**
|
||||
* set the panning
|
||||
* @param {number} pan 0-1 L-R
|
||||
*/
|
||||
Tone.PanVol.prototype.setPan = function(pan){
|
||||
this.pan.setPan(pan);
|
||||
};
|
||||
|
||||
/**
|
||||
* clean up
|
||||
*/
|
||||
Tone.PanVol.prototype.dispose = function(){
|
||||
Tone.prototype.dispose.call(this);
|
||||
this.pan.dispose();
|
||||
this.pan = null;
|
||||
this.vol.disconnect();
|
||||
this.vol = null;
|
||||
};
|
||||
|
||||
return Tone.PanVol;
|
||||
});
|
Loading…
Reference in a new issue