WAVES.JS
Loaders
Loaders
AudioBuffer loader and other loader utilities module.
# to use as a standalone module
$ npm install ircam-rnd/loaders
Example usage
// We need an audio context to decode the file
// By default,the loaders search for audioContext in the window.
var audioContext = new AudioContext();
// Load the file passing the path
var myAudioBufferLoader = new loaders.AudioBufferLoader();
myAudioBufferLoader.progressCallback = function(obj){
// Do something with the progress value obj
// obj: {value:.., total:..., loaded:...}
// value is loaded/total
}
myAudioBufferLoader.load('sound/file/url').then(function(buffer){
// Do something with the loaded audio buffer
}).catch(function(err) {
console.log(err.message);
});
Loader
.constructor (responseType:String) : Loader
responseType
default “” equal “text”, possible values: “arraybuffer”, “blob”, “document” or “json”
.load (url:String|String[]) : Promise
Method for a promise based file loading.
The url
(s) of the files to load. Accepts a url
pointing to the file location or an array of url
s.
AudioBufferLoader
.constructor () : AudioBufferLoader
.load (url:String|String[], options:Object) : Promise
Method for promise audio file loading and decoding.
The url
s of the audio files to load. Accepts a url
pointing to the file location or an array of URLs.
options: {{wrapAroundExtension: number}} - Object with a wrapAroundExtension key which set the length, in seconds to be copied from the begining at the end of the returned AudioBuffer(s)
SuperLoader
.constructor () : SuperLoader
.load (url:String|String[], options:Object) : Promise
Method for promise audio and json file loading (and decoding for audio).
The url
(s) of the files to load. Accepts a url
pointing to the file location or an array of URLs.
options: {{wrapAroundExtension: number}} [options] - Object with a wrapAroundExtension key which set the length, in seconds to be copied from the begining at the end of the returned AudioBuffer