Open gburlet opened 6 years ago
Not all PrettyMIDI
objects will be writeable as type 0 files since they can have more than 16 instruments. You could implement this and throw an error if there are too many instruments. I do not plan on implementing this.
@gburlet I also had the use case of writing type 0 files. However, instead of extending the writing functionalities of pretty_midi, I just used mido to convert from type 1 to type 0.
def midi_type1_to_type0(infile, outfile):
type1 = mido.MidiFile(infile)
type0 = mido.merge_tracks(type1.tracks)
new_file = mido.MidiFile(type=0)
new_file.tracks.append(type0)
new_file.save(outfile)
when i convert Midi files type 1 to type 0 the new file (outfile )will not have the same length as the orignal one (infile)
Currently the write function only writes Type 1 MIDI files. Allow parameter in write function to also save Type 0 MIDI files.