Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions js/midi/plugin.webaudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@
}

/// convert relative delay to absolute delay
if (delay < ctx.currentTime) {
delay += ctx.currentTime;
}
delay += ctx.currentTime;

/// create audio buffer
if (useStreamingBuffer) {
Expand Down Expand Up @@ -128,9 +126,7 @@
var bufferId = instrument + '' + noteId;
var buffer = audioBuffers[bufferId];
if (buffer) {
if (delay < ctx.currentTime) {
delay += ctx.currentTime;
}
delay += ctx.currentTime;
///
var source = sources[channelId + '' + noteId];
if (source) {
Expand Down Expand Up @@ -185,9 +181,7 @@
midi.stopAllNotes = function() {
for (var sid in sources) {
var delay = 0;
if (delay < ctx.currentTime) {
delay += ctx.currentTime;
}
delay += ctx.currentTime;
var source = sources[sid];
source.gain.linearRampToValueAtTime(1, delay);
source.gain.linearRampToValueAtTime(0, delay + 0.3);
Expand Down Expand Up @@ -323,4 +317,4 @@
return new (window.AudioContext || window.webkitAudioContext)();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please merge this bugfix into mainstream. I was trying to play Javascript generated melodies with MIDI.js and it took me 1 hour just to find this bug, which prevents MIDI.js to work correctly, so this bug-report must be accepted.

};
})();
})(MIDI);
})(MIDI);