<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFAudio",
  "identifier" : "/documentation/AVFAudio/AVAudioSession/setPreferredSampleRate(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFAudio"
    ],
    "preciseIdentifier" : "c:objc(cs)AVAudioSession(im)setPreferredSampleRate:error:"
  },
  "title" : "setPreferredSampleRate(_:)"
}
-->

# setPreferredSampleRate(_:)

Sets the preferred sample rate for audio input and output.

```
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.

## Discussion

This method requests a change to the input and output audio sample rate. To see the effect of this change, use the [`sampleRate`](/documentation/AVFAudio/AVAudioSession/sampleRate) property.

You can set a preferred sample rate before or after activating the audio session.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)