yjmidi
midi/yjk file parser/player
About yjk file
The yjk(YJKaraoke) file is a file format created for use in yj-karaoke-player.
Usage
const fs = require('fs');
const { MidiFile,YJKFile,MidiPlayer,YJKFileConverter } = 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 yjk = fs.readFileSync('...');
let file2 = new YJKFile(yjk);
file2.header;
file2.globalEvents;
file2.tempoEvents;
file2.ports;
let midi2 = fs.readFileSync('...');
fs.writeFileSync('./test.yjk',YJKFileConverter.midi2yjk(midi2));
let player = new MidiPlayer();
player.loadMidi(midi);
player.loadYJK(yjk);
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.