wav类型修改为二进制判断,两者都从buffer来播放
This commit is contained in:
parent
7839933a78
commit
4f7bf69df8
Binary file not shown.
Before Width: | Height: | Size: 320 KiB After Width: | Height: | Size: 394 KiB |
Binary file not shown.
Before Width: | Height: | Size: 137 KiB After Width: | Height: | Size: 449 KiB |
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
|
@ -1 +1 @@
|
|||
[{"code":"ja","ckey":{"card":"743b0969dd056477387012d6870b22b0","skill":"704e017ec1f8ddcfdba4058eede60cce"},"updateTime":1669045281550},{"code":"en","ckey":{"card":"b6f18f876a78eefcb47ab36e71cdb155","skill":"a8a73ea2042ce498719458a5662dae2a"},"updateTime":1668780673869},{"code":"ko","ckey":{"card":"c8e4ecef32ea8e3d35473380b7ec53ac","skill":"1b6d3a8b7a1c5c29ee575f5c977f8dec"},"updateTime":1668780673869}]
|
||||
[{"code":"ja","ckey":{"card":"43a16bab221da5df1bad19ab70184939","skill":"704e017ec1f8ddcfdba4058eede60cce"},"updateTime":1669221577930},{"code":"en","ckey":{"card":"478c9569446afc717329823450a7b21e","skill":"a8a73ea2042ce498719458a5662dae2a"},"updateTime":1669221577930},{"code":"ko","ckey":{"card":"4f3c7f8629577fb40d3546b206b84c3e","skill":"29fdbded544c840684c6b19bf085372e"},"updateTime":1669221577930}]
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -235,21 +235,32 @@ const pcmImportObj = {
|
|||
let pcmPlayer = null;
|
||||
let adpcm_wasm = null;
|
||||
|
||||
function decodeAudio(fileName, decodeCallback) {
|
||||
async function decodeAudio(fileName, decodeCallback) {
|
||||
if (pcmPlayer != null) {
|
||||
pcmPlayer.close();
|
||||
}
|
||||
pcmPlayer = new PCMPlayer(1, 44100);
|
||||
fetch(fileName).then((response) => response.arrayBuffer())
|
||||
.then((bytes) => {
|
||||
let audioData = new Uint8Array(bytes);
|
||||
let step = 160;
|
||||
for (let i = 0; i < audioData.byteLength; i += step) {
|
||||
let pcm16BitData = decodeCallback(audioData.slice(i, i + step));
|
||||
let pcmFloat32Data = Std.shortToFloatData(pcm16BitData);
|
||||
pcmPlayer.feed(pcmFloat32Data);
|
||||
}
|
||||
});
|
||||
let request = await fetch(fileName);
|
||||
let buffer = await request.arrayBuffer();
|
||||
|
||||
let audioData = new Uint8Array(buffer);
|
||||
if (audioData[16] == 0x10) { //普通WAV,建立一个audio来播放
|
||||
console.debug('当前 WAV 为 普通 WAV');
|
||||
const audioCtx = new AudioContext();
|
||||
const decodedData = await audioCtx.decodeAudioData(buffer);
|
||||
const source = new AudioBufferSourceNode(audioCtx);
|
||||
source.buffer = decodedData;
|
||||
source.connect(audioCtx.destination);
|
||||
source.start(0);
|
||||
} else { //audioData[16] == 0x14
|
||||
console.debug('当前 WAV 为 PCM WAV');
|
||||
let step = 160;
|
||||
for (let i = 0; i < audioData.byteLength; i += step) {
|
||||
let pcm16BitData = decodeCallback(audioData.slice(i, i + step));
|
||||
let pcmFloat32Data = Std.shortToFloatData(pcm16BitData);
|
||||
pcmPlayer.feed(pcmFloat32Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fetch("library/jy4340132-aaa/adpcm.wasm").then((response) => response.arrayBuffer())
|
||||
|
|
14
script.js
14
script.js
|
@ -3540,17 +3540,9 @@ function initialize(event) {
|
|||
if (parseInt(this.getAttribute("data-awoken-icon"), 10) === 63) {
|
||||
const card = Cards[editBox.mid];
|
||||
const sndURL = `sound/voice/${currentDataSource.code}/padv${card.voiceId.toString().padStart(3,'0')}.wav`;
|
||||
//美韩的王者天下音效不知道怎么变成了普通PCM WAV
|
||||
if (currentDataSource.code != 'ja' && card.voiceId >= 428) {
|
||||
const audio = new Audio(sndURL);
|
||||
audio.oncanplaythrough = function(event){
|
||||
this.play();
|
||||
}
|
||||
} else {
|
||||
const decoder = new Adpcm(adpcm_wasm, pcmImportObj);
|
||||
decoder.resetDecodeState(new Adpcm.State(0, 0));
|
||||
decodeAudio(sndURL, decoder.decode.bind(decoder));
|
||||
}
|
||||
const decoder = new Adpcm(adpcm_wasm, pcmImportObj);
|
||||
decoder.resetDecodeState(new Adpcm.State(0, 0));
|
||||
decodeAudio(sndURL, decoder.decode.bind(decoder));
|
||||
}
|
||||
}
|
||||
monEditAwokensLabel.forEach(akDom => akDom.onclick = playVoiceAwoken);
|
||||
|
|
|
@ -5151,11 +5151,15 @@ const cachesMap = new Map([
|
|||
],
|
||||
[
|
||||
"images/cards_ko/CARDS_093.PNG",
|
||||
"6ea5cfcbb0a4d093d9ab32517e0e46ac"
|
||||
"699260b62aad3b3c1c37008511ea8b7b"
|
||||
],
|
||||
[
|
||||
"images/cards_ko/CARDS_094.PNG",
|
||||
"77cc1163b31e242d7d917940afc7e331"
|
||||
"2a64b5f301d9e74eaa51a0d8a2eeeb8f"
|
||||
],
|
||||
[
|
||||
"images/cards_ko/CARDS_095.PNG",
|
||||
"9295d3d4cfda0fd8fa6fa2e2ebec5675"
|
||||
],
|
||||
[
|
||||
"sound/voice/ko/padv001.wav",
|
||||
|
@ -6809,6 +6813,10 @@ const cachesMap = new Map([
|
|||
"sound/voice/ko/padv446.wav",
|
||||
"db068c8b48ed418d517f8f979cf99767"
|
||||
],
|
||||
[
|
||||
"sound/voice/ko/padv525.wav",
|
||||
"f175f5c09a9ef7bd1afc0b6a309283b9"
|
||||
],
|
||||
[
|
||||
"fonts/fa-solid-900.woff2",
|
||||
"3e50e269ee627bb2279f91d18c085167"
|
||||
|
@ -6847,11 +6855,11 @@ const cachesMap = new Map([
|
|||
],
|
||||
[
|
||||
"script-universal_function.js",
|
||||
"a804db4b6fd181db162fac2d47a1996f"
|
||||
"24e30b4ba22b0b1c1898983ae56211f9"
|
||||
],
|
||||
[
|
||||
"script.js",
|
||||
"fab930cb6761db5376979b6e9dc18de8"
|
||||
"30a53ec95f26bd6cf638a4d3e0e8d16b"
|
||||
],
|
||||
[
|
||||
"solo.html",
|
||||
|
@ -7103,15 +7111,15 @@ const cachesMap = new Map([
|
|||
],
|
||||
[
|
||||
"monsters-info/ckey.json",
|
||||
"d902ffd4e3a7c139b44e27e92b465094"
|
||||
"8b8bbf9fbf57c51416c468a78522fad2"
|
||||
],
|
||||
[
|
||||
"monsters-info/mon_en.json",
|
||||
"b6f18f876a78eefcb47ab36e71cdb155"
|
||||
"478c9569446afc717329823450a7b21e"
|
||||
],
|
||||
[
|
||||
"monsters-info/mon_ja.json",
|
||||
"743b0969dd056477387012d6870b22b0"
|
||||
"43a16bab221da5df1bad19ab70184939"
|
||||
],
|
||||
[
|
||||
"monsters-info/mon_ja_new_formatting.json",
|
||||
|
@ -7123,7 +7131,7 @@ const cachesMap = new Map([
|
|||
],
|
||||
[
|
||||
"monsters-info/mon_ko.json",
|
||||
"c8e4ecef32ea8e3d35473380b7ec53ac"
|
||||
"4f3c7f8629577fb40d3546b206b84c3e"
|
||||
],
|
||||
[
|
||||
"monsters-info/skill_en.json",
|
||||
|
@ -7135,7 +7143,7 @@ const cachesMap = new Map([
|
|||
],
|
||||
[
|
||||
"monsters-info/skill_ko.json",
|
||||
"1b6d3a8b7a1c5c29ee575f5c977f8dec"
|
||||
"29fdbded544c840684c6b19bf085372e"
|
||||
],
|
||||
[
|
||||
"doc/export-player-data.html",
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue