Skip to main content
pygmidi logo

pygmidi

A general representation for MIDI files for symbolic music data-driven approaches

MIDI files are a common way to represent symbolic music. pygmidi (Python General Midi) is a facade for the most used python packages focused on midi files manipulation, so it can used transparently. For now, it includes:

  • midi Pattern
  • PrettyMidi
  • pianoroll Multitrack
  • MidiFile
  • MidiArray: a new minimalistic representation that uses only an array and a list of instruments, allowing to easily have a tensor representation of the midi file aimming machine learning purposes

New Features:

  • Methods to automatically orchestrate and slice midi files to help pre-processing midi data
  • sparray is a sparse array representation for efficient disk saving purposes with which you may save and load tensor representated midi files for both time and space efficiency
  • Set of evaluation tools for variable sized sequences of pianoroll blocks and metrics for music evaluation
  • A lot of different ways to export to jpg, gif and wav formats (comming exporting to PDF)

Instalation


$ git clone https://github.com/LESSSE/pygmidi
$ cd pygmidi
$ pip install . --user

Typical Use


    #!/usr/bin/env python

    from pygmidi import pygmidi
    g = pygmidi("path_to_midifile.mid")

    g.transpose(-1)
    g.to_npz("new_npz_path")
    g.to_gif("new_gif_path")

For processing midi files in a directory


    #!/usr/bin/env python

    from pygmidi import pygmidi,utils,midiarray
    from glob import glob
    from os import path

    programs_map = {('woods',False): 0,
                ('brass',False): 1,
                ('percussion',True): 2,
                ('timpani',False): 3,
                ('chromatic_percussion',False): 4,
                ('voices', False): 5,
                ('guitars',False): 6,
                ('basses',False): 6,
                ('strings',False): 6,
                ('keyboards',False): 7}

    #Tracks_map is the configuration for the new orchestrated tracks
    tracks_map = [{'program':71,'is_drum':False,"name":"woods"}, #woods
                {'program':60,'is_drum':False,"name":"brass"}, #brass
                {'program':0,'is_drum':True,"name":"percussion"},  #percussion
                {'program':47,'is_drum':False,"name":"timpani"}, #timpani
                {'program':14,'is_drum':False,"name":"tubular bells"}, #tubular bells
                {'program':52,'is_drum':False,"name":"voices"}, #voices
                {'program':48,'is_drum':False,"name":"strings"}, #strings
                {'program':1,'is_drum':False,"name":"piano"}] #piano

    for i in glob('{}/*.mid'.format("midi")):
         a = pygmidi.process(songs[0],
                  i_to_t=programs_map,
                  t_to_i=tracks_map,
                  ticks=4*24*4,
                  transpose=(0,1))
         utils.sparray.save("{}/{}.npz".format("npz",path.splitext(path.basename(i))[0]),a)

Metadata

Release files for pygmidi 4.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pygmidi 4.0.1
File Size Uploaded Provenance Actions
pygmidi-4.0.1.tar.gz 24.3 kB Without provenance Details for pygmidi-4.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pygmidi 4.0.1
File Interpreter ABI Platform Actions
pygmidi-4.0.1-py3-none-any.whl Python 3 none any Details for pygmidi-4.0.1-py3-none-any.whl

Total release size: 48.5 kB

Release files / pygmidi-4.0.1.tar.gz

Download URL pygmidi-4.0.1.tar.gz
Size 24.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5eda8db0e51f27bb61510246564bbe677e91e36ebdf36a90bb7823ce39005f2f
BLAKE2b-256 checksum
How to use checksums
b9592ca42bd01fa417b2305b04b5dfcf3b53eb71884dd1b1283aa5c5c27637bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Release files / pygmidi-4.0.1-py3-none-any.whl

Download URL pygmidi-4.0.1-py3-none-any.whl
Size 24.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6bfab99104b6384cd8c5c6a82e660fcf3cf3e70390eedcf75c794599d838b761
BLAKE2b-256 checksum
How to use checksums
dc3e060f5ebf9f5ee52e9581f3c7f1a7de80d35906a95ec2bcbbc7a38a931788
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Security for pygmidi 4.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

4.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page