Class: Sound#
Hierarchy#
Handle<sound>
↳ Sound
Constructors#
constructor#
new Sound(fileName: string, looping: boolean, is3D: boolean, stopWhenOutOfRange: boolean, fadeInRate: number, fadeOutRate: number, eaxSetting: string): SoundCreates 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:#
| Name | Type | Description |
|---|---|---|
fileName | string | The path to the file. |
looping | boolean | Looping sounds will restart once the sound duration has finished. |
is3D | boolean | 3D 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. |
stopWhenOutOfRange | boolean | |
fadeInRate | number | How quickly the sound fades in. The higher the number, the faster the sound fades in. Maximum number is 127. |
fadeOutRate | number | How quickly the sound fades out. The higher the number, the faster the sound fades out. Maximum number is 127. |
eaxSetting | string | EAX 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
Defined in: handles/handle.ts:6
Accessors#
dialogueSpeakerNameKey#
dialogueSpeakerNameKey(): stringReturns: string
Defined in: handles/sound.ts:30
dialogueSpeakerNameKey(speakerName: string): voidParameters:#
| Name | Type |
|---|---|
speakerName | string |
Returns: void
Defined in: handles/sound.ts:34
dialogueTextKey#
dialogueTextKey(): stringReturns: string
Defined in: handles/sound.ts:38
dialogueTextKey(dialogueText: string): voidParameters:#
| Name | Type |
|---|---|
dialogueText | string |
Returns: void
Defined in: handles/sound.ts:42
duration#
duration(): numberReturns: number
Defined in: handles/sound.ts:46
duration(duration: number): voidParameters:#
| Name | Type |
|---|---|
duration | number |
Returns: void
Defined in: handles/sound.ts:50
id#
id(): numberGet 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(): booleanReturns: boolean
Defined in: handles/sound.ts:54
playing#
playing(): booleanReturns: boolean
Defined in: handles/sound.ts:58
Methods#
killWhenDone#
killWhenDone(): voidReturns: void
Defined in: handles/sound.ts:62
registerStacked#
registerStacked(byPosition: boolean, rectWidth: number, rectHeight: number): voidParameters:#
| Name | Type |
|---|---|
byPosition | boolean |
rectWidth | number |
rectHeight | number |
Returns: void
Defined in: handles/sound.ts:66
setChannel#
setChannel(channel: number): voidParameters:#
| Name | Type |
|---|---|
channel | number |
Returns: void
Defined in: handles/sound.ts:70
setConeAngles#
setConeAngles(inside: number, outside: number, outsideVolume: number): voidnote This call is only valid if the sound was created with 3d enabled
Parameters:#
| Name | Type |
|---|---|
inside | number |
outside | number |
outsideVolume | number |
Returns: void
Defined in: handles/sound.ts:77
setConeOrientation#
setConeOrientation(x: number, y: number, z: number): voidnote This call is only valid if the sound was created with 3d enabled
Parameters:#
| Name | Type |
|---|---|
x | number |
y | number |
z | number |
Returns: void
Defined in: handles/sound.ts:84
setDistanceCutoff#
setDistanceCutoff(cutoff: number): voidParameters:#
| Name | Type |
|---|---|
cutoff | number |
Returns: void
Defined in: handles/sound.ts:88
setDistances#
setDistances(minDist: number, maxDist: number): voidnote This call is only valid if the sound was created with 3d enabled
Parameters:#
| Name | Type |
|---|---|
minDist | number |
maxDist | number |
Returns: void
Defined in: handles/sound.ts:95
setFacialAnimationFilepath#
setFacialAnimationFilepath(animationSetFilepath: string): voidParameters:#
| Name | Type |
|---|---|
animationSetFilepath | string |
Returns: void
Defined in: handles/sound.ts:99
setFacialAnimationGroupLabel#
setFacialAnimationGroupLabel(groupLabel: string): voidParameters:#
| Name | Type |
|---|---|
groupLabel | string |
Returns: void
Defined in: handles/sound.ts:103
setFacialAnimationLabel#
setFacialAnimationLabel(animationLabel: string): voidParameters:#
| Name | Type |
|---|---|
animationLabel | string |
Returns: void
Defined in: handles/sound.ts:107
setParamsFromLabel#
setParamsFromLabel(soundLabel: string): voidpplies default settings to the sound.
Parameters:#
| Name | Type | Description |
|---|---|---|
soundLabel | string | The 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): voidTones 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:#
| Name | Type |
|---|---|
pitch | number |
Returns: void
Defined in: handles/sound.ts:127
setPlayPosition#
setPlayPosition(millisecs: number): voidMust be called immediately after starting the sound
Parameters:#
| Name | Type | Description |
|---|---|---|
millisecs | number |
Returns: void
Defined in: handles/sound.ts:135
setPosition#
setPosition(x: number, y: number, z: number): voidnote This call is only valid if the sound was created with 3d enabled
Parameters:#
| Name | Type |
|---|---|
x | number |
y | number |
z | number |
Returns: void
Defined in: handles/sound.ts:142
setVelocity#
setVelocity(x: number, y: number, z: number): voidnote This call is only valid if the sound was created with 3d enabled
Parameters:#
| Name | Type |
|---|---|
x | number |
y | number |
z | number |
Returns: void
Defined in: handles/sound.ts:149
setVolume#
setVolume(volume: number): voidSets the sounds volume
Parameters:#
| Name | Type | Description |
|---|---|---|
volume | number | Volume, between 0 and 127 |
Returns: void
Defined in: handles/sound.ts:157
start#
start(): voidStarts 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): voidStops the sound.
Parameters:#
| Name | Type | Description |
|---|---|---|
killWhenDone | boolean | The sound gets destroyed if true. |
fadeOut | boolean | Turns 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): voidParameters:#
| Name | Type |
|---|---|
byPosition | boolean |
rectWidth | number |
rectHeight | number |
Returns: void
Defined in: handles/sound.ts:181
fromHandle#
static fromHandle(handle: sound): SoundParameters:#
| Name | Type |
|---|---|
handle | sound |
Returns: Sound
Defined in: handles/sound.ts:185
getFileDuration#
static getFileDuration(fileName: string): numberParameters:#
| Name | Type |
|---|---|
fileName | string |
Returns: number
Defined in: handles/sound.ts:189