AV Foundation Audio Settings Constants

Framework
AVFoundation/AVAudioSettings.h
Declared in
AVAudioProcessingSettings.h
AVAudioSettings.h

Overview

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

General Audio Format Settings

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

NSString *const AVFormatIDKey;
NSString *const AVSampleRateKey;
NSString *const AVNumberOfChannelsKey;
Constants
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.

Declared in AVAudioSettings.h.

AVSampleRateKey

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

Available in OS X v10.7 and later.

Declared in AVAudioSettings.h.

AVNumberOfChannelsKey

The number of channels expressed as an NSNumber integer value.

Available in OS X v10.7 and later.

Declared in AVAudioSettings.h.

Linear PCM Format Settings

Audio settings that apply to linear PCM audio formats.

NSString *const AVLinearPCMBitDepthKey;
NSString *const AVLinearPCMIsBigEndianKey;
NSString *const AVLinearPCMIsFloatKey;
NSString *const AVLinearPCMIsNonInterleaved;
Constants
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.

Declared in AVAudioSettings.h.

AVLinearPCMIsBigEndianKey

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

Available in OS X v10.7 and later.

Declared in AVAudioSettings.h.

AVLinearPCMIsFloatKey

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

Available in OS X v10.7 and later.

Declared in AVAudioSettings.h.

AVLinearPCMIsNonInterleaved

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

Available in OS X v10.7 and later.

Declared in AVAudioSettings.h.

Linear PCM Format Defines

Audio setting defines that apply to linear PCM audio formats.

#define AVLinearPCMIsNonInterleavedKey AVLinearPCMIsNonInterleaved
Constants
AVLinearPCMIsNonInterleavedKey

See AVLinearPCMIsNonInterleaved.

Available in OS X v10.7 and later.

Declared in AVAudioSettings.h.

Encoder Settings

Audio encoder settings for the AVAudioRecorder class.

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

A constant from “Audio Quality Flags.”

Available in OS X v10.7 and later.

Declared in AVAudioSettings.h.

AVEncoderBitRateKey

An integer that identifies the audio bit rate.

Available in OS X v10.7 and later.

Declared in AVAudioSettings.h.

AVEncoderBitRatePerChannelKey

An integer that identifies the audio bit rate per channel.

Available in OS X v10.7 and later.

Declared in AVAudioSettings.h.

AVEncoderBitRateStrategyKey

The value is an AVAudioBitRateStrategy constant.

Available in OS X v10.9 and later.

Declared in AVAudioSettings.h.

AVEncoderBitDepthHintKey

An integer ranging from 8 through 32.

Available in OS X v10.7 and later.

Declared in AVAudioSettings.h.

Sample Rate Conversion Settings

Sample rate converter audio quality settings.

NSString *const AVSampleRateConverterAudioQualityKey;
NSString *const AVEncoderAudioQualityForVBRKey;
Constants
AVSampleRateConverterAudioQualityKey

An NSNumber integer value. See “Audio Quality Flags.”

Available in OS X v10.7 and later.

Declared in AVAudioSettings.h.

AVEncoderAudioQualityForVBRKey

An NSNumber integer value. See “AVSampleRateConverterAlgorithmKey Values.”

Available in OS X v10.9 and later.

Declared in AVAudioSettings.h.

AVEncoderBitRateStrategyKey Values

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

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

Available in OS X v10.9 and later.

Declared in AVAudioSettings.h.

AVAudioBitRateStrategy_LongTermAverage

Available in OS X v10.9 and later.

Declared in AVAudioSettings.h.

AVAudioBitRateStrategy_VariableConstrained

Available in OS X v10.9 and later.

Declared in AVAudioSettings.h.

AVAudioBitRateStrategy_Variable

Available in OS X v10.9 and later.

Declared in AVAudioSettings.h.

AVSampleRateConverterAlgorithmKey Values

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

NSString *const AVSampleRateConverterAlgorithm_Normal;
NSString *const AVSampleRateConverterAlgorithm_Mastering;
Constants
AVSampleRateConverterAlgorithm_Normal

Available in OS X v10.9 and later.

Declared in AVAudioSettings.h.

AVSampleRateConverterAlgorithm_Mastering

Available in OS X v10.9 and later.

Declared in AVAudioSettings.h.

Time Pitch Algorithm Settings

The constants define the values for the time pitch algorithms.

NSString *const AVAudioTimePitchAlgorithmTimeDomain;
NSString *const AVAudioTimePitchAlgorithmSpectral;
NSString *const AVAudioTimePitchAlgorithmVarispeed;
Constants
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.

Declared in AVAudioProcessingSettings.h.

AVAudioTimePitchAlgorithmSpectral

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

Available in OS X v10.9 and later.

Declared in AVAudioProcessingSettings.h.

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.

Declared in AVAudioProcessingSettings.h.

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.

Channel Layout Keys

Key to retrieve channel layout information for playback.

NSString *const AVChannelLayoutKey;
Constants
AVChannelLayoutKey

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

Available in OS X v10.7 and later.

Declared in AVAudioSettings.h.

Sample Rate Conversion Audio Quality Flags

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

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

The minimum quality for sample rate conversion.

Available in OS X v10.7 and later.

Declared in AVAudioSettings.h.

AVAudioQualityLow

Low quality rate conversion.

Available in OS X v10.7 and later.

Declared in AVAudioSettings.h.

AVAudioQualityMedium

Medium quality sample rate conversion.

Available in OS X v10.7 and later.

Declared in AVAudioSettings.h.

AVAudioQualityHigh

High quality sample rate conversion.

Available in OS X v10.7 and later.

Declared in AVAudioSettings.h.

AVAudioQualityMax

Maximum quality sample rate conversion.

Available in OS X v10.7 and later.

Declared in AVAudioSettings.h.