如何在printf(缓冲区)中获取原始数据?在录音iphone

时间:2010-06-08 14:29:58

标签: iphone audio buffer

我需要原始数据,如0/1

static OSStatus recordingCallback(void *inRefCon, 
                                  AudioUnitRenderActionFlags *ioActionFlags, 
                                 // AudioQueueBufferRef inBuffer,
                                  const AudioTimeStamp *inTimeStamp, 
                                  UInt32 inBusNumber, 
                                  UInt32 inNumberFrames, 
                                  AudioBufferList *ioData) {

      ////AudioHelper *remoteIOplayer = (AudioHelper *)inRefCon;

    signalTime = CFAbsoluteTimeGetCurrent();    


    AudioBufferList list;

    // redundant
    list.mNumberBuffers = 1;
    list.mBuffers[0].mData = sampleBuffer;
    list.mBuffers[0].mDataByteSize = 2 * inNumberFrames;
    list.mBuffers[0].mNumberChannels = 1;  

    ioData = &list;        
    printf("No buffers: %d, buffer length: %d bus number: %d\n", ioData->mNumberBuffers, ioData->mBuffers[0].mData, inBusNumber);

1 个答案:

答案 0 :(得分:2)

SInt16* buf = (SInt16 *)ioData->mBuffers[0].mData;
for(int i=0; i< ioData->mBuffers[0].mDataByteSize / 2; i=i+2) {
    printf("\n%d\n%d ", buf[i], buf[i+1]);
}