diff -Nru python-mido-1.2.9/bin/mido-play python-mido-1.2.10/bin/mido-play --- python-mido-1.2.9/bin/mido-play 2018-08-21 16:04:41.000000000 +0000 +++ python-mido-1.2.10/bin/mido-play 2020-12-20 16:37:31.000000000 +0000 @@ -1,5 +1,5 @@ #!/usr/bin/env python -""" +""" Play MIDI file on output port. Example: @@ -44,7 +44,7 @@ def play_file(output, filename, print_messages): - midi_file = MidiFile(filename) + midi_file = MidiFile(filename) print('Playing {}.'.format(midi_file.filename)) length = midi_file.length diff -Nru python-mido-1.2.9/bin/mido-ports python-mido-1.2.10/bin/mido-ports --- python-mido-1.2.9/bin/mido-ports 2018-08-21 16:04:41.000000000 +0000 +++ python-mido-1.2.10/bin/mido-ports 2020-12-18 00:22:05.000000000 +0000 @@ -18,7 +18,7 @@ print_ports('Available input Ports:', mido.get_input_names()) print_ports('Available output Ports:', mido.get_output_names()) -for name in ['MIDO_DEAFULT_INPUT', +for name in ['MIDO_DEFAULT_INPUT', 'MIDO_DEFAULT_OUTPUT', 'MIDO_DEFAULT_IOPORT', 'MIDO_BACKEND']: diff -Nru python-mido-1.2.9/debian/changelog python-mido-1.2.10/debian/changelog --- python-mido-1.2.9/debian/changelog 2021-01-12 01:40:09.000000000 +0000 +++ python-mido-1.2.10/debian/changelog 2021-12-08 23:30:44.000000000 +0000 @@ -1,3 +1,14 @@ +python-mido (1.2.10-1) unstable; urgency=medium + + * New upstream release (1.2.10): + + Refresh d/patches. + * debian/control: Update homepage field to use upstream official site + instead of PyPi. + * Bump Standards-Version to 4.6.0. No changes were required. + * debian/copyright: Update copyright holder years + + -- Josue Ortega Wed, 08 Dec 2021 17:30:44 -0600 + python-mido (1.2.9-3) unstable; urgency=medium * Add autopkgtest runtime test in order to drop the previous supercial diff -Nru python-mido-1.2.9/debian/control python-mido-1.2.10/debian/control --- python-mido-1.2.9/debian/control 2021-01-12 01:40:09.000000000 +0000 +++ python-mido-1.2.10/debian/control 2021-12-08 23:30:44.000000000 +0000 @@ -7,8 +7,8 @@ python3-all, python3-setuptools, python3-pytest (>= 2.9.2) -Standards-Version: 4.5.1 -Homepage: https://pypi.python.org/pypi/mido +Standards-Version: 4.6.0 +Homepage: https://github.com/mido/mido X-Python3-Version: >= 3.6 Vcs-Git: https://salsa.debian.org/debian/python-mido.git Vcs-Browser: https://salsa.debian.org/debian/python-mido diff -Nru python-mido-1.2.9/debian/copyright python-mido-1.2.10/debian/copyright --- python-mido-1.2.9/debian/copyright 2021-01-12 01:40:09.000000000 +0000 +++ python-mido-1.2.10/debian/copyright 2021-12-08 23:30:44.000000000 +0000 @@ -7,7 +7,7 @@ License: MIT Files: debian/* -Copyright: 2016 Josue Ortega +Copyright: 2021 Josue Ortega License: MIT License: MIT diff -Nru python-mido-1.2.9/debian/patches/00-update-shebang-py3.patch python-mido-1.2.10/debian/patches/00-update-shebang-py3.patch --- python-mido-1.2.9/debian/patches/00-update-shebang-py3.patch 2021-01-12 01:40:09.000000000 +0000 +++ python-mido-1.2.10/debian/patches/00-update-shebang-py3.patch 2021-12-08 23:30:44.000000000 +0000 @@ -19,14 +19,6 @@ """ Forward all messages from one or more ports to server. """ ---- a/bin/mido-play -+++ b/bin/mido-play -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/python3 - """ - Play MIDI file on output port. - --- a/bin/mido-ports +++ b/bin/mido-ports @@ -1,4 +1,4 @@ diff -Nru python-mido-1.2.9/debian/patches/01-fix-python-version-binaries.patch python-mido-1.2.10/debian/patches/01-fix-python-version-binaries.patch --- python-mido-1.2.9/debian/patches/01-fix-python-version-binaries.patch 2021-01-12 01:40:09.000000000 +0000 +++ python-mido-1.2.10/debian/patches/01-fix-python-version-binaries.patch 2021-12-08 23:30:44.000000000 +0000 @@ -32,3 +32,11 @@ include_package_data=True, install_requires=[], extras_require={ +--- a/bin/mido-play ++++ b/bin/mido-play +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/python3 + """ + Play MIDI file on output port. + diff -Nru python-mido-1.2.9/docs/authors.rst python-mido-1.2.10/docs/authors.rst --- python-mido-1.2.9/docs/authors.rst 2018-08-21 16:03:24.000000000 +0000 +++ python-mido-1.2.10/docs/authors.rst 2020-12-20 16:37:31.000000000 +0000 @@ -1,6 +1,8 @@ Authors ======= -Ole Martin Bjørndalen (lead programmer) +Ole Martin Bjørndalen (lead programmer) and many other contributors. -Rapolas Binkys +Many people have contributed to Mido over the years, but this page has +not been updated to include them. The :doc:`/changes` page +includes names of all contributors. diff -Nru python-mido-1.2.9/docs/changes.rst python-mido-1.2.10/docs/changes.rst --- python-mido-1.2.9/docs/changes.rst 2018-10-05 11:01:06.000000000 +0000 +++ python-mido-1.2.10/docs/changes.rst 2021-05-10 15:39:39.000000000 +0000 @@ -7,6 +7,50 @@ Release History --------------- +1.2.10 (2021-05-10) +^^^^^^^^^^^^^^^^^^^ + +* New ``repr()`` format for messages, tracks and MIDI file + objects. (Implemented by John Belmonte, pull request #164.) + +* added new example ``midifiles/show_midifile.py`` based on the + new ``repr()`` format. + +* Added ``msg.is_cc()`` method. Checks if message is a control change. + Can also be used to check for a specific control change number, for + example ``msg.is_cc(7)``. + +* Fixed memory leaks in RtMidi backend (issue #256, fix by The Other Days, + pull request #264.) + +* clip now works with sysex messages (Fix by Avatar Timo Stüber, pull request + #229.) + +* Improved docs and error message for time attribute in a message. + (tomerv, pull request #249.) + +* Improved MidiFile.play to avoid time drift. (Implemented by John + Belmonte, pull request #161.) + +* bugfix: MIDO_DEFAULT_INPUT was misspelled in mido-ports causing it + to be show as 'not set' even though it was set. (Fix by Bernhard + Wagner, pull request #192.) + +* Now only copies ports once in ports.multi_receive() (Tom Ritchford, pull + request #191.) + +* Ports lists returned from ``get_input_names()`` and friends are no + longer sorted. (Suggested and implemented by Ryan McCampbell, issue + #298.) + +* Updated linke in docs to point to the new home github.com/mido/ + (Fixed by Joshua Mayers, pull request #177.) + +* thanks to Christopher Arndt, Kathryn DiPippo and Timo Stüber for fixing + flake8 issues. + + + 1.2.9 (2018-10-05) ^^^^^^^^^^^^^^^^^^ diff -Nru python-mido-1.2.9/docs/contributing.rst python-mido-1.2.10/docs/contributing.rst --- python-mido-1.2.9/docs/contributing.rst 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/docs/contributing.rst 2021-05-10 15:38:13.000000000 +0000 @@ -6,8 +6,8 @@ --------- If you have questions about contributing code or suggestions -for how to make contributing easier, please write to -https://groups.google.com/forum/#!forum/mido-community. +for how to make contributing easier, please write at +https://github.com/mido/mido/discussions. Installing for developers @@ -88,7 +88,7 @@ python setup.py bdist_wheel --universal python setup.py sdist - twine upload twine upload dist/* + twine upload dist/* Push to GitHub diff -Nru python-mido-1.2.9/docs/index.rst python-mido-1.2.10/docs/index.rst --- python-mido-1.2.9/docs/index.rst 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/docs/index.rst 2020-12-20 20:34:39.000000000 +0000 @@ -8,8 +8,7 @@ Version |version| -Mido is a library for working with MIDI messages and ports. It's -designed to be as straight forward and Pythonic as possible: +Mido is a library for working with MIDI messages and ports: .. code-block:: python @@ -22,7 +21,7 @@ >>> msg.bytes() [144, 60, 64] >>> msg.copy(channel=2) - + Message('note_on', channel=2, note=60, velocity=64, time=0) .. code-block:: python @@ -48,7 +47,7 @@ Source code ----------- -https://github.com/olemb/mido/ +https://github.com/mido/mido/ About This Document diff -Nru python-mido-1.2.9/docs/installing.rst python-mido-1.2.10/docs/installing.rst --- python-mido-1.2.9/docs/installing.rst 2018-08-21 16:04:41.000000000 +0000 +++ python-mido-1.2.10/docs/installing.rst 2020-12-21 16:16:38.000000000 +0000 @@ -4,16 +4,16 @@ Requirements ------------ -Mido targets Python 2.7 and 3.2. It is developed and tested in Ubuntu -and Mac OS X but should also work in Windows. +Mido targets Python 3.6 and 2.7. There are no external dependencies unless you want to use the port backends, which are loaded on demand. -Mido comes with backends for `RtMidi (python-rtmidi) -`_ , `PortMidi -`_ and `Pygame -`_. See :doc:`backends/index` for +Mido comes with backends for RtMidi +(`python-rtmidi `_ or +`rtmidi_python `_), +`PortMidi `_ and +`Pygame `_. See :doc:`backends/index` for help choosing a backend. diff -Nru python-mido-1.2.9/docs/intro.rst python-mido-1.2.10/docs/intro.rst --- python-mido-1.2.9/docs/intro.rst 2018-08-21 16:04:41.000000000 +0000 +++ python-mido-1.2.10/docs/intro.rst 2020-12-20 20:34:39.000000000 +0000 @@ -13,7 +13,7 @@ >>> from mido import Message >>> msg = Message('note_on', note=60) >>> msg - + Message('note_on', channel=0, note=60, velocity=64, time=0) .. note:: @@ -37,7 +37,7 @@ to use ``msg.copy()``:: >>> msg.copy(note=100, velocity=127) - >> mido.Message('note_on') - + Message('note_on', channel=0, note=0, velocity=64, time=0) You can pass attributes as keyword arguments:: >>> mido.Message('note_on', note=100, velocity=3, time=6.2) - + Message('note_on', channel=0, note=100, velocity=3, time=6.2) All attributes will default to 0. The exceptions are ``velocity``, which defaults to 64 (middle velocity) and ``data`` which defaults to @@ -33,7 +33,7 @@ ``msg.copy()``:: >>> msg.copy(note=99, time=100.0) - + Message('note_on', channel=0, note=99, velocity=64, time=100.0) .. note:: Mido always makes a copy of messages instead of modifying them so if you do the same you have immutable messages in @@ -50,6 +50,18 @@ full list of messages and their attributes, see :doc:`/message_types`. +Control Changes +--------------- + +.. code-block:: python + + if msg.is_cc(): + print('Control change message received') + + if msg.is_cc(7): + print('Volume changed to', msg.value) + + Converting To Bytes ------------------- @@ -57,7 +69,7 @@ >>> msg = mido.Message('note_on') >>> msg - + Message('note_on', channel=0, note=0, velocity=64, time=0) >>> msg.bytes() [144, 0, 64] >>> msg.bin() @@ -88,11 +100,13 @@ ------------------ Each message has a ``time`` attribute, which can be set to any value -of type ``int`` or ``float`` (and in Python 2 also ``long``). What you -do with this value is entirely up to you. +of type ``int`` or ``float`` (and in Python 2 also ``long``). Some parts of Mido use the attribute for special purposes. In MIDI -file tracks, it is used as delta time (in ticks). +file tracks, it is used as delta time (in ticks), and it must be a +non-negative integer. + +In other parts of Mido, this value is ignored. .. note:: Before 1.1.18 the ``time`` attribute was not included in comparisons. If you want the old behavior the easies way is @@ -118,7 +132,7 @@ >>> msg = Message('sysex', data=[1, 2, 3]) >>> msg - + Message('sysex', data=(1, 2, 3), time=0) >>> msg.hex() 'F0 01 02 03 F7' @@ -128,7 +142,7 @@ >>> msg.data += [4, 5] >>> msg.data += [6, 7, 8] >>> msg - + Message('sysex', data=(1, 2, 3, 4, 5, 6, 7, 8), time=0) Any sequence of integers is allowed, and type and range checking is applied to each data byte. These are all valid:: @@ -145,4 +159,4 @@ >>> msg = Message('sysex', data=bytearray(b'ABC')) >>> msg.data += bytearray(b'DEF') >>> msg - + Message('sysex', data=(65, 66, 67, 68, 69, 70), time=0) diff -Nru python-mido-1.2.9/docs/message_types.rst python-mido-1.2.10/docs/message_types.rst --- python-mido-1.2.9/docs/message_types.rst 2018-08-21 16:04:41.000000000 +0000 +++ python-mido-1.2.10/docs/message_types.rst 2020-12-18 17:05:48.000000000 +0000 @@ -63,9 +63,7 @@ value. (64 is the recommended default for devices that don't support it attack or release velocity.) -The ``time`` parameter is not included in the encoded message, and is -(currently) not used by Mido in any way. You can use it for whatever -purpose you wish. +The ``time`` is used in MIDI files as delta time. The ``data`` parameter accepts any iterable that generates numbers in 0..127. This includes:: diff -Nru python-mido-1.2.9/docs/meta_message_types.rst python-mido-1.2.10/docs/meta_message_types.rst --- python-mido-1.2.9/docs/meta_message_types.rst 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/docs/meta_message_types.rst 2020-12-20 20:34:39.000000000 +0000 @@ -250,7 +250,7 @@ These are also visible in the ``repr()`` string:: - + UnknownMetaMessage(type_byte=251, data=(1, 2, 3), time=0> Implementing New Meta Messages @@ -260,7 +260,7 @@ want to use a custom meta message, you can add it by writing a new meta message spec:: - from mido.midifiles import MetaSpec, add_meta_spec + from mido.midifiles.meta import MetaSpec, add_meta_spec class MetaSpec_light_color(MetaSpec): type_byte = 0xf0 @@ -300,7 +300,7 @@ >>> from mido import MetaMessage >>> MetaMessage('light_color', r=120, g=60, b=10) - + MetaMessage('light_color', r=120, g=60, b=10, time=0) and the new message type will now work when reading and writing MIDI files. diff -Nru python-mido-1.2.9/docs/midi_files.rst python-mido-1.2.10/docs/midi_files.rst --- python-mido-1.2.9/docs/midi_files.rst 2018-08-21 16:04:41.000000000 +0000 +++ python-mido-1.2.10/docs/midi_files.rst 2020-12-20 20:34:39.000000000 +0000 @@ -49,7 +49,8 @@ if msg.is_meta: ... -This makes it easy to play back a MIDI file on a port:: +This makes it easy to play back a MIDI file on a port (though this simple +implementation is subject to time drift):: for msg in MidiFile('song.mid'): time.sleep(msg.time) @@ -61,8 +62,8 @@ for msg in MidiFile('song.mid').play(): port.send(msg) -This does the sleeping and filtering for you. If you pass -``meta_messages=True`` you will also get meta messages. These can not +This does the sleeping and filtering for you (while avoiding drift). If you +pass ``meta_messages=True`` you will also get meta messages. These can not be sent on ports, which is why they are off by default. @@ -147,7 +148,7 @@ >>> from mido import MetaMessage >>> MetaMessage('key_signature', key='C#', mode='major') - + MetaMessage('key_signature', key='C#', mode='major', time=0) You can tell meta messages apart from normal messages with:: diff -Nru python-mido-1.2.9/docs/parsing.rst python-mido-1.2.10/docs/parsing.rst --- python-mido-1.2.9/docs/parsing.rst 2018-08-21 16:04:41.000000000 +0000 +++ python-mido-1.2.10/docs/parsing.rst 2020-12-20 20:34:39.000000000 +0000 @@ -12,11 +12,11 @@ Mido comes with a parser that turns MIDI bytes into messages. You can create a parser object, or call one of the utility functions:: >>> mido.parse([0x92, 0x10, 0x20]) - + Message('note_on', channel=2, note=16, velocity=32, time=0) >>> mido.parse_all([0x92, 0x10, 0x20, 0x82, 0x10, 0x20]) - [, - ] + [Message('note_on', channel=2, note=16, velocity=32, time=0), + Message('note_off', channel=2, note=16, velocity=32, time=0)] These functions are just shortcuts for the full ``Parser`` class. This is the parser used inside input ports to parse incoming messages. @@ -27,13 +27,13 @@ >>> p.pending() 1 >>> p.get_message() - + Message('note_on', channel=0, note=16, velocity=32, time=0) >>> p.feed_byte(0x90) >>> p.feed_byte(0x10) >>> p.feed_byte(0x20) >>> p.feed([0x80, 0x10, 0x20]) - + Message('note_on', channel=0, note=16, velocity=32, time=0) ``feed()`` accepts any iterable that generates integers in 0..255. The parser will skip and stray status bytes or data bytes, so you can diff -Nru python-mido-1.2.9/docs/resources.rst python-mido-1.2.10/docs/resources.rst --- python-mido-1.2.9/docs/resources.rst 2018-08-21 16:03:24.000000000 +0000 +++ python-mido-1.2.10/docs/resources.rst 2020-12-20 20:34:39.000000000 +0000 @@ -1,7 +1,7 @@ Resources ========= -* `MIDI Manufacturers Association `_ (midi.org) +* `MIDI Association `_ (midi.org) * `Table of MIDI Messages `_ (midi.org) diff -Nru python-mido-1.2.9/docs/roadmap.rst python-mido-1.2.10/docs/roadmap.rst --- python-mido-1.2.9/docs/roadmap.rst 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/docs/roadmap.rst 2020-12-30 15:28:07.000000000 +0000 @@ -5,29 +5,19 @@ a list of ideas. -Near Future ------------ - -* create a place for general discussion: - Now exists: https://groups.google.com/forum/#!forum/mido-community - -* a `PEP `_ like process for new - features and major changes? - - Various Improvements to MIDI File Parsing ----------------------------------------- * add ``mido.exceptions.MidiParseError``. * add better error handling to MIDI file parser as discussed in `issue - #63 `_. + #63 `_. * support RIFF MIDI files (`issue #43 - `_) + `_) * support MIDI files that end in empty meta message - (`issue #42 `_) + (`issue #42 `_) Better Support for Concurrency and Multithreading @@ -69,7 +59,7 @@ Making Messages Immutable ^^^^^^^^^^^^^^^^^^^^^^^^^ -See: https://github.com/olemb/mido/issues/36 +See: https://github.com/mido/mido/issues/36 The current workaround is frozen messages (``mido.freeze``). @@ -81,7 +71,7 @@ Native Backends (ALSA, JACK, CoreMIDI, Windows MIDI) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -See https://github.com/olemb/mido-native-backends +See https://github.com/mido/mido-native-backends No Default Backend? @@ -146,12 +136,12 @@ ----- * add a way to convert between MIDI file types as suggested in `issue - #92 `_. + #92 `_. * RtMidi backend: allow user to list ports without client name and ALSA port numbers. -* Add native backends? See https://github.com/olemb/mido-native-backends +* Add native backends? See https://github.com/mido/mido-native-backends * Currently all backends ignore ``active_sensing`` messages because they create a lot of noise and are usually not very useful. Should diff -Nru python-mido-1.2.9/docs/string_encoding.rst python-mido-1.2.10/docs/string_encoding.rst --- python-mido-1.2.9/docs/string_encoding.rst 2018-08-21 16:04:41.000000000 +0000 +++ python-mido-1.2.10/docs/string_encoding.rst 2020-12-20 20:34:39.000000000 +0000 @@ -14,7 +14,7 @@ To convert the other way (new method in 1.2):: >>> mido.Message.from_str('control_change control=1 value=122') - + Message('control_change', channel=0, control=1, value=122, time=0) Alternatively, you can call the ``format_as_string`` function directly: @@ -58,14 +58,14 @@ To parse a message, you can use ``mido.parse_string()``:: >>> parse_string('control_change control=1 value=122 time=0.5') - + Message('control_change', channel=0, control=1, value=122, time=0.5) Parameters that are left out are set to their default values. ``ValueError`` is raised if the message could not be parsed. Extra whitespace is ignored:: >>> parse_string(' control_change control=1 value=122') - + Message('control_change', channel=0, control=1, value=122, time=0) To parse messages from a stream, you can use ``mido.messages.parse_string_stream()``:: diff -Nru python-mido-1.2.9/examples/midifiles/create_midi_file.py python-mido-1.2.10/examples/midifiles/create_midi_file.py --- python-mido-1.2.9/examples/midifiles/create_midi_file.py 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/examples/midifiles/create_midi_file.py 2020-12-20 19:54:19.000000000 +0000 @@ -4,8 +4,10 @@ The file is saved to test.mid. """ +from __future__ import division import random -from mido import Message, MidiFile, MidiTrack +import sys +from mido import Message, MidiFile, MidiTrack, MAX_PITCHWHEEL notes = [64, 64+7, 64+12] @@ -16,10 +18,14 @@ track.append(Message('program_change', program=12)) -delta = 16 +delta = 300 +ticks_per_expr = int(sys.argv[1]) if len(sys.argv) > 1 else 20 for i in range(4): note = random.choice(notes) track.append(Message('note_on', note=note, velocity=100, time=delta)) - track.append(Message('note_off', note=note, velocity=100, time=delta)) + for j in range(delta // ticks_per_expr): + pitch = MAX_PITCHWHEEL * j * ticks_per_expr // delta + track.append(Message('pitchwheel', pitch=pitch, time=ticks_per_expr)) + track.append(Message('note_off', note=note, velocity=100, time=0)) outfile.save('test.mid') diff -Nru python-mido-1.2.9/examples/midifiles/play_midi_file.py python-mido-1.2.10/examples/midifiles/play_midi_file.py --- python-mido-1.2.9/examples/midifiles/play_midi_file.py 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/examples/midifiles/play_midi_file.py 2020-12-20 19:54:19.000000000 +0000 @@ -8,6 +8,7 @@ """ import sys import mido +import time from mido import MidiFile filename = sys.argv[1] @@ -18,9 +19,13 @@ with mido.open_output(portname) as output: try: - for message in MidiFile(filename).play(): + midifile = MidiFile(filename) + t0 = time.time() + for message in midifile.play(): print(message) output.send(message) + print('play time: {:.2f} s (expected {:.2f})'.format( + time.time() - t0, midifile.length)) except KeyboardInterrupt: print() diff -Nru python-mido-1.2.9/examples/midifiles/show_midifile.py python-mido-1.2.10/examples/midifiles/show_midifile.py --- python-mido-1.2.9/examples/midifiles/show_midifile.py 1970-01-01 00:00:00.000000000 +0000 +++ python-mido-1.2.10/examples/midifiles/show_midifile.py 2020-12-21 16:16:38.000000000 +0000 @@ -0,0 +1,17 @@ +#!/usr/bin/env python +import sys +import argparse +import mido + + +def parse_args(): + parser = argparse.ArgumentParser() + arg = parser.add_argument + + arg('midifile', nargs=1) + + return parser.parse_args() + + +args = parse_args() +print(repr(mido.MidiFile(args.midifile[0]))) diff -Nru python-mido-1.2.9/extras/hid_joystick.py python-mido-1.2.10/extras/hid_joystick.py --- python-mido-1.2.9/extras/hid_joystick.py 2018-08-21 16:04:41.000000000 +0000 +++ python-mido-1.2.10/extras/hid_joystick.py 2020-12-20 19:54:19.000000000 +0000 @@ -43,7 +43,7 @@ f0 fb 37 09 00 00 82 04 f0 fb 37 09 00 00 82 05 --+-- | - | 1 = button, 2 = + | 1 = button, 2 = | value (little endian unsigned) @@ -94,12 +94,12 @@ event['init'] = bool(event['type'] & JS_EVENT_INIT) event['type'] &= 0x7f # Strip away the flag bits (JS_EVENT_INIT etc.) if event['type'] != JS_EVENT_BUTTON: - + event['normalized_value'] = \ float(event['value']) / 0x7fff # Normalize to -1..1 event['type'] = {1: 'button', 2: 'axis'}[event['type']] - + return event def read_events(device_name): @@ -234,7 +234,7 @@ type_ = 'note_on' else: type_ = 'note_off' - + note = note_mapping[button] message = mido.Message(type_, channel=9, note=note, velocity=64) diff -Nru python-mido-1.2.9/.flake8 python-mido-1.2.10/.flake8 --- python-mido-1.2.9/.flake8 1970-01-01 00:00:00.000000000 +0000 +++ python-mido-1.2.10/.flake8 2020-12-18 00:22:05.000000000 +0000 @@ -0,0 +1,4 @@ +[flake8] +ignore = F401, C901, F901 +exclude = .git,__pycache__,docs/source/conf.py,old,build,dist +max-complexity = 10 diff -Nru python-mido-1.2.9/LICENSE python-mido-1.2.10/LICENSE --- python-mido-1.2.9/LICENSE 2017-10-11 16:19:26.000000000 +0000 +++ python-mido-1.2.10/LICENSE 2020-12-21 16:16:38.000000000 +0000 @@ -1,6 +1,6 @@ The MIT License -Copyright (c) 2013-infinity Ole Martin Bjørndalen +Copyright (c) Ole Martin Bjørndalen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff -Nru python-mido-1.2.9/MANIFEST.in python-mido-1.2.10/MANIFEST.in --- python-mido-1.2.9/MANIFEST.in 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/MANIFEST.in 2020-12-30 15:28:07.000000000 +0000 @@ -1,4 +1,4 @@ -include README.rst LICENSE tox.ini +include README.rst LICENSE tox.ini .flake8 recursive-include tests *.py recursive-include examples *.py recursive-include extras *.py @@ -13,3 +13,4 @@ recursive-include mido *.py recursive-include docs/images *.svg prune docs/_build +prune logo diff -Nru python-mido-1.2.9/mido/__about__.py python-mido-1.2.10/mido/__about__.py --- python-mido-1.2.9/mido/__about__.py 2018-10-05 11:02:19.000000000 +0000 +++ python-mido-1.2.10/mido/__about__.py 2021-05-10 15:40:16.000000000 +0000 @@ -1,4 +1,4 @@ -__version__ = '1.2.9' +__version__ = '1.2.10' __author__ = 'Ole Martin Bjorndalen' __author_email__ = 'ombdalen@gmail.com' __url__ = 'https://mido.readthedocs.io/' diff -Nru python-mido-1.2.9/mido/backends/backend.py python-mido-1.2.10/mido/backends/backend.py --- python-mido-1.2.9/mido/backends/backend.py 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/mido/backends/backend.py 2021-05-10 15:29:18.000000000 +0000 @@ -165,23 +165,24 @@ return [] def get_input_names(self, **kwargs): - """Return a sorted list of all input port names.""" + """Return a list of all input port names.""" devices = self._get_devices(**self._add_api(kwargs)) names = [device['name'] for device in devices if device['is_input']] - return list(sorted(names)) + return names def get_output_names(self, **kwargs): - """Return a sorted list of all output port names.""" + """Return a list of all output port names.""" devices = self._get_devices(**self._add_api(kwargs)) names = [device['name'] for device in devices if device['is_output']] - return list(sorted(names)) + return names def get_ioport_names(self, **kwargs): - """Return a sorted list of all I/O port names.""" + """Return a list of all I/O port names.""" devices = self._get_devices(**self._add_api(kwargs)) inputs = [device['name'] for device in devices if device['is_input']] - outputs = [device['name'] for device in devices if device['is_output']] - return sorted(set(inputs) & set(outputs)) + outputs = set( + [device['name'] for device in devices if device['is_output']]) + return [name for name in inputs if name in outputs] def __repr__(self): if self.loaded: diff -Nru python-mido-1.2.9/mido/backends/portmidi_init.py python-mido-1.2.10/mido/backends/portmidi_init.py --- python-mido-1.2.9/mido/backends/portmidi_init.py 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/mido/backends/portmidi_init.py 2021-04-18 20:06:41.000000000 +0000 @@ -7,7 +7,7 @@ import sys from ctypes import (CDLL, CFUNCTYPE, POINTER, Structure, c_char_p, c_int, c_long, c_uint, c_void_p, cast, - create_string_buffer, byref) + create_string_buffer) import ctypes.util dll_name = '' diff -Nru python-mido-1.2.9/mido/backends/rtmidi.py python-mido-1.2.10/mido/backends/rtmidi.py --- python-mido-1.2.9/mido/backends/rtmidi.py 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/mido/backends/rtmidi.py 2021-05-10 15:10:52.000000000 +0000 @@ -49,15 +49,19 @@ rtapi = _get_api_id(api) - input_names = set(rtmidi.MidiIn(rtapi=rtapi).get_ports()) - output_names = set(rtmidi.MidiOut(rtapi=rtapi).get_ports()) + mi = rtmidi.MidiIn(rtapi=rtapi) + mo = rtmidi.MidiOut(rtapi=rtapi) + input_names = mi.get_ports() + output_names = mo.get_ports() - for name in sorted(input_names | output_names): + for name in input_names + output_names: devices.append({'name': name, 'is_input': name in input_names, 'is_output': name in output_names, }) + mi.delete() + mo.delete() return devices @@ -103,6 +107,7 @@ class PortCommon(object): def _close(self): self._rt.close_port() + self._rt.delete() class Input(PortCommon, ports.BaseInput): diff -Nru python-mido-1.2.9/mido/backends/rtmidi_python.py python-mido-1.2.10/mido/backends/rtmidi_python.py --- python-mido-1.2.9/mido/backends/rtmidi_python.py 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/mido/backends/rtmidi_python.py 2021-05-10 15:10:52.000000000 +0000 @@ -33,10 +33,10 @@ def get_devices(api=None, **kwargs): devices = [] - input_names = set(rtmidi.MidiIn().ports) - output_names = set(rtmidi.MidiOut().ports) + input_names = rtmidi.MidiIn().ports + output_names = rtmidi.MidiOut().ports - for name in sorted(input_names | output_names): + for name in input_names + output_names: devices.append({'name': name, 'is_input': name in input_names, 'is_output': name in output_names, diff -Nru python-mido-1.2.9/mido/frozen.py python-mido-1.2.10/mido/frozen.py --- python-mido-1.2.9/mido/frozen.py 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/mido/frozen.py 2020-12-20 19:54:19.000000000 +0000 @@ -3,10 +3,6 @@ class Frozen(object): - def __repr__(self): - text = super(Frozen, self).__repr__() - return ''.format(str(self)) - def _setattr(self, name, value): if name == 'type': raise AttributeError('type attribute is read only') diff -Nru python-mido-1.2.9/mido/midifiles/meta.py python-mido-1.2.10/mido/midifiles/meta.py --- python-mido-1.2.9/mido/midifiles/meta.py 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/mido/midifiles/meta.py 2020-12-20 19:54:19.000000000 +0000 @@ -109,7 +109,7 @@ length. """ if not isinstance(value, Integral) or value < 0: - raise ValueError('variable int must be a positive integer') + raise ValueError('variable int must be a non-negative integer') bytes = [] while value: @@ -531,21 +531,12 @@ spec = _META_SPEC_BY_TYPE[self.type] data = spec.encode(self) - return ([0xff, spec.type_byte] + - encode_variable_int(len(data)) + - data) + return ([0xff, spec.type_byte] + encode_variable_int(len(data)) + data) - def __repr__(self): + def _get_value_names(self): + """Used by BaseMessage.__repr__().""" spec = _META_SPEC_BY_TYPE[self.type] - attributes = [] - for name in spec.attributes: - attributes.append('{}={!r}'.format(name, getattr(self, name))) - attributes = ' '.join(attributes) - if attributes: - attributes = (' {}'.format(attributes)) - - return ''.format(self.type, - attributes, self.time) + return spec.attributes + ['time'] class UnknownMetaMessage(MetaMessage): @@ -562,12 +553,8 @@ 'time': time}) def __repr__(self): - return ('').format(self.type_byte, - self.data, - self.time - ) + fmt = 'UnknownMetaMessage(type_byte={}, data={}, time={})' + return fmt.format(self.type_byte, self.data, self.time) def __setattr__(self, name, value): # This doesn't do any checking. @@ -575,6 +562,5 @@ vars(self)[name] = value def bytes(self): - return ([0xff, self.type_byte] + - encode_variable_int(len(self.data)) + - list(self.data)) + length = encode_variable_int(len(self.data)) + return ([0xff, self.type_byte] + length + list(self.data)) diff -Nru python-mido-1.2.9/mido/midifiles/midifiles.py python-mido-1.2.10/mido/midifiles/midifiles.py --- python-mido-1.2.9/mido/midifiles/midifiles.py 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/mido/midifiles/midifiles.py 2020-12-31 19:33:58.000000000 +0000 @@ -138,7 +138,7 @@ return Message.from_bytes([status_byte] + data_bytes, time=delta) -def read_sysex(infile, delta): +def read_sysex(infile, delta, clip=False): length = read_variable_int(infile) data = read_bytes(infile, length) @@ -149,6 +149,9 @@ if data and data[-1] == 0xf7: data = data[:-1] + if clip: + data = [byte if byte < 127 else 127 for byte in data] + return Message('sysex', data=data, time=delta) @@ -215,7 +218,7 @@ elif status_byte in [0xf0, 0xf7]: # TODO: I'm not quite clear on the difference between # f0 and f7 events. - msg = read_sysex(infile, delta) + msg = read_sysex(infile, delta, clip) else: msg = read_message(infile, status_byte, peek_data, delta, clip) @@ -244,6 +247,8 @@ for msg in fix_end_of_track(track): if not isinstance(msg.time, Integral): raise ValueError('message time must be int in MIDI file') + if msg.time < 0: + raise ValueError('message time must be non-negative in MIDI file') if msg.is_realtime: raise ValueError('realtime messages are not allowed in MIDI files') @@ -293,7 +298,8 @@ type=1, ticks_per_beat=DEFAULT_TICKS_PER_BEAT, charset='latin1', debug=False, - clip=False + clip=False, + tracks=None ): self.filename = filename @@ -309,7 +315,9 @@ raise ValueError( 'invalid format {} (must be 0, 1 or 2)'.format(format)) - if file is not None: + if tracks is not None: + self.tracks = tracks + elif file is not None: self._load(file) elif self.filename is not None: with io.open(filename, 'rb') as file: @@ -399,12 +407,18 @@ You will receive copies of the original messages, so you can safely modify them without ruining the tracks. - """ - sleep = time.sleep + start_time = time.time() + input_time = 0.0 for msg in self: - sleep(msg.time) + input_time += msg.time + + playback_time = time.time() - start_time + duration_to_next_event = input_time - playback_time + + if duration_to_next_event > 0.0: + time.sleep(duration_to_next_event) if isinstance(msg, MetaMessage) and not meta_messages: continue @@ -462,9 +476,19 @@ print('{!r}'.format(msg)) def __repr__(self): - return ''.format( - self.filename, self.type, len(self.tracks), - sum([len(track) for track in self.tracks])) + if self.tracks: + tracks_str = ',\n'.join(repr(track) for track in self.tracks) + tracks_str = ' ' + tracks_str.replace('\n', '\n ') + tracks_str = ', tracks=[\n{}\n]'.format(tracks_str) + else: + tracks_str = '' + + return '{}(type={}, ticks_per_beat={}{})'.format( + self.__class__.__name__, + self.type, + self.ticks_per_beat, + tracks_str, + ) # The context manager has no purpose but is kept around since it was # used in examples in the past. diff -Nru python-mido-1.2.9/mido/midifiles/tracks.py python-mido-1.2.10/mido/midifiles/tracks.py --- python-mido-1.2.9/mido/midifiles/tracks.py 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/mido/midifiles/tracks.py 2020-12-31 19:32:56.000000000 +0000 @@ -51,7 +51,13 @@ return self.__class__(list.__mul__(self, other)) def __repr__(self): - return ''.format(self.name, len(self)) + if len(self) == 0: + messages = '' + elif len(self) == 1: + messages = '[{}]'.format(self[0]) + else: + messages = '[\n {}]'.format(',\n '.join(repr(m) for m in self)) + return '{}({})'.format(self.__class__.__name__, messages) def _to_abstime(messages): diff -Nru python-mido-1.2.9/mido/parser.py python-mido-1.2.10/mido/parser.py --- python-mido-1.2.9/mido/parser.py 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/mido/parser.py 2020-12-30 15:28:07.000000000 +0000 @@ -8,9 +8,6 @@ from .messages import Message from .tokenizer import Tokenizer -# TODO: make sure the method signatures are as before. -# TODO: add doc strings. - class Parser(object): """ diff -Nru python-mido-1.2.9/mido/ports.py python-mido-1.2.10/mido/ports.py --- python-mido-1.2.9/mido/ports.py 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/mido/ports.py 2020-12-20 20:34:39.000000000 +0000 @@ -384,9 +384,9 @@ If block=False only pending messages will be yielded. """ + ports = list(ports) while True: # Make a shuffled copy of the port list. - ports = list(ports) random.shuffle(ports) for port in ports: diff -Nru python-mido-1.2.9/mido.egg-info/PKG-INFO python-mido-1.2.10/mido.egg-info/PKG-INFO --- python-mido-1.2.9/mido.egg-info/PKG-INFO 2018-10-05 11:10:21.000000000 +0000 +++ python-mido-1.2.10/mido.egg-info/PKG-INFO 2021-05-10 15:44:03.000000000 +0000 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: mido -Version: 1.2.9 +Version: 1.2.10 Summary: MIDI Objects for Python Home-page: https://mido.readthedocs.io/ Author: Ole Martin Bjorndalen @@ -9,11 +9,12 @@ Description: Mido - MIDI Objects for Python ============================== - .. image:: https://travis-ci.org/olemb/mido.svg?branch=master - :target: https://travis-ci.org/olemb/mido + .. image:: https://travis-ci.org/mido/mido.svg?branch=master + :target: https://travis-ci.org/mido/mido + .. image:: https://github.com/mido/mido/workflows/Test/badge.svg + :target: https://github.com/mido/mido/actions - Mido is a library for working with MIDI messages and ports. It's - designed to be as straight forward and Pythonic as possible: + Mido is a library for working with MIDI messages and ports: .. code-block:: python @@ -26,7 +27,7 @@ >>> msg.bytes() [144, 60, 64] >>> msg.copy(channel=2) - + Message('note_on', channel=2, note=60, velocity=64, time=0) .. code-block:: python @@ -65,7 +66,7 @@ used interchangeably. New port types can be written by subclassing and overriding a few methods. - * includes a reusable MIDI parser. + * includes a reusable MIDI stream parser. * full support for MIDI files (read, write, create and play) with complete access to every message in the file, including all common @@ -90,7 +91,7 @@ Requirements ------------ - Mido targets Python 2.7 and 3.2. + Mido targets Python 3.6 and 2.7. Installing @@ -111,7 +112,7 @@ Source Code ----------- - https://github.com/olemb/mido/ + https://github.com/mido/mido/ License @@ -124,24 +125,9 @@ Questions and suggestions ------------------------- - Please ask questions about Mido at - https://groups.google.com/forum/#!forum/mido-community. - - This mailing list was created to give both the user community a place to ask - and hopefully also answer questions and for the developers a space to discuss - Mido development. The success of the mailing list will depend on the community - effort to also answer questions. - - - Looking for maintainers - ----------------------- - - This project is looking for somebody to take over the maintenance since the - original author @olemb is busy with other projects. We look for somebody or a - group of people who care about the code and would like to steer this project in - future by discussing proposals, reviewing pull requests, and looking over - issues. Please write to mido-community@googlegroups.com if you would like to - help out with maintenance. + For questions and proposals which may not fit into issues or pull requests, we + recommend to ask and discuss on `Discussions + `_. Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable @@ -150,6 +136,6 @@ Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2.7 -Classifier: Programming Language :: Python :: 3.2 +Classifier: Programming Language :: Python :: 3.6 Provides-Extra: dev Provides-Extra: ports diff -Nru python-mido-1.2.9/mido.egg-info/SOURCES.txt python-mido-1.2.10/mido.egg-info/SOURCES.txt --- python-mido-1.2.9/mido.egg-info/SOURCES.txt 2018-10-05 11:10:21.000000000 +0000 +++ python-mido-1.2.10/mido.egg-info/SOURCES.txt 2021-05-10 15:44:03.000000000 +0000 @@ -1,3 +1,4 @@ +.flake8 LICENSE MANIFEST.in README.rst @@ -53,6 +54,7 @@ examples/midifiles/midifile_to_json.py examples/midifiles/play_midi_file.py examples/midifiles/print_midi_file.py +examples/midifiles/show_midifile.py examples/midifiles/test.sh examples/ports/input_filter.py examples/ports/list_ports.py diff -Nru python-mido-1.2.9/PKG-INFO python-mido-1.2.10/PKG-INFO --- python-mido-1.2.9/PKG-INFO 2018-10-05 11:10:21.000000000 +0000 +++ python-mido-1.2.10/PKG-INFO 2021-05-10 15:44:03.263329700 +0000 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: mido -Version: 1.2.9 +Version: 1.2.10 Summary: MIDI Objects for Python Home-page: https://mido.readthedocs.io/ Author: Ole Martin Bjorndalen @@ -9,11 +9,12 @@ Description: Mido - MIDI Objects for Python ============================== - .. image:: https://travis-ci.org/olemb/mido.svg?branch=master - :target: https://travis-ci.org/olemb/mido + .. image:: https://travis-ci.org/mido/mido.svg?branch=master + :target: https://travis-ci.org/mido/mido + .. image:: https://github.com/mido/mido/workflows/Test/badge.svg + :target: https://github.com/mido/mido/actions - Mido is a library for working with MIDI messages and ports. It's - designed to be as straight forward and Pythonic as possible: + Mido is a library for working with MIDI messages and ports: .. code-block:: python @@ -26,7 +27,7 @@ >>> msg.bytes() [144, 60, 64] >>> msg.copy(channel=2) - + Message('note_on', channel=2, note=60, velocity=64, time=0) .. code-block:: python @@ -65,7 +66,7 @@ used interchangeably. New port types can be written by subclassing and overriding a few methods. - * includes a reusable MIDI parser. + * includes a reusable MIDI stream parser. * full support for MIDI files (read, write, create and play) with complete access to every message in the file, including all common @@ -90,7 +91,7 @@ Requirements ------------ - Mido targets Python 2.7 and 3.2. + Mido targets Python 3.6 and 2.7. Installing @@ -111,7 +112,7 @@ Source Code ----------- - https://github.com/olemb/mido/ + https://github.com/mido/mido/ License @@ -124,24 +125,9 @@ Questions and suggestions ------------------------- - Please ask questions about Mido at - https://groups.google.com/forum/#!forum/mido-community. - - This mailing list was created to give both the user community a place to ask - and hopefully also answer questions and for the developers a space to discuss - Mido development. The success of the mailing list will depend on the community - effort to also answer questions. - - - Looking for maintainers - ----------------------- - - This project is looking for somebody to take over the maintenance since the - original author @olemb is busy with other projects. We look for somebody or a - group of people who care about the code and would like to steer this project in - future by discussing proposals, reviewing pull requests, and looking over - issues. Please write to mido-community@googlegroups.com if you would like to - help out with maintenance. + For questions and proposals which may not fit into issues or pull requests, we + recommend to ask and discuss on `Discussions + `_. Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable @@ -150,6 +136,6 @@ Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2.7 -Classifier: Programming Language :: Python :: 3.2 +Classifier: Programming Language :: Python :: 3.6 Provides-Extra: dev Provides-Extra: ports diff -Nru python-mido-1.2.9/README.rst python-mido-1.2.10/README.rst --- python-mido-1.2.9/README.rst 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/README.rst 2020-12-21 16:16:38.000000000 +0000 @@ -1,11 +1,12 @@ Mido - MIDI Objects for Python ============================== -.. image:: https://travis-ci.org/olemb/mido.svg?branch=master - :target: https://travis-ci.org/olemb/mido +.. image:: https://travis-ci.org/mido/mido.svg?branch=master + :target: https://travis-ci.org/mido/mido +.. image:: https://github.com/mido/mido/workflows/Test/badge.svg + :target: https://github.com/mido/mido/actions -Mido is a library for working with MIDI messages and ports. It's -designed to be as straight forward and Pythonic as possible: +Mido is a library for working with MIDI messages and ports: .. code-block:: python @@ -18,7 +19,7 @@ >>> msg.bytes() [144, 60, 64] >>> msg.copy(channel=2) - + Message('note_on', channel=2, note=60, velocity=64, time=0) .. code-block:: python @@ -57,7 +58,7 @@ used interchangeably. New port types can be written by subclassing and overriding a few methods. -* includes a reusable MIDI parser. +* includes a reusable MIDI stream parser. * full support for MIDI files (read, write, create and play) with complete access to every message in the file, including all common @@ -82,7 +83,7 @@ Requirements ------------ -Mido targets Python 2.7 and 3.2. +Mido targets Python 3.6 and 2.7. Installing @@ -103,7 +104,7 @@ Source Code ----------- -https://github.com/olemb/mido/ +https://github.com/mido/mido/ License @@ -116,21 +117,6 @@ Questions and suggestions ------------------------- -Please ask questions about Mido at -https://groups.google.com/forum/#!forum/mido-community. - -This mailing list was created to give both the user community a place to ask -and hopefully also answer questions and for the developers a space to discuss -Mido development. The success of the mailing list will depend on the community -effort to also answer questions. - - -Looking for maintainers ------------------------ - -This project is looking for somebody to take over the maintenance since the -original author @olemb is busy with other projects. We look for somebody or a -group of people who care about the code and would like to steer this project in -future by discussing proposals, reviewing pull requests, and looking over -issues. Please write to mido-community@googlegroups.com if you would like to -help out with maintenance. +For questions and proposals which may not fit into issues or pull requests, we +recommend to ask and discuss on `Discussions +`_. diff -Nru python-mido-1.2.9/setup.py python-mido-1.2.10/setup.py --- python-mido-1.2.9/setup.py 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/setup.py 2020-12-21 16:16:38.000000000 +0000 @@ -16,7 +16,7 @@ return about -about = get_about() +about = get_about() try: @@ -68,6 +68,6 @@ 'License :: OSI Approved :: MIT License', 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.2', + 'Programming Language :: Python :: 3.6', ), ) diff -Nru python-mido-1.2.9/tests/messages/test_messages.py python-mido-1.2.10/tests/messages/test_messages.py --- python-mido-1.2.9/tests/messages/test_messages.py 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/tests/messages/test_messages.py 2020-12-20 19:54:19.000000000 +0000 @@ -108,3 +108,9 @@ def test_from_hex_sysex_data_type(): msg = Message.from_hex('F0 01 02 03 F7') assert isinstance(msg.data, SysexData) + + +def test_repr(): + msg = Message('note_on', channel=1, note=2, time=3) + msg_eval = eval(repr(msg)) + assert msg == msg_eval diff -Nru python-mido-1.2.9/tests/midifiles/test_meta.py python-mido-1.2.10/tests/midifiles/test_meta.py --- python-mido-1.2.9/tests/midifiles/test_meta.py 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/tests/midifiles/test_meta.py 2020-12-20 19:54:19.000000000 +0000 @@ -1,5 +1,5 @@ import pytest -from mido.midifiles.meta import MetaMessage, MetaSpec_key_signature, KeySignatureError +from mido.midifiles.meta import MetaMessage, UnknownMetaMessage, MetaSpec_key_signature, KeySignatureError def test_copy_invalid_argument(): @@ -30,3 +30,15 @@ msg = MetaMessage('key_signature') MetaSpec_key_signature().decode(msg, input_bytes) assert msg.key == expect_sig + + +def test_meta_message_repr(): + msg = MetaMessage('end_of_track', time=10) + msg_eval = eval(repr(msg)) + assert msg == msg_eval + + +def test_unknown_meta_message_repr(): + msg = UnknownMetaMessage(type_byte=99, data=[1, 2], time=10) + msg_eval = eval(repr(msg)) + assert msg == msg_eval diff -Nru python-mido-1.2.9/tests/midifiles/test_midifiles.py python-mido-1.2.10/tests/midifiles/test_midifiles.py --- python-mido-1.2.9/tests/midifiles/test_midifiles.py 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/tests/midifiles/test_midifiles.py 2020-12-20 19:54:19.000000000 +0000 @@ -1,7 +1,7 @@ import io from pytest import raises from mido.messages import Message -from mido.midifiles.midifiles import MidiFile +from mido.midifiles.midifiles import MidiFile, MidiTrack from mido.midifiles.meta import MetaMessage, KeySignatureError HEADER_ONE_TRACK = """ @@ -163,3 +163,19 @@ MetaMessage('end_of_track'), ] + + +def test_midifile_repr(): + midifile = MidiFile(type=1, ticks_per_beat=123, tracks=[ + MidiTrack([ + Message('note_on', channel=1, note=2, time=3), + Message('note_off', channel=1, note=2, time=3)]), + MidiTrack([ + MetaMessage('sequence_number', number=5), + Message('note_on', channel=2, note=6, time=9), + Message('note_off', channel=2, note=6, time=9)]), + ]) + midifile_eval = eval(repr(midifile)) + for track, track_eval in zip(midifile.tracks, midifile_eval.tracks): + for m1, m2 in zip(track, track_eval): + assert m1 == m2 diff -Nru python-mido-1.2.9/tests/midifiles/test_tracks.py python-mido-1.2.10/tests/midifiles/test_tracks.py --- python-mido-1.2.9/tests/midifiles/test_tracks.py 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/tests/midifiles/test_tracks.py 2020-12-20 19:54:19.000000000 +0000 @@ -1,6 +1,10 @@ +import itertools +from mido.messages import Message from mido.midifiles.meta import MetaMessage from mido.midifiles.tracks import MidiTrack +zip = getattr(itertools, 'izip', zip) + def test_track_slice(): track = MidiTrack() @@ -16,3 +20,13 @@ # The track should use the first name it finds. track = MidiTrack([name1, name2]) assert track.name == name1.name + + +def test_track_repr(): + track = MidiTrack([ + Message('note_on', channel=1, note=2, time=3), + Message('note_off', channel=1, note=2, time=3), + ]) + track_eval = eval(repr(track)) + for m1, m2 in zip(track, track_eval): + assert m1 == m2 diff -Nru python-mido-1.2.9/tests/test_frozen.py python-mido-1.2.10/tests/test_frozen.py --- python-mido-1.2.9/tests/test_frozen.py 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/tests/test_frozen.py 2020-12-20 19:54:19.000000000 +0000 @@ -1,4 +1,5 @@ from mido.messages import Message +from mido.midifiles.meta import MetaMessage, UnknownMetaMessage from mido.frozen import (is_frozen, freeze_message, thaw_message, FrozenMessage, FrozenMetaMessage, FrozenUnknownMetaMessage) @@ -27,3 +28,24 @@ def test_is_frozen(): assert is_frozen(FrozenMessage('note_on')) assert not is_frozen(Message('note_on')) + + +def test_frozen_repr(): + msg = FrozenMessage('note_on', channel=1, note=2, time=3) + msg_eval = eval(repr(msg)) + assert isinstance(msg_eval, FrozenMessage) + assert msg == msg_eval + + +def test_frozen_meta_repr(): + msg = FrozenMetaMessage('end_of_track', time=10) + msg_eval = eval(repr(msg)) + assert isinstance(msg_eval, FrozenMetaMessage) + assert msg == msg_eval + + +def test_frozen_unknown_meta_repr(): + msg = FrozenUnknownMetaMessage(type_byte=99, data=[1, 2], time=10) + msg_eval = eval(repr(msg)) + assert isinstance(msg_eval, UnknownMetaMessage) + assert msg == msg_eval diff -Nru python-mido-1.2.9/tests/test_tokenizer.py python-mido-1.2.10/tests/test_tokenizer.py --- python-mido-1.2.9/tests/test_tokenizer.py 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/tests/test_tokenizer.py 2020-12-20 19:54:19.000000000 +0000 @@ -35,7 +35,7 @@ The sysex messages should be delivered first. This is the only case where a message is allowed inside another message. - """ + """ assert tokenize([0xf0, 1, 0xf8, 2, 0xf7]) == [[0xf8], [0xf0, 1, 2, 0xf7]] assert tokenize([0xf0, 0xf8, 0xf7]) == [[0xf8], [0xf0, 0xf7]] diff -Nru python-mido-1.2.9/tox.ini python-mido-1.2.10/tox.ini --- python-mido-1.2.9/tox.ini 2018-10-04 21:07:07.000000000 +0000 +++ python-mido-1.2.10/tox.ini 2020-12-18 00:22:05.000000000 +0000 @@ -6,4 +6,4 @@ py.test . -rs -q check-manifest -v sphinx-build docs {envtmpdir} -q -E - flake8 mido --ignore=F401 + flake8 mido