diff --git a/Tone/component/Panner.js b/Tone/component/Panner.js index 90830cf3..dd77f0f2 100644 --- a/Tone/component/Panner.js +++ b/Tone/component/Panner.js @@ -19,8 +19,9 @@ import "../core/AudioNode"; * //pan the input signal hard right. * var panner = new Tone.Panner(1); */ -Tone.Panner = function(initialPan){ +Tone.Panner = function(){ + var options = Tone.defaults(arguments, ["pan"], Tone.Panner); Tone.AudioNode.call(this); /** * the panner node @@ -37,12 +38,22 @@ Tone.Panner = function(initialPan){ this.pan = this._panner.pan; //initial value - this.pan.value = Tone.defaultArg(initialPan, 0); + this.pan.value = options.pan; this._readOnly("pan"); }; Tone.extend(Tone.Panner, Tone.AudioNode); +/** + * Defaults + * @type {Object} + * @const + * @static + */ +Tone.Panner.defaults = { + "pan" : 0 +}; + /** * Clean up. * @returns {Tone.Panner} this diff --git a/test/component/Panner.js b/test/component/Panner.js index 9cfc0c9e..44046aa5 100644 --- a/test/component/Panner.js +++ b/test/component/Panner.js @@ -29,6 +29,14 @@ describe("Panner", function(){ panner.dispose(); }); + it("can be constructed with an options object", function(){ + var panner = new Panner({ + "pan" : 0.5 + }); + expect(panner.pan.value).to.be.closeTo(0.5, 0.001); + panner.dispose(); + }); + it("passes the incoming signal through", function(){ return PassAudio(function(input){ var panner = new Panner().toMaster();