0

I figured out some of the iOS AudioKit examples (for example the Recorder-app) on a iPhone 4s but I have always the problem that there is no sound from the loudspeaker, just from the ear-speaker. I made a simple record and play-app with AudioKit but I could not fix it:

try AKSettings.setSession(category: .playAndRecord, with: .defaultToSpeaker)

does not do its work, why? I tried out other solutions which I found on different mailing lists like

AKSettings.defaultToSpeaker = true

or

try AVAudioSession.sharedInstance().overrideOutputAudioPort(AVAudioSession.PortOverride.speaker)

nothing helped. I use Xcode 11 with Swift 5 for my own coding and the current AudioKit-release. Thanks for sharing your ideas... (with my libpd apps the speaker worked always fine which means it is not a hardware problem)

Alfab
  • 11
  • 2
  • Have you tried toggling the silent mode switch? See https://stackoverflow.com/a/47695714/2717159 – c_booth Mar 14 '20 at 14:02

1 Answers1

-1

It might have to do with the order of setting it up. I've tried it with this piece of code and it works for me:

    do {
        try AVAudioSession.sharedInstance().setCategory(.playAndRecord, options: .defaultToSpeaker)
        try AVAudioSession.sharedInstance().setActive(true, options: .notifyOthersOnDeactivation)
        try AudioKit.start()
        try AVAudioSession.sharedInstance().overrideOutputAudioPort(AVAudioSession.PortOverride.speaker)
    } catch {
        AKLog("Could not set up session: error: \(error)")
    }
JTea
  • 234
  • 2
  • 5