Closed tomhaydn closed 9 months ago
It's likely because it's saved as .midi
rather than .mid
Hey @tomhaydn,
It looks like the issue is that you're passing a string for startTick
, but that parameter only accepts a number. Apologies if that isn't as well documented as it could be.
Here's your code adjusted and tested with Abelton Live 11:
var MidiWriter = require('midi-writer-js');
const fs = require('fs');
const createTrack = async (notes) => {
const track = new MidiWriter.Track();
track.setTempo(120, 0);
track.addCopyright('TEST');
track.addTrackName('Track 1');
notes.forEach((note) => {
const noteToAdd = new MidiWriter.NoteEvent(note);
track.addEvent(noteToAdd);
});
const writer = new MidiWriter.Writer(track);
const buffer = Buffer.from(writer.buildFile());
try {
await fs.writeFileSync('TEST.mid', buffer);
} catch (err) {
if (err) throw err;
}
};
createTrack([{pitch: 'C4', startTick: 44, duration: 'T4', velocity: 100}]);
From my research I've found that Ableton supports 3 formats SMF0, SMF1, SMF2: https://help.ableton.com/hc/en-us/articles/209068169-Understanding-MIDI-files
However files do not import, Ableton seems to just reject them with no error message or details. See my export function:
notes format:
System: PC Node version: v16.15.0
If there are any more details I can provide let me know! Really want to see this work :)