{ "info": { "author": "Christopher Arndt", "author_email": "chris@chrisarndt.de", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Intended Audience :: End Users/Desktop", "License :: OSI Approved :: MIT License", "Operating System :: MacOS :: MacOS X", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Multimedia :: Sound/Audio :: MIDI", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities" ], "description": "miditk-smf\n##########\n\nA toolkit for working with Standard MIDI files\n\n\nQuickstart\n==========\n\nInstall:\n\n.. code-block:: console\n\n $ pip install miditk-smf\n\nUsage:\n\n.. code-block:: python\n\n from miditk.smf import MidiFileWriter\n\n # Open file for writing in binary mode.\n with open('minimal.mid', 'wb') as smf:\n # Create standard MIDI file writer.\n midi = MidiFileWriter(smf)\n\n # Write file and track header for Type 0 file, one track, 96 pulses per\n # quarter note (ppqn). These are also the default parameter values.\n midi.header(format=0, num_tracks=1, tick_division=96)\n midi.start_of_track()\n\n # Set tempo to 120 bpm in \u00b5sec per quarter note.\n # When no tempo is set in the MIDI file, sequencers will generally assume\n # it to be 120 bpm.\n midi.tempo(int(60000000 / 120))\n\n # Add MIDI events.\n midi.note_on(channel=0, note=0x40)\n # Advance 192 ticks (i.e. a half note).\n midi.update_ticks(192)\n midi.note_off(channel=0, note=0x40)\n\n # End track and midi file.\n midi.end_of_track()\n midi.eof()\n\nFor more examples, see the `Usage examples`_ section below.\n\n\nOverview\n========\n\n``miditk-smf`` is a general-purpose library for the parsing and generation of\nStandard MIDI Files (SMF). The package is part of several planned packages\nunder the common top-level package namespace ``miditk``. This package mainly\nprovides the ``miditk.smf`` sub-package for handling standard MIDI files.\nAdditional sub-packages with more specialised MIDI libraries and tools will be\ndistributed as separate package distributions in the future.\n\n\nCompatibility\n-------------\n\n``miditk-smf`` works with Python 2.7, Python 3.4+ and PyPy 2 and 3.\n\n\nInstallation\n============\n\n``miditk-smf`` is installable via pip_ from the `Python Package Index`_:\n\n.. code-block:: console\n\n $ pip install miditk-smf\n\nIt is provided as a source distribution and a universal Python wheel for\nall supported Python versions and operating systems. It only depends on\nthe Python standard library and the third-party module six_.\n\n\nPackage contents\n================\n\n``miditk.common``\n A collection of constants from the MIDI specification used by sub-packages\n and general data types for working with MIDI events.\n\n``miditk.smf``\n An event-based standard MIDI file (SMF) parsing and generation framework.\n\n``miditk.smf.api``\n Base event handler classes, which can be sublassed for specialised event\n handling.\n\n``miditk.smf.converters``\n A collection of functions that converts the special data types used in midi\n files to and from byte strings.\n\n``miditk.smf.parser``\n The main binary MIDI file data parser.\n\n``miditk.smf.reader``\n Combines the parser with an event handler class.\n\n``miditk.smf.sequence``\n An event handler, which stores all MIDI events from a MIDI file in a\n MidiSequence container class.\n\n``miditk.smf.writer``\n An event handler to write out MIDI events to a Standard MIDI File.\n\n\nUsage examples\n==============\n\nThe following section contains a few code examples, which demonstrate several\nusage scenarios for the different modules in the package. For more examples see\nalso the scripts in the ``examples`` directory of the source distribution.\n\n\nParsing a standard MIDI file\n----------------------------\n\nThe ``miditk.smf`` module provides the ``MidiSequence`` container class, which\nuses its own MIDI event handler class to collect all information and events\nfrom parsing a midi file. Use the ``MidiSequence.fromfile()`` class method to\nparse a standard MIDI file.\n\nYou can then use several convenience methods of the returned ``MidiSequence``\ninstance to access information about the midi file properties or events.\n\n.. code-block:: python\n\n from miditk.smf import MidiSequence\n\n # Do parsing\n sequence = MidiSequence.fromfile(sys.argv[1])\n\n # Print some info from the MIDI file header,\n # e.g. number of tracks, events sequence name.\n print(sequence)\n # Print a list of events with event type, data and timestamp.\n sequence.dump_events()\n\n # Iterate over all sysex events in track 0.\n # If track is not specified, sysex_events() yields all sysex events\n # in all tracks.\n for ev in sequence.sysex_events(track=0):\n print \"Sysex event (%i bytes) @ %.2f\" (len(ev.data), ev.timestamp)\n\n # Iterate over all events sorted by timestamp and then track.\n for ev in sequence.events_by_time():\n handle_event(ev)\n\n\nChanging MIDI events in-stream\n------------------------------\n\nThe event-based parsing allows to handle MIDI events as they are read (or\nreceived via MIDI in). You need to define a sub-class of\n``miditk.smf.BaseMidiEventHandler`` or ``miditk.smf.NullMidiEventHandler``\nand overwrite only the event handling methods for the events you are\ninterested in.\n\nThe following example transposes all note on/off events by an octave (i.e. 12\nsemitones):\n\n.. code-block:: python\n\n import sys\n from miditk.smf import MidiFileReader, MidiFileWriter\n\n # MidiFileWriter is a sub-class of NullMidiEventHandler.\n class Transposer(MidiFileWriter):\n \"\"\"Transpose note values of all note on/off events by 1 octave.\"\"\"\n\n def note_on(self, channel, note, velocity):\n super().note_on(self, channel, min(127, note + 12), velocity)\n\n def note_off(self, channel, note, velocity):\n super().note_off(self, channel, min(127, note + 12), velocity)\n\n infile = sys.argv.pop(1)\n outfile = sys.argv.pop(1)\n\n # Create the parser and event handler\n with open(outfile, 'wb') as smf:\n midiout = Transposer(smf)\n midiin = MidiFileReader(infile, midiout)\n\n # Now do the processing.\n midiin.read()\n\n\nDevelopment\n===========\n\nClone the repo:\n\n.. code-block:: console\n\n $ git clone https://github.com/SpotlightKid/miditk-smf.git\n $ cd miditk-smf\n\nInstall tox:\n\n.. code-block:: console\n\n $ pip install tox\n\nOr via your Linux distribution package manager, e.g. on debian/Ubuntu:\n\n.. code-block:: console\n\n $ sudo apt-get install python-tox\n\nOr on Arch Linux:\n\n.. code-block:: console\n\n $ sudo pacman -S python-tox\n\nRun the tests via tox for all Python versions configured in `tox.ini`:\n\n.. code-block:: console\n\n $ tox\n\nIf all is well, create a new git branch and start hacking and then\ncontribute your changes by opening a `pull request`_ on GitHub.\n\n\nCode QA\n=======\n\nThe included Makefile is set up to run several Python static code checking and\nreporting tools. To print a list of available Makefile targets and the tools\nthey run, simple run:\n\n.. code-block:: console\n\n $ make\n\nThen run the Makefile target of your choice, e.g.:\n\n.. code-block:: console\n\n $ make flake8\n\nUnless noted otherwise, these targets run all tools directly, i.e. without tox,\nwhich means they need to be installed in your Python environment, preferably in\na project-specific virtual environment. To create a virtual environment and\ninstall all supported tools and their dependencies run:\n\n.. code-block:: console\n\n $ mkvirtualenv miditk-smf\n (miditk-smf)$ pip install -r requirements/dev.txt\n\n\nDocumentation\n=============\n\nPackage documentation is generated by Sphinx. The documentation can be build\nwith:\n\n.. code-block:: console\n\n $ make docs\n\nAfter a successful build the documentation index is opened in your web browser.\n\n\nAuthors and License\n===================\n\nThe ``miditk`` package is written by Christopher Arndt and licensed under the\nMIT License.\n\nThe the structure of the ``miditk.smf`` sub-package ows inspiration to the\n`python midi package`_, written by maxm@maxm.dk.\n\n\n.. _python midi package: http://www.mxm.dk/products/public/pythonmidi/\n.. _python package index: https://pypi.org/project/miditk-smf/\n.. _pip: https://pypi.org/project/pip/\n.. _six: https://pypi.org/project/six/\n.. _pull request: https://github.com/SpotlightKid/miditk-smf/pulls\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/SpotlightKid/miditk-smf", "keywords": "MIDI,parsing,multimedia,I/O", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "miditk-smf", "package_url": "https://pypi.org/project/miditk-smf/", "platform": "POSIX", "project_url": "https://pypi.org/project/miditk-smf/", "project_urls": { "Homepage": "https://github.com/SpotlightKid/miditk-smf" }, "release_url": "https://pypi.org/project/miditk-smf/0.2.2/", "requires_dist": [ "six" ], "requires_python": "", "summary": "A toolkit for working with Standard MIDI files", "version": "0.2.2" }, "last_serial": 4659544, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "943b116644ee9d9dd23954355e4d7ecc", "sha256": "6924a294ecdfdc3a4e547fb6e23a8e741032c5daece4e6faafe53ecf48bd7243" }, "downloads": -1, "filename": "miditk_smf-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "943b116644ee9d9dd23954355e4d7ecc", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 76289, "upload_time": "2018-04-09T22:05:58", "url": "https://files.pythonhosted.org/packages/ee/c8/4454566ebf8c1450389142c6b4a5fe79fe7d9068a8b7861341e83d1d51f5/miditk_smf-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "99ba4a65c87576f7effe31e512b337a3", "sha256": "7fb3af0266110fc8be9743321dc567661fbb9e0b23dc873961e4e94a89ed2290" }, "downloads": -1, "filename": "miditk-smf-0.1.0.tar.gz", "has_sig": false, "md5_digest": "99ba4a65c87576f7effe31e512b337a3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 91889, "upload_time": "2018-04-09T22:05:59", "url": "https://files.pythonhosted.org/packages/b8/1d/a0368c2ddb6f551d79bb0b87262cc9047af7f91b3f77382c7ca19e23b3f9/miditk-smf-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "383e31b3667a960d319b9c019b41f002", "sha256": "b06abcc00bdbaa17d15b593ed229d500d7c7391821356b59660e7838ac960a18" }, "downloads": -1, "filename": "miditk_smf-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "383e31b3667a960d319b9c019b41f002", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 28866, "upload_time": "2018-04-18T13:43:59", "url": "https://files.pythonhosted.org/packages/ea/62/56385b77688e368bcc7678efbda2d68e50dae9dc0b8289e0e8a5eed633a9/miditk_smf-0.2.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5ee7b228f51f34fc98e556db89ae1a2a", "sha256": "16b7f465ce0b5bf27ee8cb88179452b0614d1db765e60ab43b83a733ae1d994e" }, "downloads": -1, "filename": "miditk-smf-0.2.0.tar.gz", "has_sig": false, "md5_digest": "5ee7b228f51f34fc98e556db89ae1a2a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 45241, "upload_time": "2018-04-18T13:44:01", "url": "https://files.pythonhosted.org/packages/9e/a6/e0a0c3c1aca939fc973725e89bd90d7c0e49f726ec0dfeb847fda760eb7e/miditk-smf-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "00ea297051ace389fc586f43b12de6b8", "sha256": "a6c53c13674f9ee563be34de91bccdba9369691105ea3be27f79ba275eb14575" }, "downloads": -1, "filename": "miditk_smf-0.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "00ea297051ace389fc586f43b12de6b8", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 28958, "upload_time": "2018-08-30T15:11:22", "url": "https://files.pythonhosted.org/packages/d8/53/a5bbb0ce4dbd53188abd57479b4f9bd2c67dc12c67ed03e0369b03bc9912/miditk_smf-0.2.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "953dbe7bb449472fb53827322545d55d", "sha256": "7458a3c387da2f1197c2971813736c5cad8cae78920e9b4e8fe5eea56649dcee" }, "downloads": -1, "filename": "miditk-smf-0.2.1.tar.gz", "has_sig": false, "md5_digest": "953dbe7bb449472fb53827322545d55d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 49482, "upload_time": "2018-08-30T15:12:46", "url": "https://files.pythonhosted.org/packages/d8/8e/3d36ffa86576666a87053955f02666778388048a9716d2165c630a42b238/miditk-smf-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "a5310219e8167d2ed7327b7c4a6e5dca", "sha256": "5af6a5f2bf9b25e6c1ad403dc66d8effd0e5dd713447fb665fe3bcc78198aac7" }, "downloads": -1, "filename": "miditk_smf-0.2.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a5310219e8167d2ed7327b7c4a6e5dca", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 29986, "upload_time": "2019-01-04T09:22:19", "url": "https://files.pythonhosted.org/packages/41/5e/3d78d85b2085fc2db92334f5fe942d841d9598b81b2d62521fa1ba57ddee/miditk_smf-0.2.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "37696c5e0d32a86304cf4e36df4fc284", "sha256": "45c816ddd41fc04586c952bc12283b815476e50a6d17c7513c8ba3fbac7e959e" }, "downloads": -1, "filename": "miditk-smf-0.2.2.tar.gz", "has_sig": false, "md5_digest": "37696c5e0d32a86304cf4e36df4fc284", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 51987, "upload_time": "2019-01-04T09:22:21", "url": "https://files.pythonhosted.org/packages/1e/29/87e04d114c88daa53642ea5f51d3d69bc8131e1171421113bd25231d0059/miditk-smf-0.2.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a5310219e8167d2ed7327b7c4a6e5dca", "sha256": "5af6a5f2bf9b25e6c1ad403dc66d8effd0e5dd713447fb665fe3bcc78198aac7" }, "downloads": -1, "filename": "miditk_smf-0.2.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a5310219e8167d2ed7327b7c4a6e5dca", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 29986, "upload_time": "2019-01-04T09:22:19", "url": "https://files.pythonhosted.org/packages/41/5e/3d78d85b2085fc2db92334f5fe942d841d9598b81b2d62521fa1ba57ddee/miditk_smf-0.2.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "37696c5e0d32a86304cf4e36df4fc284", "sha256": "45c816ddd41fc04586c952bc12283b815476e50a6d17c7513c8ba3fbac7e959e" }, "downloads": -1, "filename": "miditk-smf-0.2.2.tar.gz", "has_sig": false, "md5_digest": "37696c5e0d32a86304cf4e36df4fc284", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 51987, "upload_time": "2019-01-04T09:22:21", "url": "https://files.pythonhosted.org/packages/1e/29/87e04d114c88daa53642ea5f51d3d69bc8131e1171421113bd25231d0059/miditk-smf-0.2.2.tar.gz" } ] }