daydreamer-json commited on
Commit
701febb
1 Parent(s): 75730ed
Files changed (2) hide show
  1. ba_video_test.html +21 -0
  2. stay_audio_format.html +405 -0
ba_video_test.html ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <html>
2
+ <head>
3
+ <meta charset="utf-8" />
4
+ <meta name="viewport" content="width=device-width, initial-scale=1.00" />
5
+ <meta name="robots" content="noindex,nofollow,noarchive" />
6
+ <style>
7
+ html,body,video {
8
+ color: #fff;
9
+ background: #000;
10
+ margin: 0;
11
+ line-height: 1;
12
+ width: 100vw;
13
+ height: 100vh;
14
+ font-family: system-ui;
15
+ }
16
+ </style>
17
+ </head>
18
+ <body>
19
+ <video controls src="https://cdn.discordapp.com/attachments/873258418452987997/1088752256305872926/PV_2_2160p_24Mbps.mp4"></video>
20
+ </body>
21
+ </html>
stay_audio_format.html ADDED
@@ -0,0 +1,405 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <html>
2
+ <head>
3
+ <meta charset="utf-8" />
4
+ <meta name="viewport" content="width=device-width, initial-scale=1.00" />
5
+ <meta name="robots" content="noindex,nofollow,noarchive" />
6
+ <script
7
+ src="https://code.jquery.com/jquery-3.6.1.min.js"
8
+ integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ="
9
+ crossorigin="anonymous"
10
+ ></script>
11
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/howler/2.2.3/howler.min.js"></script>
12
+ <link
13
+ rel="stylesheet"
14
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200"
15
+ />
16
+ <link
17
+ href="https://cdn.jsdelivr.net/gh/daydreamer-json/SomeFontRepo@main/somefontrepo.css"
18
+ rel="stylesheet"
19
+ type="text/css"
20
+ media="all"
21
+ />
22
+ <style>
23
+ html,
24
+ body {
25
+ color: #fff;
26
+ background: #000;
27
+ margin: 0;
28
+ line-height: 1;
29
+ width: 100vw;
30
+ height: 100vh;
31
+ font-family: "A-OTF UD Shin Go Pro", system-ui;
32
+ }
33
+ textarea,
34
+ button {
35
+ color: #fff;
36
+ background: #000;
37
+ width: 100vw;
38
+ font-family: system-ui;
39
+ resize: none;
40
+ }
41
+ .inputbox {
42
+ color: #fff;
43
+ background: #000;
44
+ width: 20vw;
45
+ font-family: system-ui;
46
+ }
47
+ </style>
48
+ </head>
49
+ <body>
50
+ <button onclick="playSync()" style="font-size: 24px">同期再生</button>
51
+ <button onclick="stopAll()" style="display: none">停止</button>
52
+ <br />
53
+ <input
54
+ class="inputbox"
55
+ id="liveIDBox"
56
+ type="number"
57
+ inputmode="numeric"
58
+ required
59
+ min="1001"
60
+ max="9999"
61
+ value="1036"
62
+ />
63
+ <select id="codecSelectBox1" class="selectBox1" required>
64
+ </select>
65
+ <select id="rcSelectBox1" class="selectBox1" required>
66
+ </select>
67
+ <select id="bitrateSelectBox1" class="selectBox1" required>
68
+ </select>
69
+ <br />
70
+ <select id="codecSelectBox2" class="selectBox2" required>
71
+ </select>
72
+ <select id="rcSelectBox2" class="selectBox2" required>
73
+ </select>
74
+ <select id="bitrateSelectBox2" class="selectBox2" required>
75
+ </select>
76
+ <br />
77
+ <textarea id="textbox" style="height: 400px" readonly>
78
+ Logger出力はここに表示されます</textarea
79
+ >
80
+ <br />
81
+ <textarea id="urllistbox" style="height: 8em" readonly></textarea>
82
+ <script>
83
+ const FORMAT_LIST_JSON = {
84
+ "codecList": [
85
+ {"id": "flac", "label": "FLAC", "ext": "flac"},
86
+ {"id": "mp3", "label": "MP3", "ext": "mp3"},
87
+ {"id": "aac_lc", "label": "AAC-LC", "ext": "m4a"},
88
+ {"id": "aac_he_v1", "label": "HE-AAC v1", "ext": "m4a"},
89
+ {"id": "aac_he_v2", "label": "HE-AAC v2", "ext": "m4a"},
90
+ {"id": "ogg", "label": "Vorbis", "ext": "ogg"},
91
+ {"id": "opus", "label": "Opus", "ext": "opus"}
92
+ ],
93
+ "flac": {
94
+ "rcList": [
95
+ {"id": "vbr", "label": "VBR", "type": "k"}
96
+ ],
97
+ "vbr": [1411]
98
+ },
99
+ "mp3": {
100
+ "rcList": [
101
+ {"id": "vbr", "label": "VBR", "type": "q"},
102
+ {"id": "abr", "label": "ABR", "type": "k"},
103
+ {"id": "cbr", "label": "CBR", "type": "k"}
104
+ ],
105
+ "vbr": [
106
+ 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
107
+ ],
108
+ "abr": [
109
+ 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320
110
+ ],
111
+ "cbr": [
112
+ 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320
113
+ ]
114
+ },
115
+ "aac_lc": {
116
+ "rcList": [
117
+ {"id": "tvbr", "label": "VBR", "type": "q"},
118
+ {"id": "cvbr", "label": "CVBR", "type": "k"},
119
+ {"id": "abr", "label": "ABR", "type": "k"},
120
+ {"id": "cbr", "label": "CBR", "type": "k"},
121
+ ],
122
+ "tvbr": [
123
+ 0, 9, 18, 27, 36, 45, 54, 64, 73, 82, 91, 100, 109, 118, 127
124
+ ],
125
+ "cvbr": [
126
+ 64, 72, 80, 96, 112, 128, 144, 160, 192, 224, 256, 288, 320
127
+ ],
128
+ "abr": [
129
+ 64, 72, 80, 96, 112, 128, 144, 160, 192, 224, 256, 288, 320
130
+ ],
131
+ "cbr": [
132
+ 64, 72, 80, 96, 112, 128, 144, 160, 192, 224, 256, 288, 320
133
+ ]
134
+ },
135
+ "aac_he_v1": {
136
+ "rcList": [
137
+ {"id": "cvbr", "label": "CVBR", "type": "k"},
138
+ {"id": "abr", "label": "ABR", "type": "k"},
139
+ {"id": "cbr", "label": "CBR", "type": "k"}
140
+ ],
141
+ "cvbr": [
142
+ 32, 40, 48, 56, 64, 80
143
+ ],
144
+ "abr": [
145
+ 32, 40, 48, 56, 64, 80
146
+ ],
147
+ "cbr": [
148
+ 32, 40, 48, 56, 64, 80
149
+ ]
150
+ },
151
+ "aac_he_v2": {
152
+ "rcList": [
153
+ {"id": "vbr", "label": "VBR", "type": "q"},
154
+ {"id": "cbr", "label": "CBR", "type": "k"}
155
+ ],
156
+ "vbr": [
157
+ 1, 2, 3, 4, 5
158
+ ],
159
+ "cbr": [
160
+ 8, 16, 24, 32, 40, 48, 56, 64, 80
161
+ ]
162
+ },
163
+ "ogg": {
164
+ "rcList": [
165
+ {"id": "vbr", "label": "VBR", "type": "q"},
166
+ {"id": "abr", "label": "ABR", "type": "k"},
167
+ {"id": "cbr", "label": "CBR", "type": "k"}
168
+ ],
169
+ "vbr": [
170
+ -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
171
+ ],
172
+ "abr": [
173
+ 32, 40, 48, 56, 64, 72, 80, 96, 112, 128, 144, 160, 192, 224, 256, 288, 320
174
+ ],
175
+ "cbr": [
176
+ 32, 40, 48, 56, 64, 72, 80, 96, 112, 128, 144, 160, 192, 224, 256, 288, 320
177
+ ]
178
+ },
179
+ "opus": {
180
+ "rcList": [
181
+ {"id": "vbr", "label": "VBR", "type": "k"},
182
+ {"id": "cvbr", "label": "CVBR", "type": "k"},
183
+ {"id": "cbr", "label": "CBR", "type": "k"}
184
+ ],
185
+ "vbr": [
186
+ 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 96, 112, 128, 144, 160, 192, 224, 256, 288, 320
187
+ ],
188
+ "cvbr": [
189
+ 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 96, 112, 128, 144, 160, 192, 224, 256, 288, 320
190
+ ],
191
+ "cbr": [
192
+ 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 96, 112, 128, 144, 160, 192, 224, 256, 288, 320
193
+ ]
194
+ }
195
+ }
196
+ const DEFAULT_SELECTED = [
197
+ {
198
+ "codec": "flac",
199
+ "rc": "vbr",
200
+ "bitrate": 1411,
201
+ },
202
+ {
203
+ "codec": "mp3",
204
+ "rc": "abr",
205
+ "bitrate": 128,
206
+ }
207
+ ];
208
+
209
+ function logger(text) {
210
+ document.getElementById("textbox").value += "\r\n" + text; // 新しい行に文字列を追加する
211
+ }
212
+ // 以下のスクリプトはBing(ChatGPT)が生成したものに追記したものです。
213
+ // プロンプト:
214
+ // ある曲のカラオケバージョンの音源と、3人分のボーカルの音源があります。つまり、4つの音声ファイルがあります。これらのファイルを完全に同期して同時再生するコードを、Howler.jsを使用した上でHTMLとJavaScriptで書いてください。
215
+
216
+ var howls = [];
217
+ // 同期再生用の関数を定義
218
+ function playSync() {
219
+ stopAll();
220
+ var liveID = document.getElementById("liveIDBox").value;
221
+ var charaID = [
222
+ document.getElementById("charaIDBox1").value,
223
+ document.getElementById("charaIDBox2").value,
224
+ document.getElementById("charaIDBox3").value,
225
+ ];
226
+ var okeVol = document.getElementById("okeVolBox").value;
227
+ var charaVol1 = document.getElementById("charaVolBox1").value;
228
+ var charaVol2 = document.getElementById("charaVolBox2").value;
229
+ var charaPan = document.getElementById("charaPanBox").value;
230
+ // 音声ファイルのパスを配列に格納
231
+ var audioFiles = [
232
+ `https://cdn.jsdelivr.net/gh/daydreamer-json/umm_assets@main/sound/l/${liveID}/snd_bgm_live_${liveID}_oke_02/snd_bgm_live_${liveID}_oke_02_1.m4a`,
233
+ `https://cdn.jsdelivr.net/gh/daydreamer-json/umm_assets@main/sound/l/${liveID}/snd_bgm_live_${liveID}_chara_${charaID[0]}_01/snd_bgm_live_${liveID}_chara_${charaID[0]}_01_1.m4a`,
234
+ `https://cdn.jsdelivr.net/gh/daydreamer-json/umm_assets@main/sound/l/${liveID}/snd_bgm_live_${liveID}_chara_${charaID[1]}_01/snd_bgm_live_${liveID}_chara_${charaID[1]}_01_1.m4a`,
235
+ `https://cdn.jsdelivr.net/gh/daydreamer-json/umm_assets@main/sound/l/${liveID}/snd_bgm_live_${liveID}_chara_${charaID[2]}_01/snd_bgm_live_${liveID}_chara_${charaID[2]}_01_1.m4a`,
236
+ ];
237
+ logger("playSync関数が呼び出されました");
238
+ logger(`liveIDは${liveID}です`);
239
+ // logger(`liveIDのtext_dataは${master_db_text_data_search(16, liveID).text}です`);
240
+ for (let i = 0; i < charaID.length; i++) {
241
+ logger(`charaIDは${charaID[i]}です: id=${i + 1}`);
242
+ }
243
+ document.getElementById("urllistbox").value = "";
244
+ remote_file_head_test(audioFiles).then((statusList) => {
245
+ if (statusList.every((status) => status === 200)) {
246
+ for (let i = 0; i < statusList.length; i++) {
247
+ logger(`リモートファイルへHEADしました: id=${i}, status=${statusList[i]}`);
248
+ };
249
+ logger(`リモートファイルは正常です`);
250
+ // 配列の要素数だけ繰り返す
251
+ for (let i = 0; i < audioFiles.length; i++) {
252
+ // Howlオブジェクトを作成して配列に追加
253
+ howls[i] = new Howl({
254
+ src: audioFiles[i], // 音声ファイルのパス
255
+ preload: true, // 読み込み完了まで待つかどうか
256
+ autoplay: false, // 自動再生するかどうか
257
+ loop: true, // ループ再生するかどうか
258
+ });
259
+ logger(`Howlオブジェクトを作成しました: id=${i}`);
260
+ }
261
+ // 全ての音声ファイルが読み込まれたら実行する関数を設定
262
+ var loadedCount = 0; // 読み込まれた音声ファイルの数
263
+ var onLoad = function () {
264
+ loadedCount++; // 読み込まれた数を増やす
265
+ logger(
266
+ `音声ファイルがプリロードされました: id=${loadedCount - 1}`
267
+ );
268
+ document.getElementById("urllistbox").value +=
269
+ audioFiles[loadedCount - 1].match(/([^\/?#]+)(?=[^\/]*$)/)[0] +
270
+ "\r\n";
271
+ if (loadedCount == audioFiles.length) {
272
+ // 全て読み込まれたら
273
+ howls[0].volume(okeVol);
274
+ logger(
275
+ `Howlオブジェクトのvolumeを変更しました: id=0, value=${okeVol}`
276
+ );
277
+ for (let j = 2; j <= 3; j++) {
278
+ howls[j].volume(charaVol2); // ボーカルの音源3つ(インデックス1から3)の音量を設定(追加したコード)
279
+ logger(
280
+ `Howlオブジェクトのvolumeを変更しました: id=${j}, value=${charaVol2}`
281
+ );
282
+ }
283
+ howls[1].volume(charaVol1);
284
+ logger(
285
+ `Howlオブジェクトのvolumeを変更しました: id=1, value=${charaVol1}`
286
+ );
287
+ howls[2].stereo(0 - charaPan); // 特定のボーカルだけ左チャンネルに寄せる(追加したコード)
288
+ logger(
289
+ `Howlオブジェクトのstereoを変更しました: id=2, value=${
290
+ 0 - charaPan
291
+ }`
292
+ );
293
+ howls[3].stereo(charaPan); // 特定のボーカルだけ右チャンネルに寄せる(追加したコード)
294
+ logger(
295
+ `Howlオブジェクトのstereoを変更しました: id=3, value=${charaPan}`
296
+ );
297
+ for (let j = 0; j < howls.length; j++) {
298
+ // 配列の要素数だけ繰り返す
299
+ howls[j].play(); // 再生する(Howlオブジェクトは自動的に同期される)
300
+ logger(`Howlオブジェクトを再生しました: id=${j}`);
301
+ }
302
+ }
303
+ };
304
+ for (let k = 0; k < howls.length; k++) {
305
+ // 配列の要素数だけ繰り返す
306
+ howls[k].once("load", onLoad); // 読み込み完了時にonLoad関数を実行するように設定
307
+ }
308
+ } else {
309
+ for (let i = 0; i < statusList.length; i++) {
310
+ logger(`リモートファイルへHEADしました: id=${i}, status=${statusList[i]}`);
311
+ }
312
+ logger(`リモートファイルの一部に問題があります`);
313
+ }
314
+ });
315
+ }
316
+ // 再生停止用の関数を定義(追加したコード)
317
+ function stopAll() {
318
+ for (var n = 0; n < howls.length; n++) {
319
+ // 配列の要素数だけ繰り返す
320
+ howls[n].stop(); // 停止する
321
+ howls[n].unload();
322
+ }
323
+ document.getElementById("textbox").value =
324
+ "Logger出力はここに表示されます";
325
+ logger(`stopAll関数が呼び出されました`);
326
+ }
327
+ function master_db_text_data_search(categoryNumber, idNumber) {
328
+ fetch(
329
+ "https://cdn.jsdelivr.net/gh/daydreamer-json/umm_master_db@main/json/text_data.json"
330
+ )
331
+ .then((response) => response.json())
332
+ .then((data) => {
333
+ var master_db_text_data = data;
334
+ logger(`マスターデータベースを読み込みました`);
335
+ let categoryResult = master_db_text_data.filter(function (obj) {
336
+ return obj.category === categoryNumber;
337
+ });
338
+ let integratedResult = categoryResult.filter(function (obj) {
339
+ return obj.id === idNumber;
340
+ });
341
+ return integratedResult[0];
342
+ })
343
+ .catch((error) => {
344
+ console.error(error);
345
+ return null;
346
+ });
347
+ }
348
+ async function remote_file_head_test(audioFilesList) {
349
+ const promises = audioFilesList.map((url) =>
350
+ fetch(url, { method: "HEAD" })
351
+ );
352
+ const responses = await Promise.all(promises);
353
+ return responses.map((response) => response.status);
354
+ }
355
+ document.addEventListener('DOMContentLoaded',function() {
356
+ for (let i = 0; i < FORMAT_LIST_JSON.length; i++) {
357
+ var temp_codecSelectBox1 = document.getElementById('codecSelectBox1');
358
+ var temp_codecSelectBox1_inOption = document.createElement('option');
359
+ temp_codecSelectBox1_inOption.value = FORMAT_LIST_JSON.codecList[i].id;
360
+ temp_codecSelectBox1_inOption.text = FORMAT_LIST_JSON.codecList[i].label;
361
+ if (FORMAT_LIST_JSON.codecList[i].id === DEFAULT_SELECTED[0].codec) {
362
+ temp_codecSelectBox1_inOption.selected = true;
363
+ }
364
+ temp_codecSelectBox1.appendChild(temp_codecSelectBox1_inOption);
365
+ }
366
+ for (let i = 0; i < FORMAT_LIST_JSON.length; i++) {
367
+ var temp_codecSelectBox2 = document.getElementById('codecSelectBox2');
368
+ var temp_codecSelectBox2_inOption = document.createElement('option');
369
+ temp_codecSelectBox2_inOption.value = FORMAT_LIST_JSON.codecList[i].id;
370
+ temp_codecSelectBox2_inOption.text = FORMAT_LIST_JSON.codecList[i].label;
371
+ if (FORMAT_LIST_JSON.codecList[i].id === DEFAULT_SELECTED[1].codec) {
372
+ temp_codecSelectBox2_inOption.selected = true;
373
+ }
374
+ temp_codecSelectBox2.appendChild(temp_codecSelectBox2_inOption);
375
+ }
376
+ });
377
+ function refreshRcSelectBox() {
378
+ var temp_codecSelectBox1_selected_index = document.getElementById('codecSelectBox1').selectedIndex;
379
+ var temp_codecSelectBox2_selected_index = document.getElementById('codecSelectBox2').selectedIndex;
380
+ var temp_codecSelectBox1_selected_option = document.getElementById('codecSelectBox1').options[temp_codecSelectBox1_selected_index];
381
+ var temp_codecSelectBox2_selected_option = document.getElementById('codecSelectBox2').options[temp_codecSelectBox2_selected_index];
382
+ for (let i = 0; i < FORMAT_LIST_JSON[temp_codecSelectBox1_selected_option.value].rcList.length; i++) {
383
+ var temp_rcSelectBox1 = document.getElementById('rcSelectBox1');
384
+ var temp_rcSelectBox1_inOption = document.createElement('option');
385
+ temp_rcSelectBox1_inOption.value = FORMAT_LIST_JSON[temp_codecSelectBox1_selected_option.value].rcList[i].id;
386
+ temp_rcSelectBox1_inOption.text = FORMAT_LIST_JSON[temp_codecSelectBox1_selected_option.value].rcList[i].label;
387
+ if (FORMAT_LIST_JSON[temp_codecSelectBox1_selected_option.value].rcList[i].id === DEFAULT_SELECTED[0].rc) {
388
+ temp_rcSelectBox1_inOption.selected = true;
389
+ }
390
+ temp_rcSelectBox1.appendChild(temp_rcSelectBox1_inOption);
391
+ }
392
+ for (let i = 0; i < FORMAT_LIST_JSON[temp_codecSelectBox2_selected_option.value].rcList.length; i++) {
393
+ var temp_rcSelectBox2 = document.getElementById('rcSelectBox2');
394
+ var temp_rcSelectBox2_inOption = document.createElement('option');
395
+ temp_rcSelectBox2_inOption.value = FORMAT_LIST_JSON[temp_codecSelectBox2_selected_option.value].rcList[i].id;
396
+ temp_rcSelectBox2_inOption.text = FORMAT_LIST_JSON[temp_codecSelectBox2_selected_option.value].rcList[i].label;
397
+ if (FORMAT_LIST_JSON[temp_codecSelectBox2_selected_option.value].rcList[i].id === DEFAULT_SELECTED[1].rc) {
398
+ temp_rcSelectBox2_inOption.selected = true;
399
+ }
400
+ temp_rcSelectBox2.appendChild(temp_rcSelectBox2_inOption);
401
+ }
402
+ }
403
+ </script>
404
+ </body>
405
+ </html>