0
votes

I am writing a beatbox sequencer for the iphone using CoreAudio.

I have 4 sounds that play on a pattern. I have a AUGraph with IORemote and MultiChannelMixer together. The 4 inputs of the mixer have a callback reading the sound buffers attached to it. It works fine as long as long as sequencer pattern is simple and does not play too many sounds at the same time. If I turn on multiple sounds at the same time, glitches appear and it sound like the CPU is overloaded (I am using an iPhone 1st gen for testing).

I a using CAF sound files (16bits, 44.1Khz) and a canonical audio format:

size_t bytesPerSample = sizeof (AudioUnitSampleType);
stereoStreamFormat.mFormatID          = kAudioFormatLinearPCM;
stereoStreamFormat.mFormatFlags       = kAudioFormatFlagsAudioUnitCanonical;
stereoStreamFormat.mBytesPerPacket    = bytesPerSample;
stereoStreamFormat.mFramesPerPacket   = 1;
stereoStreamFormat.mBytesPerFrame     = bytesPerSample;
stereoStreamFormat.mChannelsPerFrame  = 2;                    
stereoStreamFormat.mBitsPerChannel    = 8 * bytesPerSample;
stereoStreamFormat.mSampleRate        = 44100.0;

Is there something I am missing or that I should know that could improve my program? Or am I hitting the CPU limitation of an iPhone 1st gen ?

Many thanks.

Pascal

1

1 Answers

0
votes

Well, the 1st gen iPhone is a bit slow, but it should definitely be able to handle this. I suspect that the reason you are glitching is because AudioUnitSampleType is 4-bytes, though I'm not sure if this is the same for iPhone as it is on the desktop. Try using 16-bit audio instead and see if that doesn't help.