@mfcc64/ytms 11.0.2 → 12.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 +52 -4
package/package.json
CHANGED
package/script.mjs
CHANGED
|
@@ -37,6 +37,9 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
|
|
|
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
|
+
base_note: { def: 16, min: 16, max:100 },
|
|
41
|
+
semitones: { def:120, min: 36, max:120 },
|
|
42
|
+
peak_color: { def:0xffffff, min:0, max:0xffffff },
|
|
40
43
|
left_color: { def:0xdcb900, min:0, max:0xffffff },
|
|
41
44
|
right_color:{ def:0x00b9dc, min:0, max:0xffffff },
|
|
42
45
|
mid_color: { def:0xdcdcdc, min:0, max:0xffffff },
|
|
@@ -116,7 +119,7 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
|
|
|
116
119
|
e("li", "If you want to change the axis, click it."),
|
|
117
120
|
e("li", "If you want to make your change persistent, click ", e("b", "Set as Default Settings"), " button."),
|
|
118
121
|
e("li", e("b", "New Features:"), " Hz-scale axis, microphone support, YT Music support, scale options to " +
|
|
119
|
-
"reduce CPU usage, custom color."),
|
|
122
|
+
"reduce CPU usage, custom color, custom range, peak color."),
|
|
120
123
|
e("li", e("a", {href: "https://github.com/mfcc64/youtube-musical-spectrum#settings"}, {target: "_blank"}, "Read more..."))
|
|
121
124
|
),
|
|
122
125
|
e("p",
|
|
@@ -147,7 +150,7 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
|
|
|
147
150
|
af_links.style.display = !af_links_timeout || (child_menu.visible?.checked ?? true) ? "block" : "none";
|
|
148
151
|
}
|
|
149
152
|
|
|
150
|
-
const message_version =
|
|
153
|
+
const message_version = 9;
|
|
151
154
|
af_links.shadowRoot.getElementById("message").style.display = get_opt("message_version") == message_version ? "none" : "block";
|
|
152
155
|
af_links.shadowRoot.getElementById("close_message").addEventListener("click", function() {
|
|
153
156
|
set_opt("message_version", message_version);
|
|
@@ -351,10 +354,30 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
|
|
|
351
354
|
create_child_range_menu("Scale Y", "scale_y", (child) => cqt.dataset.scaleY = child.value);
|
|
352
355
|
create_child_select_codecs();
|
|
353
356
|
|
|
357
|
+
function update_range(child) {
|
|
358
|
+
if (!child_menu.base_note || !child_menu.semitones)
|
|
359
|
+
return;
|
|
360
|
+
|
|
361
|
+
const width = child_menu.semitones.value * 1;
|
|
362
|
+
const base = child_menu.base_note.value - 16;
|
|
363
|
+
if (base + width > 120) {
|
|
364
|
+
child == child_menu.semitones ?
|
|
365
|
+
(child_menu.base_note.value = 120 - width + 16, child_menu.base_note.onchange()) :
|
|
366
|
+
(child_menu.semitones.value = 120 - base, child_menu.semitones.onchange());
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
cqt.style.left = -base / width * 100 + "%";
|
|
370
|
+
cqt.style.width = 12000 / width + "%";
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
create_child_range_menu("Base Note", "base_note", child => update_range(child));
|
|
374
|
+
create_child_range_menu("Semitones", "semitones", child => update_range(child));
|
|
375
|
+
|
|
354
376
|
const number2color = n => "#" + (n|0).toString(16).padStart(6, "0");
|
|
355
377
|
const color2number = c => Number.parseInt(c.slice(1), 16);
|
|
356
|
-
const color_int = [ 0, 0, 0 ];
|
|
378
|
+
const color_int = [ 0, 0, 0, 0 ];
|
|
357
379
|
const color_table = new Array(9);
|
|
380
|
+
const peak_color = new Array(3);
|
|
358
381
|
|
|
359
382
|
function create_child_color_menu(title, name, callback) {
|
|
360
383
|
var tr = get_menu_table_tr();
|
|
@@ -386,6 +409,22 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
|
|
|
386
409
|
child.onchange();
|
|
387
410
|
}
|
|
388
411
|
|
|
412
|
+
create_child_color_menu("Peak Color", "peak_color", child => color_int[3] = color2number(child.value));
|
|
413
|
+
|
|
414
|
+
function detect_peak(color) {
|
|
415
|
+
if (color_int[3] == 0xffffff)
|
|
416
|
+
return;
|
|
417
|
+
|
|
418
|
+
for (let k = 4; k < color.length - 4; k += 4) {
|
|
419
|
+
if (color[k+3] <= color[k-1] || color[k+3] < color[k+7])
|
|
420
|
+
continue;
|
|
421
|
+
|
|
422
|
+
const alpha = (1 - (k+2) / color.length) ** 2;
|
|
423
|
+
for (let m = 0; m < 3; m++)
|
|
424
|
+
color[k+m] = Math.min(color[k+m], 1) * (1 - alpha + peak_color[m] * alpha);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
389
428
|
function update_color_table() {
|
|
390
429
|
const k = 0xb9/0xdc;
|
|
391
430
|
const color_tmp = new Array(9);
|
|
@@ -400,13 +439,17 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
|
|
|
400
439
|
color_table[0+x] = color_tmp[0+x] - k * color_table[3+x];
|
|
401
440
|
color_table[6+x] = color_tmp[6+x] - k * color_table[3+x];
|
|
402
441
|
}
|
|
442
|
+
|
|
443
|
+
peak_color[0] = ((color_int[3] >> 16) & 0xff) / 0xff;
|
|
444
|
+
peak_color[1] = ((color_int[3] >> 8) & 0xff) / 0xff;
|
|
445
|
+
peak_color[2] = (color_int[3] & 0xff) / 0xff;
|
|
403
446
|
}
|
|
404
447
|
|
|
405
448
|
create_child_color_menu("Left Color", "left_color", child => color_int[0] = color2number(child.value));
|
|
406
449
|
create_child_color_menu("Mid Color", "mid_color", child => color_int[1] = color2number(child.value));
|
|
407
450
|
create_child_color_menu("Right Color", "right_color", child => color_int[2] = color2number(child.value));
|
|
408
451
|
|
|
409
|
-
|
|
452
|
+
function transform_color(color) {
|
|
410
453
|
if (color_int[0] == 0xdcb900 && color_int[1] == 0xdcdcdc && color_int[2] == 0x00b9dc)
|
|
411
454
|
return;
|
|
412
455
|
|
|
@@ -418,6 +461,11 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
|
|
|
418
461
|
}
|
|
419
462
|
}
|
|
420
463
|
|
|
464
|
+
cqt.actual_render_callback = function(color) {
|
|
465
|
+
transform_color(color);
|
|
466
|
+
detect_peak(color);
|
|
467
|
+
}
|
|
468
|
+
|
|
421
469
|
function create_child_select_codecs() {
|
|
422
470
|
var tr = get_menu_table_tr();
|
|
423
471
|
set_common_tr_style(tr);
|