piano_fingering
A Python library to automatically determine the fingering of a serie of notes.
The algorithm is adapted from the corresponding one from https://github.com/blakewest/performer, by Blake West.
Installation
To install this library, do:
$ pip install piano_fingering
Usage
Single notes
The algorithm takes a list of MIDI notes as input:
from piano_fingering import computeFingering
notes = [
60,
62,
64,
65,
67,
69,
71,
72,
]
fingered_notes = computeFingering(notes, 'right') # or 'left'
The code above will produce the following output:
fingered_notes = [
{'notes': [60], 'fingers': [1]},
{'notes': [62], 'fingers': [2]},
{'notes': [64], 'fingers': [3]},
{'notes': [65], 'fingers': [1]},
{'notes': [67], 'fingers': [2]},
{'notes': [69], 'fingers': [3]},
{'notes': [71], 'fingers': [4]},
{'notes': [72], 'fingers': [5]},
]
Chords
You can add chords to the list too:
notes = [
[60, 62, 64],
[67, 71, 74],
]
fingered_notes = computeFingering(notes, 'right')
The code above will produce the following output:
fingered_notes = [
{'notes': [60, 62, 64], 'fingers': [1, 2, 3]},
{'notes': [67, 71, 74], 'fingers': [1, 3, 5]},
]
Rests
A rest is specified by an empty list. Note that the algorithm doesn’t take rests in consideration. They are supported to help the user of the library to use the result list. It is up to you to separate your notes on long rests, so the fingering of one part of the song doesn’t affect another one.
Example:
notes = [
60,
[],
64,
]
fingered_notes = computeFingering(notes, 'right')
The code above will produce the following output:
fingered_notes = [
{'notes': [60], 'fingers': [1]},
{'notes': [], 'fingers': []},
{'notes': [64], 'fingers': [3]},
]
User-defined fingering
In case the algorithm doesn’t produce a fingering that you find optimal, you can constrain it by specifying your own fingering on the input:
notes = [
60,
62,
64,
{'notes': [65], 'fingers': [4]},
67,
69,
71,
72,
]
fingered_notes = computeFingering(notes, 'right') # or 'left'
The code above will produce the following output:
fingered_notes = [
{'notes': [60], 'fingers': [1]},
{'notes': [62], 'fingers': [2]},
{'notes': [64], 'fingers': [3]},
{'notes': [65], 'fingers': [4]},
{'notes': [67], 'fingers': [1]},
{'notes': [69], 'fingers': [2]},
{'notes': [71], 'fingers': [3]},
{'notes': [72], 'fingers': [4]},
]
Converting a note name to a MIDI note
Two helpers functions are provided to convert note names (like C5, A#, Bb3) to MIDI notes.
To convert a single note name, use:
from piano_fingering import nameToMidi
midi_note = nameToMidi('C4')
When the octave isn’t indicated, ‘5’ is assumed.
To convert a list of notes (with the same format than for computeFingering() in the above examples), use:
from piano_fingering import listToMidi
notes = [
'C5',
['C5', 'E5', 'G5'],
{'notes': ['C5'], 'fingers': [1]},
]
midi_notes = listToMidi(notes)
Running tests
In the source package, do:
$ python setup.py test
License
piano_fingering is is made available under the MIT License. The text of the license is in the file “LICENSE.txt”.
Under the MIT License you may use piano_fingering for any purpose you wish, without warranty, and modify it if you require, subject to one condition:
“The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.”
In practice this means that whenever you distribute your application, whether as binary or as source code, you must include somewhere in your distribution the text in the file “LICENSE.txt”. This might be in the printed documentation, as a file on delivered media, or even on the credits / acknowledgements of the runtime application itself; any of those would satisfy the requirement.
Even if the license doesn’t require it, please consider to contribute your modifications back to the community.
Special thanks to
Blake West, for the initial javascript implementation.
Metadata
Release files for piano_fingering 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| piano_fingering-1.0.0.tar.gz | 10.4 kB | Without provenance | Details for piano_fingering-1.0.0.tar.gz |
Release files / piano_fingering-1.0.0.tar.gz
| Download URL | piano_fingering-1.0.0.tar.gz |
|---|---|
| Size | 10.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
737011b979f62742109842c654734167051ea402a545de542e03e915b577070f
|
|
BLAKE2b-256 checksum How to use checksums |
c9700ac2b949173eb04f7a1aabab7c19e39ef1fc5d45d00b57636efd36619c33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for piano_fingering 1.0.0
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.