Hi List,
As most google searches for Audio Queue point to this list I thought it was time to subscribe :)
I'm making a simple drum machine (for iPhone) to sequence and playback short sounds, but have come up against problems when using Audio Queue to play back sounds in quick succession; at high tempos the queue seems to not play at all and I get silence where I'm expecting a sample to play back.
Looking at a simple test case of firing one particular short sample (0.25 seconds) every 0.5 seconds, I call the following (from an NSTimer)
for (int i = 0; i < kNumberBuffers; ++i) { AQBufferCallback (this, mQueue, mBuffers[i]); } return AudioQueueStart(mQueue, inAudioQueueStartTime);
Because the sounds are so short: 1) I have kNumberBuffers set to 1. The sounds are so short they fit entirely in to one small buffer. 2) Inside my callback, the buffer is being filled via memcpy() rather than read off disk, again because they're so small. 2) All sounds are uncompressed PCM in .caf format.
This is working fine at lower speeds, however, when trying to play back more rapidly, it seems sometimes the queue doesn't play back.
(I should add that although initially I had some timing problems, and problems with the first 15-20 ms of sounds missing, both of these have been cured by using an AudioTimeStamp set a small amount in to the future, rather than NULL. )
Are there any fundamental problems with trying to re-trigger a queue like this?
I see there is a method called AudioQueueReset(), but I'm not sure if I should be using it or not.
All sample code I've seen assumes playing back longer sounds and controlling their playback, which I have no problem with.
Thanks
Steve
|