# SoundObject

## Content

[**DsPdfJS API v9.1.3**](../README)

***

[DsPdfJS API](../globals) / SoundObject

# Class: SoundObject

Represents a sound object, which is a stream containing sample values
that define a sound to be played through the computer's speakers.

## Extends

- [`ObjectBase`](ObjectBase)

## Constructors

### Constructor

> **new SoundObject**(`om`): `SoundObject`

Creates empty instance of a SoundObject object.

#### Parameters

##### om

[`ObjectManager`](ObjectManager)

[ObjectManager](ObjectManager) that controls the lifetime of the SoundObject.

#### Returns

`SoundObject`

#### Overrides

`ObjectBase.constructor`

### Constructor

> **new SoundObject**(): `SoundObject`

Creates empty instance of a SoundObject object.

#### Returns

`SoundObject`

#### Overrides

`ObjectBase.constructor`

### Constructor

> **new SoundObject**(`om`, `properties`): `SoundObject`

Creates a SoundObject object on the base of properties specified by the
[SoundObjectProperties](../type-aliases/SoundObjectProperties).

#### Parameters

##### om

[`ObjectManager`](ObjectManager)

[ObjectManager](ObjectManager) that controls the lifetime of the SoundObject.

##### properties

[`SoundObjectProperties`](../type-aliases/SoundObjectProperties)

The properties of created object.

#### Returns

`SoundObject`

#### Overrides

`ObjectBase.constructor`

### Constructor

> **new SoundObject**(`properties`): `SoundObject`

Creates a SoundObject object on the base of properties specified by the
[SoundObjectProperties](../type-aliases/SoundObjectProperties).

#### Parameters

##### properties

[`SoundObjectProperties`](../type-aliases/SoundObjectProperties)

The properties of created object.

#### Returns

`SoundObject`

#### Overrides

`ObjectBase.constructor`

### Constructor

> **new SoundObject**(`om`, `audioData`, `format?`): `SoundObject`

Creates a SoundObject from audio data of WAF or AIFF format.

#### Parameters

##### om

[`ObjectManager`](ObjectManager)

[ObjectManager](ObjectManager) that controls the lifetime of the SoundObject.

##### audioData

`Uint8Array`

The audio data.

##### format?

[`AudioFormat`](../enumerations/AudioFormat)

The audio data format, not specified means 'Auto'.

#### Returns

`SoundObject`

#### Overrides

`ObjectBase.constructor`

### Constructor

> **new SoundObject**(`audioData`, `format?`): `SoundObject`

Creates a SoundObject from audio data of WAF or AIFF format.

#### Parameters

##### audioData

`Uint8Array`

The audio data.

##### format?

[`AudioFormat`](../enumerations/AudioFormat)

The audio data format, not specified means 'Auto'.

#### Returns

`SoundObject`

#### Overrides

`ObjectBase.constructor`

## Accessors

### bitsPerSample

#### Get Signature

> **get** **bitsPerSample**(): `number`

Gets or sets the number of bits per sample value per channel.

##### Returns

`number`

#### Set Signature

> **set** **bitsPerSample**(`value`): `void`

Gets or sets the number of bits per sample value per channel.

##### Parameters

###### value

`number`

##### Returns

`void`

***

### encodingFormat

#### Get Signature

> **get** **encodingFormat**(): `string`

Gets or sets the encoding format for the sample data, one of:
"Raw", "Signed", "muLaw" or "ALaw".

##### Returns

`string`

#### Set Signature

> **set** **encodingFormat**(`value`): `void`

Gets or sets the encoding format for the sample data, one of:
"Raw", "Signed", "muLaw" or "ALaw".

##### Parameters

###### value

`string`

##### Returns

`void`

***

### id

#### Get Signature

> **get** **id**(): `number`

Gets the reference to the object.

##### Returns

`number`

#### Inherited from

[`ObjectBase`](ObjectBase).[`id`](ObjectBase#id)

***

### om

#### Get Signature

> **get** **om**(): [`ObjectManager`](ObjectManager)

Gets the owner [ObjectManager](ObjectManager) instance.

##### Returns

[`ObjectManager`](ObjectManager)

#### Inherited from

[`ObjectBase`](ObjectBase).[`om`](ObjectBase#om)

***

### samplingRate

#### Get Signature

> **get** **samplingRate**(): `number`

Gets or sets the sampling rate, in samples per second.

##### Returns

`number`

#### Set Signature

> **set** **samplingRate**(`value`): `void`

Gets or sets the sampling rate, in samples per second.

##### Parameters

###### value

`number`

##### Returns

`void`

***

### soundChannels

#### Get Signature

> **get** **soundChannels**(): `number`

Gets or sets the number of sound channels.

##### Returns

`number`

#### Set Signature

> **set** **soundChannels**(`value`): `void`

Gets or sets the number of sound channels.

##### Parameters

###### value

`number`

##### Returns

`void`

## Methods

### free()

> **free**(): `void`

Detaches the object from the [ObjectManager](ObjectManager) and deallocates its memory, if possible.

#### Returns

`void`

#### Inherited from

[`ObjectBase`](ObjectBase).[`free`](ObjectBase#free)

***

### getAudioData()

> **getAudioData**(): `Uint8Array`\<`ArrayBufferLike`\> \| `null`

Gets a Uint8Array object containing the audio data.

#### Returns

`Uint8Array`\<`ArrayBufferLike`\> \| `null`

***

### rebind()

> **rebind**(`omTo`): `void`

Rebinds the object from the current [ObjectManager](ObjectManager) to the specified one.

#### Parameters

##### omTo

[`ObjectManager`](ObjectManager)

The new [ObjectManager](ObjectManager) for the object.

#### Returns

`void`

#### Inherited from

[`ObjectBase`](ObjectBase).[`rebind`](ObjectBase#rebind)

***

### setAudioData()

> **setAudioData**(`data`): `void`

Sets the audio data.

#### Parameters

##### data

`Uint8Array`\<`ArrayBufferLike`\> | `null`

#### Returns

`void`
