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

Write Type 0 & Type 1 MIDI Files #144

Open
gburlet opened this issue Jun 10, 2018 · 3 comments
Open

Write Type 0 & Type 1 MIDI Files #144

gburlet opened this issue Jun 10, 2018 · 3 comments

Comments

@gburlet
Copy link

gburlet commented Jun 10, 2018

Currently the write function only writes Type 1 MIDI files. Allow parameter in write function to also save Type 0 MIDI files.

@craffel
Copy link
Owner

craffel commented Jun 10, 2018

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.

@fzalkow
Copy link

fzalkow commented Jul 28, 2020

@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)

@Majda995
Copy link

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)

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

4 participants