11# Fortepyan :musical_keyboard :
2+
23![ GitHub CI] ( https://github.com/Nospoko/Fortepyan/actions/workflows/ci_tests.yaml/badge.svg?branch=master ) [ ![ Python 3.9] ( https://img.shields.io/badge/python-3.9+-blue.svg )] ( https://www.python.org/downloads ) [ ![ PyPI version] ( https://img.shields.io/pypi/v/fortepyan.svg )] ( https://pypi.org/project/fortepyan/ ) [ ![ PyPI download month] ( https://img.shields.io/pypi/dm/fortepyan.svg )] ( https://pypi.org/project/fortepyan/ )
34
5+ ** fortepyan** is a glorified pandas wrapper for midi files with piano music.
6+
7+ The main class to operate with is ` MidiPiece ` , which gives you access to the notes dataframe, and some useful utilities:
8+
9+ ``` python
10+ from fortepyan import MidiPiece
11+
12+ piece = MidiPiece.from_file(" foo.mid" )
13+
14+ piece.df
15+ # pitch velocity start end duration
16+ # 0 52 70 0.000000 0.538542 0.538542
17+ # 1 52 62 0.660417 0.951562 0.291146
18+ # 2 57 62 20.769792 21.207812 0.438021
19+ # 3 67 65 62.172917 62.510937 0.338021
20+ # 4 69 56 62.179167 62.232292 0.053125
21+ ```
22+
23+ Using with HuggingFace datasets:
24+
25+
26+ ``` python
27+ from datasets import load_datasets
28+
29+ dataset = load_dataset(" epr-labs/maestro-sustain-v2" , split = " train" )
30+ piece = MidiPiece.from_huggingface(dataset[312 ])
31+ piece.source
32+ # {
33+ # 'composer': 'Franz Liszt',
34+ # 'title': 'Dante Sonata',
35+ # 'split': 'train',
36+ # 'year': 2009,
37+ # 'midi_filename': '2009/MIDI-Unprocessed_11_R1_2009_06-09_ORIG_MID--AUDIO_11_R1_2009_11_R1_2009_09_WAV.midi',
38+ # 'dataset': 'maestro'
39+ # }
40+ ```
41+
442### Usage
543
644``` python
@@ -12,6 +50,8 @@ ff.view.draw_pianoroll_with_velocities(piece)
1250ff.view.make_piano_roll_video(piece, " tmp.mp4" )
1351```
1452
53+ ## Contributing
54+
1555### Development
1656
1757Pre-commit hooks with forced python formatting ([ black] ( https://github.com/psf/black ) , [ flake8] ( https://flake8.pycqa.org/en/latest/ ) , and [ isort] ( https://pycqa.github.io/isort/ ) ):
0 commit comments