fix: add 400ms decay to MIDI noteoff for natural release
This commit is contained in:
@@ -436,6 +436,9 @@
|
|||||||
if (!_activeNotes[noteMapKey]) _activeNotes[noteMapKey] = [];
|
if (!_activeNotes[noteMapKey]) _activeNotes[noteMapKey] = [];
|
||||||
if (_activeNotes[noteMapKey].indexOf(ch) === -1) _activeNotes[noteMapKey].push(ch);
|
if (_activeNotes[noteMapKey].indexOf(ch) === -1) _activeNotes[noteMapKey].push(ch);
|
||||||
if (durationMs > 0 && durationMs < 60000) {
|
if (durationMs > 0 && durationMs < 60000) {
|
||||||
|
var releaseMs = 400;
|
||||||
|
var totalDurMs = durationMs + releaseMs;
|
||||||
|
if (totalDurMs > 60000) totalDurMs = 60000;
|
||||||
scheduledNote.off = setTimeout(function () {
|
scheduledNote.off = setTimeout(function () {
|
||||||
try {
|
try {
|
||||||
_fluidModule._fluid_synth_noteoff(_synthPtr, ch, midiPitch);
|
_fluidModule._fluid_synth_noteoff(_synthPtr, ch, midiPitch);
|
||||||
@@ -446,7 +449,7 @@
|
|||||||
if (arr.length === 0) delete _activeNotes[noteMapKey];
|
if (arr.length === 0) delete _activeNotes[noteMapKey];
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}, durSec * 1000);
|
}, totalDurMs);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn("[SonicSF] FluidSynth noteOn error:", e);
|
console.warn("[SonicSF] FluidSynth noteOn error:", e);
|
||||||
|
|||||||
Reference in New Issue
Block a user