<!--
{
  "availability" : [
    "iOS: 15.0.0 - 18.0.0",
    "iPadOS: 15.0.0 - 18.0.0",
    "macCatalyst: 15.0.0 - 18.0.0",
    "macOS: 12.0.0 - 15.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/AudioBufferResource/init(buffer:inputMode:shouldLoop:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation19AudioBufferResourceC6buffer9inputMode10shouldLoopACSo07AVAudioD0C_AA0cE0C05InputH0OSbtKcfc"
  },
  "title" : "init(buffer:inputMode:shouldLoop:)"
}
-->

# init(buffer:inputMode:shouldLoop:)

Init an AudioBufferResource from an `AVAudioBuffer` instead of a file location. This is intended for use with `AVSpeechSynthesisVoice`.

```
@MainActor @preconcurrency init(buffer: AVAudioBuffer, inputMode: AudioResource.InputMode = .spatial, shouldLoop: Bool = false) throws
```

## Parameters

`inputMode`

How the audio engine processes a resource. nonSpatial, spatial, ambient

`shouldLoop`

Bool value to decide if the audio clip should loop

## Discussion> Throws: This function throws an error when the `AVAudioBuffer`  cannot be cast or converted to `AVAudioPCMBuffer`.

---

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)