Generate a MIDI file with jsmidgen
mainTo generate a MIDI file, create a Midi.File instance, add one or more Midi.Track objects to it, and populate the tracks with musical events (notes, instrument changes, tempo, etc.). Finally, use toBytes() or toUint8Array() to serialize the file for saving or transmission.
Note that time and duration are measured in "ticks". The library uses a hardcoded value of 128 ticks per beat (e.g., a quarter note has a duration of 128).
var fs = require('fs');
var Midi = require('jsmidgen');
var file = new Midi.File();
var track = new Midi.Track();
file.addTrack(track);
track.addNote(0, 'c4', 64);
fs.writeFileSync('test.mid', file.toBytes(), 'binary');