
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
midi file parser/player
// use require() if you are using CommonJS module
import fs from 'fs';
import { MidiFile, MidiPlayer } from 'yjmidi';
let midi = fs.readFileSync('...'); // your midi file. it can be an ArrayBuffer or Uint8Array or nodejs Buffer
let file = new MidiFile(midi); // MidiFile instance
file.header.format; // 0,1 or 2
file.header.ticksPerBeat; // If division is frames per seconds, this is null
file.header.tickResolution; // microseconds per tick
file.header.tracksCount; // n
file.header.durationTick; // duration in tick
file.header.durationMs; // duration in ms
file.ports; // the tracks separated by port
file.tempoEvents; // "set tempo" events
/**
* Playing midi files
*/
let player = new MidiPlayer(); // MidiPlayer instance
player.loadMidi(midi); // loading a midi file
player.on('midievent', (event, portnum, message) => {
event; // information of event
portnum; // port number
message; // midi message. if it is null, the 'event' may be a meta event
});
player.play();
player.pause();
player.tempo; // similar to HTMLMediaElement.playbackRate
player.durationTick; // same as MidiFile.header.durationTick
player.durationMs; // same as MidiFile.header.durationMs
player.currentTick;
player.currentMs;
let buf2 = fs.readFileSync('....'); // another midi file
let midi3 = new MidiFile(buf2);
player.loadMidi(midi3); // insert an instance of MidiFile
player.play();
FAQs
midi file parser/player
We found that yjmidi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.