AudioKitEX
AudioKitEX copied to clipboard
NoteEventSequence totalDuration calculation
Previously the SequencerTrack sequence.totalDuration was calculated by combining the duration of all notes in the sequence, even if those notes were overlapping vertically.
So with enough chords early on in the sequence, the note's combined durations could exceed the SequencerTrack .length and cause the .length to be increased unnecessarily. Extended tracks would then loop out of sync. So now .add notes only increases the totalDuration value when the newly added noteEndTime > totalDuration.
Updated willSet condition of the sequence to only force the .length increase if the sequence.totalDuration is not 0.0. Reason: Whenever calling .clear() the NoteEventSequence totalDuration is reset to 0.0. Which previously caused the willSet to make the 0.01 increment increase to every empty track and print unnecessary log messages.
Also updated the .length increase value in the willSet, as the increase by 0.01 doesn't meaningfully help in the case of notes genuinely exceeding the track length. So now the .length will match the new totalDuration.