interval method
The interval between this Pitch and other.
Example:
Note.g.inOctave(4).interval(Note.d.inOctave(5)) == .P5
Note.a.flat.inOctave(3).interval(Note.d.inOctave(4)) == .A4
Note.c.inOctave(5).interval(Note.b.inOctave(4)) == -Interval.m2
Implementation
@override
Interval interval(Pitch other) {
final ordinalDelta = other.note.noteName.ordinal - note.noteName.ordinal;
final sizeDelta = ordinalDelta + 7 * (other.octave - octave);
return .fromSizeAndSemitones(
Size(sizeDelta.abs() + 1),
difference(other).abs(),
).withDescending(sizeDelta.isNegative);
}