Example #1
0
 public LilyTokenHandlers.RelativeVariablesWrapper Handle(string token, Model.LilyPondStaffAdapter staff, LilyTokenHandlers.RelativeVariablesWrapper wrapper)
 {
     // Do Nothing, it's either { or }
     return(null);
 }
Example #2
0
        public LilyTokenHandlers.RelativeVariablesWrapper Handle(string token, Model.LilyPondStaffAdapter staff, LilyTokenHandlers.RelativeVariablesWrapper wrapper)
        {
            // TODO! : Catch not valid notes/tokens -> Return null Score. Do not save this score as a Savepoint/Memento/State

            // Get the note type (g, fis etc...)
            string step = Regex.Match(token, "[a-z]+").Value;

            // Get the note duration.
            int noteDuration             = Int32.Parse(Regex.Match(token, "[0-9]+").Value);
            StaffSymbolDuration duration = StaffSymbolFactory.Instance.GetStaffSymbolDuration(noteDuration);

            // Check if it is a rest.
            if (step == "r")
            {
                Rest rest = new Rest();
                rest.Duration = duration;
                staff.Symbols.Add(rest);
            }
            else
            {
                string stepString = NOTE_CONVERSION_TABLE[step];

                // Get the octave.
                int octave = wrapper.relativeOctave + OctaveOffset(wrapper.relativeStep[0], step[0]);
                octave += (1 * token.Count(x => x == '\''));
                octave -= (1 * token.Count(x => x == ','));
                wrapper.relativeStep   = step;
                wrapper.relativeOctave = octave;

                Note note = new Note();
                note.Duration     = duration;
                note.Octave       = octave;
                note.StepString   = stepString;
                note.NumberOfDots = token.Count(x => x == '.');

                staff.Symbols.Add(note);
            }

            return(wrapper);
        }