LogoPixi’VN
indexInterfaces

Interface: AudioChannelInterface

Defined in: src/sound/interfaces/AudioChannelInterface.ts:5

Properties

alias

> readonly alias: string

Defined in: src/sound/interfaces/AudioChannelInterface.ts:9

The alias of the audio channel. This is used to reference the channel when playing sounds. The alias must be unique among all channels.


background

> readonly background: boolean

Defined in: src/sound/interfaces/AudioChannelInterface.ts:54

Whether this channel is a background channel. Background channels are special channels. Unlike normal channels, media connected to a background channel does not stop when a scene changes, but continues to play in the background.


mediaInstances

> readonly mediaInstances: MediaInterface[]

Defined in: src/sound/interfaces/AudioChannelInterface.ts:49

The MediaInstances currently playing through this channel. This is read-only and cannot be modified directly. Use the play method to add new MediaInstances to this channel.


muted

> muted: boolean

Defined in: src/sound/interfaces/AudioChannelInterface.ts:45

Whether the audio channel is muted. This is combined with the muted state of each sound played through this channel.


pan

> pan: number

Defined in: src/sound/interfaces/AudioChannelInterface.ts:37

The stereo pan position for this channel in the range [-1, 1]. -1 is full left, 0 is centre, 1 is full right.


panParam

> readonly panParam: Param<"audioRange">

Defined in: src/sound/interfaces/AudioChannelInterface.ts:141

Advanced — the raw Tone.Param<"audioRange"> for this channel's stereo pan position.

Unlike the pan property (which sets the value instantly), this Param exposes all Tone.js automation methods such as rampTo, linearRampTo, and exponentialRampTo.

Use this when you need to smoothly automate panning over time instead of setting it instantly. Values range from -1 (full left) to 1 (full right).

Example

const channel = sound.findChannel("music");

// Gradually pan to the left over 3 seconds.
channel.panParam.rampTo(-1, 3);

// Return to centre over 2 seconds.
channel.panParam.rampTo(0, 2);

volume

> volume: number

Defined in: src/sound/interfaces/AudioChannelInterface.ts:41

The volume of the audio channel, between 0 and 1. This is multiplied with the volume of each sound played through this channel.


volumeParam

> readonly volumeParam: Param<"decibels">

Defined in: src/sound/interfaces/AudioChannelInterface.ts:118

Advanced — the raw Tone.Param<"decibels"> for this channel's volume.

Unlike the volume property (which uses a linear 0–1 scale), this Param works directly in decibels and exposes all Tone.js automation methods such as rampTo, linearRampTo, and exponentialRampTo.

Use this when you need to smoothly automate volume over time instead of setting it instantly.

Example

const channel = sound.findChannel("music");

// Fade the volume from its current level to -12 dB over 3 seconds.
channel.volumeParam.rampTo(-12, 3);

// Fade to silence over 2 seconds.
channel.volumeParam.rampTo(-Infinity, 2);

Methods

chain()

> chain(...nodes): this

Defined in: src/sound/interfaces/AudioChannelInterface.ts:96

Useful for inserting channel-wide audio effects such as reverb, delay or EQ.

Install "tone" to use this method.

Parameters

nodes

...ToneAudioNode<ToneWithContextOptions>[]

One or more Tone.js ToneAudioNode instances to chain in series.

Returns

this

Instance for chaining.

Example

import * as Tone from "tone";

const channel = sound.findChannel("music");

// Create a reverb effect and wait for its impulse response to be ready.
const reverb = new Tone.Reverb({ decay: 2.5 });

// Route the channel through the reverb to the master output.
channel.chain(reverb);

pauseAll()

> pauseAll(): this

Defined in: src/sound/interfaces/AudioChannelInterface.ts:64

Pauses any playing sounds.

Returns

this

Instance for chaining.


play()

Call Signature

> play(alias, options?): Promise<MediaInterface>

Defined in: src/sound/interfaces/AudioChannelInterface.ts:18

Plays a sound.

Parameters
alias

string

The media and sound (asset) alias reference.

options?

SoundPlayOptions

The options

Returns

Promise<MediaInterface>

The sound instance, this cannot be reused after it is done playing. Returns a Promise if the sound has not yet loaded.

Call Signature

> play(mediaAlias, soundAlias, options?): Promise<MediaInterface>

Defined in: src/sound/interfaces/AudioChannelInterface.ts:28

Plays a sound.

Parameters
mediaAlias

string

The media alias reference.

soundAlias

string

The sound (asset) alias reference.

options?

SoundPlayOptions

The options

Returns

Promise<MediaInterface>

The sound instance, this cannot be reused after it is done playing. Returns a Promise if the sound has not yet loaded.


resumeAll()

> resumeAll(): this

Defined in: src/sound/interfaces/AudioChannelInterface.ts:69

Resumes any sounds.

Returns

this

Instance for chaining.


stopAll()

> stopAll(): this

Defined in: src/sound/interfaces/AudioChannelInterface.ts:59

Stops all media currently playing through this channel.

Returns

this

Instance for chaining.


toggleMuteAll()

> toggleMuteAll(): boolean

Defined in: src/sound/interfaces/AudioChannelInterface.ts:74

Toggle muted property for all sounds.

Returns

boolean

true if all sounds are muted.