@mfcc64/ytms 9.0.0 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/script.mjs +102 -32
package/package.json
CHANGED
package/script.mjs
CHANGED
|
@@ -37,6 +37,9 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
|
|
|
37
37
|
mic_pan: { def: 0, min:-10, max: 10 },
|
|
38
38
|
scale_x: { def:100, min: 30, max:100 },
|
|
39
39
|
scale_y: { def:100, min: 30, max:100 },
|
|
40
|
+
left_color: { def:0xdcb900, min:0, max:0xffffff },
|
|
41
|
+
right_color:{ def:0x00b9dc, min:0, max:0xffffff },
|
|
42
|
+
mid_color: { def:0xdcdcdc, min:0, max:0xffffff },
|
|
40
43
|
interval: { def: 1, min: 1, max: 4 },
|
|
41
44
|
codecs: { def: 1, min: 0, max: 2 },
|
|
42
45
|
transparent:{ def: 1, min: 0, max: 1 },
|
|
@@ -102,7 +105,7 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
|
|
|
102
105
|
<li>If you want to change the axis, click it.</li>
|
|
103
106
|
<li>If you want to make your change persistent, click <b>Set as Default Settings</b> button.</li>
|
|
104
107
|
<li><b>New Features:</b> Hz-scale axis, microphone support, YT Music support, scale options to
|
|
105
|
-
reduce CPU usage.</li>
|
|
108
|
+
reduce CPU usage, custom color.</li>
|
|
106
109
|
<li><a href="https://github.com/mfcc64/youtube-musical-spectrum#settings" target="_blank">Read more...</a></li>
|
|
107
110
|
</ul>
|
|
108
111
|
<p>
|
|
@@ -121,7 +124,7 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
|
|
|
121
124
|
</div>`;
|
|
122
125
|
setTimeout(() => af_links.style.opacity = "", 15000);
|
|
123
126
|
|
|
124
|
-
const message_version =
|
|
127
|
+
const message_version = 7;
|
|
125
128
|
af_links.shadowRoot.getElementById("message").style.display = get_opt("message_version") == message_version ? "none" : "block";
|
|
126
129
|
af_links.shadowRoot.getElementById("close_message").addEventListener("click", function() {
|
|
127
130
|
set_opt("message_version", message_version);
|
|
@@ -224,20 +227,15 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
|
|
|
224
227
|
menu_div.style.cursor = "default";
|
|
225
228
|
|
|
226
229
|
var current_tr = null;
|
|
230
|
+
var current_tr_count = 0;
|
|
227
231
|
|
|
228
232
|
function get_menu_table_tr() {
|
|
229
|
-
if (current_tr)
|
|
230
|
-
return current_tr;
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if (current_tr) {
|
|
236
|
-
current_tr = null;
|
|
237
|
-
} else {
|
|
238
|
-
menu_table.appendChild(tr);
|
|
239
|
-
current_tr = tr;
|
|
240
|
-
}
|
|
233
|
+
if (current_tr && current_tr_count < 3)
|
|
234
|
+
return current_tr_count++, current_tr;
|
|
235
|
+
current_tr_count = 1;
|
|
236
|
+
current_tr = document.createElement("tr");
|
|
237
|
+
menu_table.appendChild(current_tr);
|
|
238
|
+
return current_tr;
|
|
241
239
|
}
|
|
242
240
|
|
|
243
241
|
function set_common_tr_style(tr) {
|
|
@@ -257,9 +255,12 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
|
|
|
257
255
|
td.textContent = title;
|
|
258
256
|
tr.appendChild(td);
|
|
259
257
|
td = document.createElement("td");
|
|
258
|
+
td.style.width = "120px";
|
|
259
|
+
td.colSpan = 2;
|
|
260
260
|
var child = child_menu[name] = document.createElement("input");
|
|
261
261
|
var child_text = document.createElement("td");
|
|
262
262
|
child.style.cursor = "pointer";
|
|
263
|
+
child.style.width = "100%";
|
|
263
264
|
child.type = "range";
|
|
264
265
|
child.min = defaults[name].min;
|
|
265
266
|
child.max = defaults[name].max;
|
|
@@ -279,7 +280,6 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
|
|
|
279
280
|
child_text.style.textAlign = "right";
|
|
280
281
|
child_text.style.width = "32px";
|
|
281
282
|
child.onchange();
|
|
282
|
-
append_menu_table_tr(tr);
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
const mic = { };
|
|
@@ -323,9 +323,77 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
|
|
|
323
323
|
}
|
|
324
324
|
});
|
|
325
325
|
create_child_range_menu("Mic Pan", "mic_pan", (child) => mic.pan.pan.value = child.value / 10);
|
|
326
|
+
create_child_range_menu("Interval", "interval", (child) => cqt.dataset.interval = child.value);
|
|
326
327
|
create_child_range_menu("Scale X", "scale_x", (child) => cqt.dataset.scaleX = child.value);
|
|
327
328
|
create_child_range_menu("Scale Y", "scale_y", (child) => cqt.dataset.scaleY = child.value);
|
|
328
|
-
|
|
329
|
+
create_child_select_codecs();
|
|
330
|
+
|
|
331
|
+
const number2color = n => "#" + (n|0).toString(16).padStart(6, "0");
|
|
332
|
+
const color2number = c => Number.parseInt(c.slice(1), 16);
|
|
333
|
+
const color_int = [ 0, 0, 0 ];
|
|
334
|
+
const color_table = new Array(9);
|
|
335
|
+
|
|
336
|
+
function create_child_color_menu(title, name, callback) {
|
|
337
|
+
var tr = get_menu_table_tr();
|
|
338
|
+
set_common_tr_style(tr);
|
|
339
|
+
var td = document.createElement("td");
|
|
340
|
+
set_common_left_td_style(td);
|
|
341
|
+
td.textContent = title;
|
|
342
|
+
tr.appendChild(td);
|
|
343
|
+
td = document.createElement("td");
|
|
344
|
+
td.style.width = "80px";
|
|
345
|
+
var child_text = document.createElement("td");
|
|
346
|
+
child_text.style.textAlign = "right";
|
|
347
|
+
child_text.colSpan = 2;
|
|
348
|
+
var child = child_menu[name] = document.createElement("input");
|
|
349
|
+
child.style.cursor = "pointer";
|
|
350
|
+
child.style.width = "100%";
|
|
351
|
+
child.type = "color";
|
|
352
|
+
child.value = number2color(get_opt(name));
|
|
353
|
+
child.onchange = function() {
|
|
354
|
+
child_text.textContent = child.value;
|
|
355
|
+
child.textContent = child.value;
|
|
356
|
+
callback?.(child);
|
|
357
|
+
update_color_table();
|
|
358
|
+
};
|
|
359
|
+
child.oninput = child.onchange;
|
|
360
|
+
td.appendChild(child);
|
|
361
|
+
tr.appendChild(td);
|
|
362
|
+
tr.appendChild(child_text);
|
|
363
|
+
child.onchange();
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function update_color_table() {
|
|
367
|
+
const k = 0xb9/0xdc;
|
|
368
|
+
const color_tmp = new Array(9);
|
|
369
|
+
for (let x = 0; x < 3; x++) {
|
|
370
|
+
color_tmp[3*x] = ((color_int[x] >> 16) & 0xff) / 0xdc;
|
|
371
|
+
color_tmp[3*x+1] = ((color_int[x] >> 8) & 0xff) / 0xdc;
|
|
372
|
+
color_tmp[3*x+2] = (color_int[x] & 0xff) / 0xdc;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
for (let x = 0; x < 3; x++) {
|
|
376
|
+
color_table[3+x] = (color_tmp[0+x] + color_tmp[6+x] - color_tmp[3+x]) / (2 * k - 1);
|
|
377
|
+
color_table[0+x] = color_tmp[0+x] - k * color_table[3+x];
|
|
378
|
+
color_table[6+x] = color_tmp[6+x] - k * color_table[3+x];
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
create_child_color_menu("Left Color", "left_color", child => color_int[0] = color2number(child.value));
|
|
383
|
+
create_child_color_menu("Mid Color", "mid_color", child => color_int[1] = color2number(child.value));
|
|
384
|
+
create_child_color_menu("Right Color", "right_color", child => color_int[2] = color2number(child.value));
|
|
385
|
+
|
|
386
|
+
cqt.actual_render_callback = function(color) {
|
|
387
|
+
if (color_int[0] == 0xdcb900 && color_int[1] == 0xdcdcdc && color_int[2] == 0x00b9dc)
|
|
388
|
+
return;
|
|
389
|
+
|
|
390
|
+
for (let x = 0; x < color.length; x += 4) {
|
|
391
|
+
const left = color[x], mid = color[x+1], right = color[x+2];
|
|
392
|
+
color[x ] = color_table[0] * left + color_table[3] * mid + color_table[6] * right;
|
|
393
|
+
color[x+1] = color_table[1] * left + color_table[4] * mid + color_table[7] * right;
|
|
394
|
+
color[x+2] = color_table[2] * left + color_table[5] * mid + color_table[8] * right;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
329
397
|
|
|
330
398
|
function create_child_select_codecs() {
|
|
331
399
|
var tr = get_menu_table_tr();
|
|
@@ -338,6 +406,7 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
|
|
|
338
406
|
td.colSpan = 2;
|
|
339
407
|
var child = child_menu["codecs"] = document.createElement("select");
|
|
340
408
|
child.style.cursor = "pointer";
|
|
409
|
+
child.style.width = "100%";
|
|
341
410
|
var select_opt = [ "All", "Block AV1", "Only H.264" ];
|
|
342
411
|
for (var k = 0; k < select_opt.length; k++) {
|
|
343
412
|
var opt = document.createElement("option");
|
|
@@ -348,7 +417,7 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
|
|
|
348
417
|
child.value = get_opt("codecs");
|
|
349
418
|
td.appendChild(child);
|
|
350
419
|
tr.appendChild(td);
|
|
351
|
-
|
|
420
|
+
tr.appendChild(document.createElement("td"));
|
|
352
421
|
child.onchange = function() {};
|
|
353
422
|
const old_func = MediaSource.isTypeSupported;
|
|
354
423
|
MediaSource.isTypeSupported = function (mime_type) {
|
|
@@ -367,9 +436,6 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
|
|
|
367
436
|
return old_func.call(this, mime_type);
|
|
368
437
|
}
|
|
369
438
|
}
|
|
370
|
-
create_child_select_codecs();
|
|
371
|
-
|
|
372
|
-
current_tr = null;
|
|
373
439
|
|
|
374
440
|
function create_child_checkbox_menu(title, name, callback) {
|
|
375
441
|
var tr = get_menu_table_tr();
|
|
@@ -379,7 +445,7 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
|
|
|
379
445
|
td.textContent = title;
|
|
380
446
|
tr.appendChild(td);
|
|
381
447
|
td = document.createElement("td");
|
|
382
|
-
td.colSpan =
|
|
448
|
+
td.colSpan = 3;
|
|
383
449
|
var child = child_menu[name] = document.createElement("input");
|
|
384
450
|
child.style.cursor = "pointer";
|
|
385
451
|
child.type = "checkbox";
|
|
@@ -391,40 +457,42 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
|
|
|
391
457
|
child.onchange();
|
|
392
458
|
td.appendChild(child);
|
|
393
459
|
tr.appendChild(td);
|
|
394
|
-
append_menu_table_tr(tr);
|
|
395
460
|
}
|
|
396
461
|
|
|
397
462
|
create_child_checkbox_menu("Transparent", "transparent", (child) => cqt.dataset.opacity = child.checked ? "transparent" : "opaque");
|
|
398
|
-
|
|
399
463
|
create_child_checkbox_menu("Visible", "visible", (child) => af_links.style.display = cqt.style.display = child.checked ? "block" : "none");
|
|
400
464
|
|
|
401
465
|
current_tr = null;
|
|
466
|
+
set_common_tr_style(get_menu_table_tr());
|
|
467
|
+
current_tr = null;
|
|
468
|
+
|
|
469
|
+
var child_buttons_td = document.createElement("td");
|
|
470
|
+
child_buttons_td.colSpan = 4 * 3;
|
|
471
|
+
child_buttons_td.style.textAlign = "right";
|
|
472
|
+
get_menu_table_tr().appendChild(child_buttons_td);
|
|
402
473
|
|
|
403
474
|
function create_child_button_menu(title, callback) {
|
|
404
|
-
var tr = get_menu_table_tr();
|
|
405
|
-
//set_common_tr_style(tr);
|
|
406
|
-
var td = document.createElement("td");
|
|
407
|
-
set_common_left_td_style(td);
|
|
408
|
-
td.colSpan = 3;
|
|
409
475
|
var child = document.createElement("input");
|
|
410
476
|
child.type = "button";
|
|
411
477
|
child.value = title;
|
|
412
478
|
child.style.cursor = "pointer";
|
|
413
479
|
child.style.fontFamily = "inherit";
|
|
414
480
|
child.style.fontSize = "inherit";
|
|
481
|
+
child.style.marginLeft = "8px";
|
|
482
|
+
child.style.width = "180px";
|
|
415
483
|
child.onclick = function() {
|
|
416
484
|
if (callback)
|
|
417
485
|
callback(child);
|
|
418
486
|
};
|
|
419
|
-
|
|
420
|
-
tr.appendChild(td);
|
|
421
|
-
append_menu_table_tr(tr);
|
|
487
|
+
child_buttons_td.appendChild(child);
|
|
422
488
|
}
|
|
423
489
|
|
|
424
490
|
create_child_button_menu("Reset Settings", function() {
|
|
425
491
|
for (const name in child_menu) {
|
|
426
492
|
if (child_menu[name].type == "checkbox")
|
|
427
493
|
child_menu[name].checked = get_opt(name) * 1;
|
|
494
|
+
else if(child_menu[name].type == "color")
|
|
495
|
+
child_menu[name].value = number2color(get_opt(name));
|
|
428
496
|
else
|
|
429
497
|
child_menu[name].value = get_opt(name);
|
|
430
498
|
child_menu[name].onchange();
|
|
@@ -435,7 +503,9 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
|
|
|
435
503
|
child.value = "Saving...";
|
|
436
504
|
for (const name in child_menu) {
|
|
437
505
|
if (child_menu[name].type == "checkbox")
|
|
438
|
-
set_opt(name, child_menu[name].checked)
|
|
506
|
+
set_opt(name, child_menu[name].checked);
|
|
507
|
+
else if (child_menu[name].type == "color")
|
|
508
|
+
set_opt(name, color2number(child_menu[name].value));
|
|
439
509
|
else
|
|
440
510
|
set_opt(name, child_menu[name].value);
|
|
441
511
|
}
|