advance method

int advance(
  1. MusicalElement element, {
  2. int measureIndex = 0,
})

Advances the tracker to element (which lives in measure measureIndex) and returns the displacement in force AT that element.

An OctaveMark displaces itself too — the returned value for the mark element is the new span's shift — but the mark has no printed pitch, so that is inconsequential; what matters is that every following note in the span sees it.

Implementation

int advance(MusicalElement element, {int measureIndex = 0}) {
  final end = _activeEndMeasure;
  if (_active != null && end != null && measureIndex > end) {
    _active = null;
    _activeEndMeasure = null;
  }
  if (element is OctaveMark) {
    _active = element;
    _activeEndMeasure = element.endMeasure > element.startMeasure
        ? element.endMeasure
        : measureIndex;
  }
  return octaveShift;
}