Reading a MIDI file in Python

后端 未结 6 2576
被撕碎了的回忆
被撕碎了的回忆 2021-02-20 06:26

I want to be able to read events from a MIDI file in Python. I have looked for libraries, but can\'t find one that works with my MIDI file in windows. I do not need to do anythi

相关标签:
6条回答
  • 2021-02-20 06:29

    I once wrote a simple library in pure C to read/write Midifiles. If you want to have a look here it is: http://code.google.com/p/middl/

    It is a low level library that ease the task of dealing with midifiles but you should be familiar with the Midi file formaat to use it.

    0 讨论(0)
  • 2021-02-20 06:41

    There is a library called mido which is good for reading these files: https://pypi.python.org/pypi/mido/1.1.11

    0 讨论(0)
  • 2021-02-20 06:43

    Check out this python library on github, it seems to do exactly what you need:

    https://github.com/vishnubob/python-midi

    0 讨论(0)
  • 2021-02-20 06:48

    Your best bet might be to get a c or c++ library, and interact with it using the Python Extensions for c.

    0 讨论(0)
  • 2021-02-20 06:49

    the structure of a midi file is quite simple. if you can't find a ready-made library (i am not aware of any) and you only need events and time, i suggest you try parsing the file yourself.

    (prepare for a lot of bit shifting: MIDI data are stored in strings of 7 bits blocks)

    also, you say that you can't find a library which works with your MIDI file on Windows: MIDI file are supposed to be portable, and python too, so a un*x lib should work equally well on windows (or the developper missed the point of both MIDI and python).

    0 讨论(0)
  • 2021-02-20 06:52

    Just pip install mido then:

    import mido
    
    m = mido.MidiFile('tuba.mid')
    
    0 讨论(0)
提交回复
热议问题