# SoundObject

## Content

# 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

```ts
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

```ts
ObjectBase.constructor
```

### Constructor

```ts
new SoundObject(): SoundObject;
```

Creates empty instance of a SoundObject object.

#### Returns

`SoundObject`

#### Overrides

```ts
ObjectBase.constructor
```

### Constructor

```ts
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

```ts
ObjectBase.constructor
```

### Constructor

```ts
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

```ts
ObjectBase.constructor
```

### Constructor

```ts
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

```ts
ObjectBase.constructor
```

### Constructor

```ts
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

```ts
ObjectBase.constructor
```

## Accessors

### bitsPerSample

#### Get Signature

```ts
get bitsPerSample(): number;
```

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

##### Returns

`number`

#### Set Signature

```ts
set bitsPerSample(value): void;
```

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

##### Parameters

###### value

`number`

##### Returns

`void`

***

### encodingFormat

#### Get Signature

```ts
get encodingFormat(): string;
```

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

##### Returns

`string`

#### Set Signature

```ts
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

```ts
get id(): number;
```

Gets the reference to the object.

##### Returns

`number`

#### Inherited from

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

***

### om

#### Get Signature

```ts
get om(): ObjectManager;
```

Gets the owner [ObjectManager](ObjectManager) instance.

##### Returns

[`ObjectManager`](ObjectManager)

#### Inherited from

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

***

### samplingRate

#### Get Signature

```ts
get samplingRate(): number;
```

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

##### Returns

`number`

#### Set Signature

```ts
set samplingRate(value): void;
```

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

##### Parameters

###### value

`number`

##### Returns

`void`

***

### soundChannels

#### Get Signature

```ts
get soundChannels(): number;
```

Gets or sets the number of sound channels.

##### Returns

`number`

#### Set Signature

```ts
set soundChannels(value): void;
```

Gets or sets the number of sound channels.

##### Parameters

###### value

`number`

##### Returns

`void`

## Methods

### free()

```ts
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()

```ts
getAudioData(): Uint8Array<ArrayBufferLike>;
```

Gets a Uint8Array object containing the audio data.

#### Returns

`Uint8Array`&lt;`ArrayBufferLike`&gt;

***

### rebind()

```ts
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()

```ts
setAudioData(data): void;
```

Sets the audio data.

#### Parameters

##### data

`Uint8Array`&lt;`ArrayBufferLike`&gt;

#### Returns

`void`
