Beispiel #1
0
        private int ParseInternalInterval(string s, int index, NoteContext context)
        {
            if (context.IsRest)
            {
                return(index);
            }

            // An internal interval is indicated by a single quote
            if ((index < s.Length) && (s[index] == '\''))
            {
                int intervalLength = 0;
                // Verify that index+1 is a number representing the interval.
                if (index + 1 < s.Length && IsValidIntervalChar(s[index + 1]))
                {
                    intervalLength = 1;
                }
                // We'll allow for the possibility of double-sharps and double-flats.
                if ((intervalLength == 1) && (index + 2 < s.Length) && IsValidIntervalChar(s[index + 2]))
                {
                    intervalLength = 2;
                }
                if ((intervalLength == 2) && (index + 3 < s.Length) && IsValidIntervalChar(s[index + 3]))
                {
                    intervalLength = 3;
                }
                context.InternalInterval = Intervals.GetHalfsteps(s.Substring(index + 1, intervalLength));
                context.OriginalString   = Note.ToneStringWithoutOctave((context.NoteNumber + context.InternalInterval)) + (context.IsOctaveExplicitlySet ? context.OctaveNumber.ToString() : "");
                return(index + intervalLength + 1);
            }
            return(index);
        }