audio-effects
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -15,3 +15,2 @@ "use strict"; | ||
function Reverb(audioContext, buffer) { | ||
var _this = this; | ||
_super.call(this, audioContext); | ||
@@ -39,18 +38,10 @@ this.nodes = { | ||
this.level = 1; | ||
// Set the convolver buffer | ||
if (buffer) { | ||
this.buffer = buffer; | ||
} | ||
else { | ||
this.getInputResponseFile().then(function (buffer) { | ||
_this.buffer = buffer; | ||
}); | ||
} | ||
} | ||
/** | ||
* Get the standard input responsefile. | ||
* @param {string} A path to the input response file | ||
* @return {Promise<AudioBuffer>} | ||
*/ | ||
Reverb.prototype.getInputResponseFile = function () { | ||
return fetch('../../audio/hall-reverb.ogg', { | ||
Reverb.getInputResponseFile = function (file) { | ||
return fetch(file, { | ||
method: 'get' | ||
@@ -57,0 +48,0 @@ }).then(function (response) { |
{ | ||
"name": "audio-effects", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "A javascript library to create audio effects using the web-audio-api", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -120,26 +120,5 @@ # Audio-effects | ||
reverb.level = 1; // Set the level to 100% | ||
``` | ||
By default the reverb effect will use the hall-reverb impulse response file from the awesome [web-audio-playground](https://github.com/cwilso/WebAudio) by Chris Wilson. | ||
if you want to use your own impulse response file you can configure it in 2 ways: | ||
```javascript | ||
const irf = fetch('path/to/impulse-response-file', { | ||
method: 'get' | ||
}).then(response => { | ||
return response.arrayBuffer(); | ||
ReverbNode.getInputResponseFile('path/to/input-response-file').then(buffer => { | ||
reverb.buffer = buffer; | ||
}); | ||
// Option 1: pass it as a parameter when creating the reverb effect | ||
irf.then(buffer => { | ||
const reverb = new Reverb(audioContext, buffer); | ||
}); | ||
// Option 2: set the buffer after creating the reverb effect | ||
const reverb = new Reverb(audioContext); | ||
irf.then(buffer => { | ||
reverb.buffer = buffer; | ||
}); | ||
``` | ||
@@ -146,0 +125,0 @@ |
78142
1054
237