How to extract integer samples from audio queue buffer and write modified samples back?
for an iphone voice changing app (objective c), i am trying to take the sampled integer values from the recording audio queue buffer, process them in a function and write the modified values back to the play back buffer. At the moment i use something like this
AudioBuffer audioBuffer = bufferList->mBuffers[0];
int bufferSize = audioBuffer.mDataByteSize / sizeof(SInt32);
SInt32 *frame = audioBuffer.mData;
SInt32 signal开发者_如何学PythonInput[22050];
for( int i=0; i<bufferSize; i++ ) {
SInt32 currentSample = frame[i];
*(signalInput +i) = currentSample;
}
to extract the sampled values and seems to work pretty fine (signalinput is supposed to be the target vector for writing the integer samples). but writing them back to a buffer is still a problem... i searched the documentation and lots of forums to find a solution, but didnt succeed yet.
so id be very thankful for any advice, thanks in advance, lukas
If you want to modify audio in real-time you might want to try using RemoteIO Audio Unit instead.
When using audio queues, you have to save the data from the recording queue callback and later feed the processed data to the play queue callback, in a different callback at a different time. For this you probably have to use an intermediate queue or data buffer(s). To get this working, it might help to try to get a recording sound app running, and then a sample playing app running, then combining the two.
Added:
Here are some source code example's of writing sample values into an audio output queue:
http://lists.apple.com/archives/coreaudio-api/2008/Dec/msg00173.html https://bitbucket.org/ddribin/a440/wiki/Home
Just use your own pre-processed samples instead of a sine wave.
精彩评论