private void set_measures(D_Staff staff, List <string> tokens)
        {
            // This function requires staff.num_of_beats to be set
            int    current_token_index = 0;
            int    token_end_index     = tokens.Count - 1;
            double current_beat        = 0;

            while (current_token_index <= token_end_index)
            {
                string current_token = tokens[current_token_index];

                // Special case, when we encounter \relative, skip a token
                if (current_token == "\\relative")
                {
                    current_token_index++;
                }
                else if (isNote(current_token))
                {
                    // We don't care about octaves here so we pass 0 and no previous note
                    // All we care about is note length so that we may increase current_beat
                    D_Note note = LilypondNoteParser.noteFromToken(current_token, 0, null);
                    current_beat += ((double)note.length / (double)4);
                }
                else if (current_token == "\\time")
                {
                    string           time_signature       = tokens[current_token_index + 1];
                    Tuple <int, int> time_signature_tuple = StringUtil.getMeasureFromString(time_signature);
                    staff.addMeasure(time_signature_tuple.Item1, time_signature_tuple.Item2, (int)current_beat);
                }

                current_token_index++;
            }

            staff.setMeasureEndTimes();
        }
        private List <D_Note> get_notes(List <string> tokens, int current_scope_octave)
        {
            // This does not take into account repeats
            int           current_token_index = 0;
            int           token_end_index     = tokens.Count - 1;
            List <D_Note> notes         = new List <D_Note>();
            D_Note        previous_note = null;

            while (current_token_index <= token_end_index)
            {
                string current_token = tokens[current_token_index];

                // Special case, when we encounter \relative, skip a token
                if (current_token == "\\relative")
                {
                    current_token_index++;
                }
                else if (isNote(current_token))
                {
                    D_Note note = LilypondNoteParser.noteFromToken(current_token, current_scope_octave, previous_note);

                    if (!note.is_rest)
                    {
                        current_scope_octave = note.octave;
                    }

                    if (current_token_index + 1 <= token_end_index && tokens[current_token_index + 1] == "~")
                    {
                        note.note_tie = NoteTie.start;
                    }
                    else if (current_token_index > 1 && tokens[current_token_index - 2] == "~")
                    {
                        note.note_tie = NoteTie.stop;
                    }

                    notes.Add(note);
                    if (!note.is_rest)
                    {
                        previous_note = note;
                    }
                }

                current_token_index++;
            }

            return(notes);
        }