Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Midi Reader Implementation #130

Open
wileymc opened this issue Feb 1, 2024 · 2 comments
Open

Midi Reader Implementation #130

wileymc opened this issue Feb 1, 2024 · 2 comments

Comments

@wileymc
Copy link

wileymc commented Feb 1, 2024

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.

@grimmdude
Copy link
Owner

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?

@wileymc
Copy link
Author

wileymc commented Feb 5, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants