{ "info": { "author": "James Wenzel", "author_email": "jameswenzel@berkeley.edu", "bugtrack_url": null, "classifiers": [], "description": "=Mydy=\n\nMydy is a Python MIDI IO library, and a fork of python-midi by Giles Hall. Mydy is specifically re-written for Python 3, and does not support Python 2.\n\nMydy supports vectorized operations on MIDI Patterns, Tracks and Events by overloading builtin operators.\n\n==Features==\n\nFeatures specific to Mydy:\n\n* Designed for Python 3\n* Transpose patterns/tracks/events using the + and - operators\n* Change the speed of patterns/tracks/events using the * and / operators\n* Change velocity of patterns/tracks/events using the >> and << operators\n* Extend a track with copies of itself using the ** operator\n* Map functions of events over tracks with the map method\n\nFeatures from the base python-midi:\n\n* High level class types that represent individual MIDI events.\n* A multi-track aware container, that allows you to manage your MIDI events.\n* A reader and writer, so you can read and write your MIDI tracks to disk.\n\n==Installation==\n\nAfter cloning the directory, \n
\npython setup.py install\n
\n\n===Examine a MIDI File===\n\nTo examine the contents of a MIDI file run\n\n
\n$ mididump.py mary.mid\n
\n\nThis will print out a representation of \"Mary had a Little Lamb\" as executable python code.\n\n==Example Usage==\n\n===Building a MIDI File from scratch===\n\nIt is easy to build a MIDI track from scratch.\n\n
\nimport midi\n# Instantiate a MIDI Pattern (contains a list of tracks)\npattern = midi.Pattern()\n# Instantiate a MIDI Track (contains a list of MIDI events)\ntrack = midi.Track()\n# Append the track to the pattern\npattern.append(track)\n# Instantiate a MIDI note on event, append it to the track\non = midi.NoteOnEvent(tick=0, velocity=20, pitch=midi.G_3)\ntrack.append(on)\n# Instantiate a MIDI note off event, append it to the track\noff = midi.NoteOffEvent(tick=100, pitch=midi.G_3)\ntrack.append(off)\n# Add the end of track event, append it to the track\neot = midi.EndOfTrackEvent(tick=1)\ntrack.append(eot)\n# Print out the pattern\nprint pattern\n# Save the pattern to disk\nmidi.write_midifile(\"example.mid\", pattern)\n
\n\nA MIDI file is represented as a hierarchical set of objects. At the top is a\nPattern, which contains a list of Tracks, and a Track is is a list of MIDI\nEvents. \n\nThe MIDI Pattern class inherits from the standard python list, so it supports\nall list features such as append(), extend(), slicing, and iteration. Patterns\nalso contain global MIDI metadata: the resolution and MIDI Format.\n\nThe MIDI Track class also inherits from the standard python list. It does not\nhave any special metadata like Pattern, but it does provide a few helper\nfunctions to manipulate all events within a track.\n\nThere are 27 different MIDI Events supported. In this example, three different\nMIDI events are created and added to the MIDI Track: \n\n# The NoteOnEvent captures the start of note, like a piano player pushing down on a piano key. The tick is when this event occurred, the pitch is the note value of the key pressed, and the velocity represents how hard the key was pressed.\n\n# The NoteOffEvent captures the end of note, just like a piano player removing her finger from a depressed piano key. Once again, the tick is when this event occurred, the pitch is the note that is released, and the velocity has no real world analogy and is usually ignored. NoteOnEvents with a velocity of zero are equivalent to NoteOffEvents.\n\n# The EndOfTrackEvent is a special event, and is used to indicate to MIDI sequencing software when the song ends. With creating Patterns with multiple Tracks, you only need one EndOfTrack event for the entire song. Most MIDI software will refuse to load a MIDI file if it does not contain an EndOfTrack event.\n\nYou might notice that the EndOfTrackEvent has a tick value of 1. This is\nbecause MIDI represents ticks in relative time. The actual tick offset of the\nMidiTrackEvent is the sum of its tick and all the ticks from previous events.\nIn this example, the EndOfTrackEvent would occur at tick 101 (0 + 100 + 1).\n\n====Side Note: What is a MIDI Tick?====\n\nThe problem with ticks is that they don't give you any information about when\nthey occur without knowing two other pieces of information, the resolution, and\nthe tempo. The code handles these issues for you so all you have to do is\nthink about things in terms of milliseconds, or ticks, if you care about the beat. \n\nA tick represents the lowest level resolution of a MIDI track. Tempo is always\nanalogous with Beats per Minute (BPM) which is the same thing as Quarter notes\nper Minute (QPM). The Resolution is also known as the Pulses per Quarter note\n(PPQ). It analogous to Ticks per Beat (TPM).\n\nTempo is set by two things. First, a saved MIDI file encodes an initial\nResolution and Tempo. You use these values to initialize the sequencer timer.\nThe Resolution should be considered static to a track, as well as the\nsequencer. During MIDI playback, the MIDI file may have encoded sequenced\n(that is, timed) Tempo change events. These events will modulate the Tempo at\nthe time they specify. The Resolution, however, can not change from its\ninitial value during playback.\n\nUnder the hood, MIDI represents Tempo in microseconds. In other words, you\nconvert Tempo to Microseconds per Beat. If the Tempo was 120 BPM, the python\ncode to convert to microseconds looks like this:\n\n
\n>>> 60 * 1000000 / 120\n500000\n
\n\nThis says the Tempo is 500,000 microseconds per beat. This, in combination\nwith the Resolution, will allow you to convert ticks to time. If there are\n500,000 microseconds per beat, and if the Resolution is 1,000 than one tick is\nhow much time?\n\n
\n>>> 500000 / 1000\n500\n>>> 500 / 1000000.0\n0.00050000000000000001\n
\n\nIn other words, one tick represents .0005 seconds of time or half a\nmillisecond. Increase the Resolution and this number gets smaller, the inverse\nas the Resolution gets smaller. Same for Tempo.\n\nAlthough MIDI encodes Time Signatures, it has no impact on the Tempo. However,\nhere is a quick refresher on Time Signatures:\n\nhttp://en.wikipedia.org/wiki/Time_signature\n\n===Reading our Track back from Disk===\n\nIt's just as easy to load your MIDI file from disk.\n\n
\nimport midi\npattern = midi.read_midifile(\"example.mid\")\nprint pattern\n
\n\n==Website, support, bug tracking, development etc.==\n\nYou can find the latest code on the home page:\nhttps://github.com/jameswenzel/mydy/\n\nYou can also check for known issues and submit new ones to the\ntracker: https://github.com/jameswenzel/mydy/issues/\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://gitlab.com/phrz/mydy", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "mydy", "package_url": "https://pypi.org/project/mydy/", "platform": "", "project_url": "https://pypi.org/project/mydy/", "project_urls": { "Homepage": "https://gitlab.com/phrz/mydy" }, "release_url": "https://pypi.org/project/mydy/0.0.3/", "requires_dist": null, "requires_python": "", "summary": "Vectorized Python MIDI IO", "version": "0.0.3" }, "last_serial": 4018814, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "484e8badac5554ce35447f46f8747c9b", "sha256": "fccb5f8aa7d21f13f5bb57007f823c8411aa2a672c6b4aa331dbe2613bc33065" }, "downloads": -1, "filename": "mydy-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "484e8badac5554ce35447f46f8747c9b", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 14413, "upload_time": "2018-06-30T18:18:39", "url": "https://files.pythonhosted.org/packages/3c/16/09a20a1cb6f2712b16467b96ef873ccedfe38ed8f3db2d63e58b4ffc26f7/mydy-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "62e13b286a8f61aaccf549055c42d35f", "sha256": "302f3a3c9f3b64963eb3dfc3ea558748e92867a7e4a9f1b70e4ab30f323512a0" }, "downloads": -1, "filename": "mydy-0.0.2.tar.gz", "has_sig": false, "md5_digest": "62e13b286a8f61aaccf549055c42d35f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14169, "upload_time": "2018-06-30T18:18:38", "url": "https://files.pythonhosted.org/packages/bf/87/ab3acdaec9e32aa7b09147c45f05c1b4dbf1aa67ca9e93bb513124f8729c/mydy-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "0bd502301e60cd5e94fed5770d11da59", "sha256": "86f8ff111680ac968e054b69e091d82875a443a77b53359c1153550b814c10af" }, "downloads": -1, "filename": "mydy-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "0bd502301e60cd5e94fed5770d11da59", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 17122, "upload_time": "2018-06-30T18:26:25", "url": "https://files.pythonhosted.org/packages/52/c3/ddabd7037e9670e61e7ff47c6330e49c40fbdfdac0c3a2f6bc4d345cafc9/mydy-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "62e459ccd13c669b6650f2304b6a8fbc", "sha256": "747cfc1396bb45cdd4930cf90adb10977bc74942f407624daa5f29da3ceafc21" }, "downloads": -1, "filename": "mydy-0.0.3.tar.gz", "has_sig": false, "md5_digest": "62e459ccd13c669b6650f2304b6a8fbc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14840, "upload_time": "2018-06-30T18:26:24", "url": "https://files.pythonhosted.org/packages/1c/3d/c8ac8ccc8ff4dd9269bdf37a4358c0e45a48503302221fbf275b6a452707/mydy-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0bd502301e60cd5e94fed5770d11da59", "sha256": "86f8ff111680ac968e054b69e091d82875a443a77b53359c1153550b814c10af" }, "downloads": -1, "filename": "mydy-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "0bd502301e60cd5e94fed5770d11da59", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 17122, "upload_time": "2018-06-30T18:26:25", "url": "https://files.pythonhosted.org/packages/52/c3/ddabd7037e9670e61e7ff47c6330e49c40fbdfdac0c3a2f6bc4d345cafc9/mydy-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "62e459ccd13c669b6650f2304b6a8fbc", "sha256": "747cfc1396bb45cdd4930cf90adb10977bc74942f407624daa5f29da3ceafc21" }, "downloads": -1, "filename": "mydy-0.0.3.tar.gz", "has_sig": false, "md5_digest": "62e459ccd13c669b6650f2304b6a8fbc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14840, "upload_time": "2018-06-30T18:26:24", "url": "https://files.pythonhosted.org/packages/1c/3d/c8ac8ccc8ff4dd9269bdf37a4358c0e45a48503302221fbf275b6a452707/mydy-0.0.3.tar.gz" } ] }