ofSoundPlayer ios default speaker

Hi! I opened the soundPlayer example in an iphone 6s and the default speaker is the one with really low volume, that you use close to the ear, but the other one, the one that plays loud is much better for audio apps, I just don’t know how to select it from openFrameworks. Greetings, if anybody knows how to solve this, it would be great.

the volume of each player in setup() is 0.75 / 0.75/ 0.5
try to increase that value on setup() function


Yes, I did, but still on maximum volume , like synth.setVolume(1.0), or even setting it to 2.0 still sounds very weak as it is coming from the headphone speaker, not the loud speaker. Any ideas?

This code might do it globally for any sound you load. You will need to make sure the file you put it in eg: setup in testApp.cpp is set to be compiled as Obj-C++ ( see note at bottom ).

AVAudioSession * audioSession = [AVAudioSession sharedInstance];
if([audioSession setCategory:AVAudioSessionCategoryPlayAndRecord
                       error:nil]) {

Second option would be to use ofxiOSSoundPlayer directly and then access this function from its internal AVSoundPlayer.

To use it switch your code from ofSoundPlayer to ofxiOSSoundPlayer and then call getAVSoundPlayer(); to access the AVSoundPlayer functions.


auto avPlayer = myiOSSoundPlayer.getAVSoundPlayer();
if( avPlayer ){
  [avPlayer setupSharedSession];

You might need to switch the file you are calling this from to be compiled as Obj-C++ instead of C++.

Which you can do on the right side panel in Xcode:

Hope this helps!

Oh thanks!! Will try and do that, that’s great information!

Ok, so I did the first one, not sure if I did it right, but I pasted the first code in the setup function. It was build successfully, but the sound still comes from the earspeaker and not from the loud speaker.

The second solution you gave me, using the ofxiOSSoundPlayer instead of ofSoundPlayer. It also worked the same way, even when i pasted the las code you gave me. I mean, it still compiles, but I can’t get it to sound from the loudspeaker instead of the earspeaker. Any other ideas to change the default speaker? I thought It could be something similar to the camera selection: camera.setDeviceID(0), but I havent found anything similar yet. Any help would be apreciated. Thanks for the information Theo!

I’m hitting a similar issue on iPhone. Did you make any progress @uaraLab ?