简体   繁体   中英

Can't parse MIDI file in Python with music21 library

I'm trying to parse some MIDI files, and nothing happens. It's strange because some files are parsed without any problem and really fast, and some just stuck. I don't know what's the problem because it doesn't show any error, a program just stuck. What are the differences between MIDI files? Why some files can't be parsed?

    midi = converter.parse(file) # some MIDI files just stuck here

    notes_to_parse = None

    try: 
        s2 = instrument.partitionByInstrument(midi)
        notes_to_parse = s2.parts[0].recurse() 
        ...

If you run it in Windows, I think it's a problem about path. Try pass the path like "c:/data/1.mid", not like "data/1.mid", I think it will be solved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM