@mfcc64/ytms 17.0.0 → 18.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/script.mjs +22 -20
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mfcc64/ytms",
3
- "version": "17.0.0",
3
+ "version": "18.0.0",
4
4
  "description": "YouTube Musical Spectrum",
5
5
  "main": "script.mjs",
6
6
  "scripts": {
package/script.mjs CHANGED
@@ -34,23 +34,24 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
34
34
  speed: { def: 2, min: 1, max: 12 },
35
35
  mic: { def: 0, min: 0, max: 30 },
36
36
  mic_pan: { def: 0, min:-10, max: 10 },
37
+ interval: { def: 1, min: 1, max: 4 },
37
38
  scale_x: { def:100, min: 30, max:100 },
38
39
  scale_y: { def:100, min: 30, max:100 },
40
+ bar_scale: { def: 0, min: 0, max: 4 },
39
41
  base_note: { def: 16, min: 16, max:100 },
40
42
  semitones: { def:120, min: 36, max:120 },
41
- peak_color: { def:0xffffff, min:0, max:0xffffff },
43
+ scroll: { def: 0, min: 0, max: 1 },
42
44
  left_color: { def:0xdcb900, min:0, max:0xffffff },
43
- right_color:{ def:0x00b9dc, min:0, max:0xffffff },
44
45
  mid_color: { def:0xdcdcdc, min:0, max:0xffffff },
46
+ right_color:{ def:0x00b9dc, min:0, max:0xffffff },
45
47
  saturation: { def: 0, min: 0, max: 30 },
46
48
  hue: { def: 0, min:-18, max: 19 },
47
49
  hue_range: { def: 18, min:-36, max: 36 },
48
- interval: { def: 1, min: 1, max: 4 },
49
- bar_scale: { def: 0, min: 0, max: 4 },
50
50
  line_mode: { def: 0, min: 0, max: 4 },
51
51
  line_width: { def: 1, min: 1, max: 3 },
52
52
  line_color: { def:0xffffff, min:0, max:0xffffff },
53
- scroll: { def: 0, min: 0, max: 1 },
53
+ peak_range: { def: 72, min: 0, max:120 },
54
+ peak_color: { def:0xffffff, min:0, max:0xffffff },
54
55
  coord_color:{ def:0x000000, min:0, max:0xffffff },
55
56
  transparent:{ def: 1, min: 0, max: 1 },
56
57
  visible: { def: document.location.hostname != "www.youtube.com" ? 1 : 0,
@@ -126,7 +127,7 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
126
127
  e("li", "If you want to change the axis, click it."),
127
128
  e("li", "If you want to make your change persistent, click ", e("b", "Set as Default Settings"), " button."),
128
129
  e("li", e("b", "New Features:"), " Custom color, custom range," +
129
- " peak color, bar scale, line visualizer, hue rotation, more color presets, horizontal scroll, coordinate line."),
130
+ " peak color, bar scale, line visualizer, hue rotation, more color presets, horizontal scroll, coordinate line, peak range."),
130
131
  e("li", e("a", {href: "https://github.com/mfcc64/youtube-musical-spectrum#settings"}, {target: "_blank"}, "Read more..."))
131
132
  ),
132
133
  e("p",
@@ -156,7 +157,7 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
156
157
  af_links.style.display = !af_links_timeout || (child_menu.visible?.checked ?? true) ? "block" : "none";
157
158
  }
158
159
 
159
- const message_version = 13;
160
+ const message_version = 14;
160
161
  af_links.shadowRoot.getElementById("message").style.display = get_opt("message_version") == message_version ? "none" : "block";
161
162
  af_links.shadowRoot.getElementById("close_message").addEventListener("click", function() {
162
163
  set_opt("message_version", message_version);
@@ -614,19 +615,18 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
614
615
  child.onchange();
615
616
  }
616
617
 
617
- create_child_color_menu("Peak Color", "peak_color", child => color_int[3] = color2number(child.value));
618
+ create_child_select_menu("Scroll", "scroll", [ "Vertical", "Horizontal" ], update_cqt_layout);
618
619
 
619
620
  function detect_peak(color) {
620
621
  if (color_int[3] == 0xffffff)
621
622
  return;
622
623
 
623
- for (let k = 4; k < color.length - 4; k += 4) {
624
+ const range = child_menu.peak_range.value / 120 * color.length;
625
+ for (let k = 4; k + 2 < range && k < color.length - 4; k += 4) {
624
626
  if (color[k+3] <= color[k-1] || color[k+3] < color[k+7])
625
627
  continue;
626
628
 
627
- const alpha = (1 - (k+2) / color.length) ** 2 - 0.16;
628
- if (alpha <= 0)
629
- break;
629
+ const alpha = Math.cos(0.5 * Math.PI * (k+2) / range) ** 2;
630
630
 
631
631
  for (let m = 0; m < 3; m++)
632
632
  color[k+m] = Math.min(color[k+m], 1) * (1 - alpha + peak_color[m] * alpha);
@@ -794,14 +794,8 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
794
794
  tr.appendChild(td);
795
795
  }
796
796
 
797
- create_child_select_menu("Scroll", "scroll", [ "Vertical", "Horizontal" ], update_cqt_layout);
798
- create_child_checkbox_menu("Transparent", "transparent", (child) => cqt.dataset.opacity = child.checked ? "transparent" : "opaque");
799
- create_child_checkbox_menu("Visible", "visible", (child) => {
800
- cqt.style.display = child.checked ? "block" : "none";
801
- if (!child.checked)
802
- coord_line_h.style.display = coord_line_v.style.display = "none";
803
- update_af_links();
804
- });
797
+ create_child_range_menu("Peak Range", "peak_range");
798
+ create_child_color_menu("Peak Color", "peak_color", child => color_int[3] = color2number(child.value));
805
799
 
806
800
  function cqt_coord_line_leave(ev) {
807
801
  coord_line_h.style.display = coord_line_v.style.display = "none";
@@ -825,6 +819,14 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
825
819
  }
826
820
  });
827
821
 
822
+ create_child_checkbox_menu("Transparent", "transparent", (child) => cqt.dataset.opacity = child.checked ? "transparent" : "opaque");
823
+ create_child_checkbox_menu("Visible", "visible", (child) => {
824
+ cqt.style.display = child.checked ? "block" : "none";
825
+ if (!child.checked)
826
+ coord_line_h.style.display = coord_line_v.style.display = "none";
827
+ update_af_links();
828
+ });
829
+
828
830
  function create_child_select_presets() {
829
831
  const presets = [
830
832
  { title: "-- Choose Preset --" },