Пример #1
0
        private void ParseHeader(string line)
        {
            Tune tune = tunes[tunes.Count - 1];

            // this does not handle new global information after the first tune properly
            ABCInfo?i = ABCInfo.Parse(line);

            if (i.HasValue)
            {
                ABCInfo info = i.Value;
                if (info.Identifier == 'T' && strict)
                {
                    if (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 (info.Identifier == 'X')
                {
                    // start new tune
                    tune = new Tune();
                    tunes.Add(tunes.Count, tune);
                }
                else if (info.Identifier == 'K')
                {
                    // start interpreting notes
                    inTune = true;
                }

                tune.Header.AddInfo(i.Value);
            }
        }
Пример #2
0
        private void ParseHeader(string line)
        {
            Tune tune = tunes[tunes.Count - 1];

            // this does not handle new global information after the first tune properly
            ABCInfo?i = ABCInfo.Parse(line);

            if (i.HasValue)
            {
                ABCInfo info = i.Value;

                if (info.Identifier == 'X')
                {
                    // start new tune
                    tune = new Tune();
                    tunes.Add(tunes.Count, tune);
                }
                else if (info.Identifier == 'K')
                {
                    // start interpreting notes
                    inTune = true;
                }

                tune.Header.AddInfo(i.Value);
            }
        }
 public void AddInfo(ABCInfo info)
 {
     if (!Information.ContainsKey(info.Identifier))
     {
         Information.Add(info.Identifier, new List <string>());
     }
     Information[info.Identifier].Add(info.Text);
 }
Пример #4
0
        private void InlineInfo(string s)
        {
            s = s.Substring(1, s.Length - 2).Trim();
            ABCInfo?info = ABCInfo.Parse(s);

            if (info.HasValue)
            {
                if (info.Value.Identifier == 'Q')
                {
                    SetTempo(info.Value.Text);
                }
                else if (info.Value.Identifier == 'L')
                {
                    noteLength = GetNoteLength(info.Value.Text);
                }
                else if (info.Value.Identifier == 'K')
                {
                    GetKey(info.Value.Text);
                }
            }
        }
Пример #5
0
 public void AddInfo(ABCInfo info)
 {
     if (!Information.ContainsKey(info.Identifier))
         Information.Add(info.Identifier, new List<string>());
     Information[info.Identifier].Add(info.Text);
 }