Class: WebAudio

DKTools.Utils.WebAudio

The static class that defines utility methods for WebAudio class

new DKTools.Utils.WebAudio ()

Since:
  • 5.0.0

Methods

DKTools.Utils.WebAudio.load (object, filename, listener)WebAudio | null static

Loads and returns an audio file
Name Type Description
object String | WebAudio | Array | Object Path to file or WebAudio or array with parameters or object with parameters
filename String optional Name of file (if object is String)
listener function optional Function of processing after loading an audio file (if object is String)
object.folder String Path to file
object.filename String Name of file
object.listener function optional Function of processing after loading an audio file
Returns:
Type Description
WebAudio | null Loaded audio file or null

DKTools.Utils.WebAudio.loadAsync (object, filename, listener)Promise.<(WebAudio|null)> asyncstatic

Loads and returns an audio file Asynchronous version of DKTools.Utils.WebAudio.load Promise resolves a loaded audio file
Name Type Description
object String | WebAudio | Array | Object Path to file or WebAudio or array with parameters or object with parameters
filename String optional Name of file (if object is String)
listener function optional Function of processing after loading an audio file (if object is String)
object.folder String Path to file
object.filename String Name of file
object.listener function optional Function of processing after loading an audio file
Returns:
Type Description
Promise.<(WebAudio|null)> Loaded audio file or null

DKTools.Utils.WebAudio.loadBuffers (buffers, onLoadAllBuffers, onLoadSomeBuffer) static

Loads a audio files and call the callback function when all audio files are ready
Name Type Description
buffers Array.<WebAudio> | Array.<Object> Audio files to load
onLoadAllBuffers function Function that is called when all audio files are loaded and ready
onLoadSomeBuffer function optional Function that is called when some audio file are loaded and ready
object[].folder String Path to file
object[].filename String Name of file
object[].listener function optional Function of processing after loading an audio file
Example
var buffers = [];
buffers[0] = AudioManager.createBuffer('bgm', 'Battle1');
buffers[1] = {
 folder: 'bgm',
 filename: 'Battle2'
};

DKTools.Utils.WebAudio.loadBuffers(buffers, function(allBuffers) {
    // all loaded buffers
});

DKTools.Utils.WebAudio.loadBuffersAsync (buffers)Promise.<Array.<WebAudio>> asyncstatic

Asynchronously loads an audio files Promise resolves a loaded audio files
Name Type Description
buffers Array.<WebAudio> | Array.<Object> Audio files to load
object[].folder String Path to file
object[].filename String Name of file
object[].listener function optional Function of processing after loading an audio file
Returns:
Type Description
Promise.<Array.<WebAudio>> Loaded audio files