added setPreset to PolySynth

This commit is contained in:
Yotam Mann 2014-09-09 00:40:25 -04:00
parent 06987ea9e6
commit c3cb6af859

View file

@ -7,12 +7,18 @@ function(Tone){
* @class Creates a polyphonic synthesizer out of * @class Creates a polyphonic synthesizer out of
* the monophonic voice which is passed in. * 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 * @constructor
* @extends {Tone} * @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 * @param {function=} [voice=Tone.MonoSynth] the constructor of the voices
* uses Tone.MonoSynth by default * 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(){ Tone.PolySynth = function(){
@ -100,7 +106,7 @@ function(Tone){
Tone.PolySynth.prototype.triggerAttackRelease = function(value, duration, time, velocity){ Tone.PolySynth.prototype.triggerAttackRelease = function(value, duration, time, velocity){
time = this.toSeconds(time); time = this.toSeconds(time);
this.triggerAttack(value, time, velocity); 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} * set volume method borrowed form {@link Tone.Source}
* @function * @function