From c3cb6af859a6b0d4d425dbe6250fe1f865c0326e Mon Sep 17 00:00:00 2001 From: Yotam Mann Date: Tue, 9 Sep 2014 00:40:25 -0400 Subject: [PATCH] added setPreset to PolySynth --- Tone/instrument/PolySynth.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Tone/instrument/PolySynth.js b/Tone/instrument/PolySynth.js index 4930dba0..58ee6bba 100644 --- a/Tone/instrument/PolySynth.js +++ b/Tone/instrument/PolySynth.js @@ -7,12 +7,18 @@ function(Tone){ * @class Creates a polyphonic synthesizer out of * the monophonic voice which is passed in. * + * @example + * //a polysynth composed of 6 Voices of MonoSynth + * var synth = new Tone.PolySynth(6, Tone.MonoSynth); + * //set the MonoSynth preset + * synth.setPreset("Pianoetta"); + * * @constructor * @extends {Tone} - * @param {number|Object} [polyphony=6] the number of voices to create + * @param {number|Object=} [polyphony=4] the number of voices to create * @param {function=} [voice=Tone.MonoSynth] the constructor of the voices * uses Tone.MonoSynth by default - * @param {Object} voiceOptions the options to pass to the voice + * @param {Object=} voiceOptions the options to pass to the voice */ Tone.PolySynth = function(){ @@ -100,7 +106,7 @@ function(Tone){ Tone.PolySynth.prototype.triggerAttackRelease = function(value, duration, time, velocity){ time = this.toSeconds(time); this.triggerAttack(value, time, velocity); - this.triggerRelease(time + this.toSeconds(duration)); + this.triggerRelease(value, time + this.toSeconds(duration)); }; /** @@ -129,6 +135,15 @@ function(Tone){ } }; + /** + * @param {string} presetName the preset name + */ + Tone.PolySynth.prototype.setPreset = function(presetName){ + for (var i = 0; i < this._voices.length; i++){ + this._voices[i].setPreset(presetName); + } + }; + /** * set volume method borrowed form {@link Tone.Source} * @function