<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/AudioBufferResource",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation19AudioBufferResourceC"
  },
  "title" : "AudioBufferResource"
}
-->

# AudioBufferResource

An audio resource that you load from an <doc://com.apple.documentation/documentation/AVFAudio/AVAudioBuffer>.

```
@MainActor @preconcurrency class AudioBufferResource
```

## Overview

Use the resource to create an [`AudioPlaybackController`](/documentation/RealityKit/AudioPlaybackController) instance by calling an entity’s [`prepareAudio(_:)`](/documentation/RealityKit/Entity/prepareAudio(_:)) or [`playAudio(_:)`](/documentation/RealityKit/Entity/playAudio(_:)) function.
The controller plays the audio from the location in space of the entity that created the controller.

## Topics

### Creating an audio buffer resource

[`init(buffer: AVAudioBuffer, configuration: AudioBufferResource.Configuration) throws`](/documentation/RealityKit/AudioBufferResource/init(buffer:configuration:))

Creates an `AudioBufferResource` with the given `AVAudioBuffer` and configuration.

### Describing the resource

[`let configuration: AudioBufferResource.Configuration`](/documentation/RealityKit/AudioBufferResource/configuration-swift.property)

The configuration for this `AudioBufferResource`.

[`var duration: Duration`](/documentation/RealityKit/AudioBufferResource/duration)

The duration of this `AudioBufferResource`.

### Supporting types

[`struct Configuration`](/documentation/RealityKit/AudioBufferResource/Configuration-swift.struct)

### Deprecated

[`init(buffer: AVAudioBuffer, inputMode: AudioResource.InputMode, shouldLoop: Bool) throws`](/documentation/RealityKit/AudioBufferResource/init(buffer:inputMode:shouldLoop:))

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

[`var shouldLoop: Bool`](/documentation/RealityKit/AudioBufferResource/shouldLoop)

Whether or not this file loops during playback. This should be set for assets
that are prepared as seamless loops. A looping resource will play forever until it is
explicitly told to stop.

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Resource`](/documentation/RealityKit/Resource)

[`Equatable`](/documentation/Swift/Equatable)

[`Hashable`](/documentation/Swift/Hashable)

[`Sendable`](/documentation/Swift/Sendable)

### Inherits From

[`AudioResource`](/documentation/RealityKit/AudioResource)

---

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)