/** Return the duration of this staff system. This is the start time * difference between the first and last measure start time slices in the * first staff plus the duration of the last measure. (It is assumed that all * staves in the staff system have the same duration.) * This is used to compute the screen hotspots of the measure starts. */ public Rational getDuration() { if (_duration != null) { return(_duration); } if (getStaffCount() == 0 || getStaff(0).getMeasureStartCount() == 0) { // There are no staffs or time slices! This is unexpected. Just return 0. // DEBUG: maybe this should be handled more gracefully. _duration = new Rational(0, 1); return(_duration); } Staff staff = getStaff(0); MeasureStartTimeSlice lastMeasureStart = staff.getMeasureStart(staff.getMeasureStartCount() - 1); IntRatio result = new IntRatio(lastMeasureStart.getStartTime()); result.sub(getStartTime()); result.add(lastMeasureStart.getDuration()); _duration = new Rational(result); return(_duration); }
/** Return the duration of this measure. If this MeasureStartTimeSlice has * a following MeasureStartTimeSlice in the Staff, the duration is the start time * difference of this measure start and the following measure start. * If no following measure start, the duration of this measure is * the start time of the last event TimeSlice. Note that this assumes * the last event TimeSlice has zero duration, but this is reasonable * since the last event TimeSlice usually just holds a bar line. */ public Rational getDuration() { if (_duration != null) { return(_duration); } if ((getIndex() + 1) >= getParentStaff().getMeasureStartCount()) { // This is the last measure start if (getTimeSliceCount() == 0) { // No time slices, just set duration to zero _duration = new Rational(0, 1); } else { // DEBUG: This assumes the event time slices are ordered. Maybe check this. _duration = getTimeSlice(getTimeSliceCount() - 1).getStartTime(); } } else { // Compute the start time difference between the next measure and this // DEBUG: This assumes that the measure start time slices are ordered. Maybe check this. IntRatio result = new IntRatio (getParentStaff().getMeasureStart(getIndex() + 1).getStartTime()); result.sub(getStartTime()); _duration = new Rational(result); } return(_duration); }
/** Return the duration of this measure. If this MeasureStartTimeSlice has * a following MeasureStartTimeSlice in the Staff, the duration is the start time * difference of this measure start and the following measure start. * If no following measure start, the duration of this measure is * the start time of the last event TimeSlice. Note that this assumes * the last event TimeSlice has zero duration, but this is reasonable * since the last event TimeSlice usually just holds a bar line. */ public Rational getDuration() { if (_duration != null) return _duration; if ((getIndex() + 1) >= getParentStaff().getMeasureStartCount()) { // This is the last measure start if (getTimeSliceCount() == 0) // No time slices, just set duration to zero _duration = new Rational(0, 1); else // DEBUG: This assumes the event time slices are ordered. Maybe check this. _duration = getTimeSlice(getTimeSliceCount() - 1).getStartTime(); } else { // Compute the start time difference between the next measure and this // DEBUG: This assumes that the measure start time slices are ordered. Maybe check this. IntRatio result = new IntRatio (getParentStaff().getMeasureStart(getIndex() + 1).getStartTime()); result.sub(getStartTime()); _duration = new Rational(result); } return _duration; }
/** Return the duration of this staff system. This is the start time * difference between the first and last measure start time slices in the * first staff plus the duration of the last measure. (It is assumed that all * staves in the staff system have the same duration.) * This is used to compute the screen hotspots of the measure starts. */ public Rational getDuration() { if (_duration != null) return _duration; if (getStaffCount() == 0 || getStaff(0).getMeasureStartCount() == 0) { // There are no staffs or time slices! This is unexpected. Just return 0. // DEBUG: maybe this should be handled more gracefully. _duration = new Rational(0, 1); return _duration; } Staff staff = getStaff(0); MeasureStartTimeSlice lastMeasureStart = staff.getMeasureStart(staff.getMeasureStartCount() - 1); IntRatio result = new IntRatio(lastMeasureStart.getStartTime()); result.sub(getStartTime()); result.add(lastMeasureStart.getDuration()); _duration = new Rational(result); return _duration; }