SimpleAudioEngine Performance Issue


#1

Hi, guys

Here is the problem I came across:

I use SimpleAudioEngine::sharedEngine()->playEffect to play some sound when needed, the fps drops under 50 sometimes while playing sound.
But if I turn off the sound, the fps keeps stable at 54fps on my Android device. I wonder if there are any performances issues in SimpleAudioEngine?

  1. I doubt that maybe the other part of my codes effects the fps, so I create a new clean project. every time I touch the screen, I play sound once. The frame rate drops!
  2. I also set -DCOCOS2D_DEBUG=0.
  3. I checked the CocosDenshionTest, it has the same problem on my device.

Have you ever met this problem? Thanks in advance.

Attached is the wav file I used.


Sound.wav.zip (8.7 KB)


#2

Yeah i have the same problem but i think is because AudioTrack in Java code has average letancy 40 ms and OpenSL ES has 8ms

Look also here http://stackoverflow.com/questions/7266298/android-sound-api-deterministic-low-latency


#3

Dawid Drozd wrote:

Yeah i have the same problem but i think is because AudioTrack in Java code has average letancy 40 ms and OpenSL ES has 8ms
>
Look also here http://stackoverflow.com/questions/7266298/android-sound-api-deterministic-low-latency

THX so much!

In your opinion, The letancy is the reason which makes fps drops down?
Do you have any advices of solving this? I see many games in Android have a good performance with Audio.


#4

In few days i will implement my own OpenSL ES sounds in android. I have only bad performance when i for example collect coins so i really have a lot of sounds. Another problem is your bit rate. If you have all your sounds in MP3 in 320 kbps it is useless you can drop quality and you don’t hear a difference.

Another thing is do you preload your sounds? Remember preloading to much sounds is also bad :frowning:

For 1 frame in 60 FPS you have 16 ms so when you use Java code you must also add other things i think :slight_smile: except letancy


#5

SimpleAudioEngine is a great platform and works very well for many games. If your game is exceeding SimpleAudioEngine on Android, then remember you’re also exceeding the underlying Android OS sound systems like SoundPool and MediaPlayer. If those aren’t enough, you’ve got some work ahead of you, like Dawid says, implement your own OpenSL sounds.


#6

Dawid Drozd wrote:

In few days i will implement my own OpenSL ES sounds in android. I have only bad performance when i for example collect coins so i really have a lot of sounds. Another problem is your bit rate. If you have all your sounds in MP3 in 320 kbps it is useless you can drop quality and you don’t hear a difference.
>
Another thing is do you preload your sounds? Remember preloading to much sounds is also bad :frowning:
>
For 1 frame in 60 FPS you have 16 ms so when you use Java code you must also add other things i think :slight_smile: except letancy

Thanks for your reply.:slight_smile: I am considering decreasing quality of my sounds to see if it will be OK. otherwise, I have to do it with OpenSL.


#7

Cory Trese wrote:

SimpleAudioEngine is a great platform and works very well for many games. If your game is exceeding SimpleAudioEngine on Android, then remember you’re also exceeding the underlying Android OS sound systems like SoundPool and MediaPlayer. If those aren’t enough, you’ve got some work ahead of you, like Dawid says, implement your own OpenSL sounds.

THX:)
I know it’s weird. I just play a wav sound in a sample, no extra codes, the fps isn’t stable on my device. I am going to try other devices to see if there are any problems on my own device


#8

Yue Zou wrote:

Cory Trese wrote:
> SimpleAudioEngine is a great platform and works very well for many games. If your game is exceeding SimpleAudioEngine on Android, then remember you’re also exceeding the underlying Android OS sound systems like SoundPool and MediaPlayer. If those aren’t enough, you’ve got some work ahead of you, like Dawid says, implement your own OpenSL sounds.
>
THX:)
I know it’s weird. I just play a wav sound in a sample, no extra codes, the fps isn’t stable on my device. I am going to try other devices to see if there are any problems on my own device

What device are you using? I’m playing several sounds in my latest game and see no FPS drop.


#9

Cory Trese wrote:

What device are you using? I’m playing several sounds in my latest game and see no FPS drop.

Cellphone of a Chinese brand called Xiaomi.


#10

Also you can try other format like ogg i think for me it works the best but i am not sure i also must make more tests :slight_smile:


#11

Dawid Drozd wrote:

Also you can try other format like ogg i think for me it works the best but i am not sure i also must make more tests :slight_smile:
:slight_smile: ,sure I’ll try. I deploy my game on Galaxy SII, it performance better.


#12

Galaxy SII uses OpenSL hack read about it in wiki cocos2dx. Because on this model there is a bug :slight_smile: