Skip to content

AudioKit/AudioKit#2955 #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/AudioKitEX/Sequencing/Sequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public struct NoteEventSequence: Equatable {
channel: MIDIChannel = 0,
position: Double,
duration: Double) {
totalDuration += duration
totalDuration = max(totalDuration, position + duration) // Get last note in the track + its duration
var newNote = SequenceNote()

newNote.noteOn.status = noteOnByte
Expand Down
9 changes: 9 additions & 0 deletions Tests/AudioKitEXTests/SequencerTrackTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,20 @@ class SequencerTrackTests: XCTestCase {
let track = SequencerTrack(targetNode: sampler)
engine.output = sampler

track.add(noteNumber: 60, position: 0.0, duration: 1.0)
track.add(noteNumber: 60, position: 0.0, duration: 1.0)
track.add(noteNumber: 60, position: 0.0, duration: 1.0)
track.add(noteNumber: 60, position: 0.0, duration: 1.0)

XCTAssertEqual(track.length, 4, "Track length shouldn't be extended with chord duration less than existing track length")

track.add(noteNumber: 60, position: 0.0, duration: 1.0)
track.add(noteNumber: 60, position: 1.0, duration: 1.0)
track.add(noteNumber: 60, position: 2.0, duration: 1.0)
track.add(noteNumber: 60, position: 3.0, duration: 1.0)

XCTAssertEqual(track.length, 4.01, "Track length should be extended with note event position + duration greater or equal to existing track length")

track.playFromStart()
XCTAssertTrue(track.isPlaying)
let audio = engine.startTest(totalDuration: 5.0)
Expand Down
Loading