Skip to content

Commit

Permalink
Merge pull request #165 from NickCulbertson/UpdateSampleRate
Browse files Browse the repository at this point in the history
Update Settings.sampleRate for iOS 18
  • Loading branch information
NickCulbertson committed Sep 6, 2024
2 parents 0f66553 + fd5eacf commit 7148d40
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Cookbook/Cookbook/CookbookApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ struct CookbookApp: App {
#if os(iOS)
do {
Settings.bufferLength = .short

let deviceSampleRate = AVAudioSession.sharedInstance().sampleRate
if deviceSampleRate > Settings.sampleRate {
// Update sampleRate to 48_000. Default is 44_100.
Settings.sampleRate = deviceSampleRate
}

try AVAudioSession.sharedInstance().setPreferredIOBufferDuration(Settings.bufferLength.duration)
try AVAudioSession.sharedInstance().setCategory(.playAndRecord,
options: [.defaultToSpeaker, .mixWithOthers, .allowBluetoothA2DP])
Expand Down
2 changes: 1 addition & 1 deletion Cookbook/CookbookCommon/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let package = Package(
.package(url: "https://github.com/AudioKit/Waveform", branch: "visionos"),
.package(url: "https://github.com/AudioKit/Flow", from: "1.0.0"),
.package(url: "https://github.com/AudioKit/PianoRoll", from: "1.0.0"),
.package(url: "https://github.com/orchetect/MIDIKit", from: "0.9.4"),
.package(url: "https://github.com/orchetect/MIDIKit", from: "0.9.7"),
],
targets: [
.target(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ struct DrumSequencerView: View {
conductor.start()
}
.onDisappear {
conductor.isPlaying = false
conductor.drums.destroyEndpoint()
conductor.stop()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ struct DrumSynthesizersView: View {
conductor.start()
}
.onDisappear {
conductor.isRunning = false
conductor.stop()
}
}
Expand Down

0 comments on commit 7148d40

Please sign in to comment.