Skip to content

CutSound beta ​

Interface of @v12-engine/client

ts
export interface CutSound

A sound as code holds it while it plays (CN50): cut.audio.sound(...), voice, stinger, and the audio lane's clips (RunningClip.handle). Stopped, faded, made louder, faster, to a side, muffled, over so many seconds; paused and played on, seeked; and every Web Audio node of it there to reach, with a way to put nodes of one's own in its chain (insert)

Members ​

at ​

ts
at(spot: Vec2): void;

Where on the map it is heard from now: as loud, and to the side, as a sound of the game's there (nothing beyond what is heard, until it comes near again). A sound on a unit (cut.audio.sound(name, { at: unit }), an audio clip's on) is put where it is every frame (CN52)

buffer ​

ts
readonly buffer: AudioBuffer | undefined;

The file's buffer, once it is there

bus ​

ts
readonly bus: Bus;

The bus the sound plays through, which sets its volume and mute

context ​

ts
readonly context: BaseAudioContext;

The Web Audio context the sound is made in

currentTime ​

ts
readonly currentTime: number;

Seconds into the file it is now

duration ​

ts
readonly duration: number;

Seconds the file lasts (at rate 1); 0 until it is there

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;

Its fade, over its volume (0 to 1): what a clip's in and out move, and a stop's fade

gain ​

ts
readonly gain: GainNode;

Its volume (volume)

highpass ​

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

Cuts frequencies below hz, glided over seconds (at once when left out)

input ​

ts
readonly input: GainNode;

Where the source plays into

insert ​

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

Puts nodes of one's own in its chain, after the filters and before its fades (one node, or a chain of them from input to output: the output is the sound's to connect, and disconnected as it is taken out). What it gives back takes them out again

lowpass ​

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

The filters' cut, in Hz

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 (pan): what goes to the bus

pan ​

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

To which side, -1 to 1, over where it is heard from

pause ​

ts
pause(): void;

Pauses it where it is; resume plays it on

playing ​

ts
readonly playing: boolean;

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

rate ​

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

How fast it plays, and so how high

resume ​

ts
resume(): void;

Plays it on from where it was paused

seek ​

ts
seek(seconds: number): void;

Seconds into the file it plays from now

source ​

ts
readonly source: AudioBufferSourceNode | undefined;

The source playing now: a new one each time it is played on or seeked (through a gain of its own into input, that fades it in and out over a few milliseconds). None while paused or over

started ​

ts
readonly started: Promise<boolean>;

Settles once it began (true), or once it is known it never will (false: no file, too late, stopped first)

stop ​

ts
stop(fade?: number): void;

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

volume ​

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

Its volume, eased there over seconds along ease (straight when left out)