Skip to main content

Midi Insights: midi analyzer

Project description

MIDI Insights

This package inherits MidiFile of mido, adding note duration quantization functionality MidiFile.quantization and improving the MidiFile.print_tracks method.

import midii

mid = midii.MidiFile(
    midii.sample.dataset[0], # or 'song.mid'
    convert_1_to_0=True, lyric_encoding="cp949"
)
mid.quantization(unit="32")
mid.print_tracks(
    track_bound=None,
    track_list=None,
    blind_note_info=True,
    blind_lyric=True,
)

Installation

pip install midii

API

midii.sample

midii.sample: It contains some sample midi files.

  • dataset: List object that contains some midi dataset for deep learning model. The lyric encoding of these midi files is "cp949" or "utf-8"

  • simple: List object that contains some simple midi dataset. It is artificially created midi file for test purpose.

  • real: List object that contains real-world midi examples.

class midii.MidiFile

class midii.MidiFile(filename=None, file=None, type=1, ticks_per_beat=480, charset='latin1', debug=False, clip=False, tracks=None, convert_1_to_0=False, lyric_encoding='latin-1')

The parameters of this class are no different from those of the mido.MidiFile class it inherits, except for convert_1_to_0=False and lyric_encoding='latin-1'.

If you want to convert midi file type 1 to 0, pass convert_1_to_0=True.

lyric_encoding specify encoding of lyric data.

  • quantization(unit="32"): Quantize note duration. You can define least unit of quantization from "1"(whole note), "2"(half note), "4"(quarter note), "8"(eighth note), "16"(sixteenth note), "32"(thirty-second note), "64"(sixty-fourth note), "128"(hundred twenty-eighth note), "256"(two hundred fifty-sixth note)

    The smaller the minimum unit, the less sync error with the original, and the weaker the quantization effect. As the minimum unit becomes larger, the sync error with the original increases and the quantization effect increases.

  • print_tracks(track_bound=None, blind_note=False, blind_time=False, blind_lyric=True, track_list=None, blind_note_info=False): An overriding function that improves the existing mido.print_tracks.

    By default it will print all lines of track. By setting like track_bound=20, You can define upper bound of lines to be printed.

    By default it will prints all tracks. You can specify the tracks you want to output in the list track_list. For example, track_list=[], or track_list=["piano", "intro"].

Example

print_tracks

  • print_tracks: mido.MidiFile.print_tracksmidii.MidiFile.print_tracks

quantization

  • quantization(unit="32"):

    The smaller the minimum unit, the less sync error with the original, and the weaker the quantization effect.

    As the minimum unit becomes larger, the sync error with the original increases and the quantization effect increases.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

midii-0.1.10.tar.gz (1.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

midii-0.1.10-py3-none-any.whl (35.7 kB view details)

Uploaded Python 3

File details

Details for the file midii-0.1.10.tar.gz.

File metadata

  • Download URL: midii-0.1.10.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.10

File hashes

Hashes for midii-0.1.10.tar.gz
Algorithm Hash digest
SHA256 6cc1271faae970daf15a84798ae7333d903300c7d21162a19a0753d7fd3495c9
MD5 7cfa2d59c3191ff4f6a0dd8bb9af2e01
BLAKE2b-256 a8cc5525444537e953f0c804348058c2cae3238d9978778ae6f6a53588fcb633

See more details on using hashes here.

File details

Details for the file midii-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: midii-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 35.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.10

File hashes

Hashes for midii-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 7df213459a25d3ee127bfe49850c83f55b80690008ea272ac19e6c35d5984fbc
MD5 881b3171f6d826247879fae773976d83
BLAKE2b-256 79740dc0b05b475d78b127a02f49992ea7bc8ca22205fa7007e2e1b358d8ea19

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page