add @Miranet's fix for issue #11
https://github.com/mudcube/MIDI.js/issues/11
This commit is contained in:
parent
485a2be277
commit
c97c636cd1
|
@ -4,7 +4,10 @@
|
||||||
--------------------------------------------
|
--------------------------------------------
|
||||||
https://github.com/mudcube/MIDI.js
|
https://github.com/mudcube/MIDI.js
|
||||||
--------------------------------------------
|
--------------------------------------------
|
||||||
APIs:
|
Inspired by javax.sound.midi (albeit a super simple version):
|
||||||
|
http://docs.oracle.com/javase/6/docs/api/javax/sound/midi/package-summary.html
|
||||||
|
--------------------------------------------
|
||||||
|
Technologies:
|
||||||
MIDI.WebMIDIAPI
|
MIDI.WebMIDIAPI
|
||||||
MIDI.WebAudioAPI
|
MIDI.WebAudioAPI
|
||||||
MIDI.Flash
|
MIDI.Flash
|
||||||
|
@ -175,15 +178,16 @@ if (window.AudioContext || window.webkitAudioContext) (function () {
|
||||||
return source;
|
return source;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 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) {
|
||||||
delay = delay || 0;
|
delay = delay || 0;
|
||||||
|
if (delay < ctx.currentTime) delay += ctx.currentTime;
|
||||||
var source = sources[channel + "" + note];
|
var source = sources[channel + "" + note];
|
||||||
if (!source) return;
|
if (!source) return;
|
||||||
|
// @Miranet: "the values of 0.4 and 0.5 could ofcourse be used as
|
||||||
|
// a 'release' parameter for ADSR like time settings."
|
||||||
source.gain.linearRampToValueAtTime(1, delay);
|
source.gain.linearRampToValueAtTime(1, delay);
|
||||||
source.gain.linearRampToValueAtTime(0, delay + 0.75);
|
source.gain.linearRampToValueAtTime(0, delay + 0.4);
|
||||||
source.noteOff(delay + 0.75);
|
source.noteOff(delay + 0.5);
|
||||||
return source;
|
return source;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue