---
title: "registerAudioResource(_:options:)"
framework: corehaptics
role: symbol
role_heading: Instance Method
path: "corehaptics/chhapticengine/registeraudioresource(_:options:)"
---

# registerAudioResource(_:options:)

Registers an external audio to use as a custom waveform.

## Declaration

```swift
func registerAudioResource(_ resourceURL: URL, options: [AnyHashable : Any] = [:]) throws -> CHHapticAudioResourceID
```

## Parameters

- `resourceURL`: A URL that identifies the location of the audio file to register.
- `options`: A dictionary with audio resource keys and values that describe how to play this resource.

## Mentioned in

Preparing your app to play haptics

## Return Value

Return Value An identifier for the audio resource.

## Discussion

Discussion Before you initialize a Core Haptics event with your own audio file, use this method to register the file with the engine. Reference external audio files using a URL. Input the value that this method returns when creating the dictionary or event representation of a haptic pattern. note: In an Apple Haptics and Audio File (AHAP), you specify audio files by their path, as opposed to their registered resource URL. For more information, see Representing haptic patterns in AHAP files.

## Topics

### Audio Resource Keys

- [CHHapticAudioResourceKeyLoopEnabled](corehaptics/chhapticaudioresourcekeyloopenabled.md)
- [CHHapticAudioResourceKeyUseVolumeEnvelope](corehaptics/chhapticaudioresourcekeyusevolumeenvelope.md)
- [CHHapticAudioResourceKey](corehaptics/chhapticaudioresourcekey.md)

## See Also

### Registering Audio Resources

- [unregisterAudioResource(_:)](corehaptics/chhapticengine/unregisteraudioresource(_:).md)
- [CHHapticAudioResourceID](corehaptics/chhapticaudioresourceid.md)
