Beispiel #1
0
        public int GetIntDuration(StaffSymbolDuration duration)
        {
            if (intDurationDictionary.ContainsKey(duration))
            {
                return(intDurationDictionary[duration]);
            }

            throw new KeyNotFoundException();
        }
Beispiel #2
0
        public PSAMControlLibrary.MusicalSymbolDuration GetMusicalSymbolDuration(StaffSymbolDuration staffSymbolDuration)
        {
            if (psamConvertDictionary.ContainsKey(staffSymbolDuration))
            {
                return(psamConvertDictionary[staffSymbolDuration]);
            }

            throw new KeyNotFoundException();
        }
Beispiel #3
0
        private double GetDuration(StaffSymbolDuration duration, int amountOfDots)
        {
            double doubleDuration = eightsConversionDurationDictionary[duration];

            if (amountOfDots > 0)
            {
                doubleDuration *= 2;
            }

            return(doubleDuration);
        }
Beispiel #4
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);
        }