cocos2d / cocos2d-x

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
https://www.cocos.com/en/cocos2d-x
18.25k stars 7.06k forks source link

AudioEngine not working in iOS #17237

Open xdeop opened 7 years ago

xdeop commented 7 years ago

Steps to Reproduce:

experimental::AudioEngine::play2d("audio.mp3", false, 1.0); Doesn't play any sound. Always returns -1;

PD: we have SimpleAudioEngine running a BackgroundMusic and other effects. We want to change some effects to AudioEngine because in Android > 5 aren't reproducing.

Thanks.

dumganhar commented 7 years ago

I don't know which platform could this issue be reproduced on. iOS or Android? And

xdeop commented 7 years ago

Hi, thanks for your answer.

As the title suggested, AudioEngine isn't reproducing sound when testing on iOS simulator (target 10.0).

We've tried this AudioEngine as an alternative to SimpleAudioEngine because when using SimpleAudioEngine, it works fine on iOS, but some sound effects aren't reproducing on Android...

What is the best way to play sounds that works correctly on boths platforms?

dumganhar commented 7 years ago

What is the best way to play sounds that works correctly on boths platforms?

Keep going to use AudioEngine, SimpleAudioEngine will be deprecated sooner or later.

If you have issues with AudioEngine, it's better to make a demo or paste some code and resources for reproducing it.

dumganhar commented 7 years ago

@xdeop, any update for this issue? Did you resolve the problem?

hussain-sohaib commented 7 years ago

Hi,

We were having same issue, it appears SimpleAudioEngine and AudioEngine wont work together on iOS. you need to choose and select one and use it everywhere in project.

But AudioEngine has issues while playing background music, for instance it wont pause immediately after playing a background music of length around 1 mins and audio format .mp3. Example

int i= experimental::AudioEngine::play2d("audio.mp3", true, 1.0);

experimental::AudioEngine::pause(i);

wont stop. Probably because it is still in initializing state and to pause it needs to be in playing state.

Also when playing big background music which loops continually the AudioEngine has a glitch at start, meaning start of playing is not smooth, and same at the end.

thanks

On Wed, Mar 15, 2017 at 6:46 AM, James Chen notifications@github.com wrote:

@xdeop https://github.com/xdeop, any update for this issue? Did you resolve the problem?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cocos2d/cocos2d-x/issues/17237#issuecomment-286616359, or mute the thread https://github.com/notifications/unsubscribe-auth/ACC8g5jwynDV0ZMMTSklEsJsBBrylXs_ks5rl0MIgaJpZM4LobXY .

-- Best Regards Sohaib Hussain

xdeop commented 7 years ago

As @hussain-sohaib answered, SimpleAudioEngine and AudioEngine won't work together on iOS. We've moved to AudioEngine although we are having some crashes. We'll post detailed info about them.

dumganhar commented 7 years ago

@hussain-sohaib , thanks for your feedback. Could you create two issues about glitch and pause state? Could you upload the audio file which could reproduce the glitch issue?

@xdeop , if you find any issues with AudioEngine, feel free to create new issues.

hussain-sohaib commented 7 years ago

Hi,

James Chen I cant post the music here, but I can send you on your email or Skype id as it is confidential.

thanks

On Wed, Mar 15, 2017 at 3:00 PM, James Chen notifications@github.com wrote:

@hussain-sohaib https://github.com/hussain-sohaib , thanks for your feedback. Could you create two issues about glitch and pause state? Could you upload the audio file which could reproduce the glitch issue?

@xdeop https://github.com/xdeop , if you find any issues with AudioEngine, feel free to create new issues.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cocos2d/cocos2d-x/issues/17237#issuecomment-286695009, or mute the thread https://github.com/notifications/unsubscribe-auth/ACC8g1gYdcG4evCW9KERUUso0LGpon-Qks5rl7a0gaJpZM4LobXY .

-- Best Regards Sohaib Hussain

hussain-sohaib commented 7 years ago

Hi,

What could be the best sampling rate for audio file that provide quality and high optimization? Also what audio format works best with AudioEngine ? .wav, .caf or .mp3 for both background music( looping) and effects (non looping) in iOS. Also in SimpleAudioEngine we used to set pan what is the default value of pan in AudioEngine?

thanks

On Wed, Mar 15, 2017 at 3:34 PM, Sohaib Hussain sohaib.hussain7@gmail.com wrote:

Hi,

James Chen I cant post the music here, but I can send you on your email or Skype id as it is confidential.

thanks

On Wed, Mar 15, 2017 at 3:00 PM, James Chen notifications@github.com wrote:

@hussain-sohaib https://github.com/hussain-sohaib , thanks for your feedback. Could you create two issues about glitch and pause state? Could you upload the audio file which could reproduce the glitch issue?

@xdeop https://github.com/xdeop , if you find any issues with AudioEngine, feel free to create new issues.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cocos2d/cocos2d-x/issues/17237#issuecomment-286695009, or mute the thread https://github.com/notifications/unsubscribe-auth/ACC8g1gYdcG4evCW9KERUUso0LGpon-Qks5rl7a0gaJpZM4LobXY .

-- Best Regards Sohaib Hussain

-- Best Regards Sohaib Hussain

dumganhar commented 7 years ago

@hussain-sohaib My Skype ID: dumganhar

What could be the best sampling rate for audio file that provide quality and high optimization?

Mobile devices normally uses 44kHZ sample rate. If your audio match the sample rate of device. Extra resampling could be avoided. In that case, you will get better performance, lower CPU cost while playing audio.

Also what audio format works best with AudioEngine ? .wav, .caf or .mp3 for both background music( looping) and effects (non looping) in iOS.

We suggest using .ogg for android and .caf (It seems that caf file is decoded by hardware) for iOS. If you need use the same format, then consider .mp3 format.

Also in SimpleAudioEngine we used to set pan what is the default value of pan in AudioEngine?

I check the interface of AudioEngine, didn't find pan property for Stereo effect. You could create a new issue for requesting this feature.