Adding fingerings (or string numbers or stroke fingerings) outside of the music code

The scheme function \addFingering adds fingerings to a music part respecting fingeringOrientations even if single notes are not in chord brackets (<>).

In the example below, the music code is just set as follow :


    music = \relative c' { 
                c4 d <e g> <f a>
                g f <e g> <d f>
                c b a b
                <c e g c>1
            }
The fingering code is set in a string parameter :

    \addFingering \music
            #"012345           % mes 1
              xxxx '1-2''3-4'  % mes 2
              -1+2-3+4         % mes 3
              1234             % mes 4
              "

The rules are :
Each digit [0-5] is attached to the corresponding note in the music.
You can use a letter (here x) to skip a note, or if you want to skip n consecutive notes, use the syntax *nx ( for ex *15x will skip 15 notes).
Instead of one digit, you can add a substitution fingering by enclosing several digits between 2 apostrophes, with - (minus) as separator char, like that '1-2-3'.
+ and - (plus/minus) before a digit mean respectively direction UP and DOWN.They override fingeringOrientations set before.
Comments can be added at the end of the line and must start with a percent sign (%).
All other characters not mentioned above are ignored.

Notes :
1-If you are curious to know how to add various \override, you can uncomment the commented lines of the code of this snippet, but you'll need first to download here the file called "extractMusic.ly".
2-You can also use \displayLilyMusic to get single notes with fingering instructions embedded in chord brackets.
3-Two similar functions \addStringNumber and \addStrokeFinger are also provided. You can quickly add by the same way, respectively string numbers and stroke fingerings.