示例#1
0
        public GlobalMeasure(XmlReader r, int measureIndex, TimeSignature currentTimeSig)
        {
            M.Assert(r.Name == "measure-global");
            // https://w3c.github.io/mnx/specification/common/#the-measure-element

            Index = measureIndex;                                    // ji: 23.06.2020

            GlobalDirections = new GlobalDirections(currentTimeSig); // default

            if (!r.IsEmptyElement)
            {
                int count = r.AttributeCount;
                for (int i = 0; i < count; i++)
                {
                    r.MoveToAttribute(i);
                    switch (r.Name)
                    {
                    // The optional MNX-Common "index" attribute is always ignored.
                    //case "index":
                    //    Index = Int32.Parse(r.Value);
                    //    M.Assert(Index > 0);
                    //    break;
                    case "number":
                        Number = Int32.Parse(r.Value);
                        M.Assert(Number > 0);
                        break;

                    case "barline":
                        Barline = GetBarlineType(r.Value);
                        break;

                    default:
                        throw new ApplicationException("Unknown attribute");
                    }
                }

                M.ReadToXmlElementTag(r, "directions-global");

                while (r.Name == "directions-global")
                {
                    if (r.NodeType != XmlNodeType.EndElement)
                    {
                        switch (r.Name)
                        {
                        case "directions-global":
                            GlobalDirections = new GlobalDirections(r, currentTimeSig);
                            currentTimeSig   = GlobalDirections.CurrentTimeSignature;
                            break;
                        }
                    }
                    M.ReadToXmlElementTag(r, "directions-global", "measure-global");
                }
            }

            TicksDuration = new MNXDurationSymbol(currentTimeSig.Signature).GetDefaultTicks();

            M.Assert(r.Name == "measure-global"); // end of measure-global
        }
示例#2
0
        public List <List <IUniqueDef> > GetGlobalIUDsPerMeasure()
        {
            var rval = new List <List <IUniqueDef> >();

            for (var measureIndex = 0; measureIndex < GlobalMeasures.Count; measureIndex++)
            {
                List <IUniqueDef> measureList      = new List <IUniqueDef>();
                GlobalDirections  globalDirections = GlobalMeasures[measureIndex].GlobalDirections;
                if (globalDirections != null)
                {
                    var          components   = globalDirections.Components;
                    KeySignature keySignature = components.Find(x => x is KeySignature) as KeySignature;
                    if (keySignature != null)
                    {
                        measureList.Add(keySignature);
                    }
                    TimeSignature timeSignature = components.Find(x => x is TimeSignature) as TimeSignature;
                    if (timeSignature != null)
                    {
                        measureList.Add(timeSignature);
                    }
                    RepeatBegin repeatBegin = components.Find(x => x is RepeatBegin) as RepeatBegin;
                    if (repeatBegin != null)
                    {
                        measureList.Add(repeatBegin);
                    }
                    RepeatEnd repeatEnd = components.Find(x => x is RepeatEnd) as RepeatEnd;
                    if (repeatEnd != null)
                    {
                        measureList.Add(repeatEnd);
                    }
                    Segno segno = components.Find(x => x is Segno) as Segno;
                    if (segno != null)
                    {
                        measureList.Add(segno);
                    }
                    Jump jump = components.Find(x => x is Jump) as Jump;
                    if (jump != null)
                    {
                        measureList.Add(jump);
                    }
                    Fine fine = components.Find(x => x is Fine) as Fine;
                    if (fine != null)
                    {
                        measureList.Add(fine);
                    }
                }
                rval.Add(measureList);
            }
            return(rval);
        }
示例#3
0
        public Part(XmlReader r, List <GlobalMeasure> globalMeasures)
        {
            M.Assert(r.Name == "part");
            // https://w3c.github.io/mnx/specification/common/#the-part-element

            M.ReadToXmlElementTag(r, "part-name", "part-abbreviation", "instrument-sound", "measure");

            int           measureIndex   = 0;
            TimeSignature currentTimeSig = null;

            while (r.Name == "part-name" || r.Name == "part-abbreviation" || r.Name == "instrument-sound" || r.Name == "measure")
            {
                if (r.NodeType != XmlNodeType.EndElement)
                {
                    switch (r.Name)
                    {
                    case "part-name":
                        PartName = r.ReadElementContentAsString();
                        break;

                    case "part-abbreviation":
                        PartAbbreviation = r.ReadElementContentAsString();
                        break;

                    case "instrument-sound":
                        InstrumentSound = r.ReadElementContentAsString();
                        break;

                    case "measure":
                        GlobalDirections globalDirections = globalMeasures[measureIndex].GlobalDirections;
                        currentTimeSig = globalDirections.CurrentTimeSignature;
                        Measure measure = new Measure(r, measureIndex++, currentTimeSig);
                        Measures.Add(measure);
                        break;
                    }
                }
                M.ReadToXmlElementTag(r, "part-name", "part-abbreviation", "instrument-sound", "measure", "part");
            }
            M.Assert(r.Name == "part"); // end of part

            SetOctaveShiftExtendersEndTicksPos(Measures);
        }