musicalValueByVoice property

Map<int, double> get musicalValueByVoice

Rhythmic value written in each voice of this measure, keyed by voice number.

Elements without an explicit voice are accumulated under defaultVoice. Voices with no rhythmic content are omitted from the map.

This is the single source of truth for currentMusicalValue, musicalValueOfVoice, isValidlyFilled, canAddDuration and remainingValue; subclasses only need to override this getter to make the whole capacity API behave correctly for them.

Implementation

Map<int, double> get musicalValueByVoice {
  final byVoice = <int, double>{};
  for (final element in elements) {
    final value = musicalValueOf(element);
    if (value <= 0) continue;
    final voice = voiceNumberOf(element);
    byVoice[voice] = (byVoice[voice] ?? 0.0) + value;
  }
  return byVoice;
}