Ejemplo n.º 1
0
        private void Beat(Voice voice)
        {
            // duration specifier?
            if (_sy == AlphaTexSymbols.DoubleDot)
            {
                _allowNegatives = true;
                NewSy();
                _allowNegatives = false;
                if (_sy != AlphaTexSymbols.Number)
                {
                    Error("duration", AlphaTexSymbols.Number);
                }

                _currentDuration = ParseDuration((int)_syData);

                NewSy();
                return;
            }

            var beat = new Beat();

            voice.AddBeat(beat);

            if (voice.Bar.MasterBar.TempoAutomation != null && voice.Beats.Count == 1)
            {
                beat.Automations.Add(voice.Bar.MasterBar.TempoAutomation);
            }

            // notes
            if (_sy == AlphaTexSymbols.LParensis)
            {
                NewSy();

                Note(beat);
                while (_sy != AlphaTexSymbols.RParensis && _sy != AlphaTexSymbols.Eof)
                {
                    Note(beat);
                }

                if (_sy != AlphaTexSymbols.RParensis)
                {
                    Error("note-list", AlphaTexSymbols.RParensis);
                }
                NewSy();
            }
            // rest
            else if (_sy == AlphaTexSymbols.String && _syData.ToString().ToLower() == "r")
            {
                // rest voice -> no notes
                NewSy();
            }
            else
            {
                Note(beat);
            }

            // new duration
            if (_sy == AlphaTexSymbols.Dot)
            {
                _allowNegatives = true;
                NewSy();
                _allowNegatives = false;
                if (_sy != AlphaTexSymbols.Number)
                {
                    Error("duration", AlphaTexSymbols.Number);
                }

                _currentDuration = ParseDuration((int)_syData);
                NewSy();
            }
            beat.Duration = _currentDuration;

            // beat multiplier (repeat beat n times)
            var beatRepeat = 1;

            if (_sy == AlphaTexSymbols.Multiply)
            {
                NewSy();

                // multiplier count
                if (_sy != AlphaTexSymbols.Number)
                {
                    Error("multiplier", AlphaTexSymbols.Number);
                }
                else
                {
                    beatRepeat = (int)_syData;
                }
                NewSy();
            }

            BeatEffects(beat);

            for (var i = 0; i < beatRepeat - 1; i++)
            {
                voice.AddBeat(beat.Clone());
            }
        }
Ejemplo n.º 2
0
        private void Beat(Voice voice)
        {
            // duration specifier?
            if (_sy == AlphaTexSymbols.DoubleDot)
            {
                NewSy();
                if (_sy != AlphaTexSymbols.Number)
                {
                    Error("duration", AlphaTexSymbols.Number);
                }

                var duration = (int)_syData;
                switch (duration)
                {
                case 1:
                case 2:
                case 4:
                case 8:
                case 16:
                case 32:
                case 64:
                    _currentDuration = ParseDuration((int)_syData);
                    break;

                default:
                    Error("duration", AlphaTexSymbols.Number, false);
                    break;
                }

                NewSy();
                return;
            }

            var beat = new Beat();

            voice.AddBeat(beat);

            // notes
            if (_sy == AlphaTexSymbols.LParensis)
            {
                NewSy();

                Note(beat);
                while (_sy != AlphaTexSymbols.RParensis && _sy != AlphaTexSymbols.Eof)
                {
                    Note(beat);
                }

                if (_sy != AlphaTexSymbols.RParensis)
                {
                    Error("note-list", AlphaTexSymbols.RParensis);
                }
                NewSy();
            }
            // rest
            else if (_sy == AlphaTexSymbols.String && _syData.ToString().ToLower() == "r")
            {
                // rest voice -> no notes
                NewSy();
            }
            else
            {
                Note(beat);
            }

            // new duration
            if (_sy == AlphaTexSymbols.Dot)
            {
                NewSy();
                if (_sy != AlphaTexSymbols.Number)
                {
                    Error("duration", AlphaTexSymbols.Number);
                }

                var duration = (int)_syData;
                switch (duration)
                {
                case 1:
                case 2:
                case 4:
                case 8:
                case 16:
                case 32:
                case 64:
                    _currentDuration = ParseDuration((int)_syData);
                    break;

                default:
                    Error("duration", AlphaTexSymbols.Number, false);
                    break;
                }

                NewSy();
            }
            else
            {
                beat.Duration = _currentDuration;
            }

            // beat multiplier (repeat beat n times)
            var beatRepeat = 1;

            if (_sy == AlphaTexSymbols.Multiply)
            {
                NewSy();

                // multiplier count
                if (_sy != AlphaTexSymbols.Number)
                {
                    Error("multiplier", AlphaTexSymbols.Number);
                }
                else
                {
                    beatRepeat = (int)_syData;
                }
                NewSy();
            }

            BeatEffects(beat);

            for (var i = 0; i < beatRepeat - 1; i++)
            {
                voice.AddBeat(beat.Clone());
            }
        }