# Audio parameter

It is possible to pass in an audio asset to an actor as a parameter in the editor. This makes it possible to easily change the sound that an actor plays from the editor.

The code below illustrates how to define an audio parameter.

1. First define the parameter. Read more about parameters in [Actor parameters](/gameplay/actors/actor-parameters.md)
2. Inject the View controller to access the global audio listener.
3. Create the instance of a new sound instance to be able to play the audio clip.
4. Set the sound buffer using the value of the audio parameter in the `onInit` function. At this point the parameters are set. Read more about actors lifecycle functions in [Actor lifecycle](/gameplay/actors/actor-lifecycle.md)
5. Finally, we define a function that can be called on the actor to play the sound which could be called whenever the sound should play.

```typescript
import { Actor, BaseActor, ViewController, inject } from "@hology/core/gameplay";
import { Parameter } from "@hology/core/shader/parameter";
import * as THREE from 'three'

@Actor()
class ExampleActor extends BaseActor {
  @Parameter() audio: AudioBuffer;
  private view = inject(ViewController)
  private sound = new THREE.Audio(this.view.audioListener)

  onInit() {
    this.sound.setBuffer(this.audio)
  }
  
  playSound() {
    this.sound.play()
  }

}

export default ExampleActor

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hology.app/gameplay/sound/audio-parameter.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
