Skip to content

Commit

Permalink
Use for-in instead of while true
Browse files Browse the repository at this point in the history
  • Loading branch information
jpsim committed Oct 19, 2023
1 parent 9197e4d commit 6139daa
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,17 @@ public struct PitchRecording: Codable, Equatable {

let tracker = PitchTracker(sampleRate: Int32(buffer.format.sampleRate))

var iteration = 0
var pitchRecording = PitchRecording()
while true {
for iteration in 0... {
do {
try file.read(into: buffer)
let pitch = tracker.getPitch(from: buffer, amplitudeThreshold: 0.05)
let entry = PitchRecording.Entry(iteration: iteration, pitch: pitch)
pitchRecording.entries.append(entry)
} catch {
break
}

let pitch = tracker.getPitch(from: buffer, amplitudeThreshold: 0.05)
let entry = PitchRecording.Entry(iteration: iteration, pitch: pitch)
pitchRecording.entries.append(entry)
iteration += 1
}

return pitchRecording
}
}

0 comments on commit 6139daa

Please sign in to comment.