Skip to content

PlayedSound beta ​

Class of @v12-engine/client

ts
export declare class PlayedSound implements CutSound

A sound played with a handle: see the top of this file. Made by the player (SoundPlayer.sound), which hands it its file

Members ​

constructor ​

ts
constructor(
    context: BaseAudioContext, 
    name: string, 
    bus: Bus, destination: AudioNode, shape: SoundShape & {
        pan?: number;
    }, told: Told, 
    heard?: Heard, 
    mode?: HearingMode);

Constructs a new instance of the PlayedSound class

at ​

ts
at(spot: Vec2): void;

Puts it where spot is on the map: as loud and to the side as a sound of the game's there, silent beyond what is heard

buffer ​

ts
buffer: AudioBuffer | undefined;

The file's buffer, once it is loaded; undefined before

bus ​

ts
readonly bus: Bus;

The bus the sound plays through

context ​

ts
readonly context: BaseAudioContext;

The Web Audio context the sound is made in

currentTime ​

ts
get currentTime(): number;

Seconds into the file it is now, wrapped to the file's length for a loop

duration ​

ts
get duration(): number;

Seconds the file lasts at rate 1; 0 until it is loaded

ended ​

ts
readonly ended: Promise<void>;

Settles once it is over: played to its end, stopped, or never begun

fade ​

ts
fade(level: number, seconds?: number, ease?: (k: number) => number): void;

Sets its fade, over its volume, to level (not below 0), eased over seconds along ease; ignored once it is stopping

gain ​

ts
readonly gain: GainNode;

Its volume's node, set by volume

highpass ​

ts
highpass(hz: number, seconds?: number): void;

Cuts frequencies below hz, glided over seconds

input ​

ts
readonly input: GainNode;

Where the sound enters its chain: the source plays into it

insert ​

ts
insert(input: AudioNode, output?: AudioNode): () => void;

Puts the nodes input to output (the same node when left out) in its chain, and gives back a function that takes them out

lowpass ​

ts
lowpass(hz: number, seconds?: number): void;

Cuts frequencies above hz, glided over seconds

name ​

ts
readonly name: string;

The sound's name, as it was asked for

nodes ​

ts
readonly nodes: SoundNodes;

The nodes of its chain, by what each does

output ​

ts
readonly output: StereoPannerNode;

Its side's node, set by pan: what goes on to the bus

pan ​

ts
pan(pan: number, seconds?: number): void;

Sets its side to pan (clamped to -1..1), glided over seconds

pause ​

ts
pause(): void;

Pauses it where it is, or while its file loads; no effect once it is stopping or over

playing ​

ts
get playing(): boolean;

Whether it is playing now: begun, and not paused, stopped or over

rate ​

ts
rate(rate: number, seconds?: number): void;

Sets how fast it plays to rate (above 0), the position kept, glided over seconds

resume ​

ts
resume(): void;

Plays it on from where it was paused

seek ​

ts
seek(seconds: number): void;

Moves its playing position to seconds into the file (not below 0), playing on if it was playing

source ​

ts
source: AudioBufferSourceNode | undefined;

The source playing now: a new one each time it is played on or seeked, none while paused or over

started ​

ts
readonly started: Promise<boolean>;

Settles with true once it begun, or false once it is known it never will

stop ​

ts
stop(fade?: number): void;

Stops it, faded out over fade seconds (at once when 0)

volume ​

ts
volume(level: number, seconds?: number, ease?: (k: number) => number): void;

Sets its volume to level (not below 0), eased over seconds along ease