Exemplo n.º 1
0
        private void ParsePartwise(IXmlNode element)
        {
            var version = element.GetAttribute("version");

            if (!string.IsNullOrEmpty(version) && version != "2.0")
            {
                throw new UnsupportedFormatException();
            }

            element.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                    case "movement-title":
                        _score.Title = Std.GetNodeValue(c.FirstChild);
                        break;

                    case "identification":
                        ParseIdentification(c);
                        break;

                    case "part-list":
                        ParsePartList(c);
                        break;

                    case "part":
                        ParsePart(c);
                        break;
                    }
                }
            });
        }
Exemplo n.º 2
0
        private void ParseStaffTuning(IXmlNode element, Track track)
        {
            var    line         = Std.ParseInt(element.GetAttribute("line"));
            string tuningStep   = "C";
            string tuningOctave = "";
            int    tuningAlter  = 0;

            element.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                    case "tuning-step":
                        tuningStep = Std.GetNodeValue(c);
                        break;

                    case "tuning-alter":
                        tuningAlter = Std.ParseInt(Std.GetNodeValue(c));
                        break;

                    case "tuning-octave":
                        tuningOctave = Std.GetNodeValue(c);
                        break;
                    }
                }
            });

            track.Tuning[track.Tuning.Length - line] = TuningParser.GetTuningForText(tuningStep + tuningOctave) + tuningAlter;
        }
Exemplo n.º 3
0
        private void ParsePart(IXmlNode element)
        {
            var id = element.GetAttribute("id");

            if (!_trackById.ContainsKey(id))
            {
                return;
            }

            var track          = _trackById[id];
            var isFirstMeasure = true;

            element.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                    case "measure":
                        if (ParseMeasure(c, track, isFirstMeasure))
                        {
                            isFirstMeasure = false;
                        }
                        break;
                    }
                }
            });
        }
Exemplo n.º 4
0
        private void ParsePartwise(IXmlNode element)
        {
            var version = element.GetAttribute("version");
            if (!string.IsNullOrEmpty(version) && version != "2.0")
            {
                throw new UnsupportedFormatException();
            }

            element.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                        case "movement-title":
                            _score.Title = Std.GetNodeValue(c.FirstChild);
                            break;
                        case "identification":
                            ParseIdentification(c);
                            break;
                        case "part-list":
                            ParsePartList(c);
                            break;
                        case "part":
                            ParsePart(c);
                            break;
                    }
                }
            });
        }
Exemplo n.º 5
0
        private void ParseScorePart(IXmlNode element)
        {
            string id    = element.GetAttribute("id");
            var    track = new Track(1);

            _trackById[id] = track;
            _score.AddTrack(track);
            element.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                    case "part-name":
                        track.Name = Std.GetNodeValue(c.FirstChild);
                        break;

                    case "part-abbreviation":
                        track.ShortName = Std.GetNodeValue(c.FirstChild);
                        break;

                    case "midi-instrument":
                        ParseMidiInstrument(c, track);
                        break;
                    }
                }
            });

            if (track.Tuning == null || track.Tuning.Length == 0)
            {
                track.Tuning = Tuning.GetDefaultTuningFor(6).Tunings;
            }
        }
Exemplo n.º 6
0
        private void ParseRepeat(IXmlNode element, MasterBar masterBar)
        {
            var direction = element.GetAttribute("direction");
            var times     = Std.ParseInt(element.GetAttribute("times"));

            if (times < 0)
            {
                times = 2;
            }

            if (direction == "backward")
            {
                masterBar.RepeatCount = times;
            }
            else if (direction == "forward")
            {
                masterBar.IsRepeatStart = true;
            }
        }
Exemplo n.º 7
0
        private void ParseEnding(IXmlNode element, MasterBar masterBar)
        {
            var number = Std.ParseInt(element.GetAttribute("number"));

            if (number > 0)
            {
                --number;
                masterBar.AlternateEndings |= (byte)(0x01 << number);
            }
        }
Exemplo n.º 8
0
 private static void ParseTied(IXmlNode element, Note note)
 {
     if (element.GetAttribute("type") == "start")
     {
         note.IsTieOrigin = true;
     }
     else
     {
         note.IsTieDestination = true;
     }
 }
Exemplo n.º 9
0
 private static void ParseTied(IXmlNode element, Note note)
 {
     if (element.GetAttribute("type") == "start")
     {
         note.IsTieOrigin = true;
     }
     else
     {
         note.IsTieDestination = true;
     }
 }
Exemplo n.º 10
0
        private void ParseTime(IXmlNode element, MasterBar masterBar)
        {
            if (element.GetAttribute("symbol") == "common")
            {
                masterBar.TimeSignatureCommon = true;
            }
            bool beatsParsed    = false;
            bool beatTypeParsed = false;

            element.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    var v = Std.GetNodeValue(c);
                    switch (c.LocalName)
                    {
                    case "beats":
                        if (!beatsParsed)
                        {
                            if (!v.Contains("+"))     // compound TS
                            {
                                masterBar.TimeSignatureNumerator = Std.ParseInt(v);
                            }
                            else
                            {
                                masterBar.TimeSignatureNumerator = 4;
                            }
                            beatsParsed = true;
                        }
                        break;

                    case "beat-type":
                        if (!beatTypeParsed)
                        {
                            if (!v.Contains("+"))     // compound TS
                            {
                                masterBar.TimeSignatureDenominator = Std.ParseInt(v);
                            }
                            else
                            {
                                masterBar.TimeSignatureDenominator = 4;
                            }
                            beatTypeParsed = true;
                        }
                        break;
                    }
                }
            });
        }
Exemplo n.º 11
0
        private static void ParseTied(IXmlNode element, Note note)
        {
            if (note.Beat.GraceType != GraceType.None)
            {
                return;
            }

            if (element.GetAttribute("type") == "start")
            {
                note.IsTieOrigin = true;
            }
            else
            {
                note.IsTieDestination = true;
            }
        }
Exemplo n.º 12
0
Arquivo: Xsi.cs Projeto: belav/Core
        public static XmlName GetXsiType(this IXmlNode node)
        {
            var type = node.GetAttribute(Xsi.Type);

            if (type == null)
            {
                return(XmlName.Empty);
            }

            var xsiType = XmlName.ParseQName(type);

            if (xsiType.NamespaceUri != null)
            {
                var namespaceUri = node.LookupNamespaceUri(xsiType.NamespaceUri);
                xsiType = xsiType.WithNamespaceUri(namespaceUri);
            }
            return(xsiType);
        }
Exemplo n.º 13
0
        private void ParseGeneralMidi(Track track, IXmlNode node)
        {
            track.PlaybackInfo.Port = Std.ParseInt(GetValue(FindChildElement(node, "Port")));
            track.PlaybackInfo.Program = Std.ParseInt(GetValue(FindChildElement(node, "Program")));
            track.PlaybackInfo.PrimaryChannel = Std.ParseInt(GetValue(FindChildElement(node, "PrimaryChannel")));
            track.PlaybackInfo.SecondaryChannel = Std.ParseInt(GetValue(FindChildElement(node, "SecondaryChannel")));

            track.IsPercussion = node.GetAttribute("table") == "Percussion";
        }
Exemplo n.º 14
0
 private void ParseDiagramItem(Track track, IXmlNode node)
 {
     var chord = new Chord();
     var chordId = node.GetAttribute("id");
     chord.Name = node.GetAttribute("name");
     track.Chords[chordId] = chord;
 }
Exemplo n.º 15
0
        private void ParseBeat(IXmlNode node)
        {
            var beat = new Beat();
            var beatId = node.GetAttribute("id");

            node.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                        case "Notes":
                            _notesOfBeat[beatId] = GetValue(c).Split(' ');
                            break;
                        case "Rhythm":
                            _rhythmOfBeat[beatId] = c.GetAttribute("ref");
                            break;
                        case "Fadding":
                            if (GetValue(c) == "FadeIn")
                            {
                                beat.FadeIn = true;
                            }
                            break;
                        case "Tremolo":
                            switch (GetValue(c))
                            {
                                case "1/2":
                                    beat.TremoloSpeed = Duration.Eighth;
                                    break;
                                case "1/4":
                                    beat.TremoloSpeed = Duration.Sixteenth;
                                    break;
                                case "1/8":
                                    beat.TremoloSpeed = Duration.ThirtySecond;
                                    break;
                            }
                            break;
                        case "Chord":
                            beat.ChordId = GetValue(c);
                            break;
                        case "Hairpin":
                            switch (GetValue(c))
                            {
                                case "Crescendo":
                                    beat.Crescendo = CrescendoType.Crescendo;
                                    break;
                                case "Decrescendo":
                                    beat.Crescendo = CrescendoType.Decrescendo;
                                    break;
                            }
                            break;
                        case "Arpeggio":
                            if (GetValue(c) == "Up")
                            {
                                beat.BrushType = BrushType.ArpeggioUp;
                            }
                            else
                            {
                                beat.BrushType = BrushType.ArpeggioDown;
                            }
                            break;
                        // TODO: brushDuration
                        case "Properties":
                            ParseBeatProperties(c, beat);
                            break;
                        case "XProperties":
                            ParseBeatXProperties(c, beat);
                            break;
                        case "FreeText":
                            beat.Text = GetValue(c);
                            break;
                        case "Dynamic":
                            switch (GetValue(c))
                            {
                                case "PPP":
                                    beat.Dynamic = DynamicValue.PPP;
                                    break;
                                case "PP":
                                    beat.Dynamic = DynamicValue.PP;
                                    break;
                                case "P":
                                    beat.Dynamic = DynamicValue.P;
                                    break;
                                case "MP":
                                    beat.Dynamic = DynamicValue.MP;
                                    break;
                                case "MF":
                                    beat.Dynamic = DynamicValue.MF;
                                    break;
                                case "F":
                                    beat.Dynamic = DynamicValue.F;
                                    break;
                                case "FF":
                                    beat.Dynamic = DynamicValue.FF;
                                    break;
                                case "FFF":
                                    beat.Dynamic = DynamicValue.FFF;
                                    break;
                            }
                            break;
                        case "GraceNotes":
                            switch (GetValue(c))
                            {
                                case "OnBeat":
                                    beat.GraceType = GraceType.OnBeat;
                                    break;
                                case "BeforeBeat":
                                    beat.GraceType = GraceType.BeforeBeat;
                                    break;
                            }
                            break;
                    }
                }
            });

            _beatById[beatId] = beat;
        }
Exemplo n.º 16
0
        private void ParseBar(IXmlNode node)
        {
            var bar = new Bar();
            var barId = node.GetAttribute("id");

            node.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                        case "Voices":
                            _voicesOfBar[barId] = GetValue(c).Split(' ');
                            break;
                        case "Clef":
                            switch (GetValue(c))
                            {
                                case "Neutral":
                                    bar.Clef = Clef.Neutral;
                                    break;
                                case "G2":
                                    bar.Clef = Clef.G2;
                                    break;
                                case "F4":
                                    bar.Clef = Clef.F4;
                                    break;
                                case "C4":
                                    bar.Clef = Clef.C4;
                                    break;
                                case "C3":
                                    bar.Clef = Clef.C3;
                                    break;
                            }
                            break;
                            // case "SimileMark":
                    }
                }
            });

            _barsById[barId] = bar;
        }
Exemplo n.º 17
0
        private void ParseVoice(IXmlNode node)
        {
            var voice = new Voice();
            var voiceId = node.GetAttribute("id");

            node.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                        case "Beats":
                            _beatsOfVoice[voiceId] = GetValue(c).Split(' ');
                            break;
                    }
                }
            });

            _voiceById[voiceId] = voice;
        }
Exemplo n.º 18
0
 public string GetAttribute(XmlName name)
 {
     return(node.GetAttribute(name));
 }
Exemplo n.º 19
0
        private void ParseScorePart(IXmlNode element)
        {
            string id = element.GetAttribute("id");
            var track = new Track(1);
            _trackById[id] = track;
            _score.AddTrack(track);
            element.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                        case "part-name":
                            track.Name = Std.GetNodeValue(c.FirstChild);
                            break;
                        case "part-abbreviation":
                            track.ShortName = Std.GetNodeValue(c.FirstChild);
                            break;
                        case "midi-instrument":
                            ParseMidiInstrument(c, track);
                            break;
                    }
                }
            });

            if (track.Tuning == null || track.Tuning.Length == 0)
            {
                track.Tuning = Tuning.GetDefaultTuningFor(6).Tunings;
            }
        }
Exemplo n.º 20
0
Arquivo: XRef.cs Projeto: hzhhhbb/Core
 public static string GetReference(this IXmlNode node)
 {
     return(node.GetAttribute(XRef.Ref));
 }
Exemplo n.º 21
0
        private void ParseNote(IXmlNode node)
        {
            var note = new Note();
            var noteId = node.GetAttribute("id");

            node.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                        case "Properties":
                            ParseNoteProperties(c, note, noteId);
                            break;
                        case "AntiAccent":
                            if (GetValue(c).ToLower() == "normal")
                            {
                                note.IsGhost = true;
                            }
                            break;
                        case "LetRing":
                            note.IsLetRing = true;
                            break;
                        case "Trill":
                            note.TrillValue = Std.ParseInt(GetValue(c));
                            note.TrillSpeed = Duration.Sixteenth;
                            break;
                        case "Accent":
                            var accentFlags = Std.ParseInt(GetValue(c));
                            if ((accentFlags & 0x01) != 0)
                                note.IsStaccato = true;
                            if ((accentFlags & 0x04) != 0)
                                note.Accentuated = AccentuationType.Heavy;
                            if ((accentFlags & 0x08) != 0)
                                note.Accentuated = AccentuationType.Normal;
                            break;
                        case "Tie":
                            if (c.GetAttribute("origin").ToLower() == "true")
                            {
                                note.IsTieOrigin = true;
                            }
                            if (c.GetAttribute("destination").ToLower() == "true")
                            {
                                note.IsTieDestination = true;
                            }
                            break;
                        case "Vibrato":
                            switch (GetValue(c))
                            {
                                case "Slight":
                                    note.Vibrato = VibratoType.Slight;
                                    break;
                                case "Wide":
                                    note.Vibrato = VibratoType.Wide;
                                    break;
                            }
                            break;
                        case "LeftFingering":
                            note.IsFingering = true;
                            switch (GetValue(c))
                            {
                                case "P":
                                    note.LeftHandFinger = Fingers.Thumb;
                                    break;
                                case "I":
                                    note.LeftHandFinger = Fingers.IndexFinger;
                                    break;
                                case "M":
                                    note.LeftHandFinger = Fingers.MiddleFinger;
                                    break;
                                case "A":
                                    note.LeftHandFinger = Fingers.AnnularFinger;
                                    break;
                                case "C":
                                    note.LeftHandFinger = Fingers.LittleFinger;
                                    break;
                            }
                            break;
                        case "RightFingering":
                            note.IsFingering = true;
                            switch (GetValue(c))
                            {
                                case "P":
                                    note.RightHandFinger = Fingers.Thumb;
                                    break;
                                case "I":
                                    note.RightHandFinger = Fingers.IndexFinger;
                                    break;
                                case "M":
                                    note.RightHandFinger = Fingers.MiddleFinger;
                                    break;
                                case "A":
                                    note.RightHandFinger = Fingers.AnnularFinger;
                                    break;
                                case "C":
                                    note.RightHandFinger = Fingers.LittleFinger;
                                    break;
                            }
                            break;
                    }
                }
            });

            _noteById[noteId] = note;
        }
Exemplo n.º 22
0
        private bool ParseMeasure(IXmlNode element, Track track, bool isFirstMeasure)
        {
            if (element.GetAttribute("implicit") == "yes" && element.GetElementsByTagName("note").Length == 0)
            {
                return(false);
            }

            var barIndex = 0;

            if (isFirstMeasure)
            {
                _divisionsPerQuarterNote = 0;
                _trackFirstMeasureNumber = Std.ParseInt(element.GetAttribute("number"));
                if (_trackFirstMeasureNumber == int.MinValue)
                {
                    _trackFirstMeasureNumber = 0;
                }
                barIndex = 0;
            }
            else
            {
                barIndex = Std.ParseInt(element.GetAttribute("number"));
                if (barIndex == int.MinValue)
                {
                    return(false);
                }
                barIndex -= _trackFirstMeasureNumber;
            }

            // try to find out the number of staffs required
            if (isFirstMeasure)
            {
                var attributes = element.GetElementsByTagName("attributes");
                if (attributes.Length > 0)
                {
                    var stavesElements = attributes[0].GetElementsByTagName("staves");
                    if (stavesElements.Length > 0)
                    {
                        var staves = Std.ParseInt(Std.GetNodeValue(stavesElements[0]));
                        track.EnsureStaveCount(staves);
                    }
                }
            }


            // create empty bars to the current index
            Bar[]     bars      = new Bar[track.Staves.Count];
            MasterBar masterBar = null;

            for (int b = track.Staves[0].Bars.Count; b <= barIndex; b++)
            {
                for (int s = 0; s < track.Staves.Count; s++)
                {
                    var bar = bars[s] = new Bar();
                    if (track.Staves[s].Bars.Count > 0)
                    {
                        var previousBar = track.Staves[s].Bars[track.Staves[s].Bars.Count - 1];
                        bar.Clef = previousBar.Clef;
                    }
                    masterBar = GetOrCreateMasterBar(barIndex);
                    track.AddBarToStaff(s, bar);

                    for (int v = 0; v < _maxVoices; v++)
                    {
                        var emptyVoice = new Voice();
                        bar.AddVoice(emptyVoice);
                        var emptyBeat = new Beat {
                            IsEmpty = true
                        };
                        emptyVoice.AddBeat(emptyBeat);
                    }
                }
            }

            var attributesParsed = false;

            element.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                    case "note":
                        ParseNoteBeat(c, bars);
                        break;

                    case "forward":
                        ParseForward(c, bars);
                        break;

                    case "direction":
                        ParseDirection(c, masterBar);
                        break;

                    case "attributes":
                        if (!attributesParsed)
                        {
                            ParseAttributes(c, bars, masterBar);
                            attributesParsed = true;
                        }
                        break;

                    case "harmony":
                        ParseHarmony(c, track);
                        break;

                    case "sound":
                        // TODO
                        break;

                    case "barline":
                        ParseBarline(c, masterBar);
                        break;
                    }
                }
            });

            return(true);
        }
Exemplo n.º 23
0
Arquivo: XRef.cs Projeto: hzhhhbb/Core
 public static string GetId(this IXmlNode node)
 {
     return(node.GetAttribute(XRef.Id));
 }
Exemplo n.º 24
0
        private void ParseMeasure(IXmlNode element, Track track, bool isFirstMeasure)
        {
            var barIndex = 0;

            if (isFirstMeasure)
            {
                _trackFirstMeasureNumber = Std.ParseInt(element.GetAttribute("number"));
                barIndex = 0;
            }
            else
            {
                barIndex = Std.ParseInt(element.GetAttribute("number")) - _trackFirstMeasureNumber;
            }

            // create empty bars to the current index
            Bar       bar       = null;
            MasterBar masterBar = null;

            for (int i = track.Bars.Count; i <= barIndex; i++)
            {
                bar       = new Bar();
                masterBar = GetOrCreateMasterBar(barIndex);
                track.AddBar(bar);

                for (int j = 0; j < _maxVoices; j++)
                {
                    var emptyVoice = new Voice();
                    bar.AddVoice(emptyVoice);
                    var emptyBeat = new Beat {
                        IsEmpty = true
                    };
                    emptyVoice.AddBeat(emptyBeat);
                }
            }

            bool chord       = false;
            bool isFirstBeat = true;

            element.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                    case "note":
                        chord       = ParseNoteBeat(c, track, bar, chord, isFirstBeat);
                        isFirstBeat = false;
                        break;

                    case "forward":
                        break;

                    case "direction":
                        ParseDirection(c, masterBar);
                        break;

                    case "attributes":
                        ParseAttributes(c, bar, masterBar);
                        break;

                    case "harmony":
                        // TODO
                        break;

                    case "sound":
                        // TODO
                        break;

                    case "barline":
                        // TODO
                        break;
                    }
                }
            });
        }
Exemplo n.º 25
0
        private void ParseMeasure(IXmlNode element, Track track, bool isFirstMeasure)
        {
            var barIndex = 0;
            if (isFirstMeasure)
            {
                _trackFirstMeasureNumber = Std.ParseInt(element.GetAttribute("number"));
                barIndex = 0;
            }
            else
            {
                barIndex = Std.ParseInt(element.GetAttribute("number")) - _trackFirstMeasureNumber;
            }

            // create empty bars to the current index
            Bar bar = null;
            MasterBar masterBar = null;
            for (int i = track.Staves[0].Bars.Count; i <= barIndex; i++)
            {
                bar = new Bar();
                masterBar = GetOrCreateMasterBar(barIndex);
                track.AddBarToStaff(0, bar);

                for (int j = 0; j < _maxVoices; j++)
                {
                    var emptyVoice = new Voice();
                    bar.AddVoice(emptyVoice);
                    var emptyBeat = new Beat { IsEmpty = true };
                    emptyVoice.AddBeat(emptyBeat);
                }
            }

            bool chord = false;
            bool isFirstBeat = true;

            element.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                        case "note":
                            chord = ParseNoteBeat(c, track, bar, chord, isFirstBeat);
                            isFirstBeat = false;
                            break;
                        case "forward":
                            break;
                        case "direction":
                            ParseDirection(c, masterBar);
                            break;
                        case "attributes":
                            ParseAttributes(c, bar, masterBar);
                            break;
                        case "harmony":
                            // TODO
                            break;
                        case "sound":
                            // TODO
                            break;
                        case "barline":
                            // TODO
                            break;
                    }
                }
            });
        }
Exemplo n.º 26
0
        private void ParseRhythm(IXmlNode node)
        {
            var rhythm = new GpxRhythm();
            var rhythmId = node.GetAttribute("id");
            node.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                        case "NoteValue":
                            switch (GetValue(c))
                            {
                                case "Long":
                                    rhythm.Value = Duration.QuadrupleWhole;
                                    break;
                                case "DoubleWhole":
                                    rhythm.Value = Duration.DoubleWhole;
                                    break;
                                case "Whole":
                                    rhythm.Value = Duration.Whole;
                                    break;
                                case "Half":
                                    rhythm.Value = Duration.Half;
                                    break;
                                case "Quarter":
                                    rhythm.Value = Duration.Quarter;
                                    break;
                                case "Eighth":
                                    rhythm.Value = Duration.Eighth;
                                    break;
                                case "16th":
                                    rhythm.Value = Duration.Sixteenth;
                                    break;
                                case "32nd":
                                    rhythm.Value = Duration.ThirtySecond;
                                    break;
                                case "64th":
                                    rhythm.Value = Duration.SixtyFourth;
                                    break;
                                case "128th":
                                    rhythm.Value = Duration.OneHundredTwentyEighth;
                                    break;
                                case "256th":
                                    rhythm.Value = Duration.TwoHundredFiftySixth;
                                    break;
                            }
                            break;
                        case "PrimaryTuplet":
                            rhythm.TupletNumerator = Std.ParseInt(c.GetAttribute("num"));
                            rhythm.TupletDenominator = Std.ParseInt(c.GetAttribute("den"));
                            break;
                        case "AugmentationDot":
                            rhythm.Dots = Std.ParseInt(c.GetAttribute("count"));
                            break;
                    }
                }
            });

            _rhythmById[rhythmId] = rhythm;
        }
Exemplo n.º 27
0
 private void ParsePart(IXmlNode element)
 {
     var id = element.GetAttribute("id");
     var track = _trackById[id];
     var isFirstMeasure = true;
     element.IterateChildren(c =>
     {
         if (c.NodeType == XmlNodeType.Element)
         {
             switch (c.LocalName)
             {
                 case "measure":
                     ParseMeasure(c, track, isFirstMeasure);
                     isFirstMeasure = false;
                     break;
             }
         }
     });
 }
Exemplo n.º 28
0
        private void ParseTrack(IXmlNode node)
        {
            var track = new Track(1);
            var trackId = node.GetAttribute("id");

            node.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                        case "Name":
                            track.Name = GetValue(c);
                            break;
                        case "Instrument":
                            var instrumentName = c.GetAttribute("ref");
                            if (instrumentName.EndsWith("-gs") || instrumentName.EndsWith("GrandStaff"))
                            {
                                track.EnsureStaveCount(2);
                            }
                            break;
                        case "ShortName":
                            track.ShortName = GetValue(c);
                            break;
                        //TODO: case "Lyrics": parseLyrics(track, c);
                        case "Properties":
                            ParseTrackProperties(track, c);
                            break;
                        case "GeneralMidi":
                            ParseGeneralMidi(track, c);
                            break;
                        case "PlaybackState":
                            var state = GetValue(c);
                            track.PlaybackInfo.IsSolo = state == "Solo";
                            track.PlaybackInfo.IsMute = state == "Mute";
                            break;
                    }
                }
            });

            _tracksById[trackId] = track;
        }
Exemplo n.º 29
0
        public bool TryGetReference(IXmlNode node, out int id)
        {
            var text = node.GetAttribute(XRef.Ref);

            return(int.TryParse(text, IntegerStyle, Culture, out id));
        }
Exemplo n.º 30
0
 private void ParseTrackProperty(Track track, IXmlNode node)
 {
     var propertyName = node.GetAttribute("name");
     switch (propertyName)
     {
         case "Tuning":
             var tuningParts = GetValue(FindChildElement(node, "Pitches")).Split(' ');
             var tuning = new int[tuningParts.Length];
             for (int i = 0; i < tuning.Length; i++)
             {
                 tuning[tuning.Length - 1 - i] = Std.ParseInt(tuningParts[i]);
             }
             track.Tuning = tuning;
             break;
         case "DiagramCollection":
             ParseDiagramCollection(track, node);
             break;
         case "CapoFret":
             track.Capo = Std.ParseInt(GetValue(FindChildElement(node, "Fret")));
             break;
     }
 }
Exemplo n.º 31
0
Arquivo: Xsi.cs Projeto: belav/Core
 public static bool IsXsiNil(this IXmlNode node)
 {
     return(node.GetAttribute(Xsi.Nil) == NilValue);
 }
Exemplo n.º 32
0
		public bool TryGetReference(IXmlNode node, out int id)
		{
			var text = node.GetAttribute(XRef.Ref);
			return int.TryParse(text, IntegerStyle, Culture, out id);
		}