I am using OpenAL for a music app for iPad. It has worked fine before, but now, after updating my device to iOS 4.3, there are popping/crackling noises on playback. They become apparent when multiple samples are played (i.e开发者_StackOverflow中文版. chords), and happen at the beginning of a new sample, after the 1st or 2nd sample has already been played. Besides these artifacts, the rest of the audio output is normal.
I buffer audio data for each instrument, create a source for each sound to be played, and attach the source to a cached buffer. The buffer is attached to a sample of audio data by using alBufferDataStaticProc()
I have also changed AL_FREQUENCY of the AL context to match the sampling frequency of the files (16 khz), but that only fixes the issue when the sample (source) to be played has an AL_PITCH value of 1. So what's certain is that if you change AL_PITCH, you change the output frequency of the source, which will not match the output frequency of the AL context, causing the problem
Some of the code is borrowed from Finch, which does a lot of data initialization. Here is a URL to the source code: https://github.com/zoul/Finch
I look forward to any pointers.
They become apparent ... after the 1st or 2nd sample has already been played
Could it be that you're adding unintialised data to the buffer? Possibly as a result of queuing an array that was not fully filled.
精彩评论