mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 16:48:00 +00:00
adding triggerAttackRelease method
Instrument one does not work with MultiSampler since a note is required as the first argument
This commit is contained in:
parent
91734d23c7
commit
0a42b3ef54
1 changed files with 16 additions and 0 deletions
|
@ -148,6 +148,22 @@ define(["Tone/core/Tone", "Tone/instrument/Instrument", "Tone/core/Buffers", "To
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Invoke the attack phase, then after the duration, invoke the release.
|
||||
* @param {Frequency} note The note to play
|
||||
* @param {Time} duration The time the note should be held
|
||||
* @param {Time=} time When to start the attack
|
||||
* @param {NormalRange} [velocity=1] The velocity of the attack
|
||||
* @return {Tone.MultiSampler} this
|
||||
*/
|
||||
Tone.MultiSampler.prototype.triggerAttackRelease = function(note, duration, time, velocity){
|
||||
time = this.toSeconds(time);
|
||||
duration = this.toSeconds(duration);
|
||||
this.triggerAttack(note, time, velocity);
|
||||
this.triggerRelease(note, time + duration);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Add a note to the sampler.
|
||||
* @param {Note|Midi} note The buffer's pitch.
|
||||
|
|
Loading…
Reference in a new issue