Instance Method

setPreferredSampleRate(_:)

Sets the preferred sample rate for audio input and output.

Declaration

func setPreferredSampleRate(_ sampleRate: Double) throws

Parameters

sampleRate

The hardware sample rate to use. The available range is device dependent and is typically from 8000 through 48000 hertz.

Return Value

true if a request was successfully made, otherwise false.

Discussion

This method requests a change to the input and output audio sample rate. To see the effect of this change, use the sampleRate property.

You can set a preferred sample rate 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.

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.

func setPreferredIOBufferDuration(TimeInterval)

Sets the preferred audio I/O buffer duration.