Skip to content

Commit eb70ed9

Browse files
Update Settings.sampleRate for iOS 18
1 parent 0f66553 commit eb70ed9

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

Cookbook/Cookbook/CookbookApp.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ struct CookbookApp: App {
1111
#if os(iOS)
1212
do {
1313
Settings.bufferLength = .short
14+
15+
let deviceSampleRate = AVAudioSession.sharedInstance().sampleRate
16+
if deviceSampleRate > Settings.sampleRate {
17+
// Update sampleRate to 48_000. Default is 44_100.
18+
Settings.sampleRate = deviceSampleRate
19+
}
20+
21+
1422
try AVAudioSession.sharedInstance().setPreferredIOBufferDuration(Settings.bufferLength.duration)
1523
try AVAudioSession.sharedInstance().setCategory(.playAndRecord,
1624
options: [.defaultToSpeaker, .mixWithOthers, .allowBluetoothA2DP])

Cookbook/CookbookCommon/Sources/CookbookCommon/Recipes/MiniApps/DrumSequencer.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ struct DrumSequencerView: View {
127127
conductor.start()
128128
}
129129
.onDisappear {
130+
conductor.isPlaying = false
130131
conductor.drums.destroyEndpoint()
131132
conductor.stop()
132133
}

Cookbook/CookbookCommon/Sources/CookbookCommon/Recipes/MiniApps/DrumSynthesizers.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ struct DrumSynthesizersView: View {
6464
conductor.start()
6565
}
6666
.onDisappear {
67+
conductor.isRunning = false
6768
conductor.stop()
6869
}
6970
}

0 commit comments

Comments
 (0)