예제 #1
0
        public PartDirections(XmlReader r)
        {
            M.Assert(r.Name == "directions-part");

            // These are just the elements used in the first set of examples.
            // Other elements need to be added later.
            M.ReadToXmlElementTag(r, "clef", "key");

            while (r.Name == "clef" || r.Name == "key")
            {
                if (r.NodeType != XmlNodeType.EndElement)
                {
                    switch (r.Name)
                    {
                    case "clef":
                        Clef = new Clef(r);
                        Components.Add(Clef);
                        break;

                    case "key":
                        // https://w3c.github.io/mnx/specification/common/#the-key-element
                        KeySignature = new KeySignature(r);
                        Components.Add(KeySignature);
                        break;
                    }
                }
                M.ReadToXmlElementTag(r, "clef", "key", "directions-part");
            }

            M.Assert(r.Name == "directions-part"); // end of "directions-part"
        }
예제 #2
0
        /// <summary>
        /// Returns one of the following strings "t", "t1", "t2", "t3", "b", "b1", "b2", "b3"
        /// </summary>
        private StringBuilder GetClefType(MNX.Common.Clef mnxClefDef)
        {
            StringBuilder rval = new StringBuilder();

            if (mnxClefDef.Sign == MNX.Common.ClefType.G)
            {
                M.Assert(mnxClefDef.Line == 2, "G-clefs are only supported on line 2.");
                rval.Append("t");
                switch (mnxClefDef.Octave)
                {
                case 0:
                    break;

                case 1:
                    rval.Append("1");
                    break;

                case 2:
                    rval.Append("2");
                    break;

                case 3:
                    rval.Append("3");
                    break;

                default:
                    // other treble clefs not supported
                    break;
                }
            }
            if (mnxClefDef.Sign == MNX.Common.ClefType.F)
            {
                M.Assert(mnxClefDef.Line == 3, "F-clefs are only supported on line 3.");
                rval.Append("b");
                switch (mnxClefDef.Octave)
                {
                case 0:
                    break;

                case -1:
                    rval.Append("1");
                    break;

                case -2:
                    rval.Append("2");
                    break;

                case -3:
                    rval.Append("3");
                    break;

                default:
                    // other bass clefs not supported
                    break;
                }
            }
            if (mnxClefDef.Sign == MNX.Common.ClefType.C)
            {
                M.Assert(false, "C-clefs are not supported.");
            }
            return(rval);
        }
예제 #3
0
        public SequenceDirections(XmlReader r, TimeSignature currentTimeSignature)
        {
            M.Assert(r.Name == "directions");

            M.ReadToXmlElementTag(r, "clef", "cresc", "dim", "dynamics", "expression", "instruction", "octave-shift", "wedge", "text-block");

            while (r.Name == "clef" || r.Name == "cresc" || r.Name == "dim" || r.Name == "dynamics" ||
                   r.Name == "expression" || r.Name == "instruction" || r.Name == "octave-shift" || r.Name == "wedge" || r.Name == "text-block")
            {
                if (r.NodeType != XmlNodeType.EndElement)
                {
                    switch (r.Name)
                    {
                    case "clef":
                        Clef = new Clef(r);
                        Components.Add(Clef);
                        break;

                    case "cresc":
                        // TODO
                        break;

                    case "dim":
                        // TODO
                        break;

                    case "dynamics":
                        // TODO
                        break;

                    case "expression":
                        // TODO
                        break;

                    case "instruction":
                        // TODO
                        break;

                    case "octave-shift":
                        OctaveShift = new OctaveShift(r);
                        Components.Add(OctaveShift);
                        break;

                    case "wedge":
                        // TODO
                        break;

                    case "text-block":
                        TextBlock = new TextBlock(r);
                        Components.Add(TextBlock);
                        break;
                    }
                }
                M.ReadToXmlElementTag(r, "clef", "cresc", "dim", "dynamics", "expression", "instruction", "octave-shift", "wedge", "text-block", "directions");
            }

            if (Repeats != null)
            {
                SetDefaultRepeatPositions(Repeats, currentTimeSignature);
            }

            M.Assert(r.Name == "directions"); // end of "directions"
        }
예제 #4
0
 public Clef(Voice voice, MNX.Common.Clef mnxClefDef, double fontHeight)
     : base(voice)
 {
     _clefType   = GetClefType(mnxClefDef).ToString();
     _fontHeight = fontHeight;
 }