Mac Developer Library

Developer

AVFoundation Framework Reference AV Foundation Audio Settings Constants

Options
Deployment Target:

On This Page
Language:

AV Foundation Audio Settings Constants

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


Swift

import AVFoundation

Objective-C

@import AVFoundation;

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: String let AVSampleRateKey: String let AVNumberOfChannelsKey: String

    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 OS X v10.7 and later.

    • AVSampleRateKey

      AVSampleRateKey

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

      Available in OS X v10.7 and later.

    • AVNumberOfChannelsKey

      AVNumberOfChannelsKey

      The number of channels expressed as an NSNumber integer value.

      Available in OS X v10.7 and later.

  • Audio settings that apply to linear PCM audio formats.

    Declaration

    Swift

    let AVLinearPCMBitDepthKey: String let AVLinearPCMIsBigEndianKey: String let AVLinearPCMIsFloatKey: String let AVLinearPCMIsNonInterleaved: String

    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 OS X v10.7 and later.

    • AVLinearPCMIsBigEndianKey

      AVLinearPCMIsBigEndianKey

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

      Available in OS X v10.7 and later.

    • AVLinearPCMIsFloatKey

      AVLinearPCMIsFloatKey

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

      Available in OS X v10.7 and later.

    • AVLinearPCMIsNonInterleaved

      AVLinearPCMIsNonInterleaved

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

      Available in OS X v10.7 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: String let AVEncoderBitRateKey: String let AVEncoderBitRatePerChannelKey: String let AVEncoderBitRateStrategyKey: String let AVEncoderBitDepthHintKey: String

    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 OS X v10.7 and later.

    • AVEncoderBitRateKey

      AVEncoderBitRateKey

      An integer that identifies the audio bit rate.

      Available in OS X v10.7 and later.

    • AVEncoderBitRatePerChannelKey

      AVEncoderBitRatePerChannelKey

      An integer that identifies the audio bit rate per channel.

      Available in OS X v10.7 and later.

    • AVEncoderBitRateStrategyKey

      AVEncoderBitRateStrategyKey

      The value is an AVAudioBitRateStrategy constant.

      Available in OS X v10.9 and later.

    • AVEncoderBitDepthHintKey

      AVEncoderBitDepthHintKey

      An integer ranging from 8 through 32.

      Available in OS X v10.7 and later.

  • Sample rate converter audio quality settings.

    Declaration

    Swift

    let AVSampleRateConverterAudioQualityKey: String let AVEncoderAudioQualityForVBRKey: String let AVSampleRateConverterAlgorithmKey: String

    Objective-C

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

    Constants

    • AVSampleRateConverterAudioQualityKey

      AVSampleRateConverterAudioQualityKey

      An NSNumber integer value. See Audio Quality Flags.

      Available in OS X v10.7 and later.

    • AVEncoderAudioQualityForVBRKey

      AVEncoderAudioQualityForVBRKey

      An NSNumber integer value. See AVAudioQuality for supported values.

      Available in OS X v10.9 and later.

    • AVSampleRateConverterAlgorithmKey

      AVSampleRateConverterAlgorithmKey

      An NSNumber integer value. See AVSampleRateConverterAlgorithmKey Values.

      Available in OS X v10.9 and later.

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

    Declaration

    Swift

    let AVAudioBitRateStrategy_Constant: String let AVAudioBitRateStrategy_LongTermAverage: String let AVAudioBitRateStrategy_VariableConstrained: String let AVAudioBitRateStrategy_Variable: String

    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 OS X v10.9 and later.

    • AVAudioBitRateStrategy_LongTermAverage

      AVAudioBitRateStrategy_LongTermAverage

      A long term average rate strategy.

      Available in OS X v10.9 and later.

    • AVAudioBitRateStrategy_VariableConstrained

      AVAudioBitRateStrategy_VariableConstrained

      A constrained variable rate strategy.

      Available in OS X v10.9 and later.

    • AVAudioBitRateStrategy_Variable

      AVAudioBitRateStrategy_Variable

      A variable rate strategy.

      Available in OS X v10.9 and later.

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

    Declaration

    Swift

    let AVSampleRateConverterAlgorithm_Normal: String let AVSampleRateConverterAlgorithm_Mastering: String

    Objective-C

    NSString *const AVSampleRateConverterAlgorithm_Normal; NSString *const AVSampleRateConverterAlgorithm_Mastering;

    Constants

    • AVSampleRateConverterAlgorithm_Normal

      AVSampleRateConverterAlgorithm_Normal

      Use the normal encoder bit rate strategy.

      Available in OS X v10.9 and later.

    • AVSampleRateConverterAlgorithm_Mastering

      AVSampleRateConverterAlgorithm_Mastering

      Use the mastering encoder bit rate strategy.

      Available in OS X v10.9 and later.

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

    Declaration

    Swift

    let AVAudioTimePitchAlgorithmTimeDomain: String let AVAudioTimePitchAlgorithmSpectral: String let AVAudioTimePitchAlgorithmVarispeed: String

    Objective-C

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

    Constants

    • AVAudioTimePitchAlgorithmTimeDomain

      AVAudioTimePitchAlgorithmTimeDomain

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

      Available in OS X v10.9 and later.

    • AVAudioTimePitchAlgorithmSpectral

      AVAudioTimePitchAlgorithmSpectral

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

      Available in OS X v10.9 and later.

    • AVAudioTimePitchAlgorithmVarispeed

      AVAudioTimePitchAlgorithmVarispeed

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

      Available in OS X v10.9 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: String

    Objective-C

    NSString *const AVChannelLayoutKey;

    Constants

    • AVChannelLayoutKey

      AVChannelLayoutKey

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

      Available in OS X v10.7 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 OS X v10.7 and later.

    • Low

      AVAudioQualityLow

      Low quality rate conversion.

      Available in OS X v10.7 and later.

    • Medium

      AVAudioQualityMedium

      Medium quality sample rate conversion.

      Available in OS X v10.7 and later.

    • High

      AVAudioQualityHigh

      High quality sample rate conversion.

      Available in OS X v10.7 and later.

    • Max

      AVAudioQualityMax

      Maximum quality sample rate conversion.

      Available in OS X v10.7 and later.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.