# Sound

Class · category: Sound

Source: https://github.com/playcanvas/engine/blob/970d89f6d3bc6667f4e1f88153abd6e7e82ed52c/src/platform/sound/sound.js#L12

Represents the raw audio data of a playable sound. A Sound is the resource of an audio
[Asset](https://api.playcanvas.com/engine/classes/Asset.md). An audio asset can be assigned to a [SoundSlot](https://api.playcanvas.com/engine/classes/SoundSlot.md) owned by a
[SoundComponent](https://api.playcanvas.com/engine/classes/SoundComponent.md).

The [buffer](https://api.playcanvas.com/engine/classes/Sound.md#buffer) is the decoded Web Audio `AudioBuffer`, so [duration](https://api.playcanvas.com/engine/classes/Sound.md#duration) is known as soon
as the asset has loaded. Playing a sound creates one [SoundInstance](https://api.playcanvas.com/engine/classes/SoundInstance.md) per playback, normally
through a slot rather than by constructing the instance directly.

## Constructors

### constructor

```ts
new Sound(buffer: AudioBuffer)
```

Create a new Sound instance.

**Parameters**

- `buffer` (`AudioBuffer`): The decoded audio data.

## Properties

### buffer

```ts
buffer: AudioBuffer
```

Contains the decoded audio data.

## Accessors

### duration

```ts
get duration(): number
```

Gets the duration of the sound. If the sound is not loaded it returns 0.
