public TimeMark(TimeMarkShort tms, float milliseconds = 0)
 {
     this.Measure      = tms.Measure;
     this.Beat         = tms.Beat;
     this.PartialBeat  = tms.PartialBeat;
     this.Milliseconds = (short)milliseconds;
 }
        public static float ToFraction(this PartialBeats PartialBeat)
        {
            switch (PartialBeat)
            {
            case PartialBeats.TwoOfFour:
                return(.25f);

            case PartialBeats.TwoOfThree:
                return(1 / 3f);

            case PartialBeats.TwoOfTwo:
                return(.5f);

            case PartialBeats.ThreeOfFour:
                return(.5f);

            case PartialBeats.ThreeOfThree:
                return(2 / 3f);

            case PartialBeats.FourOfFour:
                return(.75f);

            default:
                return(0f);
            }
        }
        public static string ToString(this PartialBeats PartialBeat)
        {
            switch (PartialBeat)
            {
            case PartialBeats.TwoOfFour:
                return("+2/4");

            case PartialBeats.TwoOfThree:
                return("+2/3");

            case PartialBeats.TwoOfTwo:
                return("+2/2");

            case PartialBeats.ThreeOfThree:
                return("+3/3");

            case PartialBeats.ThreeOfFour:
                return("+3/4");

            case PartialBeats.FourOfFour:
                return("+4/4");

            default:
                return("");
            }
        }
Exemple #4
0
        public float ToTimeHelper(short measure, short beat = 1, PartialBeats partialBeat = PartialBeats.None, short milliseconds = 0)
        {
            if ((measure < 0) || (measure >= measures.Length))
            {
                return(0f);
            }
            Measure curr = measures[measure];

            if (curr == null)
            {
                return(0f);
            }

            return(curr.StartingTime
                   + curr.TimePerBeat
                   * (((measure - curr.StartingMeasure) * curr.BeatsPerMeasure)
                      + ((beat > 1) ? (beat - 1) : 0) + partialBeat.ToFraction())
                   + milliseconds / 1000f);
        }
        public TimeMark(short measure, short beat = 1, PartialBeats partialBeat = PartialBeats.None, short milliseconds = 0)
        {
            if (measure < 1)
            {
                throw new ArgumentOutOfRangeException("Measure must be > 0");
            }
            if (beat < 1)
            {
                throw new ArgumentOutOfRangeException("Beat must be > 0");
            }
            if (milliseconds < 0)
            {
                throw new ArgumentOutOfRangeException("Milliseconds must be >= 0");
            }

            this.Measure      = measure;
            this.Beat         = beat;
            this.PartialBeat  = partialBeat;
            this.Milliseconds = milliseconds;
        }
Exemple #6
0
 public void AddTimePoint(int x, int measure, int beat, PartialBeats partial)
 {
     timePoints.Add(x, new TimeMarkShort(measure, beat, partial));
 }
 public TimeMarkShort(int measure, int beat, PartialBeats partial)
 {
     Measure     = (short)measure;
     Beat        = (byte)beat;
     PartialBeat = partial;
 }