One Logo Pool Ball
RealityFoundation · IOS API REFERENCE

AudioBufferResource

class · iOS 15.0+ · SDK 27.1

@MainActor @preconcurrency class AudioBufferResource

An audio resource that you load from an <doc://com.apple.documentation/documentation/avfaudio/avaudiobuffer>. Use the resource to create an ``AudioPlaybackController`` instance by calling an entity’s ``Entity/prepareAudio(_:)`` or ``Entity/playAudio(_:)`` function. The controller plays the audio from the location in space of the entity that created the controller.

Members (5)

get · iOS 15.0+ · Deprecated in iOS 18.0

shouldLoop

TypeScript
get shouldLoop(): Promise<boolean>
Swift declaration
@MainActor @preconcurrency var shouldLoop: Bool { get }

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.

get · iOS 18.0+

configuration

TypeScript
get configuration(): Promise<AudioBufferResource_Configuration>
Swift declaration
@MainActor @preconcurrency final let configuration: AudioBufferResource.Configuration

The configuration for this `AudioBufferResource`.

init · iOS 18.0+

init

TypeScript
static initBufferConfiguration(buffer: _AVFAudio_AVAudioBuffer, configuration?: AudioBufferResource_Configuration): Promise<AudioBufferResource>
Swift declaration
@MainActor @preconcurrency init(buffer: AVAudioBuffer, configuration: AudioBufferResource.Configuration = .init()) throws

Creates an `AudioBufferResource` with the given `AVAudioBuffer` and configuration. - Throws: An error if the given `buffer` is not or cannot be converted to a non-interleaved PCM buffer.

init · iOS 15.0+ · Deprecated in iOS 18.0

init

TypeScript
static initBufferInputModeShouldLoop(buffer: _AVFAudio_AVAudioBuffer, inputMode?: AudioResource_InputMode, shouldLoop?: boolean): Promise<AudioBufferResource>
Swift declaration
@MainActor @preconcurrency init(buffer: AVAudioBuffer, inputMode: AudioResource.InputMode = .spatial, shouldLoop: Bool = false) throws

Init an AudioBufferResource from an `AVAudioBuffer` instead of a file location. This is intended for use with `AVSpeechSynthesisVoice`. - Parameter from: The `AVAudioBuffer` containing PCM audio data to be loaded as an `AudioResource`. - Parameter inputMode: How the audio engine processes a resource. nonSpatial, spatial, ambient - Parameter shouldLoop: Bool value to decide if the audio clip should loop - Throws: This function throws an error when the `AVAudioBuffer` cannot be cast or converted to `AVAudioPCMBuffer`.

get · iOS 18.0+

duration

TypeScript
get duration(): Promise<SDKHandle>
Swift declaration
@MainActor @preconcurrency var duration: Duration { get }

The duration of this `AudioBufferResource`.

Skipped declarations

No declarations were skipped in this snapshot.

All RealityFoundation types →