yjmidi
midi file parser/player
Usage
CommonJS require()
is not supported in version 3.0.0-rc1 or higher.
import fs from 'fs';
import { MidiFile, MidiPlayer } from 'yjmidi';
let midi = fs.readFileSync('...');
let file = new MidiFile(midi);
file.header.format;
file.header.ticksPerBeat;
file.header.tickResolution;
file.header.tracksCount;
file.durationTick;
file.durationMs;
file.tracks;
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();