Esempio n. 1
0
        void ParseHeader(string line)
        {
            Tune    tune     = tunes[tunes.Count - 1];
            ABCInfo?nullable = ABCInfo.Parse(line);

            if (!nullable.HasValue)
            {
                return;
            }

            ABCInfo abcInfo = nullable.Value;

            if (abcInfo.Identifier == 'T' && strict && (tune.Header.Information.Count != 1 || tune.Header.Information.Count <= 0 || !tune.Header.Information.ContainsKey('X')))
            {
                throw new ABCStrictException("Error reading ABC notation, 'T:title' information field is only allowed after 'X:number' field in strict mode.");
            }

            if (abcInfo.Identifier == 'X')
            {
                tune = new Tune();
                tunes.Add(tunes.Count, tune);
            }
            else if (abcInfo.Identifier == 'K')
            {
                inTune = true;
            }

            tune.Header.AddInfo(nullable.Value);
        }
Esempio n. 2
0
        void InlineInfo(string s)
        {
            s = s.Substring(1, s.Length - 2).Trim();
            ABCInfo?nullable = ABCInfo.Parse(s);

            if (!nullable.HasValue)
            {
                return;
            }

            switch (nullable.Value.Identifier)
            {
            case 'Q':
                SetTempo(nullable.Value.Text);
                break;

            case 'L':
                noteLength = GetNoteLength(nullable.Value.Text);
                break;

            default: {
                if (nullable.Value.Identifier != 'K')
                {
                    return;
                }

                GetKey(nullable.Value.Text);
                break;
            }
            }
        }