Ejemplo n.º 1
0
        private static long ConvertFromByTicksPerQuarterNote(MusicalTime time, short ticksPerQuarterNote, TempoMap tempoMap)
        {
            ThrowIfArgument.IsNull(nameof(time), time);
            ThrowIfArgument.IsNull(nameof(tempoMap), tempoMap);

            //

            var timeBars          = time.Bars;
            var accumulatedBars   = 0;
            var lastTime          = 0L;
            var lastTimeSignature = TimeSignature.Default;

            foreach (var timeSignatureChange in tempoMap.TimeSignature.Values)
            {
                var timeSignatureChangeTime = timeSignatureChange.Time;

                var bars = GetBarsCount(timeSignatureChangeTime - lastTime, lastTimeSignature, ticksPerQuarterNote);
                if (accumulatedBars + bars > timeBars)
                {
                    break;
                }

                accumulatedBars  += bars;
                lastTimeSignature = timeSignatureChange.Value;
                lastTime          = timeSignatureChangeTime;
            }

            var beatLength = GetBeatLength(lastTimeSignature, ticksPerQuarterNote);

            return(lastTime + (timeBars - accumulatedBars) * GetBarLength(lastTimeSignature, ticksPerQuarterNote) +
                   time.Beats * beatLength +
                   time.Fraction.ToTicks(ticksPerQuarterNote));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Determines whether the specified object is equal to the current object.
 /// </summary>
 /// <param name="time">The object to compare with the current object.</param>
 /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
 public bool Equals(MusicalTime time)
 {
     return(this == time);
 }