Skip to content
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) // Compare latest note position and duration to current totalDuration.
var newNote = SequenceNote()

newNote.noteOn.status = noteOnByte
Expand Down
13 changes: 13 additions & 0 deletions Tests/AudioKitEXTests/SequencerTrackTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,24 @@ 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.add(noteNumber: 60, position: 1.0, duration: 5.0)

XCTAssertEqual(track.length, 6.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
2 changes: 1 addition & 1 deletion Tests/AudioKitEXTests/ValidatedMD5s.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let validatedMD5s: [String: String] = [
"-[SequencerTrackTests testLoop]": "3a7ebced69ddc6669932f4ee48dabe2b",
"-[SequencerTrackTests testOneShot]": "3fbf53f1139a831b3e1a284140c8a53c",
"-[SequencerTrackTests testTempo]": "1eb7efc6ea54eafbe616dfa8e1a3ef36",
"-[SequencerTrackTests testNoteBounds]": "6679c7b949d28130549c6a1eb4ceaf59",
"-[SequencerTrackTests testNoteBounds]": "f3b3935e30380367c15652c0a76a8a57",
"-[DryWetMixerTests testBalance0]": "789c1e77803a4f9d10063eb60ca03cea",
"-[DryWetMixerTests testBalance1]": "3932bc5d49cbefd4a9dd587d16f4b81c",
"-[DryWetMixerTests testDefault]": "45a639729d8698a28f134bbe4ccc9d6c",
Expand Down
Loading