|
<!DOCTYPE html> |
|
<html> |
|
<head> |
|
<meta charset="utf-8"> |
|
<title>デモ:クライシスコアFFVIIのナビゲーション音声をHTML5でできる限り再現してみた</title> |
|
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico"> |
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> |
|
<script type="text/javascript"> |
|
var files = [ |
|
"sound/spreader50-65ms.wav", // エフェクト用 |
|
"sound/Modulating_Phase.mp3", |
|
"sound/Activating_Combat_Mode.mp3", |
|
"sound/Conflict_Resolved.mp3", |
|
"sound/Activating_Combat_Mode_Daniel.mp3", |
|
"sound/Activating_Combat_Mode_Emily.mp3", |
|
"sound/Activating_Combat_Mode_Jill.mp3", |
|
"sound/Activating_Combat_Mode_Monica.mp3", |
|
"sound/Activating_Combat_Mode_Samantha.mp3", |
|
"sound/Activating_Combat_Mode_Serena.mp3", |
|
"sound/Activating_Combat_Mode_Kyoko.mp3", |
|
]; |
|
|
|
if(typeof(webkitAudioContext)!=="undefined") |
|
var audioctx = new webkitAudioContext(); |
|
else if(typeof(AudioContext)!=="undefined") |
|
var audioctx = new AudioContext(); |
|
|
|
var source = null; |
|
|
|
|
|
|
|
var buffers = []; |
|
var loadidx = 0; |
|
var req = new XMLHttpRequest(); |
|
|
|
function LoadBuffers() { |
|
req.open("GET", files[loadidx], true); |
|
req.responseType = "arraybuffer"; |
|
req.onload = function() { |
|
if(req.response) { |
|
audioctx.decodeAudioData(req.response,function(b){ |
|
buffers[loadidx]=b; |
|
if(++loadidx < files.length) |
|
LoadBuffers(); |
|
},function(){}); |
|
} |
|
else |
|
buffers[loadidx] = audioctx.createBuffer(VBArray(req.responseBody).toArray(), false); |
|
}; |
|
req.send(); |
|
} |
|
function Play(number) { |
|
source = audioctx.createBufferSource(); |
|
|
|
var convolver = audioctx.createConvolver(); |
|
var revlevel = audioctx.createGain(); |
|
revlevel.gain.value = 6; |
|
convolver.connect(revlevel); |
|
revlevel.connect(audioctx.destination); |
|
|
|
var compressor = audioctx.createDynamicsCompressor(); |
|
var volume = audioctx.createGain(); |
|
|
|
source.buffer = buffers[number]; |
|
convolver.buffer = buffers[0]; |
|
|
|
source.connect(volume); |
|
volume.gain.value = 1; |
|
volume.connect(compressor); |
|
|
|
compressor.connect(convolver); |
|
compressor.connect(audioctx.destination); |
|
|
|
source.start(0); |
|
} |
|
function RawPlay(number) { |
|
source = audioctx.createBufferSource(); |
|
|
|
source.buffer = buffers[number]; |
|
|
|
var compressor = audioctx.createDynamicsCompressor(); |
|
var volume = audioctx.createGain(); |
|
|
|
source.connect(volume); |
|
volume.gain.value = 1; |
|
volume.connect(compressor); |
|
|
|
compressor.connect(audioctx.destination); |
|
|
|
source.start(0); |
|
} |
|
</script> |
|
</head> |
|
<body onload="LoadBuffers()"> |
|
<a class="btn btn-lg btn-primary" href="#" role="button" onclick="Play(2)">Activating Combat Mode</a> |
|
<a class="btn btn-lg btn-primary" href="#" role="button" onclick="RawPlay(2)">Activating Combat Mode</a><br> |
|
<a class="btn btn-lg btn-primary" href="#" role="button" onclick="Play(4)">Activating Combat Mode</a><br> |
|
<a class="btn btn-lg btn-primary" href="#" role="button" onclick="Play(5)">Activating Combat Mode</a><br> |
|
<a class="btn btn-lg btn-primary" href="#" role="button" onclick="Play(6)">Activating Combat Mode</a><br> |
|
<a class="btn btn-lg btn-primary" href="#" role="button" onclick="Play(7)">Activating Combat Mode</a><br> |
|
<a class="btn btn-lg btn-primary" href="#" role="button" onclick="Play(8)">Activating Combat Mode</a><br> |
|
<a class="btn btn-lg btn-primary" href="#" role="button" onclick="Play(9)">Activating Combat Mode</a><br> |
|
<a class="btn btn-lg btn-primary" href="#" role="button" onclick="Play(10)">Activating Combat Mode</a><br> |
|
</body> |
|
</html> |