Open jochemstoel opened 7 years ago
@jochemstoel I don't think it is doable out of the box right now. Any PR allowing to do so would be merged.
Here is how I read that. Currently, the event with a subtype of EVENT_META_TRACK_NAME has the data
property. Just need to convert it to a string.
import MidiEvents from "midievents";
import UTF8 from "utf-8";
import MidiFile from "midifile";
const midi = new MidiFile(this.arrayBuffer);
const events = midi.getEvents();
events.forEach(event => {
if (event.subtype === MidiEvents.EVENT_META_TRACK_NAME) {
const text = UTF8.getStringFromBytes(event.data, 0, event.length, true);
this.song.header.name.push(text);
}
})
Thank you for creating NPM package midifile. I read the 'documentation' and had a quick browse through the code but did not find an answer there.
How do I read the names of separate tracks of the MIDI file as a String? By names I mean the optional label assigned to the track by the creator of the file. For example
drums
oracoustic guitar one
orvocals
.Thanks in advance.