NoteEventSequence totalDuration calculation #29
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.