melanchall / drywetmidi

.NET library to read, write, process MIDI files and to work with MIDI devices
https://melanchall.github.io/drywetmidi
MIT License
540 stars 75 forks source link

How to combin 2 midifile? #228

Closed tramper2 closed 1 year ago

tramper2 commented 1 year ago

Hello~

i have a piano midi file and a drum midi file.

i want to combin two midi file into one midi file.

what is the best way?

Thanks Danny

melanchall commented 1 year ago

Hello,

Please attach those two files to the issue.

Thanks, Max

tramper2 commented 1 year ago

Drum_pt4_4_hi-hats.zip Hi it is zip file and two midi file length is different. Thanks

melanchall commented 1 year ago

Unfortunately your files have different tempo maps (different time divisions, different tempo) so there is no way to merge files easily. Merging is possible but it's pretty complex algorithm to preserve both tempos and I have no time right now to implement it. I have such plans but for future releases.

In general you need to reduce both time divisions to least common multiple and handle all tempo and time signature changes (depending on what time type you need to preserve – seconds, bars/beats or smth else).

tramper2 commented 1 year ago

Unfortunately your files have different tempo maps (different time divisions, different tempo) so there is no way to merge files easily. Merging is possible but it's pretty complex algorithm to preserve both tempos and I have no time right now to implement it. I have such plans but for future releases.

In general you need to reduce both time divisions to least common multiple and handle all tempo and time signature changes (depending on what time type you need to preserve – seconds, bars/beats or smth else).

oh i understand~ thanks!