Enabled noteOff with a linear fade to 0

fade out smoothly using gain and ramping to value.

I've chosen an arbitrary amount to fade by here, which I guess isn't great.
This commit is contained in:
Pete Otaqui 2012-11-21 06:19:25 +03:00
parent 37684b82c5
commit 15d4d0cb1e

View file

@ -102,11 +102,14 @@ if (window.AudioContext || window.webkitAudioContext) (function () {
}; };
// FIX: needs some way to fade out smoothly.. // FIX: needs some way to fade out smoothly..
// POSSIBLE FIX: fade out smoothly using gain and ramping to value
root.noteOff = function (channel, note, delay) { root.noteOff = function (channel, note, delay) {
// var source = sources[channel+""+note]; var source = sources[channel+""+note];
// if (!source) return; if (!source) return;
// source.noteOff(delay || 0); source.gain.linearRampToValueAtTime(1, delay);
// return source; source.gain.linearRampToValueAtTime(0, delay + 0.1);
source.noteOff(delay || 0);
return source;
}; };
root.chordOff = function (channel, chord, delay) { root.chordOff = function (channel, chord, delay) {