gdmp.audio
Это содержимое пока не доступно на вашем языке.
Since API level 90.
Sounds on the players’ PCs, played by GDMP’s own mixer (not GD’s audio engine), at the player’s GD SFX volume (the slider as it was when the session started). A client plays on its own PC; the server sends a request to one player or everyone, and each client plays it. Nothing is downloaded: a sound is a file of the package, or one GD already has.
| sound | where it comes from |
|---|---|
"sounds/tag.ogg" |
a file of the package (.ogg, .wav or .mp3, ≤ 16 MB, mono or stereo) |
{ sfx: 4395 } |
GD’s SFX library, by id: the 260 sounds GD ships in Resources/sfx, or one GD has downloaded |
{ gd: "door01" } |
one of GD’s own game sounds, by name (door01, explode_11, achievement_01, dangerLoop, tower01…) |
| Call | What it does |
|---|---|
client: play(sound[, options]) → bool |
false = not played (no such sound on this PC; the log says why). At most 40 a second |
server: play(sound[, options[, playerId]]) → bool |
to everyone, or one player |
client: stop([id]) / server: stop([id[, playerId]]) → bool |
every sound with that id; no id = every sound |
Options: volume 0..2 (1), speed 0.25..4 (1; the pitch moves with it), loop (false), id (a name to stop it by;
1..32 of A-Z a-z 0-9 _ . : -), at: {x, y} + range 30..100000 (600): a positional sound – it sits at that
point of the level, fades out with the distance from the local player (silent at range) and pans left / right.
// server: both players hear the tag, the one who was tagged a little loudergdmp.audio.play({ sfx: 4395 }, { volume: 0.8 }, tagger);gdmp.audio.play({ gd: "explode_11" }, { volume: 1.0, speed: 1.3 }, tagged);// client: a humming machine in the level, louder as you get near itgdmp.audio.play({ gd: "dangerLoop" }, { loop: true, id: "hum", at: { x: 900, y: 300 }, range: 500 });TypeScript
Section titled “TypeScript”The declarations from the GDMP types (namespace GDMP), comments included:
/** A package file (`"sounds/tag.ogg"`), GD's SFX library by id, or one of GD's own game sounds by name. */type Sound = string | { sfx: number } | { gd: string };
interface SoundOptions { /** 0..2 (1). */ volume?: number; /** 0.25..4 (1); the pitch moves with it. */ speed?: number; loop?: boolean; /** A name to stop it by: 1..32 of `A-Z a-z 0-9 _ . : -`. */ id?: string; /** A positional sound: it sits at that point and fades with the distance from the local player. */ at?: { x: number; y: number }; /** 30..100000 (600). */ range?: number;}
interface AudioServer { /** To everyone, or to one player. */ play(sound: Sound, options?: SoundOptions, playerId?: PlayerId): boolean; stop(id?: string, playerId?: PlayerId): boolean;}
interface AudioClient { /** `false` = not played (the log says why). At most 40 a second. */ play(sound: Sound, options?: SoundOptions): boolean; stop(id?: string): boolean;}