Skip to main content

rmidipy

This python library is intended to open midi files as python objects. Midi file is binary files, list in form of tracks. Every track contains sequence of events. Each event is assosiated delta time, which refers to time from perivous event, current event should occur.

In same structure rmidi has MIDI as base class, MIDI.Track for track representation and MIDI.Track.Event to represent each event.

Getting Started

rmidi is available on python pip. You can install library through below command.

    pip install rmidi

MIDI

>>> from rmidi import MIDI
>>> y = MIDI.parse_midi(<midi_file_name>)

OUTPUT

| Absolute Time   |  Duration       |  Delta Time |  ETYPE     |   Event ID | META  | LENGTH     | DATA
|______________________________________________________________________________________________________________________________ . . .
| 0.000000        | 0.000000        | 0x0         | META       | 0xff       | 0x58  | 0x4        |  0x04  0x02 0x18  0x08

| 0.000000        | 0.000000        | 0x0         | META       | 0xff       | 0x59  | 0x2        |  0x00  0x00

| 0.000000        | 0.000000        | 0x0         | META       | 0xff       | 0x51  | 0x3        |  0x07  0xa1 0x20

| 0.000000        | 0.000000        | 0x0         | CHANNEL    | 0xb0       | 0     | 0x2        |  0x79  0x00

| 0.000000        | 0.000000        | 0x0         | CHANNEL    | 0xc0       | 0     | 0x1        |  0x00

| 0.000000        | 0.000000        | 0x0         | CHANNEL    | 0xb0       | 0     | 0x2        |  0x07  0x64

| 0.000000        | 0.000000        | 0x0         | CHANNEL    | 0xb0       | 0     | 0x2        |  0x0a  0x40

| 0.000000        | 0.000000        | 0x0         | CHANNEL    | 0xb0       | 0     | 0x2        |  0x5b  0x00

| 0.000000        | 0.000000        | 0x0         | CHANNEL    | 0xb0       | 0     | 0x2        |  0x5d  0x00

| 0.000000        | 0.000000        | 0x0         | META       | 0xff       | 0x21  | 0x1        |  0x00

| 0.000000        | 0.000000        | 0x0         | CHANNEL    | 0x90       | 0     | 0x2        |  0x48  0x50

| 0.000000        | 0.000000        | 0x71f       | CHANNEL    | 0x90       | 0     | 0x2        |  0x48  0x00

| 0.000000        | 0.000000        | 0x61        | CHANNEL    | 0x90       | 0     | 0x2        |  0x4a  0x50

| 0.000000        | 0.000000        | 0x71f       | CHANNEL    | 0x90       | 0     | 0x2        |  0x4a  0x00

| 0.000000        | 0.000000        | 0x61        | CHANNEL    | 0x90       | 0     | 0x2        |  0x4c  0x50

| 0.000000        | 0.000000        | 0x71f       | CHANNEL    | 0x90       | 0     | 0x2        |  0x4c  0x00

| 0.000000        | 0.000000        | 0x61        | CHANNEL    | 0x90       | 0     | 0x2        |  0x4d  0x50

| 0.000000        | 0.000000        | 0x71f       | CHANNEL    | 0x90       | 0     | 0x2        |  0x4d  0x00

| 0.000000        | 0.000000        | 0x61        | CHANNEL    | 0x90       | 0     | 0x2        |  0x4f  0x50

| 0.000000        | 0.000000        | 0x71f       | CHANNEL    | 0x90       | 0     | 0x2        |  0x4f  0x00

| 0.000000        | 0.000000        | 0x61        | CHANNEL    | 0x90       | 0     | 0x2        |  0x51  0x50

| 0.000000        | 0.000000        | 0x71f       | CHANNEL    | 0x90       | 0     | 0x2        |  0x51  0x00

| 0.000000        | 0.000000        | 0x61        | CHANNEL    | 0x90       | 0     | 0x2        |  0x53  0x50

| 0.000000        | 0.000000        | 0x71f       | CHANNEL    | 0x90       | 0     | 0x2        |  0x53  0x00

| 0.000000        | 0.000000        | 0x61        | CHANNEL    | 0x90       | 0     | 0x2        |  0x54  0x50

| 0.000000        | 0.000000        | 0x71f       | CHANNEL    | 0x90       | 0     | 0x2        |  0x54  0x00

| 0.000000        | 0.000000        | 0x1         | META       | 0xff       | 0x2f  | 0x0        |

OR

Absolute Time Duration Delta Time ETYPE Event ID META LENGTH DATA
0.000000 0.000000 0x0 META 0xff 0x58 0x4 0x04 0x02 0x18 0x08
0.000000 0.000000 0x0 META 0xff 0x59 0x2 0x00 0x00
0.000000 0.000000 0x0 META 0xff 0x51 0x3 0x07 0xa1 0x20
0.000000 0.000000 0x0 CHANNEL 0xb0 0 0x2 0x79 0x00
0.000000 0.000000 0x0 CHANNEL 0xc0 0 0x1 0x00
0.000000 0.000000 0x0 CHANNEL 0xb0 0 0x2 0x07 0x64
0.000000 0.000000 0x0 CHANNEL 0xb0 0 0x2 0x0a 0x40
0.000000 0.000000 0x0 CHANNEL 0xb0 0 0x2 0x5b 0x00
0.000000 0.000000 0x0 CHANNEL 0xb0 0 0x2 0x5d 0x00
0.000000 0.000000 0x0 META 0xff 0x21 0x1 0x00
0.000000 0.000000 0x0 CHANNEL 0x90 0 0x2 0x48 0x50
0.000000 0.000000 0x71f CHANNEL 0x90 0 0x2 0x48 0x00
0.000000 0.000000 0x61 CHANNEL 0x90 0 0x2 0x4a 0x50
0.000000 0.000000 0x71f CHANNEL 0x90 0 0x2 0x4a 0x00
0.000000 0.000000 0x61 CHANNEL 0x90 0 0x2 0x4c 0x50
0.000000 0.000000 0x71f CHANNEL 0x90 0 0x2 0x4c 0x00
0.000000 0.000000 0x61 CHANNEL 0x90 0 0x2 0x4d 0x50
0.000000 0.000000 0x71f CHANNEL 0x90 0 0x2 0x4d 0x00
0.000000 0.000000 0x61 CHANNEL 0x90 0 0x2 0x4f 0x50
0.000000 0.000000 0x71f CHANNEL 0x90 0 0x2 0x4f 0x00
0.000000 0.000000 0x61 CHANNEL 0x90 0 0x2 0x51 0x50
0.000000 0.000000 0x71f CHANNEL 0x90 0 0x2 0x51 0x00
0.000000 0.000000 0x61 CHANNEL 0x90 0 0x2 0x53 0x50
0.000000 0.000000 0x71f CHANNEL 0x90 0 0x2 0x53 0x00
0.000000 0.000000 0x61 CHANNEL 0x90 0 0x2 0x54 0x50
0.000000 0.000000 0x71f CHANNEL 0x90 0 0x2 0x54 0x00
0.000000 0.000000 0x1 META 0xff 0x2f 0x0

Absolute midi

Absolute Midi is defined as its time from start, in seconds.

>>> from rmidi import MIDI, AbosluteMidi
>>> y = MIDI.parse_midi('Kuch_Toh_Hai_1.mid')
>>> yabs = AbsoluteMidi.to_abs_midi(y)

OUTPUT

| Absolute Time   |  Duration       |  Note  Time         |  Delta Time |  ETYPE     |   Event ID | META  | LENGTH     | DATA
|______________________________________________________________________________________________________________________________ . . .
| 0.000000        | 0.000000        | 0                    | 0x0         | META       | 0xff       | 0x58  | 0x4        |  0x04  0x02 0x18  0x08
| 0.000000        | 0.000000        | 0                    | 0x0         | META       | 0xff       | 0x59  | 0x2        |  0x00  0x00
| 0.000000        | 0.000000        | 0                    | 0x0         | META       | 0xff       | 0x51  | 0x3        |  0x07  0xa1 0x20
| 0.000000        | 0.000000        | 0                    | 0x0         | CHANNEL    | 0xb0       | 0     | 0x2        |  0x79  0x00
| 0.000000        | 0.000000        | 0                    | 0x0         | CHANNEL    | 0xc0       | 0     | 0x1        |  0x00
| 0.000000        | 0.000000        | 0                    | 0x0         | CHANNEL    | 0xb0       | 0     | 0x2        |  0x07  0x64
| 0.000000        | 0.000000        | 0                    | 0x0         | CHANNEL    | 0xb0       | 0     | 0x2        |  0x0a  0x40
| 0.000000        | 0.000000        | 0                    | 0x0         | CHANNEL    | 0xb0       | 0     | 0x2        |  0x5b  0x00
| 0.000000        | 0.000000        | 0                    | 0x0         | CHANNEL    | 0xb0       | 0     | 0x2        |  0x5d  0x00
| 0.000000        | 0.000000        | 0                    | 0x0         | META       | 0xff       | 0x21  | 0x1        |  0x00
| 0.000000        | 31.649306       | 1.0666666666666667   | 0x0         | CHANNEL    | 0x90       | 0     | 0x2        |  0x48  0x50
| 33.333333       | 31.649306       | 1.0666666666666667   | 0x61        | CHANNEL    | 0x90       | 0     | 0x2        |  0x4a  0x50
| 66.666667       | 31.649306       | 1.0666666666666667   | 0x61        | CHANNEL    | 0x90       | 0     | 0x2        |  0x4c  0x50
| 100.000000      | 31.649306       | 1.0666666666666667   | 0x61        | CHANNEL    | 0x90       | 0     | 0x2        |  0x4d  0x50
| 133.333333      | 31.649306       | 1.0666666666666667   | 0x61        | CHANNEL    | 0x90       | 0     | 0x2        |  0x4f  0x50
| 166.666667      | 31.649306       | 1.0666666666666667   | 0x61        | CHANNEL    | 0x90       | 0     | 0x2        |  0x51  0x50
| 200.000000      | 31.649306       | 1.0666666666666667   | 0x61        | CHANNEL    | 0x90       | 0     | 0x2        |  0x53  0x50
| 233.333333      | 31.649306       | 1.0666666666666667   | 0x61        | CHANNEL    | 0x90       | 0     | 0x2        |  0x54  0x50
| 0.000000        | 0.000000        | 0                    | 0x1         | META       | 0xff       | 0x2f  | 0x0        |
*******************************************************************************************************************

OR

Absolute Time Duration Note Time Delta Time ETYPE Event ID META LENGTH DATA
0.000000 0.000000 0 0x0 META 0xff 0x58 0x4 0x04 0x02 0x18 0x08
0.000000 0.000000 0 0x0 META 0xff 0x59 0x2 0x00 0x00
0.000000 0.000000 0 0x0 META 0xff 0x51 0x3 0x07 0xa1 0x20
0.000000 0.000000 0 0x0 CHANNEL 0xb0 0 0x2 0x79 0x00
0.000000 0.000000 0 0x0 CHANNEL 0xc0 0 0x1 0x00
0.000000 0.000000 0 0x0 CHANNEL 0xb0 0 0x2 0x07 0x64
0.000000 0.000000 0 0x0 CHANNEL 0xb0 0 0x2 0x0a 0x40
0.000000 0.000000 0 0x0 CHANNEL 0xb0 0 0x2 0x5b 0x00
0.000000 0.000000 0 0x0 CHANNEL 0xb0 0 0x2 0x5d 0x00
0.000000 0.000000 0 0x0 META 0xff 0x21 0x1 0x00
0.000000 31.649306 1.0666666666666667 0x0 CHANNEL 0x90 0 0x2 0x48 0x50
33.333333 31.649306 1.0666666666666667 0x61 CHANNEL 0x90 0 0x2 0x4a 0x50
66.666667 31.649306 1.0666666666666667 0x61 CHANNEL 0x90 0 0x2 0x4c 0x50
100.000000 31.649306 1.0666666666666667 0x61 CHANNEL 0x90 0 0x2 0x4d 0x50
133.333333 31.649306 1.0666666666666667 0x61 CHANNEL 0x90 0 0x2 0x4f 0x50
166.666667 31.649306 1.0666666666666667 0x61 CHANNEL 0x90 0 0x2 0x51 0x50
200.000000 31.649306 1.0666666666666667 0x61 CHANNEL 0x90 0 0x2 0x53 0x50
233.333333 31.649306 1.0666666666666667 0x61 CHANNEL 0x90 0 0x2 0x54 0x50
0.000000 0.000000 0 0x1 META 0xff 0x2f 0x0

Metadata

Release files for rmidi 0.0.29

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

Source distribution (sdist)

Source distribution for rmidi 0.0.29
File Size Uploaded
rmidi-0.0.29.tar.gz 27.6 kB Details

Built distribution (wheel)

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

Total release size: 59.8 kB

Release files / rmidi-0.0.29.tar.gz

Download URL rmidi-0.0.29.tar.gz
Size 27.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a91ff855680171e8aab72804914dcc9196b7dbfc784b1c379067e0dacaceb8d3
BLAKE2b-256 checksum
How to use checksums
98a3a900b3610aedd7f71086cc89e2362bb15480cd66641fcfc233c087bfe800
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.7

Release files / rmidi-0.0.29-py3-none-any.whl

Download URL rmidi-0.0.29-py3-none-any.whl
Size 32.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6d1b2e7f4c33a7393b9958c2dc890243739ff19c2dbdf23abdac59b8a29a6c25
BLAKE2b-256 checksum
How to use checksums
cebd72dc80b6b731c1e19c84e62703185fb198ae76ef15eeb3ec7692d414fdc5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.7

Release history Release notifications | RSS feed

0.0.37

1 release file

0.0.36

1 release file

0.0.35

1 release file

0.0.31

1 release file

This release

0.0.29 This release

2 release files

0.0.28

2 release files

0.0.27

2 release files

0.0.26

2 release files

0.0.25

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

1 release file

0.0.3

1 release file

0.0.2

2 release files

0.0.1

2 release files

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