Exemplo n.º 1
0
        void tryFingerChoice(int[] pitches, ref List <FingerChord> choices, FingerChord constrait, FingerChord fc, int currentNoteIndex, int emptyQuota)
        {
            if (currentNoteIndex >= pitches.Length)
            {
                choices.Add(new FingerChord(fc));

                /*Finger[] fa = new Finger[fc.Values.Count];
                 * fc.Values.CopyTo(fa, 0);
                 * UnityEngine.Debug.Log("fc: " + String.Join(",", Array.ConvertAll(fa, x => ((int)x).ToString())));*/
            }
            else
            {
                int currentPitch = pitches[currentNoteIndex];

                if (constrait != null && constrait.ContainsKey(currentPitch) && constrait[currentPitch] != Finger.EMPTY)
                {
                    fc[currentPitch] = constrait[currentPitch];
                    tryFingerChoice(pitches, ref choices, constrait, fc, currentNoteIndex + 1, emptyQuota);
                }
                else
                {
                    foreach (Finger f in FingerConstants.SolveTypeFingers[HandType])
                    {
                        bool pass = true;
                        for (int index = currentNoteIndex - 1; index >= 0; --index)
                        {
                            int    pitch  = pitches[index];
                            Finger finger = fc[pitch];

                            float distance = Piano.pitchPairDistance(pitch, currentPitch);

                            pass = FingerConstants.testFingerDistance(finger, f, Config, distance);
                            if (!pass)
                            {
                                break;
                            }
                        }

                        if (pass)
                        {
                            fc[currentPitch] = f;
                            tryFingerChoice(pitches, ref choices, constrait, fc, currentNoteIndex + 1, emptyQuota);
                        }
                    }

                    if (emptyQuota > 0)
                    {
                        fc[currentPitch] = Finger.EMPTY;
                        tryFingerChoice(pitches, ref choices, constrait, fc, currentNoteIndex + 1, emptyQuota - 1);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public Range getFingerRange(Finger f)
        {
            Range range = getWristRangePerFinger()[FingerConstants.getFingerNumber(f)];

            if (f < Finger.EMPTY)
            {
                range = new Range {
                    low = -range.high, high = -range.low
                }
            }
            ;

            return(range);
        }