Skip to content

Commit 7148d40

Browse files
Merge pull request #165 from NickCulbertson/UpdateSampleRate
Update Settings.sampleRate for iOS 18
2 parents 0f66553 + fd5eacf commit 7148d40

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

Cookbook/Cookbook/CookbookApp.swift

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ 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+
1421
try AVAudioSession.sharedInstance().setPreferredIOBufferDuration(Settings.bufferLength.duration)
1522
try AVAudioSession.sharedInstance().setCategory(.playAndRecord,
1623
options: [.defaultToSpeaker, .mixWithOthers, .allowBluetoothA2DP])

Cookbook/CookbookCommon/Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ let package = Package(
2020
.package(url: "https://github.com/AudioKit/Waveform", branch: "visionos"),
2121
.package(url: "https://github.com/AudioKit/Flow", from: "1.0.0"),
2222
.package(url: "https://github.com/AudioKit/PianoRoll", from: "1.0.0"),
23-
.package(url: "https://github.com/orchetect/MIDIKit", from: "0.9.4"),
23+
.package(url: "https://github.com/orchetect/MIDIKit", from: "0.9.7"),
2424
],
2525
targets: [
2626
.target(

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

+1
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

+1
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)