FAQ

How can I minimize CPU and battery usage?

In general, try to reduce the amount of audio data being pushed through the system and the amount of resampling that must be done.

All sounds (apart from compressed streams on Android) are resampled by the Cricket Audio mixer to the output sample rate of 48 kHz.  The mixer has predefined resamplers at some standard sample rates:
Any sounds at these predefined sample rates can be mixed together and then resampled to 48 kHz, rather than being resampled individually.  So if you will be playing many sounds at once, it is more efficient if they are all at one of these sample rates.

Applying pitch shift (or, equivalently, a speed factor) to a sound requires an additional resampling pass for that sound.

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.

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.)

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 the following formats:
Hardware support is limited to a single stream; additional streams will use software decoding, if available.
For more information, see the iOS Multimedia Programming Guide.


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

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 pitch on 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 4.0 and later.

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

On Android, note that some features are unavailable depending on the Android version of the device:

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?

After calling CkInit(), call CkSuspend().  This stops audio processing entirely, 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 call CkSound::newCustomStream(), passing in an instance of your subclass.