How can I minimize CPU and battery usage?

In general, try to reduce the amount of audio data being pushed through the system.  Using mono instead of stereo, and lower sample rate source data, will decrease the amount of data that needs to be processed; this will lower your CPU usage, as well as decrease the size of your bank files, but there may be a loss of audio quality.

Increasing the audio update interval (with Config.audioUpdateMs) to something greater than the default of 5ms will decrease CPU usage somewhat, but will increase latency (the amount of time between when you make an API call and when you hear the results of that call).

Also, your choice of audio encoding is important.  PCM16 and PCM8 are the most efficient; ADPCM is less efficient; and stream formats such as MP3, MP4, or Ogg Vorbis are the least efficient.  (However, depending on your target platform, there may be hardware support for decoding some of these stream formats; see this FAQ entry.)

What audio format should I use for my streams?

This will depend, of course, on the requirements of your app, but in general, we recommend either .cks or .ogg streams.  These formats are decoded in software by Cricket Audio, so they will work identically on all platforms and all devices, and do not require any licensing fees.

Streams in the .ogg format are compressed much more than .cks streams, so they take up less storage space, but require significantly more CPU to decode. 

Is there support for hardware acceleration of decoding?

This depends on the particular audio encoding, and your platform.


On iOS, at time of writing, there is hardware support for decoding streams in the following formats:
For more information on the hardware decoders provided by iOS, see the iOS Multimedia Programming Guide.

In Cricket Audio, hardware decoding support is only enabled if CkConfig.enableHardwareDecoding is true.  Note that this is set to false by default, because streams that use the hardware decoder take slightly longer (about 300ms) to initialize, we have found the difference in CPU usage between hardware and software decoding as measured by Instruments to be negligible.

Hardware support is limited to a single stream, and may not be available at all depending on the audio session category and whether the hardware decoder is in use by another app.  If the hardware decoder is not available, a software decoder will be used.  If the hardware decoder is available when a stream is created, that stream will keep ownership of the decoder until the stream is destroyed.


On Android, there are no guarantees about hardware support; it is entirely up to the device manufacturer.

Windows Phone 8

There is no support for hardware decoding on Windows Phone 8.

Why can't I load my large bank file on Android?  I get an error message about "UNCOMPRESS_DATA_MAX".

Android versions prior to 2.3 cannot read compressed assets with an uncompressed size greater than 1 MB.   To get around this restriction, you can try to break up your bank file into multiple smaller banks with uncompressed size less than 1 MB, or you can disable compression for your bank. 

To disable compression, if you are building your .apk manually using the aapt tool, you can use the -0 flag (e.g. "-0 ckb" to disable compression for bank files with the .ckb file extension).  However, if you are building your .apk automatically from Eclipse, there is currently no way to specify this flag; a workaround is to give your bank file a file extension for which aapt already disables compression, such as .jpg or .wma.

See this link for a more detailed description of this problem and its workarounds.  Note that Android versions 2.3 and later do not have this restriction.

Why can't I set a pitch shift or apply effects to MP3 streams on Android?

Whenever possible, we try to use the Android platform (using the OpenSL ES API) for decoding of audio, so we can take advantage of any hardware acceleration present on the device.  While the Android platform provides a way to play compressed streams (e.g. MP3, etc), it does not provide a way to decompress them into memory.  This means we cannot decompress the data using the Android platform, and then perform our own processing with them, so we are limited to using the features provided by Android itself for compressed streams.

Cricket Audio can decode Ogg Vorbis audio files using a software decoder on all platforms, if CkConfig.enableOggVorbis is set to true (which is the default), so pitch adjustment and other processing can be done with those files.

Which iOS and Android versions do you support?

On iOS, Cricket Audio is tested for versions 5.0 and later.

On Android, Cricket Audio is tested for versions 2.2 and later. 

How do I determine the URL for an item in the iTunes library for use with CkSound::newAssetStreamSound()?

Here's some sample code that will create a sound to play an item with a particular title in the iTunes library:
#import <MediaPlayer/MediaPlayer.h>

MPMediaQuery *query = [[MPMediaQuery alloc] init];
[query addFilterPredicate:[MPMediaPropertyPredicate predicateWithValue:@"Some Song Title" forProperty:MPMediaItemPropertyTitle]];
CkSound* sound = NULL;
if ([query.items count] > 0)
    MPMediaItem* item = [query.items objectAtIndex:0];
    NSURL* assetUrl = [item valueForProperty:MPMediaItemPropertyAssetURL];
    // assetUrl will be nil if track is protected with DRM
    if (assetUrl)
       sound = CkSound::newAssetStreamSound([assetUrl.absoluteString UTF8String]);

For full details, see the iPod Library Access Programming Guide in the iOS Developer Library.

I'm writing a music app for iOS, and am supporting remote control events.  How do I make the play icon in the status bar disappear when I'm not playing music?

If your app calls the beginReceivingRemoteControlEvents method on its UIApplication instance, the play icon will show up as long as Cricket Audio is active.

After calling CkInit(), call CkSuspend().  This suspends Cricket Audio, causing iOS to hide the play icon in the status bar.  When you start to play music, call CkResume() to show the icon; when the music stops, call CkSuspend() again to hide it.

Why are my banks/streams loading on the iPhone/iPad Simulator, but not on the device?

File paths are case-sensitive on iOS devices, but not on the simulator; make sure your file paths have the correct case.

How can I stream audio that is in a proprietary or unsupported data format?

First, create a subclass of CkCustomStream that decodes your data into 16-bit signed integer PCM audio data; then register a factory function that returns an instance of that class with CkSound::setCustomStreamHandler().