Open wileymc opened 8 months ago
Hi @wileymc, there isn't currently a way to read a MIDI file into this library and modify its contents. Given the serial nature of adding events with MidiWriterJS I'm not sure how modifying an existing MIDI file would work exactly. Do you have any thoughts about how that would look?
The way I imagine it being used would look something like this:
const write = new MidiWriter.Writer(track);
const uri = write.dataUri();
const track = new MidiWriter.Track().fromUri();
track.addEvent(
new MidiWriter.ProgramChangeEvent({ instrument: 5 })
);
For the implementation, I think something similar to what tonejs has done here would be possible but may be difficult given MidiWriters current architecture.
I've found a case where I need to take a URI generated by MidiWriterJS and modify it and output an updated URI. Is there a good way to do this with the existing library functionality? If not, I propose a new
Reader
class that accepts a URI or File as an input and generates the Track object from it. I can take a shot at the implementation.