---
title: "init(buffer:inputMode:shouldLoop:)"
framework: realitykit
role: symbol
role_heading: Initializer
path: "realitykit/audiobufferresource/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.

## Declaration

```swift
@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

Discussion note: This function throws an error when the AVAudioBuffer  cannot be cast or converted to AVAudioPCMBuffer.

## See Also

### Deprecated

- [shouldLoop](realitykit/audiobufferresource/shouldloop.md)
