我正在尝试了解AudioStreamBasicDescription的结果。几乎没有我能得到的对我来说有意义。例如:
AudioStreamBasicDescription(mSampleRate:44100.0,mFormatID:1819304813,mFormatFlags:41,mBytesPerPacket:4,mFramesPerPacket:1,mBytesPerFrame:4,mChannelsPerFrame:2,mBitsPerChannel:32,mReserved:0)] >>
我期望的是:“每个数据包的字节数”和“每帧的字节数”应为8而非4:
4
(32位浮点的大小)x 2(每帧两个通道)x 1(每包1帧)= 8字节为什么是4?
import CoreAudio
import AudioUnit
var inputUnitDescription = AudioComponentDescription(componentType: kAudioUnitType_Output,
componentSubType: kAudioUnitSubType_HALOutput,
componentManufacturer: kAudioUnitManufacturer_Apple,
componentFlags: 0,
componentFlagsMask: 0)
let defaultInput = AudioComponentFindNext(nil, &inputUnitDescription)
var inputUnit: AudioUnit?
AudioComponentInstanceNew(defaultInput!, &inputUnit)
var asbd = AudioStreamBasicDescription()
var propertySize = UInt32(MemoryLayout<AudioStreamBasicDescription>.size)
AudioUnitGetProperty(inputUnit!,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output,
1,
&asbd,
&propertySize)
dump(asbd)
我正在尝试了解AudioStreamBasicDescription的结果。几乎没有我能得到的对我来说有意义。例如:AudioStreamBasicDescription(mSampleRate:44100.0,mFormatID:...
您的ABSD具有mFormatFlags == 41。