Why do we use only the first buffer in aurioTouch project

放肆的年华 提交于 2019-12-12 09:49:56

问题


I'm investigating aurioTouch2 sample code.
And I noticed, that when we analize audio data, we use only the first buffer of this data, and never other buffers. in void FFTBufferManager::GrabAudioData(AudioBufferList *inBL) function:

    UInt32 bytesToCopy = min(inBL->mBuffers[0].mDataByteSize, mAudioBufferSize - mAudioBufferCurrentIndex * sizeof(Float32));
    memcpy(mAudioBuffer+mAudioBufferCurrentIndex, inBL->mBuffers[0].mData, bytesToCopy);

in function

static OSStatus PerformThru(
                            void                        *inRefCon, 
                            AudioUnitRenderActionFlags  *ioActionFlags, 
                            const AudioTimeStamp        *inTimeStamp, 
                            UInt32                      inBusNumber, 
                            UInt32                      inNumberFrames, 
                            AudioBufferList             *ioData)
if (THIS->displayMode == aurioTouchDisplayModeOscilloscopeWaveform)
{
        AudioConverterConvertComplexBuffer(THIS->audioConverter, inNumberFrames, ioData, THIS->drawABL);
        SInt8 *data_ptr = (SInt8 *)(THIS->drawABL->mBuffers[0].mData);
}

The question is why do we ignore data in inBL->mBuffers1.mData?


回答1:


Since there's only 1 mic on your iPhone, the samples in the 2 stereo channel buffers (L and R) are identical. Since the second buffer is just redundant (or in some configurations empty), that data there doesn't need to be analyzed (again).




回答2:


May be, I'm wrong, but there is now difference, what buffer to use. You have only 2 buffers: mBuffers[0] and mBuffers1. I tried to use buffer 0 in spectrogram and than buffer 1 (pronouncing equal sounds). Left part of image was done, using buffer 0; right part - using buffer 1 (right peak was made during making of snapshot).

So, you can see , there is no difference.



来源:https://stackoverflow.com/questions/11503139/why-do-we-use-only-the-first-buffer-in-auriotouch-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!