/// <summary>
 /// Creates a new instance of a Note.
 /// </summary>
 /// <param name="notePitch">Pitch</param>
 /// <param name="noteDuration">Duration</param>
 /// <param name="noteStemDirection">Stem direction</param>
 /// <param name="noteTieType">Tie type</param>
 /// <param name="noteBeamList">Beam list</param>
 public Note(Pitch notePitch, RhythmicDuration noteDuration, VerticalDirection noteStemDirection, NoteTieType noteTieType, List <NoteBeamType> noteBeamList)
 {
     Duration      = noteDuration;
     pitch         = notePitch;
     stemDirection = noteStemDirection;
     beamList      = noteBeamList;
     tieType       = noteTieType;
     Lyrics        = new LyricsCollection(this);
     Ornaments     = new List <Ornament>();
     DetermineMusicalCharacter();
 }
Example #2
0
 public Note(string noteStep, int noteAlter, int noteOctave, MusicalSymbolDuration noteDuration,
             NoteStemDirection noteStemDirection, NoteTieType noteTieType, List <NoteBeamType> noteBeamList)
 {
     type          = MusicalSymbolType.Note;
     duration      = noteDuration;
     step          = noteStep;
     octave        = noteOctave;
     alter         = noteAlter;
     stemDirection = noteStemDirection;
     beamList      = noteBeamList;
     tieType       = noteTieType;
     midiPitch     = ToMidiPitch(step, alter, octave);
     DetermineMusicalCharacter();
 }
Example #3
0
        static private MusicalSymbol getNoteMusicalSymbol(D_Note note)
        {
            String note_level                = getNoteLevel(note.level);
            int    note_alteration           = getNoteAlteration(note.alteration);
            int    octave                    = note.octave;
            int    numberOfDots              = getNumberOfDots(note.length_modifier);
            MusicalSymbolDuration duration   = getNoteDuration(getVisualLength(note.length, note.length_modifier));
            NoteStemDirection     direction  = getStemDirection(note.octave);
            NoteTieType           note_tie   = getNoteTie(note.note_tie);
            List <NoteBeamType>   note_beams = new List <NoteBeamType>()
            {
                NoteBeamType.Single
            };

            return(new Note(note_level, note_alteration, octave, duration, direction, note_tie, note_beams)
            {
                NumberOfDots = numberOfDots
            });
        }
Example #4
0
        private static IEnumerable <MusicalSymbol> GetStaffsFromTokens(LinkedList <LilypondToken> tokens)
        {
            List <MusicalSymbol> symbols = new List <MusicalSymbol>();

            Clef currentClef             = null;
            int  previousOctave          = 4;
            char previousNote            = 'c';
            bool inRepeat                = false;
            bool inAlternative           = false;
            int  alternativeRepeatNumber = 0;

            LilypondToken currentToken = tokens.First();

            while (currentToken != null)
            {
                // TODO: There are a lot of switches based on LilypondTokenKind, can't those be eliminated en delegated?
                // HINT: Command, Decorator, Factory etc.

                // TODO: Repeats are somewhat weirdly done. Can we replace this with the COMPOSITE pattern?
                switch (currentToken.TokenKind)
                {
                case LilypondTokenKind.Unknown:
                    break;

                case LilypondTokenKind.Repeat:
                    inRepeat = true;
                    symbols.Add(new Barline()
                    {
                        RepeatSign = RepeatSignType.Forward
                    });
                    break;

                case LilypondTokenKind.SectionEnd:
                    if (inRepeat && currentToken.NextToken?.TokenKind != LilypondTokenKind.Alternative)
                    {
                        inRepeat = false;
                        symbols.Add(new Barline()
                        {
                            RepeatSign = RepeatSignType.Backward, AlternateRepeatGroup = alternativeRepeatNumber
                        });
                    }
                    else if (inAlternative && alternativeRepeatNumber == 1)
                    {
                        alternativeRepeatNumber++;
                        symbols.Add(new Barline()
                        {
                            RepeatSign = RepeatSignType.Backward, AlternateRepeatGroup = alternativeRepeatNumber
                        });
                    }
                    else if (inAlternative && currentToken.NextToken.TokenKind == LilypondTokenKind.SectionEnd)
                    {
                        inAlternative           = false;
                        alternativeRepeatNumber = 0;
                    }
                    break;

                case LilypondTokenKind.SectionStart:
                    if (inAlternative && currentToken.PreviousToken.TokenKind != LilypondTokenKind.SectionEnd)
                    {
                        alternativeRepeatNumber++;
                        symbols.Add(new Barline()
                        {
                            AlternateRepeatGroup = alternativeRepeatNumber
                        });
                    }
                    break;

                case LilypondTokenKind.Alternative:
                    inAlternative = true;
                    inRepeat      = false;
                    currentToken  = currentToken.NextToken;    // Skip the first bracket open.
                    break;

                case LilypondTokenKind.Note:
                    // Tied
                    // TODO: A tie, like a dot and cross or mole are decorations on notes. Is the DECORATOR pattern of use here?
                    NoteTieType tie = NoteTieType.None;
                    if (currentToken.Value.StartsWith("~"))
                    {
                        tie = NoteTieType.Stop;
                        var lastNote = symbols.Last(s => s is Note) as Note;
                        if (lastNote != null)
                        {
                            lastNote.TieType = NoteTieType.Start;
                        }
                        currentToken.Value = currentToken.Value.Substring(1);
                    }
                    // Length
                    int noteLength = Int32.Parse(Regex.Match(currentToken.Value, @"\d+").Value);
                    // Crosses and Moles
                    int alter = 0;
                    alter += Regex.Matches(currentToken.Value, "is").Count;
                    alter -= Regex.Matches(currentToken.Value, "es|as").Count;
                    // Octaves
                    int distanceWithPreviousNote = notesorder.IndexOf(currentToken.Value[0]) - notesorder.IndexOf(previousNote);
                    if (distanceWithPreviousNote > 3)     // Shorter path possible the other way around
                    {
                        distanceWithPreviousNote -= 7;    // The number of notes in an octave
                    }
                    else if (distanceWithPreviousNote < -3)
                    {
                        distanceWithPreviousNote += 7;     // The number of notes in an octave
                    }

                    if (distanceWithPreviousNote + notesorder.IndexOf(previousNote) >= 7)
                    {
                        previousOctave++;
                    }
                    else if (distanceWithPreviousNote + notesorder.IndexOf(previousNote) < 0)
                    {
                        previousOctave--;
                    }

                    // Force up or down.
                    previousOctave += currentToken.Value.Count(c => c == '\'');
                    previousOctave -= currentToken.Value.Count(c => c == ',');

                    previousNote = currentToken.Value[0];

                    var note = new Note(currentToken.Value[0].ToString().ToUpper(), alter, previousOctave, (MusicalSymbolDuration)noteLength, NoteStemDirection.Up, tie, new List <NoteBeamType>()
                    {
                        NoteBeamType.Single
                    });
                    note.NumberOfDots += currentToken.Value.Count(c => c.Equals('.'));

                    symbols.Add(note);
                    break;

                case LilypondTokenKind.Rest:
                    var restLength = Int32.Parse(currentToken.Value[1].ToString());
                    symbols.Add(new Rest((MusicalSymbolDuration)restLength));
                    break;

                case LilypondTokenKind.Bar:
                    symbols.Add(new Barline()
                    {
                        AlternateRepeatGroup = alternativeRepeatNumber
                    });
                    break;

                case LilypondTokenKind.Clef:
                    currentToken = currentToken.NextToken;
                    if (currentToken.Value == "treble")
                    {
                        currentClef = new Clef(ClefType.GClef, 2);
                    }
                    else if (currentToken.Value == "bass")
                    {
                        currentClef = new Clef(ClefType.FClef, 4);
                    }
                    else
                    {
                        throw new NotSupportedException($"Clef {currentToken.Value} is not supported.");
                    }

                    symbols.Add(currentClef);
                    break;

                case LilypondTokenKind.Time:
                    currentToken = currentToken.NextToken;
                    var times = currentToken.Value.Split('/');
                    symbols.Add(new TimeSignature(TimeSignatureType.Numbers, UInt32.Parse(times[0]), UInt32.Parse(times[1])));
                    break;

                case LilypondTokenKind.Tempo:
                    // Tempo not supported
                    break;

                default:
                    break;
                }
                currentToken = currentToken.NextToken;
            }

            return(symbols);
        }
Example #5
0
        public override void Interpret(LilypondContext context)
        {
            if (_noteName == 'r')
            {
                // This note is a rest
                context.Sequence.Symbols.Add(new Rest {
                    Duration = (MusicalSymbolDuration)_length
                });
                return;
            }

            // Raise or lower the current octave based on the distance between the previous/current note
            if (context.PreviousNotePitch != null)
            {
                if (context.PreviousNotePitch - _notePitch > 5)
                {
                    context.CurrentOctave++;
                }
                else if (_notePitch - context.PreviousNotePitch > 5)
                {
                    context.CurrentOctave--;
                }
            }

            context.CurrentOctave += _octaveChange;

            // Link the note and the note decorations
            NoteDecoration previousDecoration = null;

            foreach (NoteDecoration decoration in _noteProperties)
            {
                if (previousDecoration != null)
                {
                    previousDecoration.Note = decoration;
                }
                else
                {
                    previousDecoration = decoration;
                }
            }

            // Linking notes
            NoteTieType tieType = NoteTieType.None;

            if (context.LinkingNote && _linkingNote)
            {
                tieType = NoteTieType.StopAndStartAnother;
            }
            else if (context.LinkingNote)
            {
                tieType = NoteTieType.Stop;
            }
            else if (_linkingNote)
            {
                tieType = NoteTieType.Start;
            }

            context.PreviousTieType = tieType;

            INote note = new Note
            {
                NoteName    = _noteName,
                Pitch       = _notePitch + context.CurrentOctave * 12,
                Duration    = (MusicalSymbolDuration)_length,
                NoteTieType = tieType
            };

            _noteProperties.Add(note);

            if (previousDecoration != null)
            {
                previousDecoration.Note = note;
            }

            context.Sequence.Symbols.Add(_noteProperties.First());

            context.PreviousNotePitch = _notePitch;
        }
        public static bool ParseXml(IMusicalNotesViewer viewer) //Returns true if there are no errors
        {
            viewer.ClearMusicalIncipit();
            XmlNodeList measures        = viewer.XmlIncipit.SelectNodes("/score-partwise/part/measure");
            int         skipMeasures    = 0;
            string      partID          = "";
            bool        firstLoop       = true;
            int         currentTempo    = 120;
            int         currentDynamics = 80;

            try
            {
                foreach (XmlNode measure in measures)
                {
                    bool barlineAlreadyAdded = false;
                    if (measure.ParentNode.Name == "part")  //Don't take the other voices than the upper into account / Nie uwzględniaj innych głosów niż górny
                    {
                        if (!firstLoop)
                        {
                            if (measure.ParentNode.Attributes["id"].Value != partID)
                            {
                                break;
                            }
                        }
                        else
                        {
                            partID = measure.ParentNode.Attributes["id"].Value;
                        }
                    }
                    if (skipMeasures > 0)
                    {
                        skipMeasures--; continue;
                    }
                    if (measure.HasChildNodes == false)
                    {
                        continue;
                    }
                    foreach (XmlNode symbol in measure.ChildNodes)
                    {
                        if (symbol.HasChildNodes == false)
                        {
                            continue;
                        }
                        if (symbol.Name == "attributes")
                        {
                            foreach (XmlNode attribute in symbol.ChildNodes)
                            {
                                if (attribute.Name == "clef")
                                {
                                    ClefType typeOfClef = ClefType.GClef;
                                    int      line       = 1;
                                    foreach (XmlNode clefAttribute in attribute.ChildNodes)
                                    {
                                        if (clefAttribute.Name == "sign")
                                        {
                                            if (clefAttribute.InnerText.ToUpper() == "G")
                                            {
                                                typeOfClef = ClefType.GClef;
                                            }
                                            else if (clefAttribute.InnerText.ToUpper() == "C")
                                            {
                                                typeOfClef = ClefType.CClef;
                                            }
                                            else if (clefAttribute.InnerText.ToUpper() == "F")
                                            {
                                                typeOfClef = ClefType.FClef;
                                            }
                                            else
                                            {
                                                throw (new Exception("Unknown clef"));
                                            }
                                        }
                                        if (clefAttribute.Name == "line")
                                        {
                                            line = Convert.ToInt16(clefAttribute.InnerText);
                                        }
                                    }
                                    viewer.AddMusicalSymbol(new Clef(typeOfClef, line));
                                }
                                if (attribute.Name == "time")
                                {
                                    uint numberOfBeats      = 4;
                                    uint beatType           = 4;
                                    TimeSignatureType sType = TimeSignatureType.Numbers;
                                    foreach (XmlNode timeAttribute in attribute.ChildNodes)
                                    {
                                        if (timeAttribute.Name == "beats")
                                        {
                                            numberOfBeats = Convert.ToUInt32(timeAttribute.InnerText);
                                        }
                                        if (timeAttribute.Name == "beat-type")
                                        {
                                            beatType = Convert.ToUInt32(timeAttribute.InnerText);
                                        }
                                    }
                                    if (attribute.Attributes.Count > 0)
                                    {
                                        foreach (XmlAttribute a in attribute.Attributes)
                                        {
                                            if (a.Name == "symbol")
                                            {
                                                if (a.Value == "common")
                                                {
                                                    sType = TimeSignatureType.Common;
                                                }
                                                else if (a.Value == "cut")
                                                {
                                                    sType = TimeSignatureType.Cut;
                                                }
                                            }
                                        }
                                    }
                                    viewer.AddMusicalSymbol(new TimeSignature(sType, numberOfBeats, beatType));
                                }
                                if (attribute.Name == "key")
                                {
                                    foreach (XmlNode keyAttribute in attribute.ChildNodes)
                                    {
                                        if (keyAttribute.Name == "fifths")
                                        {
                                            viewer.AddMusicalSymbol(new Key(Convert.ToInt16(keyAttribute.InnerText)));
                                        }
                                    }
                                }
                                if (attribute.Name == "measure-style")
                                {
                                    foreach (XmlNode measureStyleAttribute in attribute.ChildNodes)
                                    {
                                        if (measureStyleAttribute.Name == "multiple-rest")
                                        {
                                            skipMeasures = Convert.ToInt32(measureStyleAttribute.InnerText) - 1;
                                        }
                                    }
                                }
                            }
                        }
                        else if (symbol.Name == "sound")
                        {
                            if (((XmlElement)symbol).HasAttribute("tempo"))
                            {
                                currentTempo = Convert.ToInt32(symbol.Attributes["tempo"].Value);
                            }
                            if (((XmlElement)symbol).HasAttribute("dynamics"))
                            {
                                currentDynamics = Convert.ToInt32(symbol.Attributes["dynamics"].Value);
                            }
                        }
                        else if (symbol.Name == "direction")
                        {
                            foreach (XmlNode direction in symbol.ChildNodes)
                            {
                                if (direction.Name == "sound")
                                {
                                    if (((XmlElement)direction).HasAttribute("tempo"))
                                    {
                                        currentTempo = Convert.ToInt32(direction.Attributes["tempo"].Value);
                                    }
                                    if (((XmlElement)direction).HasAttribute("dynamics"))
                                    {
                                        currentDynamics = Convert.ToInt32(direction.Attributes["dynamics"].Value);
                                    }
                                }
                                if (direction.Name == "direction-type")
                                {
                                    foreach (XmlNode directionType in direction.ChildNodes)
                                    {
                                        if (directionType.Name == "dynamics")
                                        {
                                            DirectionPlacementType placement = DirectionPlacementType.Above;
                                            int    defaultY = 0;
                                            string text     = "";
                                            if (((XmlElement)directionType).HasAttribute("default-y"))
                                            {
                                                defaultY  = Convert.ToInt32(directionType.Attributes["default-y"].Value);
                                                placement = DirectionPlacementType.Custom;
                                            }
                                            if (((XmlElement)directionType).HasAttribute("placement") &&
                                                placement != DirectionPlacementType.Custom)
                                            {
                                                if (directionType.Attributes["placement"].Value == "above")
                                                {
                                                    placement = DirectionPlacementType.Above;
                                                }
                                                else if (directionType.Attributes["placement"].Value == "below")
                                                {
                                                    placement = DirectionPlacementType.Below;
                                                }
                                            }
                                            foreach (XmlNode dynamicsType in directionType.ChildNodes)
                                            {
                                                text = dynamicsType.Name;
                                            }
                                            Direction dir = new Direction();
                                            dir.DefaultY  = defaultY;
                                            dir.Placement = placement;
                                            dir.Text      = text;
                                            viewer.AddMusicalSymbol(dir);
                                        }
                                    }
                                }
                            }
                        }
                        else if (symbol.Name == "note")
                        {
                            int    octave       = 0;
                            int    alter        = 0;
                            string step         = "C";
                            bool   isRest       = false;
                            int    numberOfDots = 0;
                            MusicalSymbolDuration     duration              = MusicalSymbolDuration.Whole;
                            NoteStemDirection         stemDirection         = NoteStemDirection.Up;
                            NoteTieType               tieType               = NoteTieType.None;
                            TupletType                tuplet                = TupletType.None;
                            List <NoteBeamType>       beamList              = new List <NoteBeamType>();
                            List <LyricsType>         lyric                 = new List <LyricsType>();
                            List <string>             lyricText             = new List <string>();
                            ArticulationPlacementType articulationPlacement = ArticulationPlacementType.Below;
                            ArticulationType          articulation          = ArticulationType.None;
                            bool          hasNatural            = false;
                            bool          isGraceNote           = false;
                            bool          isChordElement        = false;
                            bool          hasFermataSign        = false;
                            float         stemDefaultY          = 28;
                            bool          customStemEndPosition = false;
                            int           tremoloLevel          = 0;
                            NoteSlurType  slur      = NoteSlurType.None;
                            NoteTrillMark trillMark = NoteTrillMark.None;
                            int           voice     = 1;

                            foreach (XmlNode noteAttribute in symbol.ChildNodes)
                            {
                                if (noteAttribute.Name == "pitch")
                                {
                                    foreach (XmlNode pitchAttribute in noteAttribute.ChildNodes)
                                    {
                                        if (pitchAttribute.Name == "step")
                                        {
                                            step = pitchAttribute.InnerText;
                                        }
                                        else if (pitchAttribute.Name == "octave")
                                        {
                                            octave = Convert.ToInt16(pitchAttribute.InnerText);
                                        }
                                        else if (pitchAttribute.Name == "alter")
                                        {
                                            alter = Convert.ToInt16(pitchAttribute.InnerText);
                                        }
                                    }
                                }
                                else if (noteAttribute.Name == "voice")
                                {
                                    voice = Convert.ToInt32(noteAttribute.InnerText);
                                }
                                else if (noteAttribute.Name == "grace")
                                {
                                    isGraceNote = true;
                                }
                                else if (noteAttribute.Name == "chord")
                                {
                                    isChordElement = true;
                                }
                                else if (noteAttribute.Name == "type")
                                {
                                    if (noteAttribute.InnerText == "whole")
                                    {
                                        duration = MusicalSymbolDuration.Whole;
                                    }
                                    else if (noteAttribute.InnerText == "half")
                                    {
                                        duration = MusicalSymbolDuration.Half;
                                    }
                                    else if (noteAttribute.InnerText == "quarter")
                                    {
                                        duration = MusicalSymbolDuration.Quarter;
                                    }
                                    else if (noteAttribute.InnerText == "eighth")
                                    {
                                        duration = MusicalSymbolDuration.Eighth;
                                    }
                                    else if (noteAttribute.InnerText == "16th")
                                    {
                                        duration = MusicalSymbolDuration.Sixteenth;
                                    }
                                    else if (noteAttribute.InnerText == "32nd")
                                    {
                                        duration = MusicalSymbolDuration.d32nd;
                                    }
                                    else if (noteAttribute.InnerText == "64th")
                                    {
                                        duration = MusicalSymbolDuration.d64th;
                                    }
                                    else if (noteAttribute.InnerText == "128th")
                                    {
                                        duration = MusicalSymbolDuration.d128th;
                                    }
                                }
                                else if (noteAttribute.Name == "accidental")
                                {
                                    if (noteAttribute.InnerText == "natural")
                                    {
                                        hasNatural = true;
                                    }
                                }
                                else if (noteAttribute.Name == "tie")
                                {
                                    if (noteAttribute.Attributes["type"].Value == "start")
                                    {
                                        if (tieType == NoteTieType.Stop)
                                        {
                                            tieType = NoteTieType.StopAndStartAnother;
                                        }
                                        else
                                        {
                                            tieType = NoteTieType.Start;
                                        }
                                    }
                                    else
                                    {
                                        tieType = NoteTieType.Stop;
                                    }
                                }
                                else if (noteAttribute.Name == "rest")
                                {
                                    isRest = true;
                                }
                                else if (noteAttribute.Name == "dot")
                                {
                                    numberOfDots++;
                                }
                                else if (noteAttribute.Name == "stem")
                                {
                                    if (noteAttribute.InnerText == "down")
                                    {
                                        stemDirection = NoteStemDirection.Down;
                                    }
                                    else
                                    {
                                        stemDirection = NoteStemDirection.Up;
                                    }
                                    foreach (XmlAttribute xa in noteAttribute.Attributes)
                                    {
                                        if (xa.Name == "default-y")
                                        {
                                            stemDefaultY = float.Parse(xa.Value.Replace('.',
                                                                                        Convert.ToChar(NumberFormatInfo.CurrentInfo.CurrencyDecimalSeparator)));
                                            customStemEndPosition = true;
                                        }
                                    }
                                }
                                else if (noteAttribute.Name == "beam")
                                {
                                    if (noteAttribute.InnerText == "begin")
                                    {
                                        beamList.Add(NoteBeamType.Start);
                                    }
                                    else if (noteAttribute.InnerText == "end")
                                    {
                                        beamList.Add(NoteBeamType.End);
                                    }
                                    else if (noteAttribute.InnerText == "continue")
                                    {
                                        beamList.Add(NoteBeamType.Continue);
                                    }
                                    else if (noteAttribute.InnerText == "forward hook")
                                    {
                                        beamList.Add(NoteBeamType.ForwardHook);
                                    }
                                    else if (noteAttribute.InnerText == "backward hook")
                                    {
                                        beamList.Add(NoteBeamType.BackwardHook);
                                    }
                                }
                                else if (noteAttribute.Name == "notations")
                                {
                                    foreach (XmlNode notationAttribute in noteAttribute.ChildNodes)
                                    {
                                        if (notationAttribute.Name == "tuplet")
                                        {
                                            if (notationAttribute.Attributes["type"].Value == "start")
                                            {
                                                tuplet = TupletType.Start;
                                            }
                                            else if (notationAttribute.Attributes["type"].Value == "stop")
                                            {
                                                tuplet = TupletType.Stop;
                                            }
                                        }
                                        if (notationAttribute.Name == "dynamics")
                                        {
                                            DirectionPlacementType placement = DirectionPlacementType.Above;
                                            int    defaultY = 0;
                                            string text     = "";
                                            if (((XmlElement)notationAttribute).HasAttribute("default-y"))
                                            {
                                                defaultY  = Convert.ToInt32(notationAttribute.Attributes["default-y"].Value);
                                                placement = DirectionPlacementType.Custom;
                                            }
                                            if (((XmlElement)notationAttribute).HasAttribute("placement") &&
                                                placement != DirectionPlacementType.Custom)
                                            {
                                                if (notationAttribute.Attributes["placement"].Value == "above")
                                                {
                                                    placement = DirectionPlacementType.Above;
                                                }
                                                else if (notationAttribute.Attributes["placement"].Value == "below")
                                                {
                                                    placement = DirectionPlacementType.Below;
                                                }
                                            }
                                            foreach (XmlNode dynamicsType in notationAttribute.ChildNodes)
                                            {
                                                text = dynamicsType.Name;
                                            }
                                            Direction dir = new Direction();
                                            dir.DefaultY  = defaultY;
                                            dir.Placement = placement;
                                            dir.Text      = text;
                                            viewer.AddMusicalSymbol(dir);
                                        }
                                        else if (notationAttribute.Name == "articulations")
                                        {
                                            foreach (XmlNode articulationAttribute in notationAttribute.ChildNodes)
                                            {
                                                if (articulationAttribute.Name == "staccato")
                                                {
                                                    articulation = ArticulationType.Staccato;
                                                }
                                                else if (articulationAttribute.Name == "accent")
                                                {
                                                    articulation = ArticulationType.Accent;
                                                }

                                                if (articulationAttribute.Attributes["placement"].Value == "above")
                                                {
                                                    articulationPlacement = ArticulationPlacementType.Above;
                                                }
                                                else if (articulationAttribute.Attributes["placement"].Value == "below")
                                                {
                                                    articulationPlacement = ArticulationPlacementType.Below;
                                                }
                                            }
                                        }
                                        else if (notationAttribute.Name == "ornaments")
                                        {
                                            foreach (XmlNode ornamentAttribute in notationAttribute.ChildNodes)
                                            {
                                                if (ornamentAttribute.Name == "trill-mark")
                                                {
                                                    if (ornamentAttribute.Attributes["placement"].Value == "above")
                                                    {
                                                        trillMark = NoteTrillMark.Above;
                                                    }
                                                    else if (ornamentAttribute.Attributes["placement"].Value == "below")
                                                    {
                                                        trillMark = NoteTrillMark.Below;
                                                    }
                                                }
                                                else if (ornamentAttribute.Name == "tremolo")
                                                {
                                                    tremoloLevel = Convert.ToInt32(ornamentAttribute.InnerText);
                                                }
                                            }
                                        }
                                        else if (notationAttribute.Name == "slur")
                                        {
                                            if ((Convert.ToInt32(notationAttribute.Attributes["number"].Value)) != 1)
                                            {
                                                continue;
                                            }
                                            if (notationAttribute.Attributes["type"].Value == "start")
                                            {
                                                slur = NoteSlurType.Start;
                                            }
                                            else if (notationAttribute.Attributes["type"].Value == "stop")
                                            {
                                                slur = NoteSlurType.Stop;
                                            }
                                        }
                                        else if (notationAttribute.Name == "fermata")
                                        {
                                            hasFermataSign = true;
                                        }
                                        else if (notationAttribute.Name == "sound")
                                        {
                                            if (((XmlElement)notationAttribute).HasAttribute("dynamics"))
                                            {
                                                currentDynamics = Convert.ToInt32(notationAttribute.Attributes["dynamics"].Value);
                                            }
                                        }
                                    }
                                }
                                else if (noteAttribute.Name == "lyric")
                                {
                                    foreach (XmlNode lyricAttribute in noteAttribute.ChildNodes)
                                    {
                                        if (lyricAttribute.Name == "syllabic")
                                        {
                                            if (lyricAttribute.InnerText == "begin")
                                            {
                                                lyric.Add(LyricsType.Begin);
                                            }
                                            else if (lyricAttribute.InnerText == "middle")
                                            {
                                                lyric.Add(LyricsType.Middle);
                                            }
                                            else if (lyricAttribute.InnerText == "end")
                                            {
                                                lyric.Add(LyricsType.End);
                                            }
                                            else if (lyricAttribute.InnerText == "single")
                                            {
                                                lyric.Add(LyricsType.Single);
                                            }
                                        }
                                        else if (lyricAttribute.Name == "text")
                                        {
                                            lyricText.Add(lyricAttribute.InnerText);
                                        }
                                    }
                                }
                            }
                            if (beamList.Count == 0)
                            {
                                beamList.Add(NoteBeamType.Single);
                            }
                            if (!isRest)
                            {
                                Note nt = new Note(step, alter, octave, duration, stemDirection, tieType, beamList);
                                nt.NumberOfDots          = numberOfDots;
                                nt.Tuplet                = tuplet;
                                nt.Lyrics                = lyric;
                                nt.LyricTexts            = lyricText;
                                nt.Articulation          = articulation;
                                nt.ArticulationPlacement = articulationPlacement;
                                nt.HasNatural            = hasNatural;
                                nt.IsGraceNote           = isGraceNote;
                                nt.IsChordElement        = isChordElement;
                                nt.StemDefaultY          = stemDefaultY;
                                nt.CustomStemEndPosition = customStemEndPosition;
                                nt.CurrentTempo          = currentTempo;
                                nt.TrillMark             = trillMark;
                                nt.Slur           = slur;
                                nt.HasFermataSign = hasFermataSign;
                                nt.TremoloLevel   = tremoloLevel;
                                nt.Voice          = voice;
                                nt.Dynamics       = currentDynamics;
                                viewer.AddMusicalSymbol(nt);
                            }
                            else
                            {
                                Rest rt = new Rest(duration);
                                rt.NumberOfDots   = numberOfDots;
                                rt.Tuplet         = tuplet;
                                rt.MultiMeasure   = skipMeasures + 1;
                                rt.CurrentTempo   = currentTempo;
                                rt.HasFermataSign = hasFermataSign;
                                rt.Voice          = voice;
                                viewer.AddMusicalSymbol(rt);
                            }
                        }
                        else if (symbol.Name == "barline")
                        {
                            Barline b = new Barline();
                            foreach (XmlNode barlineAttribute in symbol.ChildNodes)
                            {
                                if (barlineAttribute.Name == "repeat")
                                {
                                    if (((XmlElement)barlineAttribute).HasAttribute("direction"))
                                    {
                                        if (barlineAttribute.Attributes["direction"].Value == "forward")
                                        {
                                            b.RepeatSign = RepeatSignType.Forward;
                                        }
                                        else if (barlineAttribute.Attributes["direction"].Value == "backward")
                                        {
                                            b.RepeatSign = RepeatSignType.Backward;
                                        }

                                        viewer.AddMusicalSymbol(b);
                                        barlineAlreadyAdded = true;
                                    }
                                }
                            }
                        }
                    }
                    if (!barlineAlreadyAdded)
                    {
                        viewer.AddMusicalSymbol(new Barline());
                    }
                    firstLoop = false;
                }
            }
            catch
            {
                return(false);
            }
            return(true);
        }
 internal Note(string noteStep, int noteAlter, int noteOctave, RhythmicDuration noteDuration,
               VerticalDirection noteStemDirection, NoteTieType noteTieType, List <NoteBeamType> noteBeamList) :
     this(new Pitch(noteStep, noteAlter, noteOctave), noteDuration, noteStemDirection, noteTieType, noteBeamList)
 {
 }