I'm able to get the audio description from AVCaptureDeviceFormat.
let formats = device.formats
for format in formats {
print(format.formatDescription)
}
But would like to get directly to the mSampleRate and mBitsPerChannel property.
CMAudioFormatDescription 0x60000010b880 [0x7fffadb29d80] {
mediaType:'soun'
mediaSubType:'lpcm'
mediaSpecific: {
ASBD: {
mSampleRate: 44100.000000
mFormatID: 'lpcm'
mFormatFlags: 0x9
mBytesPerPacket: 8
mFramesPerPacket: 1
mBytesPerFrame: 8
mChannelsPerFrame: 2
mBitsPerChannel: 32 }
cookie: {(null)}
ACL: {Stereo (L R)}
FormatList Array: {(null)}
}
extensions: {(null)}
}
How might I go about this? I have been looking into the AudioFormatGetProperty() in the AudioToolBox framework, but am getting lost. All help greatly appreciated.
You can get the
AudioStreamBasicDescription
from the format description, and from that the data you need: