Skip to content

Commit c332d7a

Browse files
committed
Prefer for in to forEach
1 parent 4e3e9a0 commit c332d7a

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

Sources/AudioKitEX/Sequencing/Sequence.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public struct NoteEventSequence: Equatable {
140140
allEvents.append(contentsOf: events)
141141
/// Get all SequenceEvents from Notes
142142
var noteEvents: [SequenceEvent] = []
143-
notes.forEach { note in
143+
for note in notes {
144144
noteEvents.append(note.noteOn)
145145
noteEvents.append(note.noteOff)
146146
}

Sources/AudioKitEX/Sequencing/Sequencer.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ open class Sequencer {
1515
/// Overall playback speed
1616
open var tempo: BPM {
1717
get { return tracks.first?.tempo ?? 0 }
18-
set { tracks.forEach { $0.tempo = newValue } }
18+
set { for track in tracks { track.tempo = newValue } }
1919
}
2020

2121
/// Length in beats
2222
open var length: Double {
2323
get { return tracks.max(by: { $0.length > $1.length })?.length ?? 0 }
24-
set { tracks.forEach { $0.length = newValue } }
24+
set { for track in tracks { track.length = newValue } }
2525
}
2626

2727
/// Whether or not looping is enabled
2828
open var loopEnabled: Bool {
2929
get { return tracks.first?.loopEnabled ?? false }
30-
set { tracks.forEach { $0.loopEnabled = newValue } }
30+
set { for track in tracks { track.loopEnabled = newValue } }
3131
}
3232

3333
/// Is the sequencer currently playing
@@ -63,27 +63,27 @@ open class Sequencer {
6363

6464
/// Start playback of the track from the current position (like unpause)
6565
public func play() {
66-
tracks.forEach { $0.play() }
66+
for track in tracks { track.play() }
6767
}
6868

6969
/// Start the playback of the track from the beginning
7070
public func playFromStart() {
71-
tracks.forEach { $0.playFromStart() }
71+
for track in tracks { track.playFromStart() }
7272
}
7373

7474
/// Start playback after a certain number of beats
7575
public func playAfterDelay(beats: Double) {
76-
tracks.forEach { $0.playAfterDelay(beats: beats) }
76+
for track in tracks { track.playAfterDelay(beats: beats) }
7777
}
7878

7979
/// Stop playback
8080
public func stop() {
81-
tracks.forEach { $0.stop() }
81+
for track in tracks { track.stop() }
8282
}
8383

8484
/// Rewind playback
8585
public func rewind() {
86-
tracks.forEach { $0.rewind() }
86+
for track in tracks { track.rewind() }
8787
}
8888

8989
/// Load MIDI data from a file URL
@@ -159,13 +159,13 @@ open class Sequencer {
159159

160160
/// Remove all notes
161161
public func clear() {
162-
tracks.forEach { $0.clear() }
162+
for track in tracks { track.clear() }
163163
}
164164

165165
/// Move to a new time in the playback
166166
/// - Parameter position: Time to jump to, in beats
167167
public func seek(to position: Double) {
168-
tracks.forEach { $0.seek(to: position) }
168+
for track in tracks { track.seek(to: position) }
169169
}
170170

171171
/// Equivalent to stop

0 commit comments

Comments
 (0)