{"id":13434224,"url":"https://github.com/craffel/pretty-midi","last_synced_at":"2025-05-13T23:11:03.560Z","repository":{"id":9832673,"uuid":"11820959","full_name":"craffel/pretty-midi","owner":"craffel","description":"Utility functions for handling MIDI data in a nice/intuitive way.","archived":false,"fork":false,"pushed_at":"2024-12-11T01:16:03.000Z","size":7808,"stargazers_count":924,"open_issues_count":36,"forks_count":155,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-04-14T22:03:52.286Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/craffel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-08-01T15:50:19.000Z","updated_at":"2025-04-12T06:38:07.000Z","dependencies_parsed_at":"2024-06-18T13:48:13.240Z","dependency_job_id":"cadcb080-69ac-4b33-8f80-a4ab657bf287","html_url":"https://github.com/craffel/pretty-midi","commit_stats":{"total_commits":233,"total_committers":26,"mean_commits":8.961538461538462,"dds":0.1673819742489271,"last_synced_commit":"1e0fb75dca0a40aa810db3571ea5059c49124876"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craffel%2Fpretty-midi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craffel%2Fpretty-midi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craffel%2Fpretty-midi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craffel%2Fpretty-midi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/craffel","download_url":"https://codeload.github.com/craffel/pretty-midi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254042340,"owners_count":22004901,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T02:01:50.429Z","updated_at":"2025-05-13T23:10:58.534Z","avatar_url":"https://github.com/craffel.png","language":"Jupyter Notebook","funding_links":[],"categories":["Jupyter Notebook","Uncategorized","Open Source Libraries","Music Theory \u0026 Composition"],"sub_categories":["Uncategorized","Text-to-Speech"],"readme":"`pretty_midi` contains utility function/classes for handling MIDI data, so that it's in a format which is easy to modify and extract information from.\n\nDocumentation is available [here](http://craffel.github.io/pretty-midi/).  You can also find a Jupyter notebook tutorial [here](https://nbviewer.org/github/craffel/pretty-midi/blob/main/Tutorial.ipynb) (click [here](https://colab.research.google.com/github/craffel/pretty-midi/blob/main/Tutorial.ipynb) to load in Colab).\n\n`pretty_midi` is available via [pip](https://pypi.python.org/pypi/pretty_midi) or via the [setup.py](https://github.com/craffel/pretty-midi/blob/master/setup.py) script. In order to synthesize MIDI data using fluidsynth, you need the [fluidsynth](http://www.fluidsynth.org/) program and [pyfluidsynth](https://pypi.python.org/pypi/pyfluidsynth).\n\nIf you end up using `pretty_midi` in a published research project, please cite the following report:\n\nColin Raffel and Daniel P. W. Ellis. [_Intuitive Analysis, Creation and Manipulation of MIDI Data with pretty_midi_](http://colinraffel.com/publications/ismir2014intuitive.pdf). In Proceedings of the 15th International Conference on Music Information Retrieval Late Breaking and Demo Papers, 2014.\n\n\nExample usage for analyzing, manipulating and synthesizing a MIDI file:\n\n```python\nimport pretty_midi\n# Load MIDI file into PrettyMIDI object\nmidi_data = pretty_midi.PrettyMIDI('example.mid')\n# Print an empirical estimate of its global tempo\nprint(midi_data.estimate_tempo())\n# Compute the relative amount of each semitone across the entire song, a proxy for key\ntotal_velocity = sum(sum(midi_data.get_chroma()))\nprint([sum(semitone)/total_velocity for semitone in midi_data.get_chroma()])\n# Shift all notes up by 5 semitones\nfor instrument in midi_data.instruments:\n    # Don't want to shift drum notes\n    if not instrument.is_drum:\n        for note in instrument.notes:\n            note.pitch += 5\n# Synthesize the resulting MIDI data using sine waves\naudio_data = midi_data.synthesize()\n```\n\nExample usage for creating a simple MIDI file:\n\n```python\nimport pretty_midi\n# Create a PrettyMIDI object\ncello_c_chord = pretty_midi.PrettyMIDI()\n# Create an Instrument instance for a cello instrument\ncello_program = pretty_midi.instrument_name_to_program('Cello')\ncello = pretty_midi.Instrument(program=cello_program)\n# Iterate over note names, which will be converted to note number later\nfor note_name in ['C5', 'E5', 'G5']:\n    # Retrieve the MIDI note number for this note name\n    note_number = pretty_midi.note_name_to_number(note_name)\n    # Create a Note instance for this note, starting at 0s and ending at .5s\n    note = pretty_midi.Note(velocity=100, pitch=note_number, start=0, end=.5)\n    # Add it to our cello instrument\n    cello.notes.append(note)\n# Add the cello instrument to the PrettyMIDI object\ncello_c_chord.instruments.append(cello)\n# Write out the MIDI data\ncello_c_chord.write('cello-C-chord.mid')\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcraffel%2Fpretty-midi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcraffel%2Fpretty-midi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcraffel%2Fpretty-midi/lists"}