# SoundComponentElement

Class · extends [`ComponentElement`](https://api.playcanvas.com/web-components/classes/ComponentElement.md)`<SoundComponent>` · category: Components

Source: https://github.com/playcanvas/web-components/blob/252f001881302c266c8d727044408c32be2bb5e7/src/components/sound-component.ts#L21

The SoundComponentElement interface provides properties and methods for manipulating
[`<pc-sound>`](https://developer.playcanvas.com/user-manual/web-components/tags/pc-sound/) elements.
The SoundComponentElement interface also inherits the properties and methods of the
[HTMLElement](https://developer.mozilla.org/docs/Web/API/HTMLElement) interface.

Engine component: [SoundComponent](https://api.playcanvas.com/engine/classes/SoundComponent.html) (`sound`).

**elementSummary** The `<pc-sound>` element holds the `<pc-sound-slot>` children that play sounds at
its entity, along with the positional audio settings they share. Must be a child of a
`<pc-entity>`, `<pc-model>` or `<pc-node>`.

## Accessors

### component

```ts
get component(): SoundComponent | null
```

Gets the underlying PlayCanvas sound component. `null` until the element is
ready — see [ComponentElement.component](https://api.playcanvas.com/web-components/classes/ComponentElement.md#component).

### distanceModel

```ts
get distanceModel(): "linear" | "exponential" | "inverse"
set distanceModel(value: "linear" | "exponential" | "inverse")
```

Gets which algorithm to use to reduce the volume of the sound as it moves away from the listener.

### maxDistance

```ts
get maxDistance(): number
set maxDistance(value: number)
```

Gets the maximum distance from the listener at which audio falloff stops.

### pitch

```ts
get pitch(): number
set pitch(value: number)
```

Gets the pitch of the sound.

### positional

```ts
get positional(): boolean
set positional(value: boolean)
```

Gets whether the sounds play positionally.

### refDistance

```ts
get refDistance(): number
set refDistance(value: number)
```

Gets the reference distance for reducing volume as the sound source moves further from the listener.

### rollOffFactor

```ts
get rollOffFactor(): number
set rollOffFactor(value: number)
```

Gets the factor used in the falloff equation.

### volume

```ts
get volume(): number
set volume(value: number)
```

Gets the volume of the sound.

## Methods

### getInitialComponentData

```ts
protected getInitialComponentData(): { distanceModel: "linear" | "exponential" | "inverse"; maxDistance: number; pitch: number; positional: boolean; refDistance: number; rollOffFactor: number; volume: number }
```

Returns the data the component is created with. Overridden by subclasses to supply the
initial values of their cached properties. The element's `enabled` state is not among them:
the base class adds it when it creates the component.

**Returns** `{ distanceModel: "linear" | "exponential" | "inverse"; maxDistance: number; pitch: number; positional: boolean; refDistance: number; rollOffFactor: number; volume: number }`: The initial component data.

## Inherited from [ComponentElement](https://api.playcanvas.com/web-components/classes/ComponentElement.md)

- `get closestApp(): AppElement | null`
- `get closestEntity(): EntityBaseElement | null`
- `get enabled(): boolean` · `set enabled(value: boolean)`
- `protected _onReady(): void`
- `protected _resetReady(): void`
- `protected initComponent(): void`
- `ready(): Promise<SoundComponentElement>`
