Exemplo n.º 1
0
        public Measure CreateMeasure(TimeSignature ts = null, Clef c = null)
        {
            if (ts != null)
            {
                timeSig = ts;
            }
            Measure newMeasure = new Measure(currentMeasure++, timeSig, c);

            measures.Add(newMeasure);
            newMeasure.Progenitor = this;
            newMeasure.Oflow      = oflow;
            MeasureCreated?.Invoke(this, new MeasureCreatedEventArgs(newMeasure, currentMeasure - 1));
            return(newMeasure);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="measureNumber">Which measure this is.</param>
        /// <param name="ts">The time signature you want used. Defaults to 4/4 time.</param>
        /// <param name="c">The clef you want used. Defaults to percussion.</param>
        public Measure(int measureNumber, TimeSignature ts = null, Clef c = null)
        {
            beatVal       = ts?.BeatVal ?? 8;//assume 4/4 time
            beatNum       = ts?.BeatNum ?? 4;
            MeasureNumber = measureNumber;
            StringBuilder sb = new StringBuilder();

            sb.AppendLine($"<!--============== Part: P1, Measure: {MeasureNumber} ==============-->");
            sb.AppendLine($"<measure number=\"{MeasureNumber}\">");
            if (MeasureNumber == 1)//attributes are only needed in the first measure
            {
                sb.AppendLine("<attributes>");
                sb.AppendLine("<divisions>8</divisions>");
                sb.AppendLine("<key>");
                sb.AppendLine("<fifths>0</fifths>");
                sb.AppendLine("</key>");
                if (ts == null)
                {
                    sb.AppendLine("<time>");
                    sb.AppendLine("<beats>4</beats>");
                    sb.AppendLine("<beat-type>4</beat-type>");
                    sb.AppendLine("</time>");
                }
                else
                {
                    sb.Append(ts.GetXml());
                }
                if (c == null)
                {
                    sb.AppendLine("<clef>");
                    sb.AppendLine("<sign>percussion</sign>");
                    sb.AppendLine("<line>2</line>");
                    sb.AppendLine("</clef>");
                }
                else
                {
                    sb.Append(c.GetXml());
                }
                sb.AppendLine("</attributes>");
            }
            sb.AppendLine("</measure>");

            Meas = XElement.Parse(sb.ToString());
        }