In this issue of the
midly crate, GitHub user Dimev asks how to use
midly to play back a midi file. This requires several steps:
a.1. Parsing the midi file. This is what
a.2. Converting the delta times into “absolute” times
a.3. Merging all the tracks
a.4. Looping over the midi events and actually producing sounds or sending the midi events to a midi device.
Step a.4. (sending the midi events) depends heavily on what system you’re working with (Linux/Windows/Mac OS/…) and there are already crates for that purpose (e.g. jack, alsa, …). So what remains are steps a.2. and a.3. As it happens, I’ve already implemented steps a.2. and a.3. in
rsynth (“cutting edge” version, not in the version released on crates.io). Now I don’t think
rsynth is the appropriate place.
midly maintainer negamartin doesn’t seem to be eager to include this functionality either.
So how to proceed with this? Any ideas? The most logical thing currently seems to implement a.2. and a.3. in a separate crate, maybe with the name
midly-player. Now there’s also the converse problem of recording midi. For this you would need the converse:
b.1. Capturing midi events from a midi device (can be done with existing crates)
b.2. Converting absolute time into relative time.
b.3. Split tracks (optionally)
b.4. Save the tracks to a file (can be done with
So then we can also create a crate that does a.2. and a.3., maybe with the name
midly-recorder. Now, converting times would be a shared functionality between
midly-recorder, so we can split that off in a separate crate, let’s call it
So then a typical dependency tree would look like the following for a crate that plays midi files
(your crate that plays midi files) ├── midly-player │ ├── time-conversion │ └── midly ├── alsa or jack or ... └── ... (other dependencies)
A typical dependency tree would look like the following for a crate that records midi files
(your crate that records midi files) ├── midly-recorder │ ├── time-conversion │ └── midly ├── alsa or jack or ... └── ... (other dependencies)
Any thoughts, opinions or suggestions?