Lengthening MIDI.js piano note duration

272 Views Asked by At

I'm using MIDI.js to build a music app that allows users to play piano through their keyboard. Everything is working, but the problem I'm having is that the notes (called with MIDI.noteOn) only last 3 seconds, then just cut off. I'm trying to find a way to: 1- Make the note last for longer. 2- Make the note fade to nothing as opposed to just cutting off.

Could anyone point me in the right direction with there? There is so little documentation & discussion on MIDI.js.

Thanks in advance!

EDIT: The instrument name is acoustic_grand_piano

1

There are 1 best solutions below

0
On

In theory, you need to call noteOff at the proper time.

In practice, MIDI.Plugin.js has this:

    // FIX: needs some way to fade out smoothly..
    root.noteOff = function (channel, note, delay) {
//      var source = sources[channel+""+note];
//      if (!source) return;
//      source.noteOff(delay || 0);
//      return source;
    };