Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Panning sound between top and bottom speaker on iPhone 7

Is it possible to pan sound to either the top or bottom speaker on the iPhone 7 and newer models? I don't have one of these phones, but my understanding is that iOS mixes stereo sound and plays it back from both speakers when the phone is in portrait mode. I know it routes left and right channels to their respective speakers in landscape, but I can't find documentation about the behavior in portrait mode.

Is it possible to limit playback to just one speaker or the other, or to pan between top and bottom? My library cannot operate with the destructive interference of both speakers playing at the same time.

like image 928
Brian Armstrong Avatar asked Jan 29 '18 22:01

Brian Armstrong


People also ask

Should both speakers work on iPhone 7?

So, do both speakers work on my iPhone7? The answer is yes. Here's why. The iPhone 7 has a bottom-firing speaker and a top-firing earpiece for calls.

How do you fix speaker mode on iPhone?

Go to Settings > Sounds (or Settings > Sounds & Haptics), and drag the Ringer and Alerts slider back and forth a few times. If you don't hear any sound, or if your speaker button on the Ringer and Alerts slider is dimmed, your speaker might need service.


1 Answers

It turns out my question was misguided. It's hard to get credible information when you can't test on the device yourself.

On iPhone 7 and newer, the stereo channels are actually routed to the individual speakers, even though there is no stereo separation. The left channel routes to the bottom speaker, and the right channel routes to the top/headset speaker. Using the pan attribute can also accomplish the same thing.

Finally, there's one more option with channel assignments. Using AVAudioSession.sharedInstance.currentRoute.outputs, the two speakers combined show up as a single output (outputs[0]). Inside this output are two channels, outputs[0].channels[0] and outputs[0].channels[1]. Mapping to either of these with channel assignments works as well, with the first channel mapping to the bottom speaker and the second to the top.

Any of these methods works fine as a way to route sound output to the new stereo speakers, even when the phone is in portrait orientation.

For anyone who wants to try on their own device, I put together a test application that tests out the various approaches https://github.com/brian-armstrong/speaker-tester

like image 165
Brian Armstrong Avatar answered Oct 04 '22 16:10

Brian Armstrong