canAddDuration method

bool canAddDuration(
  1. Duration duration, {
  2. int voice = defaultVoice,
})

Returns true if there is room to add duration to voice.

Each voice is measured independently, so a full voice 1 does not prevent writing into voice 2.

Implementation

bool canAddDuration(Duration duration, {int voice = defaultVoice}) {
  final ts = timeSignature;
  if (ts == null) return true; // No time signature = always can add
  return musicalValueOfVoice(voice) + duration.realValue <=
      ts.measureValue + capacityTolerance;
}