iOS Developer Library

Developer

AVFoundation Framework Reference AV Foundation Audio Settings Constants

Options
Deployment Target:

On This Page
Language:

AV Foundation Audio Settings Constants

Use these audio settings keys to configure an AVAudioRecorder object. You can also use some of these keys to retrieve information about the sound associated with an AVAudioPlayer object, such as audio data format, sample rate, and number of channels.

Constants

  • Audio settings that apply to all audio formats handled by the AVAudioPlayer and AVAudioRecorder classes.

    Declaration

    Swift

    let AVFormatIDKey: NSString! let AVSampleRateKey: NSString! let AVNumberOfChannelsKey: NSString!

    Objective-C

    NSString *const AVFormatIDKey; NSString *const AVSampleRateKey; NSString *const AVNumberOfChannelsKey;

    Constants

    • AVFormatIDKey

      AVFormatIDKey

      A format identifier. See the “Audio Data Format Identifiers” enumeration in Core Audio Data Types Reference.

      Available in iOS 3.0 and later.

    • AVSampleRateKey

      AVSampleRateKey

      A sample rate, in hertz, expressed as an NSNumber floating point value.

      Available in iOS 3.0 and later.

    • AVNumberOfChannelsKey

      AVNumberOfChannelsKey

      The number of channels expressed as an NSNumber integer value.

      Available in iOS 3.0 and later.

  • Audio settings that apply to linear PCM audio formats.

    Declaration

    Swift

    let AVLinearPCMBitDepthKey: NSString! let AVLinearPCMIsBigEndianKey: NSString! let AVLinearPCMIsFloatKey: NSString! let AVLinearPCMIsNonInterleaved: NSString!

    Objective-C

    NSString *const AVLinearPCMBitDepthKey; NSString *const AVLinearPCMIsBigEndianKey; NSString *const AVLinearPCMIsFloatKey; NSString *const AVLinearPCMIsNonInterleaved;

    Constants

    • AVLinearPCMBitDepthKey

      AVLinearPCMBitDepthKey

      An NSNumber integer that indicates the bit depth for a linear PCM audio format—one of 8, 16, 24, or 32.

      Available in iOS 3.0 and later.

    • AVLinearPCMIsBigEndianKey

      AVLinearPCMIsBigEndianKey

      A Boolean value that indicates whether the audio format is big endian (YEStrue) or little endian (NOfalse).

      Available in iOS 3.0 and later.

    • AVLinearPCMIsFloatKey

      AVLinearPCMIsFloatKey

      A Boolean value that indicates that the audio format is floating point (YEStrue) or fixed point (NOfalse).

      Available in iOS 3.0 and later.

    • AVLinearPCMIsNonInterleaved

      AVLinearPCMIsNonInterleaved

      A Boolean value that indicates that the audio format is non-interleaved (YEStrue) or interleaved (NOfalse).

      Available in iOS 4.0 and later.

  • Audio setting defines that apply to linear PCM audio formats.

    Declaration

    Objective-C

    #define AVLinearPCMIsNonInterleavedKey AVLinearPCMIsNonInterleaved

    Constants

  • Audio encoder settings for the AVAudioRecorder class.

    Declaration

    Swift

    let AVEncoderAudioQualityKey: NSString! let AVEncoderBitRateKey: NSString! let AVEncoderBitRatePerChannelKey: NSString! let AVEncoderBitRateStrategyKey: NSString! let AVEncoderBitDepthHintKey: NSString!

    Objective-C

    NSString *const AVEncoderAudioQualityKey; NSString *const AVEncoderBitRateKey; NSString *const AVEncoderBitRatePerChannelKey; NSString *const AVEncoderBitRateStrategyKey; NSString *const AVEncoderBitDepthHintKey;

    Constants

    • AVEncoderAudioQualityKey

      AVEncoderAudioQualityKey

      A constant from Audio Quality Flags.

      Available in iOS 3.0 and later.

    • AVEncoderBitRateKey

      AVEncoderBitRateKey

      An integer that identifies the audio bit rate.

      Available in iOS 3.0 and later.

    • AVEncoderBitRatePerChannelKey

      AVEncoderBitRatePerChannelKey

      An integer that identifies the audio bit rate per channel.

      Available in iOS 4.0 and later.

    • AVEncoderBitRateStrategyKey

      AVEncoderBitRateStrategyKey

      The value is an AVAudioBitRateStrategy constant.

      Available in iOS 7.0 and later.

    • AVEncoderBitDepthHintKey

      AVEncoderBitDepthHintKey

      An integer ranging from 8 through 32.

      Available in iOS 3.0 and later.

  • Sample rate converter audio quality settings.

    Declaration

    Swift

    let AVSampleRateConverterAudioQualityKey: NSString! let AVEncoderAudioQualityForVBRKey: NSString! let AVSampleRateConverterAlgorithmKey: NSString!

    Objective-C

    NSString *const AVSampleRateConverterAudioQualityKey; NSString *const AVEncoderAudioQualityForVBRKey; NSString *const AVSampleRateConverterAlgorithmKey;

    Constants

    • AVSampleRateConverterAudioQualityKey

      AVSampleRateConverterAudioQualityKey

      An NSNumber integer value. See Audio Quality Flags.

      Available in iOS 3.0 and later.

    • AVEncoderAudioQualityForVBRKey

      AVEncoderAudioQualityForVBRKey

      An NSNumber integer value. See AVAudioQuality for supported values.

      Available in iOS 7.0 and later.

    • AVSampleRateConverterAlgorithmKey

      AVSampleRateConverterAlgorithmKey

      An NSNumber integer value. See AVSampleRateConverterAlgorithmKey Values.

      Available in iOS 7.0 and later.

  • These constants are the supported values for the AVEncoderBitRateStrategyKey encoder setting.

    Declaration

    Swift

    let AVAudioBitRateStrategy_Constant: NSString! let AVAudioBitRateStrategy_LongTermAverage: NSString! let AVAudioBitRateStrategy_VariableConstrained: NSString! let AVAudioBitRateStrategy_Variable: NSString!

    Objective-C

    NSString *const AVAudioBitRateStrategy_Constant; NSString *const AVAudioBitRateStrategy_LongTermAverage; NSString *const AVAudioBitRateStrategy_VariableConstrained; NSString *const AVAudioBitRateStrategy_Variable;

    Constants

    • AVAudioBitRateStrategy_Constant

      AVAudioBitRateStrategy_Constant

      A constant rate strategy.

      Available in iOS 7.0 and later.

    • AVAudioBitRateStrategy_LongTermAverage

      AVAudioBitRateStrategy_LongTermAverage

      A long term average rate strategy.

      Available in iOS 7.0 and later.

    • AVAudioBitRateStrategy_VariableConstrained

      AVAudioBitRateStrategy_VariableConstrained

      A constrained variable rate strategy.

      Available in iOS 7.0 and later.

    • AVAudioBitRateStrategy_Variable

      AVAudioBitRateStrategy_Variable

      A variable rate strategy.

      Available in iOS 7.0 and later.

  • These constants are the supported values for the AVEncoderBitRateStrategyKey encoder setting.

    Declaration

    Swift

    let AVSampleRateConverterAlgorithm_Normal: NSString! let AVSampleRateConverterAlgorithm_Mastering: NSString!

    Objective-C

    NSString *const AVSampleRateConverterAlgorithm_Normal; NSString *const AVSampleRateConverterAlgorithm_Mastering;

    Constants

    • AVSampleRateConverterAlgorithm_Normal

      AVSampleRateConverterAlgorithm_Normal

      Use the normal encoder bit rate strategy.

      Available in iOS 7.0 and later.

    • AVSampleRateConverterAlgorithm_Mastering

      AVSampleRateConverterAlgorithm_Mastering

      Use the mastering encoder bit rate strategy.

      Available in iOS 7.0 and later.

  • The constants define the values for the time pitch algorithms.

    Declaration

    Swift

    let AVAudioTimePitchAlgorithmLowQualityZeroLatency: NSString! let AVAudioTimePitchAlgorithmTimeDomain: NSString! let AVAudioTimePitchAlgorithmSpectral: NSString! let AVAudioTimePitchAlgorithmVarispeed: NSString!

    Objective-C

    NSString *const AVAudioTimePitchAlgorithmLowQualityZeroLatency; NSString *const AVAudioTimePitchAlgorithmTimeDomain; NSString *const AVAudioTimePitchAlgorithmSpectral; NSString *const AVAudioTimePitchAlgorithmVarispeed;

    Constants

    • AVAudioTimePitchAlgorithmLowQualityZeroLatency

      AVAudioTimePitchAlgorithmLowQualityZeroLatency

      Low quality and very low computationally intensive pitch algorithm. Suitable for brief fast-forward and rewind effects as well as low quality voice. The rate is snapped to {0.5, 0.666667, 0.8, 1.0, 1.25, 1.5, 2.0}.

      Available in iOS 7.0 and later.

    • AVAudioTimePitchAlgorithmTimeDomain

      AVAudioTimePitchAlgorithmTimeDomain

      Modest quality pitch algorithm that is less computationally intensive. Suitable for voice. Variable rate from 1/32 to 32.

      Available in iOS 7.0 and later.

    • AVAudioTimePitchAlgorithmSpectral

      AVAudioTimePitchAlgorithmSpectral

      Highest quality, most computationally expensive. Suitable for music. Variable rate from 1/32 to 32.

      Available in iOS 7.0 and later.

    • AVAudioTimePitchAlgorithmVarispeed

      AVAudioTimePitchAlgorithmVarispeed

      High quality, no pitch correction. Pitch varies with rate. Variable rate from 1/32 to 32.

      Available in iOS 7.0 and later.

    Discussion

    On OS X, the default algorithm for all time pitch operations is AVAudioTimePitchAlgorithmSpectral.

    On iOS, the default algorithm for playback is AVAudioTimePitchAlgorithmLowQualityZeroLatency and the default for export & other offline processing is AVAudioTimePitchAlgorithmSpectral.

    For scaled audio edits, i.e. when the timeMapping of an AVAssetTrackSegment is between timeRanges of unequal duration, it is important to choose an algorithm that supports the full range of edit rates present in the source media. AVAudioTimePitchAlgorithmSpectral is often the best choice due to the highly inclusive range of rates it supports, assuming that it is desirable to maintain a constant pitch regardless of the edit rate. If it is instead desirable to allow the pitch to vary with the edit rate, AVAudioTimePitchAlgorithmVarispeed is the best choice.

  • Key to retrieve channel layout information for playback.

    Declaration

    Swift

    let AVChannelLayoutKey: NSString!

    Objective-C

    NSString *const AVChannelLayoutKey;

    Constants

    • AVChannelLayoutKey

      AVChannelLayoutKey

      The corresponding value is an NSData object containing an AudioChannelLayout structure.

      Available in iOS 4.0 and later.

  • Keys that specify sample rate conversion quality, used for the AVSampleRateConverterAudioQualityKey property.

    Declaration

    Swift

    enum AVAudioQuality : Int { case Min case Low case Medium case High case Max }

    Objective-C

    enum { AVAudioQualityMin = 0, AVAudioQualityLow = 0x20, AVAudioQualityMedium = 0x40, AVAudioQualityHigh = 0x60, AVAudioQualityMax = 0x7F }; typedef NSInteger AVAudioQuality;

    Constants

    • Min

      AVAudioQualityMin

      The minimum quality for sample rate conversion.

      Available in iOS 3.0 and later.

    • Low

      AVAudioQualityLow

      Low quality rate conversion.

      Available in iOS 3.0 and later.

    • Medium

      AVAudioQualityMedium

      Medium quality sample rate conversion.

      Available in iOS 3.0 and later.

    • High

      AVAudioQualityHigh

      High quality sample rate conversion.

      Available in iOS 3.0 and later.

    • Max

      AVAudioQualityMax

      Maximum quality sample rate conversion.

      Available in iOS 3.0 and later.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 3.0 and later.