This will only work when Web MIDI API is enabled.(https://caniuse.com/#feat=midi)
$ npm install web-midi-recording
const { MIDIRecording } = require('web-midi-recording');
MIDIRecording.attachHandler(InputMIDIDevice);
MIDIRecording.startRecording();
MIDIRecording.stopRecording()
const smfData = MIDIRecording.getSMF();
Copyright (c) 2020 cagpie cagpie@gmail.com
Code licensed under the MIT License: http://opensource.org/licenses/MIT