# Class: Audio

Defined in: [index.ts:50](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/audio/src/index.ts#L50)

## Constructors

### Constructor

> **new Audio**(): `Audio`

Defined in: [index.ts:57](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/audio/src/index.ts#L57)

#### Returns

`Audio`

## Properties

### ctx

> `readonly` **ctx**: `AudioContext`

Defined in: [index.ts:51](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/audio/src/index.ts#L51)

## Accessors

### unlocked

#### Get Signature

> **get** **unlocked**(): `boolean`

Defined in: [index.ts:81](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/audio/src/index.ts#L81)

##### Returns

`boolean`

## Methods

### buffer()

> **buffer**(`id`): `AudioBuffer` \| `undefined`

Defined in: [index.ts:95](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/audio/src/index.ts#L95)

A decoded sound, to play through your own nodes (a positional audio plugin, say).

#### Parameters

##### id

`string`

#### Returns

`AudioBuffer` \| `undefined`

***

### bus()

> **bus**(`name`): `GainNode`

Defined in: [index.ts:77](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/audio/src/index.ts#L77)

A bus's gain node, to plug other audio in (a music generator such as plonk: `new Player({ context: audio.ctx,
destination: audio.bus("music") })`), so it shares the game's volume and mute.

#### Parameters

##### name

[`Bus`](../type-aliases/Bus.md)

#### Returns

`GainNode`

***

### decode()

> **decode**(`id`, `data`): `Promise`\<`void`\>

Defined in: [index.ts:85](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/audio/src/index.ts#L85)

#### Parameters

##### id

`string`

##### data

`ArrayBuffer`

#### Returns

`Promise`\<`void`\>

***

### has()

> **has**(`id`): `boolean`

Defined in: [index.ts:90](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/audio/src/index.ts#L90)

#### Parameters

##### id

`string`

#### Returns

`boolean`

***

### play()

> **play**(`id`, `options?`): [`Voice`](../interfaces/Voice.md)

Defined in: [index.ts:99](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/audio/src/index.ts#L99)

#### Parameters

##### id

`string`

##### options?

[`PlayOptions`](../interfaces/PlayOptions.md) = `{}`

#### Returns

[`Voice`](../interfaces/Voice.md)

***

### stream()

> **stream**(`url`, `options?`): [`Stream`](../interfaces/Stream.md)

Defined in: [index.ts:161](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/audio/src/index.ts#L161)

Stream a long track (music, ambience) through an `<audio>` element into a bus. Unlike `play`, it
isn't decoded into memory up front, so it starts immediately and stays light on mobile.
If audio is still locked by the browser's autoplay policy, playback starts on the first gesture.

#### Parameters

##### url

`string`

##### options?

[`StreamOptions`](../interfaces/StreamOptions.md) = `{}`

#### Returns

[`Stream`](../interfaces/Stream.md)

***

### synth()

> **synth**(`o`): [`Voice`](../interfaces/Voice.md)

Defined in: [index.ts:123](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/audio/src/index.ts#L123)

Synthesize a short blip/zap/hit without any asset: one oscillator with a pitch slide, for a placeholder until
the game has its sound. For sound effects a game keeps, use plonk's `player.sfx(instrument, { degree })`, which
plays in the song's key (see `bus`).

#### Parameters

##### o

[`SynthOptions`](../interfaces/SynthOptions.md)

#### Returns

[`Voice`](../interfaces/Voice.md)

***

### volume()

> **volume**(`bus`, `value`): `void`

Defined in: [index.ts:232](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/audio/src/index.ts#L232)

#### Parameters

##### bus

[`Bus`](../type-aliases/Bus.md) \| `"master"`

##### value

`number`

#### Returns

`void`
