/// <summary> /// Calculates the time spent in this bar. (unit: midi ticks) /// </summary> /// <returns></returns> public int CalculateDuration() { var ticks = Duration.ToTicks(); if (Dots == 2) { ticks = MidiUtils.ApplyDot(ticks, true); } else if (Dots == 1) { ticks = MidiUtils.ApplyDot(ticks, false); } if (TupletDenominator > 0 && TupletNumerator >= 0) { ticks = MidiUtils.ApplyTuplet(ticks, TupletNumerator, TupletDenominator); } return(ticks); }