Cricket Audio Engine with cocos2d-x

Cricket Audio Engine with cocos2d-x


We now looking for cheap/free Sound engine for cocos2d-x, as default one seems can’t handle properly sounds on Android.

SO far we trying Cricket Audio Engine:

We found manual how to integrate it:

Successfully added to new project, but what we don’t like so far - to create sounds bank we should use wav files which are x10 bigger then mp3 files, also they streaming audio function seems doesn;t work oe we doing something wrong.

Is there any production app with it, maybe someone have more info about this engine and how to handle audio formats and size for it?


I believe at least one user has a game released using this.

Have you tried .ogg format instead of .mp3? It should support playing both, but ogg files seem to be the preferred format on Android.


Yes, I saw that post that why wanted to try this engine, but seems it not perfect:)

@MatrixAndrew what is your current experience with it? Which file formats u using and have u managed to play streaming sound?


According to the docco
“16-bit PCM: This is the default format. The data is uncompressed, so it requires very few CPU cycles to play, but uses 2 bytes per sample per channel (about the same as a typical uncompressed .wav or .aiff file).
8-bit PCM: Also uncompressed, but only uses 1 byte per sample per channel (half the space of 16-bit PCM), and lower audio quality.
ADPCM: A compressed format that requires somewhat more CPU cycles to play, but requires 1/3 of the space of 16-bit PCM. Audio quality is typically somewhat worse than 16-bit PCM but better than 8-bit PCM. Samples are packed in blocks of 36 samples (24 bytes).”


*"The most portable formats for a stream sound are:
.ogg (Ogg Vorbis)
These formats are supported on all platforms, including Windows and OS X, and we recommend that you use them for most purposes.

Files in the .cks format are created using cktool; the audio data can be in the same formats supported by bank sounds (16-bit PCM, 8-bit PCM, or ADPCM).

Streams can also be in other audio file formats; support for these varies by platform. Currently, the following additional formats are supported on both iOS and Android:
.wav (uncompressed, or with �-law or a-law compression)
.mp4 (AAC compression)
.m4a (AAC compression)
The iOS version can read the following additional audio file formats:
.aac, .adts (AAC compression)
.aiff, .aif, .aifc
.m4a (Apple Lossless compression)
.snd, .au (uncompressed, or �-law compression)
The Android version can read the following additional audio file formats:


Yeah, we were trying to create bank and it was accepting only wav files, mp3 files was showed as error. So we converted 35kb mp3 to 334kb wav and it used it as it is without any compression - so I think it little to much space.

Regarding stream sounds - it just not playing any file we passing, was trying wav, mp3, cks - maybe there is some issue in latest SDK version or something not mentioned in tutorial? It all the time was saying sound not ready… Have you managed to stream sounds?


Yes I use .ogg stream sounds without any problem. Stream sounds are not instantly ready so obtaining information about them before they are loaded is not recommended, but the message about it not being ready doesn’t mean there is an error (at least I don’t think). I use it like this and it works as intended:

CkSound* sound = CkSound::newStreamSound("mysound.ogg");

Bank sounds have the same size as the sum of the wav files put into them because there is not much compression going on. In the other hand playing sounds from banks is instantaneous and cheap.


That strange, we used exactly same construction and it was not playing sound. just all the time sound.iSReady() was false. u using 1.6.2 version?


I use 1.6.1.


ok, maybe that why it not playing on our end, will try to get somwhere older version. Could you try update your sdk and check if it works for you?


This is the changelog on 1.6.2:



  • Added support for tvOS.
  • Removed support for Windows Phone 8.
  • Removed support for Visual Studio 2012 on Windows.
  • Fixed sample rate problem on iPhone 6s.

So there is no changelog lol. Seems like it’s not a stable release or not a release at all, weird. Just use 1.6.1. If you send them an email I’m sure they would tell you about this and/or point you to a location to download 1.6.1


Make sure to call CkUpdate() at every iteration.


I haven’t tried it at all, to be honest; it’s been in my Downloads folder for weeks waiting for me to have time to play with it!


Alright guys, I have very little understanding of what I actually did, but thanks to @MatrixAndrew’s posts and I was able to get it going on my Windows and Android builds.

I didn’t make these commits with the intention of sharing the code, so it’s very sloppy and imperfect, but these two commits, and got the Windows integration with cricket going and this commit got Android and Cricket working, based off that tutorial I couldn’t understand.

The gist of it is for the Windows one, I added the CkConfig stuff to AppDelegate’s init, added the CkUpdate to my main updateloop in a scene, added some audio ogg files, then added ..\Classes\cricket_audio\inc; to my compiler include, since the entire cricket install was put there, and the library linker whatever was `$(SolutionDir)…\Classes\cricket_audio\lib\win\vs12.0$(PlatformTarget)\DebugDynamic\ck.lib; Didn’t need to mess with any preprocessors, just needed to make sure my lib was matching my debug status and the library’s compiler version matched my own.

For the android part, and this is where I really don’t understand, it seems like I added two C++ files that the JNI uses at hellocpp/CricketAndroidJni.cpp and hellocpp/CricketAndroidJni.h' as aLOCAL_C_INCLUDES` addition, marked the cricket library as a static library similar to how Magic Particles did it, and in the Java activity it makes a call out to that external JNI’s code in the two C++ files.

I hope there’s something in my commits that can help you guys.


hi, i successfully run cricket audio engine on windows but on android give me some strange errors:cry: in build.these are my softwares:

cricket audio: v1.6.6
cocos2dx: v3.16
ndk: v 15

and `according to i made and other scripts so finally in building on android give me error about ‘abs’ ans ‘labs’ here it is:


[armeabi] Compile++ thumb: cocos2dxandroid_static <= Java_org_cocos2dx_lib_Cocos2dxHelper.cpp
[armeabi] Compile++ thumb: cocos2dxandroid_static <= Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp
[armeabi] Compile++ thumb: cocos2dxandroid_static <= Java_org_cocos2dx_lib_Cocos2dxEngineDataManager.cpp
[armeabi] Compile++ thumb: cocos2dxandroid_static <= JniHelper.cpp
[armeabi] Compile++ thumb: cocos2dxandroid_static <= TouchesJni.cpp
[armeabi] Compile thumb : cpufeatures <= cpu-features.c
[armeabi] StaticLibrary : libcocostudio.a
[armeabi] StaticLibrary : libui.a
[armeabi] StaticLibrary : libcocosdenshion.a
[armeabi] StaticLibrary : libextension.a
[armeabi] StaticLibrary : libaudioengine.a
[armeabi] StaticLibrary : libbox2d.a
[armeabi] StaticLibrary : libpvmp3dec.a
[armeabi] StaticLibrary : libcocos2dxinternal.a
[armeabi] StaticLibrary : librecast.a
[armeabi] StaticLibrary : libcocos2dandroid.a
[armeabi] StaticLibrary : libcocos2d.a
[armeabi] StaticLibrary : libcocosbuilder.a
[armeabi] StaticLibrary : libcocos3d.a
[armeabi] StaticLibrary : libspine.a
[armeabi] StaticLibrary : flatbuffers.a
[armeabi] StaticLibrary : libnetwork.a
[armeabi] StaticLibrary : libvorbisidec.a
[armeabi] StaticLibrary : libcpufeatures.a
[armeabi] SharedLibrary :
/Users/steve/work/ck/ext/tremor/sharedbook.c:228: error: undefined reference to ‘abs’
/Users/steve/work/ck/ext/tremor/sharedbook.c:262: error: undefined reference to ‘abs’
/Users/steve/work/ck/ext/tremor/misc.h:202: error: undefined reference to ‘abs’
/Users/steve/work/ck/ext/tremor/floor0.c:202: error: undefined reference to ‘labs’
/Users/steve/work/ck/ext/tremor/floor0.c:203: error: undefined reference to ‘labs’
/Users/steve/work/ck/ext/tremor/floor0.c:209: error: undefined reference to ‘labs’
/Users/steve/work/ck/ext/tremor/floor0.c:210: error: undefined reference to ‘labs’
/Users/steve/work/ck/ext/tremor/floor1.c:217: error: undefined reference to ‘abs’
collect2.exe: error: ld returned 1 exit status
make: *** [C:/MyGameX008/] Error 1

help me,plz, what should i do now:neutral_face:?


It sounds to me like you are missing a reference. I recall this happens with things like rand, etc. Perhaps an Android specific forum might get you a faster answer.


Hey, we also integrated cricket audio engine into ios and android game. Regarding that abs stuff for us looks that developers of sdk wrongly compiled it, we had exactly same issue when compiled as debug build, u should use release libs and compule in release mode build then it will works. Also could u please write to cricket audion engine support saying about this issue. We contacted them already but they think that our envirnment setup incorrect not their code, so your exactly same issue just proves that they did wrong compile of lib on their side


I am working on a fix and a new version of Cricket Audio will be released when I have one. I believe the problem lies with the fact that those math functions are inlined in some versions of the NDK and not in others. As @energyy says, release builds seem to work, and at least one developer has said that it worked for him when he compiled with the minimum SDK version set to 19.



Cricket Audio 1.6.6b update released
Posted on March 22, 2018 by steve
This minor update fixes a link error on Android when targeting older OS versions with the NDK.

We tested your sent lib and it seems worked :slight_smile: correctly now


Thanks a lot energy,sjmerel and slackmoehrle
by updating new version of Cricket Audio, it’s possible run on both debug and release mode :heart_eyes: