(See Roadmap for future plans.)
- bugfix: RtMidi backend ignored
apiargument. (Fix by Tom Feist, pull request #91.)
- fixed outdated python-rtmidi install instructions. (Reported by Christopher Arndt, issue #87.)
- typo and incorrect links in docs fixed by Michael (miketwo) (pull requests #84 and #85).
- bugfix: sysex data was broken in string format encoding and decoding. The data was encoded with spaces (‘data=(1, 2, 3)’) instead of as one word (‘data=(1,2,3)’).
- added some tests for string format.
BaseOutput.send()raised string instead of
bugfix: IO port never received anything when used with RtMidi backend. (Reported by dagargo, issue #83.)
This was caused by a very old bug introduced in 1.0.3. IOPort mistakenly called the inner method
self.input.receive(). This happens to work for ports that override
_receive()but not for the new RtMidi backend which overrides
receive(). (The default implementation of
_receive()just drops the message on the floor.)
bugfix: PortMidi backend was broken due to missing import (
ctypes.byref). (Introduced in 1.2.0.)
New implementation of messages and parser:
- completely reimplemented messages. The code is now much simpler, clearer and easier to work with.
- new contructors
- new message attributes
Frozen (immutable) messages:
FrozenMetaMessage. These are immutable versions of
MetaMessagethat are hashable and thus can be used as dictionary keys. These are available in
mido.frozen. (Requested by Jasper Lyons, issue #36.)
RtMidi is now the default backend:
switched default backend from PortMidi to RtMidi. RtMidi is easier to install on most systems and better in every way.
If you want to stick to PortMidi you can either set the environment variable
mido.set_backend('mido.backends.portmidi')in your program.
refactored the RtMidi backend to have a single
Portclass instead of inheriting from base ports. It was getting hard to keep track of it all. The code is now a lot easier to reason about.
you can now pass
client_namewhen opening RtMidi ports:
open_output('Test', client_name='My Client'). When
client_nameis passed the port will automatically be a virtual port.
LINUX_ALSAyou can now omit client name and ALSA client/port number when opening ports, allowing you to do
mido.open_output('TiMidity port 0')instead of
mido.open_output('TiMidity:TiMidity port 0 128:0'). (See RtMidi backend docs for more.)
Changes to the port API:
- ports now have
- new functions
second2tick(). (By Carl Thomé, pull request #71.)
BasePort. You can set this to
Falsein a subclass to do your own locking.
_receive()is now allowed to return a messages. This makes the API more consistent and makes it easier to implement thread safe ports.
pending()is gone. This had to be done to allow for the new
- improved MIDI file documentation. (Written by Carl Thomé.)
- bugfix: if a port inherited from both
BaseOutputthis would cause
BasePort.__init__()to be called twice, which means
self._open()was also called twice. As a workaround
BasePort.__init__()will check if
mido.set_backend()can now be called with
MAX_SONGPOSare now available in the top level module (for example
- added experimental new backend
mido.backends.amidi. This uses the ALSA
amidicommand to send and receive messages, which makes it very inefficient but possibly useful for sysex transfer.
- added new backend
mido.backends.rtmidi_python(previously available in the examples folder.) This uses the
rtmidi-pythonpackage instead of
python-rtmidi. For now it lacks some of features of the
rtmidibackend, but can still be useful on systems where
python-rtmidiis not available. (Requested by netchose, issue #55.)
- bugfix: PortMidi backend was broken on macOS due to a typo. (Fix by Sylvain Le Groux, pull request #81.)
read_syx_file()didn’t handle ‘n’ in text format file causing it to crash. (Reported by Paul Forgey, issue #80.)
- the bugfix in 1.1.20 broke blocking receive() for RtMidi. Reverting the changes. This will need some more investigation.
- bugfix: MidiFile save was broken in 1.1.20 due to a missing import.
bugfix: close() would sometimes hang for RtMidi input ports. (The bug was introduced in 1.1.18 when the backend was rewritten to support true blocking.)
Numpy numbers can now be used for all message attributes. (Based on implementation by Henry Mao, pull request #78.)
The code checks against numbers.Integral and numbers.Real (for the time attribute) so values can be any subclass of these.
- Pygame backend can now receive sysex messages. (Fix by Box of Stops.)
libportmidi.dylibwas not found when using MacPorts. (Fix by yam655, issue #77.)
SocketPort.__init()was not calling
IOPort.__init__()which means it didn’t get a
self._lock. (Fixed by K Lars Lohn, pull request #72. Also reported by John J. Foerch, issue #79.)
- fixed typo in intro example (README and index.rst). Fix by Antonio Ospite (pull request #70), James McDermott (pull request #73) and Zdravko Bozakov (pull request #74).
- fixed typo in virtual ports example (Zdravko Bozakov, pull request #75.)
timeis included in message comparison.
msg1 == msg2will now give the same result as
str(msg1) == str(msg2)and
This means you can now compare tracks wihout any trickery, for example:
mid1.tracks == mid2.tracks.
If you need to leave out time the easiest was is
msg1.bytes() == msg2.bytes().
This may in rare cases break code.
end_of_trackmessages in MIDI files were not handled correctly. (Reported by Colin Raffel, issue #62).
merge_tracks()dropped messages after the first
end_of_trackmessage. The new implementation removes all
end_of_trackmessages and adds one at the end, making sure to adjust the delta times of the remaining messages.
refactored MIDI file code.
mido-playnow has a new option
-m / --print-messageswhich prints messages as they are played back.
SocketPortuse it so it should be public.
Parser()now takes an option arugment
datawhich is passed to
- RtMidi now supports true blocking
receive()in Python 3. This should result in better performance and lower latency. (Thanks to Adam Roberts for helping research queue behavior. See issue #49 for more.)
MidiTrack.copy()(Python 3 only) returned
- fixed example
queue_port.pywhich broke when locks where added.
MidiTrackcrashed instead of returning a message on
track[index]. Fix by Colin Raffel (pull request #61).
*will return tracks instead of lists.
poll()method to input ports as a shortcut for
rtmidi_python_backend.py, a backend for the rtmidi-python package (which is different from the python-rtmidi backend that Mido currently uses.) This may at some point be added to the package but for now it’s in the examples folder. (Requested by netchose, issue #55.)
_import_module(). Its only function was to make import errors more informative by showing the full module path, such as
ImportError: mido.backends.rtmidiinstead of just
ImportError: rtmidi. Unfortunately it ended up masking import errors in the backend module, causing confusion.
importlib.import_module()can be called with the full path, and on Python 3 it will also display the full path in the
Sending and receiving messages is now thread safe. (Initial implementation by Adam Roberts.)
__init__from the wrong class. (Fix by Nathan Hurst.)
MidiTrack()now takes a as a parameter an iterable of messages. Examples:
MidiTrack(messages) MidiTrack(port.iter_pending()) MidiTrack(msg for msg in some_generator)
MidiTrack. (It used to return a
Added the ability to use file objects as well as filenames when reading, writing and saving MIDI files. This allows you to create a MIDI file dynamically, possibly not using mido, save it to an io.BytesIO, and then play that in-memory file, without having to create an intermediate external file. Of course the memory file (and/or the MidiFile) can still be saved to an external file. (Implemented by Brian O’Neill.)
PortMidi backend now uses pm.lib.Pm_GetHostErrorText() to get host error messages instead of just the generic “PortMidi: `Host error’”. (Implemented by Tom Manderson.)
Thanks to Richard Vogl and Tim Cook for reporting errors in the docs.
bugfix: merge_tracks() concatenated the tracks instead of merging them. This caused tracks to be played back one by one. (Issue #28, reported by Charles Gillingham.)
added support for running status when writing MIDI files. (Implemented by John Benediktsson.)
rewrote the callback system in response to issues #23 and #25.
there was no way to set a callback function if the port was opened without one. (Issue#25, reported by Nils Werner.)
Callbacks can now be set and cleared at any time by either passing one to
open_input()or updating the
This causes some slight changes to the behavior of the port when using callbacks. Previously if you opened the port with a callback and then set
port.callback = Nonethe callback thread would keep running but drop any incoming messages. If you do the same now the callback thread will stop and the port will return normal non-callback behavior. If you want the callback thread to drop messages you can set
port.callback = lambda message: None.
receive()no longer checks
self.callback. This was inconsistent as it was the only method to do so. It also allows ports that don’t support callbacks to omit the
bugfix: closing a port would sometimes cause a segfault when using callbacks. (Issue #24, reported by Francesco Ceruti.)
bugfix: Pygame ports were broken due to a faulty check for
IOErrorif you pass
callbackwhile opening a port and the backend doesn’t support them. (An unsupported argument is not an IO error.)
fixed some errors in backend documentation. (Pull request #23 by velolala.)
MultiPortnow has a
yield_portargument just like
- the PortMidi backend will now return refresh the port list when you ask for port names are open a new port, which means you will see devices that you plug in after loading the backend. (Due to limitations in PortMidi the list will only be refreshed if there are no open ports.)
tempo2bpm()was broken and returned the wrong value for anything but 500000 microseconds per beat (120 BPM). (Reported and fixed by Jorge Herrera, issue #21)
merge_tracks()didn’t work with empty list of tracks.
- added proper keyword arguments and doc strings to open functions.
- raises IOError if you try to open a virtual port with PortMidi or Pygame. (They are not supported by these backends.)
- removed undocumented method
MidiFile.get_messages(). (Replaced by
self.callbackwhich didn’t exist for all ports, causing an
- fixed error in documentation (patch by Michael Silver).
- added notes about channel numbers to documentation (reported by ludwig404 / leonh, issue #18).
- bugfix: MidiFile.length was computer incorrectly.
- bugfix: tempo changes caused timing problems in MIDI file playback. (Reported by Michelle Thompson.)
- mido-ports now prints port names in single ticks.
- MidiFile.__iter__() now yields end_of_track. This means playback will end there instead of at the preceding message.
- bugfix: _compute_tick_time() was not renamed to _compute_seconds_per_tick() everywhere.
- bugfix: sleep time in play() was sometimes negative.
- bugfix: timing in MIDI playback was broken from 1.1.7 on. Current time was subtracted before time stamps were converted from ticks to seconds, leading to absurdly large delta times. (Reported by Michelle Thompson.)
read_syx_file()didn’t handle empty file.
some classes and functions have been moved to more accessible locations:
from mido import MidiFile, MidiTrack, MetaMessage from mido.midifiles import MetaSpec, add_meta_spec
you can now iterate over a MIDI file. This will generate all MIDI messages in playback order. The
timeattribute of each message is the number of seconds since the last message or the start of the file. (Based on suggestion by trushkin in issue #16.)
added get_sleep_time() to complement set_sleep_time().
the Backend object no longer looks for the backend module exists on startup, but will instead just import the module when you call one of the
get_*()functions. This test didn’t work when the library was packaged in a zip file or executable.
This means that Mido can now be installed as Python egg and frozen with tools like PyInstaller and py2exe. See “Freezing Mido Programs” for more on this.
(Issue #17 reported by edauenhauer and issue #14 reported by netchose.)
switched to pytest for unit tests.
- bugfix: package didn’t work with easy_install. (Issue #14, reported by netchose.)
- bugfix: 100% memory consumption when calling blocking receive() on a PortMidi input. (Issue #15, reported by Francesco Ceruti.)
- added wheel support: http://pythonwheels.com/
- removed the ‘mode’ attribute from key_signature messages. Minor keys now have an ‘m’ appended, for example ‘Cm’.
- bugfix: sysex was broken in MIDI files.
- bugfix: didn’t handle MIDI files without track headers.
- bugfix: MIDI files didn’t handle channel prefix > 15
- bugfix: MIDI files didn’t handle SMPTE offset with frames > 29
- bugfix: files with key signatures Cb, Db and Gb failed due to faulty error handling.
- bugfix: when reading some MIDI files Mido crashed with the message “ValueError: attribute must be in range 0..255”. The reason was that Meta messages set running status, which caused the next statusless message to be falsely interpreted as a meta message. (Reported by Domino Marama).
- fixed a typo in MidiFile._read_track(). Sysex continuation should work now.
- rewrote tests to make them more readable.
- messages are now copied on send. This allows the sender to modify the message and send it to another port while the two ports receive their own personal copies that they can modify without any side effects.
- bugfix: non-ASCII character caused trouble with installation when LC_ALL=C. (Reported by Gene De Lisa)
- bugfix: used old exception handling syntax in rtmidi backend which broke in 3.3
- fixed broken link in
- bugfix: mido.backends package was not included in distribution.
- added support for selectable backends (with MIDO_BACKEND) and included python-rtmidi and pygame backends in the official library (as mido.backend.rtmidi and mido.backend.pygame).
- added full support for MIDI files (read, write playback)
- added MIDI over TCP/IP (socket ports)
- added utility programs mido-play, mido-ports, mido-serve and mido-forward.
- added support for SMPTE time code quarter frames.
- port constructors and
open_*()functions can now take keyword arguments.
- output ports now have reset() and panic() methods.
- new environment variables MIDO_DEFAULT_INPUT, MIDO_DEFAULT_OUTPUT and MIDO_DEFAULT_IOPORT. If these are set, the open_*() functions will use them instead of the backend’s default ports.
- added new meta ports MultiPort and EchoPort.
- added new examples and updated the old ones.
- format_as_string() now takes an include_time argument (defaults to True) so you can leave out the time attribute.
- sleep time inside sockets can now be changed.
- Message() no longer accepts a status byte as its first argument. (This was only meant to be used internally.)
- added callbacks for input ports (PortMidi and python-rtmidi)
- PortMidi and pygame input ports now actually block on the device instead of polling and waiting.
- removed commas from repr() format of Message and MetaMessage to make them more consistent with other classes.
- rewrote parser
- bugfix: __exit__() didn’t close port.
- changed repr format of message to start with “message”.
- removed support for undefined messages. (0xf4, 0xf5, 0xf7, 0xf9 and 0xfd.)
- default value of velocity is now 64 (0x40). (This is the recommended default for devices that don’t support velocity.)
- fixed some errors in the documentation.
- multi_receive() and multi_iter_pending() had wrong implementation. They were supposed to yield only messages by default.
Basic functionality: messages, ports and parser.