Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AudioBuffer sourceBuffer = audioBufferList->mBuffers[0];
- // we check here if the input data byte size has changed
- if (inAudioBuffer.mDataByteSize != sourceBuffer.mDataByteSize) {
- // clear old buffer
- free(inAudioBuffer.mData);
- // assing new byte size and allocate them on mData
- inAudioBuffer.mDataByteSize = sourceBuffer.mDataByteSize;
- inAudioBuffer.mData = malloc(sourceBuffer.mDataByteSize);
- }
- int currentBuffer =0;
- int maxBuf = 800;
- NSMutableData *data=[[NSMutableData alloc] init];
- // CMBlockBufferRef blockBuffer;
- // CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(ref, NULL, &audioBufferList, sizeof(audioBufferList), NULL, NULL, 0, &blockBuffer);
- // NSLog(@"%@",blockBuffer);
- // audioBufferList->mBuffers[0].mData, audioBufferList->mBuffers[0].mDataByteSize
- for( int y=0; y<audioBufferList->mNumberBuffers; y++ )
- {
- if (currentBuffer < maxBuf){
- AudioBuffer audioBuff = audioBufferList->mBuffers[y];
- Float32 *frame = (Float32*)audioBuff.mData;
- [data appendBytes:frame length:inAudioBuffer.mDataByteSize];
- currentBuffer += audioBuff.mDataByteSize;
- }
- else{
- break;
- }
- }
- // copy incoming audio data to the audio buffer (no need since we are not using playback)
- //memcpy(inAudioBuffer.mData, audioBufferList->mBuffers[0].mData, audioBufferList->mBuffers[0].mDataByteSize);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement