Hey,
I’ve recently tried to switch from the SimpleAudioEngine to the experimental::AudioEngine
and followed the Supported format guide :https://docs.cocos2d-x.org/cocos2d-x/en/audio/getting_started.html where it says *wav should be supported fro Windows, but it turns out that some audio files don’t work with the AudioEngine at least with the .wav format. Ogg. seems to work fine even though it’s not listed for Windows.
experimental::AudioProfile p;
p.name = "test";
p.maxInstances = 10;
experimental::AudioEngine::play2d("electro_music_1.wav", false, 1.f, &p);
Here is the outpuit:
D/AudioEngine-Win32 (280): AudioEngineImpl::_play2d, cache was destroyed or not ready!
V/AudioPlayer (69): ~AudioPlayer() (1341F498), id=2
V/AudioPlayer (83): AudioPlayer::destroy begin, id=2
V/AudioPlayer (128): Before alSourceStop
V/AudioPlayer (130): Before alSourcei
V/AudioPlayer (136): AudioPlayer::destroy end, id=2
maybe the audio is too long? since some *.wav files work just fine.
Right now I just use .ogg for windows since it will be my main format for Android as well.
If you are using this then i will prefer you to use .mp3
only for all platforms.
As per my experience.
1 Like
I’ll try mp3 then, but seems like *.ogg on Windows and *.aac on OSX works as well
These do work and I will add them to the docs to avoid future issues.
1 Like
BTW i just noticed that *.ogg decoding is pretty slow on android(even non my new device). I’ve seen mutliple old posts about this. Are there any newer guides to speed this up?
I’m using the AudioEngine::preload function for all my audio formats.
Not that I know of. But let’s see.
@slackmoehrle
Any info on the ogg loading times?
(it’s only an issue on android)
I probably simply try to use mp3 for now, even though this isn’t optimal because of the size difference.
Have you created a GitHub issue for this yet?
Not yet, I’ve noticed mp3 is just a little bit faster, but not much.
Maybe preloading is slow in general for Android.
There were some posts about the simpleaudio engine in the past: PreloadEffect very slow loading
But i’m using the “AudioEngine” anyway which should be fast.
@slackmoehrle
How is the audio actually loaded when it’s not preloaded?
Is it streaming the audio, or is it just loading it on the fly.
Last time I’ve checked the code I thought it was loading it on the fly, therefore I’ve started using the preload effect feature(which seems to only preload effects for short audios)
Without preloading anything it seems to be pretty fast…