Instance Method


Sets the preferred audio I/O buffer duration.


func setPreferredIOBufferDuration(_ duration: TimeInterval) throws



The audio I/O buffer duration, in seconds, that you want to use.

Return Value

true if a request was successfully made, otherwise false.


This method requests a change to the I/O buffer duration. To determine whether the change has taken effect, use the ioBufferDuration property.

The audio I/O buffer duration is the number of seconds for a single audio input/output cycle. For example, with an I/O buffer duration of 0.005 s, on each audio I/O cycle:

  • You receive 0.005 s of audio if obtaining input.

  • You must provide 0.005 s of audio if providing output.

The typical maximum I/O buffer duration is 0.93 s (corresponding to 4,096 sample frames at a sample rate of 44.1 kHz). The minimum I/O buffer duration is at least 0.005 s (256 frames) but might be lower depending on the hardware in use.

You can set a preferred I/O buffer duration before or after activating the audio session.

See Also

Working with Audio Device Settings

var inputGain: Float

The gain applied to inputs associated with the session.

var isInputGainSettable: Bool

A Boolean value that indicates whether you can set the input gain.

func setInputGain(Float)

Changes the input gain to the specified value.

var outputVolume: Float

The systemwide output volume set by the user.

var sampleRate: Double

The current audio sample rate, in hertz.

var preferredSampleRate: Double

The preferred sample rate, in hertz.

func setPreferredSampleRate(Double)

Sets the preferred sample rate for audio input and output.

var inputLatency: TimeInterval

The latency for audio input, in seconds.

var outputLatency: TimeInterval

The latency for audio output, in seconds.

var ioBufferDuration: TimeInterval

The current I/O buffer duration, in seconds.

var preferredIOBufferDuration: TimeInterval

The preferred I/O buffer duration, in seconds.