Hi all,
I am working on a cross-platform app that uses, among other things, ofSoundPlayer to trigger sounds. It is working great on Mac OS X, but as we started developing for iOS we noticed that there was a significant drop in the frame rate as sounds were being played. So we came up with the following code to try and isolate the problem.
in ofApp.mm:
void ofApp::setup(){
ofBackground(127,127,127);
player1.load("switch_on.wav", false);
player1.setVolume(0.7f);
}
void ofApp::draw(){
cout << ofGetFrameRate() << endl;
}
void ofApp::touchDown(ofTouchEventArgs &touch){
player1.play();
}
So it prints the frame rate to the console on each frame. “switch_on.wav” is a .wav sound in 44 100/16bits, lasting for 0.16 seconds. Here’s what happens (tested with a metronome):
-
When there’s no interaction it prints a frame rate of 60, as you would expect;
-
Clicking once each second first causes it to drop to around 53, then it becomes stable around 58;
-
Clicking four times each second causes it to drop at first to around 48 then it becomes stable around 50. It also causes it not to trigger some of the sounds, now and again;
-
Clicking 8 times each second causes it to drop to 35, and it becomes stable around that value;
-
Clicking as fast as I can causes the frame rate to drop to 11, and no sound is played at all.
I think this may be similar to this topic right here, but I couldn’t get ofxOpenALSoundPlayer to work, with the following error:
Field type 'ofxOpenALSoundPlayer' is an abstract class
Any help will be greatly appreciated!
Edit: forgot to mention. Testing on iPhone 5!