我需要帮助了解以下ASBD。这是分配给RemoteIO
的新实例的默认ASBD(我通过在AudioUnitGetProperty(..., kAudioUnitProperty_StreamFormat, ...)
音频单元上执行RemoteIO
,在分配和初始化之后立即获得它。)
Float64 mSampleRate 44100
UInt32 mFormatID 1819304813
UInt32 mFormatFlags 41
UInt32 mBytesPerPacket 4
UInt32 mFramesPerPacket 1
UInt32 mBytesPerFrame 4
UInt32 mChannelsPerFrame 2
UInt32 mBitsPerChannel 32
UInt32 mReserved 0
问题是,mBytesPerFrame
不应该是8
吗?如果每个通道有32位(4字节),每帧2个通道,那么每个帧的长度不应该是8个字节(而不是4个)吗?
提前致谢。
答案 0 :(得分:5)
mBytesPerFrame
的值取决于mFormatFlags
。来自CoreAudioTypes.h:
Typically, when an ASBD is being used, the fields describe the complete layout
of the sample data in the buffers that are represented by this description -
where typically those buffers are represented by an AudioBuffer that is
contained in an AudioBufferList.
However, when an ASBD has the kAudioFormatFlagIsNonInterleaved flag, the
AudioBufferList has a different structure and semantic. In this case, the ASBD
fields will describe the format of ONE of the AudioBuffers that are contained in
the list, AND each AudioBuffer in the list is determined to have a single (mono)
channel of audio data. Then, the ASBD's mChannelsPerFrame will indicate the
total number of AudioBuffers that are contained within the AudioBufferList -
where each buffer contains one channel. This is used primarily with the
AudioUnit (and AudioConverter) representation of this list - and won't be found
in the AudioHardware usage of this structure.
答案 1 :(得分:0)
我认为因为格式标志指定kAudioFormatFlagIsNonInterleaved
,所以任何缓冲区中帧的大小只能是1通道帧的大小。如果这是正确的mChannelsPerFrame
肯定是一个令人困惑的名字。
我希望其他人确认/澄清这一点。