简体   繁体   中英

What are the valid 'settings' key/values for AVAudioRecorder?

I'm working on a Swift application for macOS that uses AVAudioRecorder . The initializer method of this class may consume a 'settings' dictionary . The relevant AV docs all make an URL-less, plain-text reference to where these settings key/values are defined with statements such as:

For information on the settings available for an audio recorder, see AV Foundation Audio Settings Constants.

I've searched quite a lot for this document and failed to locate it. I've actually submitted a feedback report to Apple requesting they update their API docs with links to that document as it's referred to in many places, but only by name.

I've tried googling extensively. I've used Apple's own search function on their developer site and I've searched with the API docs within Xcode itself. That effort has not located a document titled AV Foundation Audio Settings Constants , but I can find many docs that refer to it by that precise name.

Does anyone out there know where this mystical API doc actually exists?

I've not found any actual authoritative doc on this, here's just a running list of the parameters I've encountered thus far:

AVFormatIDKey : kAudioFormatAppleLossless , kAudioFormatMPEG4AAC

AVNumberOfChannelsKey : 2

AVSampleRateKey : 44100.0

AVEncoderBitRateKey: 192000 , 320000

AVEncoderAudioQualityKey : AVAudioQuality.min.rawValue , AVAudioQuality.max.rawValue


Here's a Swift example of creating a settings dictionary with some of these values:

let settings:[String : Any] = [ AVFormatIDKey : kAudioFormatAppleLossless,
    AVEncoderAudioQualityKey : AVAudioQuality.max.rawValue,
    AVEncoderBitRateKey: 320000,
    AVNumberOfChannelsKey : 2,
    AVSampleRateKey : 44100.0 ] as [String : Any]

I hope to keep updating this with more options as I go. Others are welcome to update this too, just please follow the format I have here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM