window.AudioContext = window.AudioContext || window.webkitAudioContext;
// Create the instance of AudioContext
var context = new AudioContext();
// for legacy browsers
context.createDelay = context.createDelay || context.createDelayNode;
// Max delay time
var MAX_DELAY_TIME = 5; // 5 sec
// Create the instance of DelayNode
var delay = context.createDelay(MAX_DELAY_TIME);
window.AudioContext = window.AudioContext || window.webkitAudioContext;
// Create the instance of AudioContext
var context = new AudioContext();
// Create the instance of ConvolverNode
var convolver = context.createConvolver();
window.AudioContext = window.AudioContext || window.webkitAudioContext;
// Create the instance of AudioContext
var context = new AudioContext();
var xhr = new XMLHttpRequest();
var url = 'http:// xxx.jp/reverb.wav';
// XMLHttpRequest Level 2
xhr.responseType = 'arraybuffer';
xhr.onload = function() {
if (xhr.status === 200) {
var arrayBuffer = xhr.response;
if (arrayBuffer instanceof ArrayBuffer) {
// The 2nd argument for decodeAudioData
var successCallback = function(audioBuffer) {
/* audioBuffer is the instance of AudioBuffer */
// Create the instance of ConvolverNode
var convolver = context.createConvolver();
// Set the instance of AudioBuffer
convolver.buffer = audioBuffer;
};
// The 3rd argument for decodeAudioData
var errorCallback = function(error) {
if (error instanceof Error) {
window.alert(error.message);
} else {
window.alert('Error : "decodeAudioData" method.');
}
};
// Create the instance of AudioBuffer (Asynchronously)
context.decodeAudioData(arrayBuffer, successCallback, errorCallback);
}
}
};
xhr.open('GET', url, true);
xhr.send(null);
/*
* Add code to sample code 05
*/
// ....
var successCallback = function(audioBuffer) {
/* audioBuffer is the instance of AudioBuffer */
// Create the instance of ConvolverNode
var convolver = context.createConvolver();
// Set the instance of AudioBuffer
convolver.buffer = audioBuffer;
// Create the instance of OscillatorNode
var oscillator = context.createOscillator();
// for legacy browsers
oscillator.start = oscillator.start || oscillator.noteOn;
oscillator.stop = oscillator.stop || oscillator.noteOff;
// for legacy browsers
context.createGain = context.createGain || context.createGainNode;
// Create the instance of GainNode
var dry = context.createGain(); // for gain of original sound
var wet = context.createGain(); // for gain of effect (Revreb) sound
// Set parameters
dry.gain.value = 0.7;
wet.gain.value = 0.3;
// Connect nodes for original sound
// OscillatorNode (Input) -> GainNode (Dry) -> AudioDestinationNode (Output)
oscillator.connect(dry);
dry.connect(context.destination);
// Connect nodes for effect (Reverb) sound
// OscillatorNode (Input) -> ConvolverNode (Reverb) -> GainNode (Wet) -> AudioDestinationNode (Output)
oscillator.connect(convolver);
convolver.connect(wet);
wet.connect(context.destination);
oscillator.start(0);
};
// ....
とりあえず, 制作者から1つ紹介するのは, こちらのサイトです.
readme.txtの5. Copyrightのセクションに,
「The data are provided free for noncommercial purposes, provided the authors are cited when the data are used in any research application.」 と記載されているので,
非商用であれば, 自分のサイトにおいてWebアプリに利用しても問題なさそうです.