I am actually working on a program of sorts. This program takes a user entered value that specifies how many white keys they can span with one hand on a piano. It then computes (based on research) the general reach from one finger to the next one can expect based on the main hand's reach. This information is then used to try and compute proper finger assignments for any combination of piano keys one must hit in an instant.

For example: Keys: 50, 52, 60, 90, 95 Would correspond to: fingers: 1, 2, 5, 6, 9 respectively

With the fingers starting at the left hand pinky (1) to the right hand pinky (10). This is all well and good, however I notice the simplistic approach of just taking the first key and finding the distance to the next key and using the first finger within reach causes the program to favor the left hand and the pinky specifically. So, I added in a bit of hysteresis whereby a moving average between the minimum key on the left hand is recorded and calculated from the previous iteration and used in the next. Here, I then apply the moving average and act as if the key is an active key that needs to be hit, only so I can keep the previous hands position in mind when calculating the finger assignment... This works out well, I first try to calculate the finger assignment with this moving average, and if successful, good, if not I increment the moving average by one key and try again. However, this has the result that I cannot apply a minimum to the right hand calculation.

In essence, I am basically trying to use hysteresis to minimize hand movement of the user from one key press iteration to the next. The confusion I have is that I would like to apply this minimization not just on the left hand calculation, but on the right hand as well. The problem is that the right hand calculation and thus minimization is dependent on the left hand's minimization calculation.

To make a long story short, what are some methods of applying minimum optimization to two functions whereby the optimization of the second depends on the optimization of the first?

P.S. I apologize for the verbosity of this question, but I just wanted to give a good idea of what I'm going for. If you need any further clarification, let me know and I'll edit my question, thank you.


I think that your problem is that the right hand keys are based on the left hand fingers. The right hand should be independent from the left; it is, after all, a separate hand. I am not exactly sure what your optimizations entail, but I would suggest dealing with your left hand, then passing the remaining keys that need to be pressed to the right. This way, you can comfortably deal with notes in the left, and pass the rest to the right, which makes sense because the right hand is usually more adept.

However, I have a few words of warning to you, being a piano player for 9 years. First, fingerings are often determined by more than distance from other notes. For example, the thumbs should almost never go on black keys, in, say, a scale, but it is ok when one is playing octaves. Another problem is speed. A computer can play notes as fast as it wants, but a human hand can play faster in certain hand positions. The right hand is often accustomed to playing melodies, and so sometimes it is easier to cross your hands to play a lower melody with chords on the top. Finally, I strongly recommend looking ahead in the music for future fingerings. This is often the root of fingerings - to make future fingerings easier.

In conclusion, fingering are most often used in edge cases, where players would not know how to proceed normally, making implementing a computer program especially hard. I would recommend doing it yourself or getting a piano player friend to do it for you.

  • $\begingroup$ Yes! I knew someone would be able to help me here. Thinking about them independently I can probably do a windowing algorithm that looks for two spans of hands, make sure they don't overlap, and apply a minimization optimization to them separately. Though I agree, fingerings are not ideal, but when you look at a video explaining my project you'll understand: youtube.com/watch?v=Df9m185SPBQ I have taken into consideration that thumbs can't play black keys well and I skip to the next finger in those cases, I'm sure I can further refine these rules. $\endgroup$ Sep 15 '14 at 11:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.