Instance Method

setPreferredSampleRate:error:

Sets the preferred sample rate for audio input and output.

Declaration

- (BOOL)setPreferredSampleRate:(double)sampleRate error:(NSError * _Nullable *)outError;

Parameters

sampleRate

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

outError

On input, a pointer to an error object. If an error occurs, the system sets the pointer to an NSError object that describes the error. If you don’t want error information, pass in nil.

Return Value

YES if a request was successfully made, otherwise NO.

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

inputGain

The gain applied to inputs associated with the session.

inputGainSettable

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

- setInputGain:error:

Changes the input gain to the specified value.

outputVolume

The systemwide output volume set by the user.

sampleRate

The current audio sample rate, in hertz.

preferredSampleRate

The preferred sample rate, in hertz.

inputLatency

The latency for audio input, in seconds.

outputLatency

The latency for audio output, in seconds.

IOBufferDuration

The current I/O buffer duration, in seconds.

preferredIOBufferDuration

The preferred I/O buffer duration, in seconds.

- setPreferredIOBufferDuration:error:

Sets the preferred audio I/O buffer duration.

currentHardwareSampleRate

The audio hardware sample rate, in hertz.

Deprecated
preferredHardwareSampleRate

The preferred hardware sample rate, in hertz.

Deprecated
- setPreferredHardwareSampleRate:error:

Sets the preferred hardware sample rate for input and output.

Deprecated