Constructor
new Sound(zzfxSound, rangeopt, taperopt)
Create a sound object and cache the zzfx samples for later use
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
zzfxSound | Array | Array of zzfx parameters, ex. [.5,.5] | ||
range | Number | <optional> | soundDefaultRange | World space max range of sound, will not play if camera is farther away |
taper | Number | <optional> | soundDefaultTaper | At what percentage of range should it start tapering off |
- Source
// create a sound
const sound_example = new Sound([.5,.5]);
// play the sound
sound_example.play();
Members
range
PropertiesType | Description |
---|---|
Number | World space max range of sound, will not play if camera is farther away |
- Source
taper
PropertiesType | Description |
---|---|
Number | At what percentage of range should it start tapering off |
- Source
Methods
play(posopt, volumeopt, pitchopt, randomnessScaleopt) → {AudioBufferSourceNode}
Play the sound
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pos | Vector2 | <optional> | World space position to play the sound, sound is not attenuated if null | |
volume | Number | <optional> | 1 | How much to scale volume by (in addition to range fade) |
pitch | Number | <optional> | 1 | How much to scale pitch by (also adjusted by this.randomness) |
randomnessScale | Number | <optional> | 1 | How much to scale randomness |
- Source
- The audio, can be used to stop sound later
- Type:
- AudioBufferSourceNode
playNote(semitoneOffset, posopt, volumeopt) → {AudioBufferSourceNode}
Play the sound as a note with a semitone offset
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
semitoneOffset | Number | How many semitones to offset pitch | ||
pos | Vector2 | <optional> | World space position to play the sound, sound is not attenuated if null | |
volume | Number | <optional> | 1 | How much to scale volume by (in addition to range fade) |
- Source
- The audio, can be used to stop sound later
- Type:
- AudioBufferSourceNode