Audio Engine Problem on Cocos2dx 3.17-2

Audio Engine Problem on Cocos2dx 3.17-2

Hi people, my name is Artur.

I’ve been developing a game with cocos 2dx for since a long time, and I’ve been using Simple Audio engine on this game until recently, when I decided to change to AudioEngine (I was using cocos2dx 3.15 I’m now using cocos2dx 3.17-2).

The Audio requirements of my game are quite intensive, I would say. It is a racing game, so It has a lot of short sound effects for the bumps and craches, and looping music tracks during gameplay. In addition it has a narration voice and some other sound effects.

Sound effects are small WAV files while music tracks are bigger MP3 ones. The average specs for sound effect files are 360k of 44kHz mono WAV files and for music we have 4MB of 44kHz MP3 files.

We have been built the game for Mac, Windows, IOS and Android.

First of all, I have to say that Simple Audio Engine was doing very well. Except for some glitches on android and windows. For android, we were able to manage workarounds that keep the game very playable. But on Windows we experienced frame drops, that we investigate and confirm that are originated on the sound system.

At first, I ignored those windows problems because that were not a target platform for my game, but now things changed and my company is targeting the windows platform. Since I have beean observing the evolution of AudioEngine I decided to shift to it, in hope to solve the glitches on windows.

I did all the necessary adaptations in my code to use AudioEngine ( and it was very straight forward). Despite some initial problems , like abandoning WAV format I managed to put it to work in All my platforms including windows, and I’m very happy to say that the frame drop problem of windos has gone.

But a new big problem has appeared, and it is happening in all platforms: For some reasion, music tracks (the bigger mp3 files) are not played completly. Any music track stops someware at the middle, and never completes an entire loop. Sometimes music lasts only a few seconds. For the other sound effects everything works fine.

I have noticed that many users have been experiencing similar problems, and it seems that some have managed to fix it by changing the engine internals ( using patches). Mas estas noticias de problemas e soluções em foruns são bastante antigas (2015 to 2016) and than I think it was probably already solved on the engine.

I’m Afraid I’m missing something basic, and I would like to get some help from you people. I’m sorry I can not share all the code with you, but I would say that I’m just using AudioEngine::Play2d() for both sound effects and music. I’m nothing sending an AudioProfile on those calls ( Tryed to send one with max instances =1 for music but didnot solve the problem).

Thanks in advance.

Artur Corrêa

Is there any chance you could use OGG format for those large audio files, purely for the sake of testing? If the OGG files play without interruption, then at least that would narrow down the issue to being in the MP3 section of code. If OGG files also have the same problem, then the issue may be something unrelated to the decoding libraries.

Thanks for the answer.

Yes, I did the test. The same problem happens , and more. It seems that ogg does not work on MAC.

Maybe you should try external audio engine. I have tried cricket and I see no issues (plus it supports cool audio features).

Kds, thanks for the suggestion. Do you mean using a different audio library instead of Audio engine? Well I confess that I really considered writing my own audio system or using another one. My reserves about doing it is because I’m sure the problem I’m experiencing must be just because a very simple detail I have missed. As I said, Simple Audio engine was working well even with big files, so there is no reason for the new engine to not work. Wright now I’m reading Audio engine internal code in order to understand it and with hope to figure out the problem.

By any chance, have you tested the audio issue using a simple project (like a newly created project)? If so, is the issue still present?

It’s a good idea Kds, I will consider doing this test if I am unsuccessful in my current research. For now I found out that my music’s audiosource is going into AL_STOPPED state, so it’s being canceled. I don’t know why this is happening.

This is really strange. I was using AudioEngine and I didn’t have any issue with playing the music (I had others issues ;)). I switched to other audio engine just because I wanted to use some features which are not available in cocos engine (e.g. you have racing game, what about changing the speed of the sound of the engine while you drive? ;)).

Check what @R101 suggested with your audio files - just to make sure that your game code is not messing with the audio.