I am new to working with MIDI in my javascript code, and I would like to create an application that simply generates a MIDI file based on the user's input. I have looked at using MIDI.js, but I'm not sure if I need any of the library. Ideally, I would like to be able to work with note values rather than hexadecimal MIDI codes... would I need to use the converter within plugin.js
?
My current research has indicated that generated soundfonts are the suggested way to go; however, I would like to export/generate a MIDI file for use in a professional DAW.
Thanks for any help.
Export one or more MIDI regions as standard MIDI files In Logic Pro, select the MIDI regions to export. Choose File > Export > Selection as MIDI File. Choose the destination directory, enter a name, then click Save. The selected MIDI regions are saved as a Format 1 MIDI file.
The MIDI data is stored in separate tracks, which are additionally wrapped in containers, so it's possible to have e.g. several tracks using the same MIDI channels.
You can use a library I found called MidiWriterJS.
It is very easy to use:
The easiest way to insall is to use npm.
$ npm install midi-writer-js
Then
var MidiWriter = require('midi-writer-js');
var tracks = [];
for(t of <your existing track array>){
var notes = [];
for(n of <your existing note array for the track>){
notes.push(new MidiWriter.NoteEvent({pitch: <array of all notes in the chord>, duration: <how long the chord should last>});
}
var newTrack = new MidiWriter.Track();
newTrack.addEvent(notes, function(event, index){ return {sequential: true}; });
tracks.push(newTrack);
}
var writer = new MidiWriter.Writer(tracks);
writer.saveMIDI(<filename>);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With