3
votes

Have an app that can record audio and play it with another audio simultaneously.

What I Want: To be able to switch Audio Input And Output devices. For example. Record Audio from iPhone build in mic and listen audio through wired or bluetooth headphones. and vice versa

What am I trying to do:

            do {
                print("Seted Input:\(String(describing: AudioKit.inputDevice))")
                if let inputs = AudioKit.inputDevices {
                    print("Selected Input:\(String(describing: [indexPath.row]))")
                    try AudioKit.setInputDevice(inputs[indexPath.row])
                    try PlayerManager.sharedInstance.mic.setDevice(inputs[indexPath.row])
                    print("Selected Input:\(String(describing: AudioKit.inputDevice))")
                }
            } catch let error as NSError{
                print(error)
            }

Result:

Seted Input:Optional(<Device: Микрофон гарнитуры (Wired Microphone)>)
Selected Input:<Device: iPhone Микрофон (Built-In Microphone Снизу)>
Selscted Input:Optional(<Device: Микрофон гарнитуры (Wired Microphone)>)
Selected Output:Optional(<Device: Наушники (Wired Headphones)>)

Question: How to properly set input device with AudioKit.

I'am using xCode 9.3 (9E145) and AudioKit (4.2.1)

P.S It would be great if some one help me with output setting too. AudioKit.outputDevices always return 1 device to me, even if bluetooth and wired headphones connected

1
Did you find a solution to this? I have the same problemuser759885
No. still no luckAndrew Dubenkov
Did you find out the solution in the end?Mr_P

1 Answers

0
votes
do {
        try AudioKit.setInputDevice(AudioKit.inputDevices![0])
    } catch {
        AKLog("AudioKit setInputDevice failed")
    }