mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 16:48:00 +00:00
added setPreset to PolySynth
This commit is contained in:
parent
06987ea9e6
commit
c3cb6af859
1 changed files with 18 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue