How to detect main sound direction from AVAudioSession

Viewed 172

I want to detect the main direction of the sound recorded from iPhone. For example, I want to detect if the sound comes from "front" or "rear" camera.

https://developer.apple.com/documentation/avfoundation/avaudiosessiondatasourcedescription This link describes how to set, but not how to detect in real time.

UPDATE:

Example use: I start recording with front and back camera at the same time. I want to detect if audio comes from front o rear to change camera automaticatlly.

Is there any way?

Thanks!

1 Answers

You can iterate over AVAudioSession.inputDataSources, to check out available sources and obtain the one you want, and then set it to AVAudioSession.setPreferredInput(). If You don't need to set the input but just check it, use AVAudioSession.currentRoute.inputs

Related