trying to merge two midi files together so that the note events and track events of each midi file play in sequence. That is, play the first note in the first midi file. Then play the first note in the second midi file. Then play the second note in the first midi file. Then the second note in the second midi file. and so on and so forth.
Currently using drywetmidi but I am not sold on this midi package and if there is another one more suitable to this task I will be happy to try.
What I have tried:
So far the best I have been able to do is read a midi file and creating an (empty) midi file with the following code:
private void button1_Click(object sender, EventArgs e)
{
var midiFile = MidiFile.Read(midFilIn0);
try
{
midiFile.Write(midFilOut);
}
catch (IOException ioExp)
{
var midi = MidiFile.Read("f:\\Midi Files\\My Future Great Song.mid");
var outputDevice = OutputDevice.GetByName("Microsoft GS Wavetable Synth");
_playback = midi.GetPlayback(outputDevice);
_playback.Start();
SpinWait.SpinUntil(() => !_playback.IsRunning);
MessageBox.Show(ioExp.ToString());
File.Delete(midFilOut);
midiFile.Write(midFilOut);
}
}
All this does, however, is open a midi file and creating an (empty) midi file and does not make a copy of anything. Once I figure out how to create a copy of the file, then I can simply open the second file and merge it with the first.
Any help will be greatly appreciated.