Constructor
new SoundWave(filename, randomnessopt, rangeopt, taperopt, onloadCallbackopt)
Create a sound object and cache the wave file for later use
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
filename | string | Filename of audio file to load | ||
randomness | number | <optional> | 0 | How much to randomize frequency each time sound plays |
range | number | <optional> | soundDefaultRange | World space max range of sound |
taper | number | <optional> | soundDefaultTaper | At what percentage of range should it start tapering |
onloadCallback | function | <optional> | callback function to call when sound is loaded |
- Source
Example
// create a sound
const sound_example = new SoundWave('sound.mp3');
// play the sound
sound_example.play();
Members
onloadCallback
PropertiesType | Description |
---|---|
function | callback function to call when sound is loaded |
- Source
Methods
(async) loadSound(filename) → {Promise.<void>}
Loads a sound from a URL and decodes it into sample data. Must be used with await!
Parameters:
Name | Type | Description |
---|---|---|
filename | string |
- Source
Returns:
- Type:
- Promise.<void>