diff --git a/app/static/js/services/soundfontPlayer.js b/app/static/js/services/soundfontPlayer.js index bdaf5a4..281b7b3 100644 --- a/app/static/js/services/soundfontPlayer.js +++ b/app/static/js/services/soundfontPlayer.js @@ -356,6 +356,7 @@ var midiVel = Math.min(127, Math.max(1, Math.floor( typeof velocity === 'number' ? (velocity > 1 ? velocity : velocity * 127) : 100 ))); + var _origChannel = channel; var ch = channel; var usedBank = 0, usedProg = 0; if (synthEngine) { @@ -375,7 +376,6 @@ try { _fluidModule._fluid_synth_program_change(_synthPtr, ch, usedProg); } catch (e) {} - if (channel === undefined) channel = ch; } else if (program !== undefined) { usedProg = program; if (ch === undefined) ch = 0; @@ -394,13 +394,13 @@ try { console.log("[SonicSF] noteOn ch:", ch, "pitch:", midiPitch, "vel:", midiVel); _fluidModule._fluid_synth_noteon(_synthPtr, ch, midiPitch, midiVel); - _activeNotes[(channel !== undefined ? channel : 0) + ':' + midiPitch] = ch; - var noteMapKey = (channel !== undefined ? channel : 0) + ':' + midiPitch; + _activeNotes[(_origChannel !== undefined ? _origChannel : 0) + ':' + midiPitch] = ch; + var noteMapKey = (_origChannel !== undefined ? _origChannel : 0) + ':' + midiPitch; if (durationMs > 0 && durationMs < 60000) { scheduledNote.off = setTimeout(function () { try { _fluidModule._fluid_synth_noteoff(_synthPtr, ch, midiPitch); - delete _activeNotes[noteMapKey]; + delete _activeNotes[(_origChannel !== undefined ? _origChannel : 0) + ':' + midiPitch]; } catch (e) {} }, durSec * 1000); }