yjmidi
midi file parser/player
Usage
const fs = require('fs');
const { MidiFile,MidiPlayer } = require('yjmidi');
let midi = fs.readFileSync('...');
let file = new MidiFile(midi);
file.header.format;
file.header.ticksPerBeat;
file.header.tickResolution;
file.header.tracksCount;
file.header.durationTick;
file.header.durationMs;
file.ports;
file.tempoEvents;
let player = new MidiPlayer();
player.loadMidi(midi);
player.on('midievent',(event,portnum,message) => {
event;
portnum;
message;
});
player.play();
player.pause();
player.tempo;
player.durationTick;
player.durationMs;
player.currentTick;
player.currentMs;
let buf2 = fs.readFileSync('....');
let midi3 = new MidiFile(buf2);
player.loadMidi(midi3);
player.play();
Others
This library is using midifile to parse midi files.