Class: Sound#

Hierarchy#

Constructors#

constructor#

new Sound(fileName: string, looping: boolean, is3D: boolean, stopWhenOutOfRange: boolean, fadeInRate: number, fadeOutRate: number, eaxSetting: string): Sound

Creates a sound handle.

note You can only play the same sound handle once.

note You can only play the same sound filepath four times.

note You can only play 16 sounds in general.

note Sounds of the same filepath (on different sound handles) must have a delay of at least 0.1 seconds inbetween them to be played. You can overcome this by starting one earlier and then using SetSoundPosition.

Parameters:#

NameTypeDescription
fileNamestringThe path to the file.
loopingbooleanLooping sounds will restart once the sound duration has finished.
is3Dboolean3D Sounds can be played on particular areas of the map. They are at their loudest when the camera is close to the sound's coordinates.
stopWhenOutOfRangeboolean
fadeInRatenumberHow quickly the sound fades in. The higher the number, the faster the sound fades in. Maximum number is 127.
fadeOutRatenumberHow quickly the sound fades out. The higher the number, the faster the sound fades out. Maximum number is 127.
eaxSettingstringEAX is an acronym for environmental audio extensions. In the sound editor, this corresponds to the "Effect" setting.

Returns: Sound

Defined in: handles/sound.ts:5

Properties#

handle#

• Readonly handle: sound

Inherited from: Handle.handle

Defined in: handles/handle.ts:6

Accessors#

dialogueSpeakerNameKey#

dialogueSpeakerNameKey(): string

Returns: string

Defined in: handles/sound.ts:30

dialogueSpeakerNameKey(speakerName: string): void

Parameters:#

NameType
speakerNamestring

Returns: void

Defined in: handles/sound.ts:34


dialogueTextKey#

dialogueTextKey(): string

Returns: string

Defined in: handles/sound.ts:38

dialogueTextKey(dialogueText: string): void

Parameters:#

NameType
dialogueTextstring

Returns: void

Defined in: handles/sound.ts:42


duration#

duration(): number

Returns: number

Defined in: handles/sound.ts:46

duration(duration: number): void

Parameters:#

NameType
durationnumber

Returns: void

Defined in: handles/sound.ts:50


id#

id(): number

Get the unique ID of the handle. The ID is recycled once you destroy the object.

Returns: number

The unique ID of a handle object.

Defined in: handles/handle.ts:18


loading#

loading(): boolean

Returns: boolean

Defined in: handles/sound.ts:54


playing#

playing(): boolean

Returns: boolean

Defined in: handles/sound.ts:58

Methods#

killWhenDone#

killWhenDone(): void

Returns: void

Defined in: handles/sound.ts:62


registerStacked#

registerStacked(byPosition: boolean, rectWidth: number, rectHeight: number): void

Parameters:#

NameType
byPositionboolean
rectWidthnumber
rectHeightnumber

Returns: void

Defined in: handles/sound.ts:66


setChannel#

setChannel(channel: number): void

Parameters:#

NameType
channelnumber

Returns: void

Defined in: handles/sound.ts:70


setConeAngles#

setConeAngles(inside: number, outside: number, outsideVolume: number): void

note This call is only valid if the sound was created with 3d enabled

Parameters:#

NameType
insidenumber
outsidenumber
outsideVolumenumber

Returns: void

Defined in: handles/sound.ts:77


setConeOrientation#

setConeOrientation(x: number, y: number, z: number): void

note This call is only valid if the sound was created with 3d enabled

Parameters:#

NameType
xnumber
ynumber
znumber

Returns: void

Defined in: handles/sound.ts:84


setDistanceCutoff#

setDistanceCutoff(cutoff: number): void

Parameters:#

NameType
cutoffnumber

Returns: void

Defined in: handles/sound.ts:88


setDistances#

setDistances(minDist: number, maxDist: number): void

note This call is only valid if the sound was created with 3d enabled

Parameters:#

NameType
minDistnumber
maxDistnumber

Returns: void

Defined in: handles/sound.ts:95


setFacialAnimationFilepath#

setFacialAnimationFilepath(animationSetFilepath: string): void

Parameters:#

NameType
animationSetFilepathstring

Returns: void

Defined in: handles/sound.ts:99


setFacialAnimationGroupLabel#

setFacialAnimationGroupLabel(groupLabel: string): void

Parameters:#

NameType
groupLabelstring

Returns: void

Defined in: handles/sound.ts:103


setFacialAnimationLabel#

setFacialAnimationLabel(animationLabel: string): void

Parameters:#

NameType
animationLabelstring

Returns: void

Defined in: handles/sound.ts:107


setParamsFromLabel#

setParamsFromLabel(soundLabel: string): void

pplies default settings to the sound.

Parameters:#

NameTypeDescription
soundLabelstringThe label out of one of the SLK-files, whose settings should be used, e.g. values like volume, pitch, pitch variance, priority, channel, min distance, max distance, distance cutoff or eax.

Returns: void

Defined in: handles/sound.ts:115


setPitch#

setPitch(pitch: number): void

Tones the pitch of the sound, default value is 1. Increasing it you get the chipmunk version and the sound becomes shorter, when decremented the sound becomes low-pitched and longer.

bug This native has very weird behaviour. See this for an explenation and this for a non-bugged implementation.

Parameters:#

NameType
pitchnumber

Returns: void

Defined in: handles/sound.ts:127


setPlayPosition#

setPlayPosition(millisecs: number): void

Must be called immediately after starting the sound

Parameters:#

NameTypeDescription
millisecsnumber

Returns: void

Defined in: handles/sound.ts:135


setPosition#

setPosition(x: number, y: number, z: number): void

note This call is only valid if the sound was created with 3d enabled

Parameters:#

NameType
xnumber
ynumber
znumber

Returns: void

Defined in: handles/sound.ts:142


setVelocity#

setVelocity(x: number, y: number, z: number): void

note This call is only valid if the sound was created with 3d enabled

Parameters:#

NameType
xnumber
ynumber
znumber

Returns: void

Defined in: handles/sound.ts:149


setVolume#

setVolume(volume: number): void

Sets the sounds volume

Parameters:#

NameTypeDescription
volumenumberVolume, between 0 and 127

Returns: void

Defined in: handles/sound.ts:157


start#

start(): void

Starts the sound.

note You can only play the same sound handle once.

note You can only play 16 sounds in general.

note Sounds of the same filepath (on different sound handles) must have a delay of at least 0.1 seconds inbetween them to be played. You can overcome this by starting one earlier and then using setPosition.

Returns: void

Defined in: handles/sound.ts:168


stop#

stop(killWhenDone: boolean, fadeOut: boolean): void

Stops the sound.

Parameters:#

NameTypeDescription
killWhenDonebooleanThe sound gets destroyed if true.
fadeOutbooleanTurns down the volume with fadeOutRate as stated in constructor.

Returns: void

Defined in: handles/sound.ts:177


unregisterStacked#

unregisterStacked(byPosition: boolean, rectWidth: number, rectHeight: number): void

Parameters:#

NameType
byPositionboolean
rectWidthnumber
rectHeightnumber

Returns: void

Defined in: handles/sound.ts:181


fromHandle#

static fromHandle(handle: sound): Sound

Parameters:#

NameType
handlesound

Returns: Sound

Defined in: handles/sound.ts:185


getFileDuration#

static getFileDuration(fileName: string): number

Parameters:#

NameType
fileNamestring

Returns: number

Defined in: handles/sound.ts:189