editor › Globals › SoundPlayer
Class: SoundPlayer
Hierarchy
- SoundPlayer
Index
Constructors
Properties
- audioContext
- decodedAudioBuffers
- loopingSources
- scaleFactor
- testedFormats
- upVectorTransformationQuaternion
- workingFormat
Methods
Constructors
constructor
+ new SoundPlayer(): SoundPlayer
Defined in src/util/SoundPlayer.ts:18
Returns: SoundPlayer
Properties
Private Readonly audioContext
• audioContext: AudioContext | null = null
Defined in src/util/SoundPlayer.ts:11
Private Readonly decodedAudioBuffers
• decodedAudioBuffers: Map‹string, AudioBuffer› = new Map
Defined in src/util/SoundPlayer.ts:12
Private Readonly loopingSources
• loopingSources: Map‹string, AudioBufferSourceNode› = new Map
Defined in src/util/SoundPlayer.ts:13
Private Readonly scaleFactor
• scaleFactor: number = Config.get("sound.scaleFactor")
Defined in src/util/SoundPlayer.ts:14
Private Readonly testedFormats
• testedFormats: string[] = []
Defined in src/util/SoundPlayer.ts:15
Private Readonly upVectorTransformationQuaternion
• upVectorTransformationQuaternion: Quaternion = TransformsHelper.createUpVectorTransformationQuaternion()
Defined in src/util/SoundPlayer.ts:16
Private workingFormat
• workingFormat: string = null
Defined in src/util/SoundPlayer.ts:18
Methods
Private _connectNodes
▸ _connectNodes(...nodes: AudioNode[]): void
Defined in src/util/SoundPlayer.ts:182
Parameters:
| Name | Type |
|---|---|
...nodes |
AudioNode[] |
Returns: void
Private _createPanner
▸ _createPanner(position: Vector3): PannerNode
Defined in src/util/SoundPlayer.ts:175
Parameters:
| Name | Type |
|---|---|
position |
Vector3 |
Returns: PannerNode
Private _play
▸ _play(soundFileName: string, volume: number, source: AudioBufferSourceNode, filterNodes: PannerNode[]): boolean
Defined in src/util/SoundPlayer.ts:139
Parameters:
| Name | Type | Default |
|---|---|---|
soundFileName |
string | - |
volume |
number | - |
source |
AudioBufferSourceNode | this.audioContext.createBufferSource() |
filterNodes |
PannerNode[] | [] |
Returns: boolean
Private _tryLoad
▸ _tryLoad(soundFileName: string, format: string): Promise‹void›
Defined in src/util/SoundPlayer.ts:119
Parameters:
| Name | Type |
|---|---|
soundFileName |
string |
format |
string |
Returns: Promise‹void›
loop
▸ loop(soundFileName: string, volume: number, position?: Vector3): boolean
Defined in src/util/SoundPlayer.ts:74
Parameters:
| Name | Type | Default |
|---|---|---|
soundFileName |
string | - |
volume |
number | 1 |
position? |
Vector3 | - |
Returns: boolean
oneShot
▸ oneShot(soundFileName: string, volume: number, position?: Vector3): boolean
Defined in src/util/SoundPlayer.ts:64
Parameters:
| Name | Type | Default |
|---|---|---|
soundFileName |
string | - |
volume |
number | 1 |
position? |
Vector3 | - |
Returns: boolean
preload
▸ preload(soundFileName: string): Promise‹void›
Defined in src/util/SoundPlayer.ts:36
Parameters:
| Name | Type |
|---|---|
soundFileName |
string |
Returns: Promise‹void›
setListenerPosition
▸ setListenerPosition(position: Vector3, orientation: Vector3, up: Vector3): void
Defined in src/util/SoundPlayer.ts:108
Parameters:
| Name | Type |
|---|---|
position |
Vector3 |
orientation |
Vector3 |
up |
Vector3 |
Returns: void
stopLoop
▸ stopLoop(soundFileName: string): boolean
Defined in src/util/SoundPlayer.ts:98
Parameters:
| Name | Type |
|---|---|
soundFileName |
string |
Returns: boolean