Skip to main content

Fortepyan :musical_keyboard:

GitHub CI Python 3.9 PyPI version PyPI download month

fortepyan is a glorified pandas wrapper for midi files with piano music.

The main class to operate with is MidiPiece, which gives you access to the notes dataframe, and some useful utilities:

from fortepyan import MidiPiece

piece = MidiPiece.from_file("foo.mid")

piece.df
#        pitch  velocity        start          end  duration
# 0         52        70     0.000000     0.538542  0.538542
# 1         52        62     0.660417     0.951562  0.291146
# 2         57        62    20.769792    21.207812  0.438021
# 3         67        65    62.172917    62.510937  0.338021
# 4         69        56    62.179167    62.232292  0.053125

Using with HuggingFace datasets:

from datasets import load_datasets

dataset = load_dataset("epr-labs/maestro-sustain-v2", split="train")
piece = MidiPiece.from_huggingface(dataset[312])
piece.source
# {
#     'composer': 'Franz Liszt',
#     'title': 'Dante Sonata',
#     'split': 'train',
#     'year': 2009,
#     'midi_filename': '2009/MIDI-Unprocessed_11_R1_2009_06-09_ORIG_MID--AUDIO_11_R1_2009_11_R1_2009_09_WAV.midi',
#     'dataset': 'maestro'
# }

Usage

import fortepyan as ff

piece = ff.MidiPiece.from_file("mymidi.mid")

ff.view.draw_pianoroll_with_velocities(piece)
ff.view.make_piano_roll_video(piece, "tmp.mp4")

Contributing

Development

Pre-commit hooks with forced python formatting (black, flake8, and isort):

pip install pre-commit
pre-commit install

Whenever you execute git commit the files altered / added within the commit will be checked and corrected. black and isort can modify files locally - if that happens you have to git add them again. You might also be prompted to introduce some fixes manually.

To run the hooks against all files without running git commit:

pre-commit run --all-files

Package release:

# from the root directory with clean working tree
# replace patch with one of: [major, minor, patch]
./scripts/release/start_release.sh patch

# Make any additional changes to the release commit
./scripts/release/finish_release.sh

Tests

Recommended way to run and monitor tests is using pytest-watch:

ptw

Metadata

Release files for fortepyan 0.5.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 fortepyan 0.5.1
File Size Uploaded
fortepyan-0.5.1.tar.gz 25.6 kB Details

Built distribution (wheel)

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

Total release size: 57.4 kB

Release files / fortepyan-0.5.1.tar.gz

Download URL fortepyan-0.5.1.tar.gz
Size 25.6 kB
Tags Source
SHA-256 checksum
How to use checksums
72a89f54cd6f459adbddd9075be3751cea3ae481c195d1974290721ccdff68a0
BLAKE2b-256 checksum
How to use checksums
956411f7889f0fe0b301fadc891f3ae61a6cf58aee6af9e613e5558591c95032
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.20

Release files / fortepyan-0.5.1-py3-none-any.whl

Download URL fortepyan-0.5.1-py3-none-any.whl
Size 31.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
edc32c01aa2d40995973a9df0582c782e5402bd9a0f883d981e299884fd57794
BLAKE2b-256 checksum
How to use checksums
e11dc883b4d4de167fc3615e8fbe08e9ebc243ef41b4f2b27c9d1a8c27a924fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.20

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files

0.5.0

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.0

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

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