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!