Package: piano_fingering
A Python library to automatically determine the fingering of a serie of notes.The algorithm is adapted from the corresponding one fromhttps://github.com/blakewest/performer, by Blake West.InstallationTo install this library, do:$ pip install piano_fingeringUsageSingle notesThe 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]},
]ChordsYou 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]},
]RestsA 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 fingeringIn 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 noteTwo helpers functions are provided to convert note names (likeC5,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 forcomputeFingering()in
the above examples), use:from piano_fingering import listToMidi

notes = [
    'C5',
    ['C5', 'E5', 'G5'],
    {'notes': ['C5'], 'fingers': [1]},
]

midi_notes = listToMidi(notes)Running testsIn the source package, do:$ python setup.py testLicensepiano_fingeringis is made available under the MIT License. The text of the license
is in the file “LICENSE.txt”.Under the MIT License you may usepiano_fingeringfor 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 toBlake West, for the initial javascript implementation.