@fretfall/player 0.0.1
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/LICENSE +21 -0
- package/README.md +72 -0
- package/demo.atex +113 -0
- package/favicon.svg +6 -0
- package/fingering.js +1 -0
- package/highway.js +1 -0
- package/index.html +883 -0
- package/music.js +1 -0
- package/package.json +24 -0
- package/perf.js +2 -0
- package/player.js +1 -0
- package/sync.js +1 -0
- package/themes.js +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Angelo Dini
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Fretfall Player
|
|
2
|
+
|
|
3
|
+
An arcade-style note highway for Guitar Pro and MusicXML tabs, in the browser.
|
|
4
|
+
|
|
5
|
+
[](https://github.com/FinalAngel/fretfall-player/actions/workflows/ci.yml)
|
|
6
|
+
[](https://github.com/FinalAngel/fretfall-player/actions/workflows/perf.yml)
|
|
7
|
+
[](https://www.npmjs.com/package/@fretfall/player)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
|
|
10
|
+
Open a tab and play along: the notes fall down a 3D fretboard, with hand positions and fingering worked out for you. Add the
|
|
11
|
+
band's recording and the player lines the tab up with it on its own.
|
|
12
|
+
|
|
13
|
+
- **Formats**: `.gp`, `.gp3`–`.gp5`, `.gpx`, `.musicxml`, `.mxl`, plus `.mp3`, `.m4a`, `.ogg`, `.wav`, `.flac` recordings
|
|
14
|
+
- **Practice**: phrase loops, speed control with a speed trainer, metronome, 3D highway or 2D tab
|
|
15
|
+
- **Band**: every part in a window of its own, all in time
|
|
16
|
+
- **Lean**: plain HTML and ES modules, no framework, no runtime dependencies, about 58 kB gzipped
|
|
17
|
+
|
|
18
|
+
## Quick start
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
npm install @fretfall/player
|
|
22
|
+
npx serve node_modules/@fretfall/player
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Any static file server works. Tabs are read and played by [alphaTab](https://www.alphatab.net), loaded from jsDelivr.
|
|
26
|
+
|
|
27
|
+
## Build on it
|
|
28
|
+
|
|
29
|
+
Serve the package's files and add your own page around it. The player exposes `window.fretfall` once it dispatches
|
|
30
|
+
`fretfall:ready`:
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
if (!window.fretfall) await new Promise((ready) => addEventListener('fretfall:ready', ready, { once: true }));
|
|
34
|
+
|
|
35
|
+
addEventListener('fretfall:song', (e) => console.log(e.detail.title, e.detail.parts));
|
|
36
|
+
await fretfall.open(files, { audio: recording }); // File[] from an input or a drop
|
|
37
|
+
fretfall.part = 1;
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
| Member | |
|
|
41
|
+
|:--|:--|
|
|
42
|
+
| `open(files, options)` / `pick()` | Open songs, or show the file dialog |
|
|
43
|
+
| `playing`, `time`, `length` | Where playback is, in seconds |
|
|
44
|
+
| `parts`, `part` | The song's parts, and the one shown (settable) |
|
|
45
|
+
| `addFormat({ name, extensions, open })` | Read another file type: `open(file)` resolves to `{ song, audio }` |
|
|
46
|
+
| `closeSheets()` | Close Settings and the notation sheet |
|
|
47
|
+
|
|
48
|
+
Events on `window`: `fretfall:ready`, `fretfall:song`, `fretfall:playing`, `fretfall:sheet`. The modules import on their own
|
|
49
|
+
too, for example `music.js` for tunings and note names.
|
|
50
|
+
|
|
51
|
+
Keys: <kbd>Space</kbd> play · <kbd>L</kbd> loop · <kbd>O</kbd> open · <kbd>D</kbd> 2D tab · <kbd>K</kbd> metronome ·
|
|
52
|
+
<kbd>F</kbd> full screen · <kbd>S</kbd> settings · <kbd>?</kbd> everything else. Add `?perf` to the URL for a frame profiler.
|
|
53
|
+
|
|
54
|
+
## Develop
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
npm ci
|
|
58
|
+
npm test # node --test
|
|
59
|
+
npm run lint # oxlint: correctness and performance rules
|
|
60
|
+
npm run build # dist/, the published package
|
|
61
|
+
npm run bench # frame time, draw calls, sync and size of dist/
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
No pull request may make the player slower or bigger. CI builds it and the base branch, benchmarks both in turns on the same
|
|
65
|
+
runner, and fails on more than 10% frame or sync time, 5% draw calls or 1% gzipped size. A regression taken on purpose
|
|
66
|
+
passes with the `perf-ok` label.
|
|
67
|
+
|
|
68
|
+
Releases: bump `version`, publish a GitHub release tagged `v<version>`, and CI publishes to npm with provenance.
|
|
69
|
+
|
|
70
|
+
## License
|
|
71
|
+
|
|
72
|
+
[MIT](LICENSE)
|
package/demo.atex
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// Fretfall's demo: an original practice piece, so there's something to play before you open a file. About two
|
|
2
|
+
// minutes, and it uses every notation the highway draws: mutes, repeats, slides (legato, shift, in and out), hammer-ons
|
|
3
|
+
// and pull-offs, bends (pre-bend, release), whammy bar, vibrato (wide too), ties, let ring, tremolo picking, tapping with
|
|
4
|
+
// either hand, every harmonic type, accents, staccato, ghost and grace notes, trills and ornaments, dynamics and
|
|
5
|
+
// hairpins, fades, wah, fermata, ottava, pick strokes, picking-hand fingers, strums and rolled chords, barres, slap, pop,
|
|
6
|
+
// golpe, rasgueado, string numbers, free text, lyrics, and at the bar lines: repeats with endings, segno and coda, key,
|
|
7
|
+
// tempo, meter and feel. Written in alphaTex, alphaTab's text format. Lyrics go on beats as
|
|
8
|
+
// {lyrics "syllable"}: a "-" at the end joins a syllable to the next, a "+" ends the line.
|
|
9
|
+
\title "Fretfall Demo"
|
|
10
|
+
\subtitle "Original practice piece"
|
|
11
|
+
\tempo 100
|
|
12
|
+
.
|
|
13
|
+
\track "Guitar"
|
|
14
|
+
\staff {tabs}
|
|
15
|
+
\instrument distortionguitar
|
|
16
|
+
:1 r |
|
|
17
|
+
:1 r |
|
|
18
|
+
\section "Chugs" \ro :8 (0.6{pm} 2.5{pm}){ch "E5" lyrics "Plug"} (0.6{pm} 2.5{pm}){lyrics "it"} (0.6{pm} 2.5{pm}){lyrics "in"} (0.6{pm} 2.5{pm}){lyrics "and"} (3.6{sl} 5.5{sl}){ch "G5" lyrics "turn"} (5.6{ac} 7.5{ac}){ch "A5" lyrics "it"} (x.6 x.5){lyrics "up+"} (x.6 x.5) |
|
|
19
|
+
\rc 2 :8 0.6{pm lyrics "watch"} 0.6{pm lyrics "the"} 0.6{pm lyrics "high-"} 0.6{pm lyrics "way"} (7.6{hac} 9.5{hac}){ch "B5" lyrics "come"} (7.6 9.5){lyrics "a-"} (5.5{pm} 7.4{pm}){ch "D5" lyrics "live+"} (5.5{pm} 7.4{pm}) |
|
|
20
|
+
:16 0.6{pm} 0.6{pm} :8 0.6{pm} :16 0.6{pm} 0.6{pm} :8 0.6{pm} :4 (5.6 7.5 7.4){ch "A5" lyrics "Rea-"} (5.6 7.5 7.4){lyrics "dy,"} |
|
|
21
|
+
:8 (x.6 x.5 x.4) (x.6 x.5 x.4) :4 (3.6 5.5 5.4){ch "G5" lyrics "set,"} :2 (5.6 7.5 7.4){ch "A5" lyrics "go!+"} |
|
|
22
|
+
\section "Riff" :16 5.6{h lf 2} 7.6{lf 4} 5.5{h lf 2} 7.5{lf 4} 7.4{h lf 4} 5.4{lf 2} 7.4{h lf 4} 5.4{lf 2} :8 7.3{sl lf 4} 9.3{lf 5} 7.4{lf 3} 5.4{lf 2} |
|
|
23
|
+
:8 5.3{ss lf 2} 12.3{lf 2} :16 12.2{h lf 2} 15.2{lf 5} 12.1{h lf 2} 15.1{lf 5} 15.1{h lf 5} 12.1{lf 2} 14.2{h lf 4} 12.2{lf 2} :4 14.3{lf 4} |
|
|
24
|
+
\section "Lead" :4 14.3{b (0 4) lf 4} 14.3{b (0 2) lf 4} :8 12.2{lf 2} 15.2{b (0 4 4 0) lf 5} :4 14.2{v lf 4} |
|
|
25
|
+
:2 17.1{v lf 4} :4 -.1 12.1{tp 16 lf 2} |
|
|
26
|
+
:16 19.1{tt h} 12.1{h} 15.1{h} 12.1 19.1{tt h} 12.1{h} 15.1{h} 12.1 19.2{tt h} 12.2{h} 15.2{h} 12.2 19.2{tt h} 12.2{h} 15.2{h} 12.2 |
|
|
27
|
+
\section "Harmonics" :4 (12.3{nh} 12.2{nh} 12.1{nh}) 7.3{nh} :8 5.2{nh} 5.1{nh} :4 5.3{ph lf 2} |
|
|
28
|
+
\section "Chords" :2 (3.6 2.5 0.4 0.3 0.2 3.1){ch "G" lyrics "Watch"} (0.5 2.4 2.3 1.2 0.1){ch "Am" lyrics "the"} |
|
|
29
|
+
:2 (3.5 2.4 0.3 1.2 0.1){ch "C" lyrics "notes"} (0.4 2.3 3.2 2.1){ch "D" lyrics "fall+"} |
|
|
30
|
+
:4 (1.6{lf 2} 3.5{lf 4} 3.4{lf 5} 2.3{lf 3} 1.2{lf 2} 1.1{lf 2}){ch "F" lyrics "Play"} (1.6 3.5 3.4 2.3 1.2 1.1){lyrics "them"} (1.6 3.5 3.4 2.3 1.2 1.1){lyrics "on"} (1.6 3.5 3.4 2.3 1.2 1.1){lyrics "time+"} |
|
|
31
|
+
:8 (2.5 4.4 4.3 3.2 2.1){ch "Bm" lyrics "let"} (2.5 4.4 4.3 3.2 2.1){lyrics "the"} (2.5 4.4 4.3 3.2 2.1){lyrics "strings"} (2.5 4.4 4.3 3.2 2.1){lyrics "ring"} :2 (0.6 2.5 2.4 1.3 0.2 0.1){ch "E" lyrics "out+"} |
|
|
32
|
+
\section "Double stops" :8 (6.3 7.2) (6.3 7.2) (6.3 7.2) (6.3 7.2) (4.3{sl} 5.2{sl}) (6.3 7.2) :4 (8.3 10.2) |
|
|
33
|
+
:16 (6.3 7.2) (6.3 7.2) (6.3 7.2) (6.3 7.2) (6.3 7.2) (6.3 7.2) (6.3 7.2) (6.3 7.2) :8 (4.3 5.2) (4.3 5.2) :4 (6.3 7.2) |
|
|
34
|
+
\ts 3 4 \tempo 120 \section "Waltz" :4 0.5{lyrics "Waltz"} (2.4 2.3 1.2){ch "Am" lyrics "a-"} (2.4 2.3 1.2){lyrics "long"} |
|
|
35
|
+
:4 3.6{lyrics "in"} (0.4 0.3 3.1){ch "G" lyrics "three,+"} (0.4 0.3 3.1){lyrics "and"} |
|
|
36
|
+
:4 0.4{lyrics "round"} (2.3 3.2 2.1){ch "D" lyrics "and"} (2.3 3.2 2.1){lyrics "round+"} |
|
|
37
|
+
\ts 4 4 \tempo 100 \section "Solo" :8 12.3{h lf 2} 14.3{lf 4} 12.2{lf 2} 15.2{b (0 4) lf 5} 15.2{lf 5} 12.2{lf 2} 14.3{lf 4} 12.3{lf 2} |
|
|
38
|
+
:16 17.1{sl lf 3} 19.1{lf 5} 17.1{h lf 3} 15.1{lf 2} 17.2{h lf 4} 15.2{lf 2} 16.3{h lf 3} 14.3{lf 2} :4 17.2{b (0 4) v lf 4} 15.1{v lf 2} |
|
|
39
|
+
:4 12.2{tp 32 lf 2} 12.2{tp 32 lf 2} :2 7.3{ph v lf 2} |
|
|
40
|
+
\section "Articulation" :4 5.3{ac dy p} 7.3{hac} 5.3{ten st} 7.3{g} |
|
|
41
|
+
:8 5.2{cre} 7.2{cre} 8.2{cre} 10.2{cre} :4 12.2{dy ff} 10.2{dec} |
|
|
42
|
+
:2 (3.6{lr} 2.5{lr} 0.4{lr}){ch "G"} :4 0.3{lr} 0.2{lr dy mf} |
|
|
43
|
+
\section "Slides and harmonics" :4 7.3{sib} 9.3{sou} 7.2{sia} 5.2{sod} |
|
|
44
|
+
:4 12.3{ah} 7.2{th} 5.3{sh} 7.4{fh} |
|
|
45
|
+
\section "Bends and whammy" :4 7.3{b (4 4 0)} 7.3{b (0 4 4 0)} 0.6{tb (0 -4 0)} 0.6{tb (0 -8)} |
|
|
46
|
+
\section "Ornaments" :4 5.2{tr 7 16} 5.2{turn} 5.2{iturn} 5.2{umordent} |
|
|
47
|
+
:4 3.3{gr} 5.3 5.3{lmordent} :2 7.3{vw} |
|
|
48
|
+
\section "Picking" :8 5.4{sd rf 2} 7.4{su rf 3} 5.3{sd rf 2} 7.3{su rf 3} 5.2{sd rf 4} 7.2{su rf 3} 5.1{sd rf 5} 7.1{su rf 1} |
|
|
49
|
+
:4 (0.6 2.5 2.4 1.3 0.2 0.1){bd ch "E"} (0.6 2.5 2.4 1.3 0.2 0.1){bu} (0.6 2.5 2.4 1.3 0.2 0.1){ad} (0.6 2.5 2.4 1.3 0.2 0.1){au} |
|
|
50
|
+
\section "Barres" :2 (5.6 7.5 7.4 6.3 5.2 5.1){barre 5 full ch "A"} (7.5 9.4 9.3 8.2 7.1){barre 7 half ch "E/B"} |
|
|
51
|
+
\section "Percussive" :8 0.4{s} 0.3{p} 5.4{s} 7.3{p} :4 0.6{glpt} 0.6{glpf} |
|
|
52
|
+
:4 (0.6 2.5 2.4 1.3 0.2 0.1){rasg amii ch "E"} 12.1{lht} 15.1{tt} 12.1{string} |
|
|
53
|
+
\section "Colour" :4 5.3{f} 7.3{vs} 5.3{fo} 7.3{waho} |
|
|
54
|
+
:4 5.3{wahc} 7.3{fermata medium} 12.2{ot 8va} 12.2{ot regular} |
|
|
55
|
+
:4 3.5{txt "pizz."} 3.5 3.5{txt "bass stop"} r |
|
|
56
|
+
\ks g \tf triplet8th \jump segno \section "Swing" \ro :8 3.6{lyrics "Swing"} 5.6{lyrics "it,"} 3.6{lyrics "swing"} 5.6{lyrics "it,"} 7.6{lyrics "let"} 5.6{lyrics "the"} 3.6{lyrics "notes"} 5.6{lyrics "roll+"} |
|
|
57
|
+
\ae 1 \rc 2 :4 (3.6 5.5 5.4){ch "G5" lyrics "Once"} (5.6 7.5 7.4){ch "A5" lyrics "a-"} :2 (7.6 9.5 9.4){ch "B5" lyrics "gain+"} |
|
|
58
|
+
\ae 2 \tf none \ks c \jump coda :4 (8.6 10.5 10.4){ch "C5" lyrics "Take"} (10.6 12.5 12.4){ch "D5" lyrics "it"} :2 (0.6 2.5 2.4){ch "E5" lyrics "home+"} |
|
|
59
|
+
\section "Outro" :8 0.6{pm} x.6 0.6{pm} x.6 (0.6{ac} 2.5{ac} 2.4{ac}){ch "E5"} (x.6 x.5 x.4) (3.6 5.5){ch "G5"} (x.6 x.5) |
|
|
60
|
+
:8 0.6{pm} 0.6{pm} 0.6{pm} 0.6{pm} :4 (5.6{ac} 7.5{ac}){ch "A5" lyrics "That's"} (7.6{hac} 9.5{hac}){ch "B5" lyrics "a"} |
|
|
61
|
+
:1 (0.6 2.5 2.4 1.3 0.2 0.1){ch "E" lyrics "wrap+"} |
|
|
62
|
+
:2 (-.6 -.5 -.4 -.3 -.2 -.1) r |
|
|
63
|
+
\track "Bass"
|
|
64
|
+
\staff {tabs}
|
|
65
|
+
\tuning (G2 D2 A1 E1)
|
|
66
|
+
\instrument electricbassfinger
|
|
67
|
+
:1 r |
|
|
68
|
+
:1 r |
|
|
69
|
+
\ro :8 0.4 0.4 0.4 0.4 3.4 3.4 5.4 5.4 |
|
|
70
|
+
\rc 2 :8 0.4 0.4 0.4 0.4 7.4 7.4 5.3 5.3 |
|
|
71
|
+
:16 0.4 0.4 :8 0.4 :16 0.4 0.4 :8 0.4 :4 5.4 5.4 |
|
|
72
|
+
:4 r 3.4 :2 5.4 |
|
|
73
|
+
:8 5.4 5.4 5.4 5.4 7.4 7.4 5.4 5.4 |
|
|
74
|
+
:4 5.4 3.4 2.3 0.3 |
|
|
75
|
+
:2 7.3 7.3 |
|
|
76
|
+
:1 0.4 |
|
|
77
|
+
:4 0.4 0.4 0.4 0.4 |
|
|
78
|
+
:1 r |
|
|
79
|
+
:2 3.4 0.3 |
|
|
80
|
+
:2 3.3 0.2 |
|
|
81
|
+
:4 1.4 1.4 1.4 1.4 |
|
|
82
|
+
:2 2.3 0.4 |
|
|
83
|
+
:4 3.4 3.4 5.4 5.4 |
|
|
84
|
+
:4 3.4 3.4 5.4 5.4 |
|
|
85
|
+
\ts 3 4 :4 0.3 r r |
|
|
86
|
+
:4 3.4 r r |
|
|
87
|
+
:4 0.2 r r |
|
|
88
|
+
\ts 4 4 :2 0.4 0.4 |
|
|
89
|
+
:2 5.4 7.4 |
|
|
90
|
+
:2 0.4 5.3 |
|
|
91
|
+
:2 0.3 0.3 |
|
|
92
|
+
:2 0.2 5.3 |
|
|
93
|
+
:1 3.4 |
|
|
94
|
+
:2 0.3 0.2 |
|
|
95
|
+
:1 0.3 |
|
|
96
|
+
:2 0.4 0.4 |
|
|
97
|
+
:1 0.2 |
|
|
98
|
+
:1 0.3 |
|
|
99
|
+
:2 0.4 0.4 |
|
|
100
|
+
:1 0.4 |
|
|
101
|
+
:2 5.4 7.4 |
|
|
102
|
+
:8 0.4{s} 0.4{p} 0.4{s} 0.4{p} :2 0.4 |
|
|
103
|
+
:1 0.4 |
|
|
104
|
+
:1 0.3 |
|
|
105
|
+
:1 0.3 |
|
|
106
|
+
:1 r |
|
|
107
|
+
\ro :8 3.4 3.4 5.4 5.4 7.4 7.4 5.4 5.4 |
|
|
108
|
+
\ae 1 \rc 2 :4 3.4 5.4 :2 7.4 |
|
|
109
|
+
\ae 2 :4 8.4 10.4 :2 0.4 |
|
|
110
|
+
:8 0.4 0.4 0.4 0.4 0.4 0.4 3.4 3.4 |
|
|
111
|
+
:8 0.4 0.4 0.4 0.4 :4 5.4 7.4 |
|
|
112
|
+
:1 0.4 |
|
|
113
|
+
:2 -.4 r |
|
package/favicon.svg
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
2
|
+
<style>rect { fill: #1f2329 } @media (prefers-color-scheme: dark) { rect { fill: #e9eef7 } }</style>
|
|
3
|
+
<rect x="4" y="3" width="4.5" height="18" rx="1.5" />
|
|
4
|
+
<rect x="4" y="3" width="16" height="4.5" rx="1.5" />
|
|
5
|
+
<rect x="10.5" y="11.67" width="9" height="4.5" rx="1.5" transform="rotate(14 15 13.92)" />
|
|
6
|
+
</svg>
|
package/fingering.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const P=4,A=(a,n)=>Math.min(4,Math.max(1,a-n+1));function y(a){const n=[];for(const t of a){if(t.fret<=0)continue;const o=n.at(-1);o&&t.time-o.time<.005?o.notes.push(t):n.push({time:t.time,notes:[t]})}if(!n.length)return{anchors:[],fingers:new Map};for(const t of n){const o=t.notes.map(e=>e.fret);t.low=Math.min(...o),t.high=Math.max(...o),t.end=Math.max(...t.notes.map(e=>e.time+e.sustain));const s=Math.max(1,t.high-4+1);t.options=s<=t.low?Array.from({length:t.low-s+1},(e,r)=>s+r):[t.low]}const m=(t,o)=>.1*(t.low-o);let h=new Map(n[0].options.map(t=>[t,m(n[0],t)]));const l=[null];for(let t=1;t<n.length;t++){const o=n[t],s=o.time-n[t-1].end>.4,e=new Map,r=new Map;for(const f of o.options){let p=1/0,g=null;for(const[M,x]of h){const w=Math.abs(f-M),d=x+(w?(1+.3*w)*(s?.5:1):0);d<p&&([p,g]=[d,M])}e.set(f,p+m(o,f)),r.set(f,g)}h=e,l.push(r)}let c=[...h].reduce((t,o)=>o[1]<t[1]?o:t)[0];for(let t=n.length-1;t>=0;t--)n[t].position=c,c=l[t]?.get(c);const u=new Map,i=[];for(const t of n){for(const e of t.notes)u.set(e,A(e.fret,t.position));const o=Math.max(4,t.high-t.position+1),s=i.at(-1);s?.fret===t.position?s.width=Math.max(s.width,o):i.push({time:t.time,endTime:1/0,fret:t.position,width:o})}return i.forEach((t,o)=>t.endTime=i[o+1]?.time??n.at(-1).end),{anchors:i,fingers:u}}export{A as fingerFor,y as suggestPositions};
|
package/highway.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{lap as fe}from"./perf.js";import{noteName as bi}from"./music.js";const Ft=900,yi=84,Yn=28,qn=2.2,Si=.9,ki=2.4,Ti=a=>yi*(a.drawDistance??1)/(Yn*(a.noteSpeed??1)),Pi=.34,Lt=24,an=1.2,Ai=1.25,wi=1.25,Ce=5,sn=1,vi=1.6,Wi=2,ln=.19,Xn=.12,Un=3,$i=11,Ii=[{time:-1/0,endTime:1/0,fret:1,width:4}],jn=[3,5,7,9,12,15,17,19,21,24],Jn=(a,l,h,o,t)=>{const[m,M,d,e]=[Math.min(a,l),Math.max(a,l),Math.min(h,o),Math.max(h,o)],$=Math.min(t,(M-m)/2,(e-d)/2),_=(U,ct,R)=>{const ot=Array.from({length:5},(lt,vt)=>[U+Math.cos(R+vt*Math.PI/8)*$,ct+Math.sin(R+vt*Math.PI/8)*$]);return[ot[0],...ot,ot[4]]};return[..._(M-$,e-$,0),..._(m+$,e-$,Math.PI/2),..._(m+$,d+$,Math.PI),..._(M-$,d+$,1.5*Math.PI)]},Li=a=>[...a,a.at(-1),...a.slice(0,-1).reverse().map(([l,h])=>[l,-h])],Di={inline:{label:"6 in line",outline:[[0,1],[.42,1.05],[.73,1.3],[1.01,1.53],[1.46,1.45],[2.73,1.08],[4.38,.62],[5.79,.17],[6.54,-.13],[6.88,-.35],[7.03,-.88],[6.98,-1.56],[6.64,-2.11],[6.14,-2.38],[5.59,-2.34],[5.21,-2.05],[4.99,-1.66],[4.75,-1.39],[4.25,-1.3],[3.5,-1.39],[2.6,-1.6],[1.85,-1.81],[1.18,-1.75],[.83,-1.36],[.47,-1.06],[0,-1]],posts:{from:[1.56,.95],to:[6.01,-.58]},keys:"machine",tree:2.47},fourTwo:{label:"4 + 2",outline:[[0,1],[.48,1.03],[.94,1.35],[1.21,1.72],[1.52,1.72],[2.99,1.31],[4.23,.95],[5.53,.57],[5.92,.28],[6.07,-.36],[6.05,-1.03],[5.79,-1.53],[5.36,-1.67],[4.95,-1.53],[4.68,-1.29],[4.36,-1.19],[4.02,-1.32],[3.67,-1.56],[2.99,-1.67],[2.08,-1.6],[1.4,-1.43],[.94,-1.16],[.48,-1.03],[0,-1]],posts:{from:[1.81,1.08],to:[4.94,-.03],treble:{share:1/3,from:[2.33,-1.03],to:[3.38,-.69]}},keys:"machine"},openBook:{label:"3 + 3 open book",outline:Li([[0,1],[.48,1.07],[.96,1.33],[1.47,1.53],[3.16,1.67],[4.98,1.76],[6.25,1.8],[6.25,1.8],[6.42,.93],[6.3,0]]),posts:{from:[2.5,1.07],to:[5.1,1.07],treble:{share:1/2}},keys:"tulip",cover:[[.22,0],[.22,.4],[.36,.5],[.78,.4],[1.3,.25],[1.82,.16],[2.13,.1],[2.24,0],[2.13,-.1],[1.82,-.16],[1.3,-.25],[.78,-.4],[.36,-.5],[.22,-.4],[.22,0]],screws:[[.43,0],[1.98,0]]},pointed:{label:"3 + 3 pointed",outline:[[0,1],[.36,1.12],[.75,1.47],[1.07,1.84],[1.38,1.93],[2.29,1.73],[3.26,1.55],[4.36,1.35],[5.45,1.12],[5.75,.95],[5.86,.43],[5.98,-.22],[6.29,-.75],[6.75,-1.22],[6.75,-1.22],[6.17,-1.24],[5.33,-1.3],[4.36,-1.37],[3.26,-1.55],[2.29,-1.73],[1.38,-1.93],[1.07,-1.84],[.75,-1.47],[.36,-1.12],[0,-1]],posts:{from:[2.07,1],to:[4.65,.46],treble:{share:1/2}},keys:"machine",cover:[[.1,.44],[.1,.44],[.59,.4],[1.1,.28],[1.69,0],[1.69,0],[1.1,-.28],[.59,-.4],[.1,-.44],[.1,-.44],[.1,.44]],screws:[]},headless:{label:"Headless",outline:Jn(.2,.95,-1.06,1.06,.2),clamps:.58}};function Ci(a,l){const h=l.length,o=Qn(a.outline,10);let t=l.map(e=>[a.clamps,e]),m=l.map(()=>1);if(a.posts){const{from:e,to:$,treble:_}=a.posts,U=_?Math.floor(h*_.share+1e-9):0,ct=h-U,R=(Q,G,A)=>P=>Q.map((Mt,tt)=>Mt+(G[tt]-Mt)*P/Math.max(1,A-1)),ot=([Q,G])=>[Q,-G],lt=R(e,$,ct),vt=R(_?.from??ot(e),_?.to??ot($),U);t=l.map((Q,G)=>G<ct?lt(G):vt(h-1-G)),m=l.map((Q,G)=>G<ct?1:-1)}const M=(e,$)=>{let _=null;for(let U=1;U<o.length;U++){const[ct,R]=o[U-1],[ot,lt]=o[U];if((ct-e)*(ot-e)>0||ct===ot)continue;const vt=R+(lt-R)*(e-ct)/(ot-ct);(_===null||vt*$>_*$)&&(_=vt)}return _??$},d=a.keys?t.map(([e],$)=>({u:e,side:m[$],edge:M(e,m[$])})):[];return{outline:o,ends:t,keys:d}}const Kn=new WeakMap,ze=new Map,Ri=(a,l)=>{const h=l.join(),o=Kn.get(a);if(o?.key===h)return o.parts;const t=Ci(a,l);return Kn.set(a,{key:h,parts:t}),t},Vn=(a,l)=>(ze.has(a)||(ze.size>500&&ze.clear(),ze.set(a,l())),ze.get(a)),Qn=(a,l=8)=>[...a.slice(0,-1).flatMap((h,o)=>{const t=a[Math.max(0,o-1)],m=a[o+1],M=a[Math.min(a.length-1,o+2)];return h[0]===m[0]&&h[1]===m[1]?[h]:Array.from({length:l},(d,e)=>{const $=e/l;return[0,1].map(_=>.5*(2*h[_]+(m[_]-t[_])*$+(2*t[_]-5*h[_]+4*m[_]-M[_])*$*$+(3*h[_]-t[_]-3*m[_]+M[_])*$**3))})}),a.at(-1)],Wn=(a,l)=>{if(!a.startsWith("#"))return a;const h=o=>{const t=parseInt(a.slice(o,o+2),16);return Math.round(l>0?t+(255-t)*l:t*(1+l)).toString(16).padStart(2,"0")};return`#${h(1)}${h(3)}${h(5)}`},rn=new Map,L=(a,l)=>{if(!a.startsWith("#"))return a;const h=a+l;let o=rn.get(h);return o||(rn.size>1e3&&rn.clear(),rn.set(h,o=`rgba(${parseInt(a.slice(1,3),16)}, ${parseInt(a.slice(3,5),16)}, ${parseInt(a.slice(5,7),16)}, ${l})`)),o},Ge=(a,l)=>{let h=0,o=a.length;for(;h<o;){const t=h+o>>1;a[t].time<l?h=t+1:o=t}return h};function Zn(a){if(a.links?.next.length===a.notes.length)return a.links;const l=a.notes.length,h=new Array(l).fill(-1),o=new Array(l).fill(-1),t={};let m=0;for(let M=0;M<l;M++){const{string:d,sustain:e}=a.notes[M];t[d]!==void 0&&([o[M],h[t[d]]]=[t[d],M]),t[d]=M,m=Math.max(m,e)}return a.links={next:h,prev:o,held:m}}const ce=a=>Math.round(a*4)/4,de=32,hn=new Map;let ti=0;const jt=(a,l,h)=>{let o=hn.get(l);o||hn.set(l,o=new Map);let t=o.get(h);if(!t){++ti>5e3&&([ti,o]=[0,new Map],hn.clear(),hn.set(l,o)),a.font=l;const m=a.measureText(h);o.set(h,t={width:m.width,middle:(m.actualBoundingBoxAscent-m.actualBoundingBoxDescent)/2})}return t},fn=128,$n=new WeakMap,Ei=a=>{if(!$n.has(a)){const l=new OffscreenCanvas(1,fn),h=l.getContext("2d"),[o,t]=[a.floor0,a.floor1].map(M=>[1,3,5].map(d=>parseInt(M.slice(d,d+2),16))),m=Array.from({length:fn},(M,d)=>{const e=(d+.5)/fn;return`rgba(${o.map(($,_)=>Math.round($+(t[_]-$)*e))}, ${1-e})`});m.forEach((M,d)=>{h.fillStyle=M,h.fillRect(0,fn-1-d,1,1)}),$n.set(a,{strip:l,near:m[0]})}return $n.get(a)},Re=new Map,ei=new WeakMap,ni=(a,l,h)=>{let o=ei.get(a);o||ei.set(a,o=new Map);let t=o.get(l);if(!t){t=a.createLinearGradient(0,0,0,1);for(const[m,M]of h)t.addColorStop(m,M);o.set(l,t)}return t},cn=new Map,ii=(a,l,h,o,t)=>{const m=`${l}|${h}|${o}|${t}`;let M=cn.get(m);return M||(cn.size>20&&cn.clear(),M=a.createLinearGradient(0,l,0,h),M.addColorStop(0,o),M.addColorStop(1,t),cn.set(m,M)),M},dn=(a,l)=>[a[0]-l[0],a[1]-l[1],a[2]-l[2]],mn=(a,l)=>a[0]*l[0]+a[1]*l[1]+a[2]*l[2],Oi=(a,l)=>[a[1]*l[2]-a[2]*l[1],a[2]*l[0]-a[0]*l[2],a[0]*l[1]-a[1]*l[0]],Bi=a=>a.map(l=>l/Math.hypot(...a)),gn=(a,l)=>{let h=0,o=a.length;for(;h<o;){const t=h+o>>1;a[t].time<=l?h=t+1:o=t}return a[Math.max(0,h-1)]},oi=a=>a*a*(3-2*a),_i=.3,ai=new WeakMap;function si(a,l){let h=ai.get(a);if(h||ai.set(a,h={}),!(l in h)){const o=Math.max(a.sustain,.05),m=(a[l]??(l==="bendCurve"&&a.bend?[[0,0],[.25,a.bend]]:null))?.map(([M,d])=>[M*o,d,!1])??[];m.length&&m[0][0]>.001&&(m[0][2]=!0,m.unshift([0,0,!1])),h[l]=m.length?m:null}return h[l]}function li(a,l){if(!a)return 0;let h=a[0][1];for(let o=1;o<a.length&&l>a[o-1][0];o++){const[[t,m],[M,d,e]]=[a[o-1],a[o]],$=Math.min(M-t,_i)||1e-6;h=m+(d-m)*oi(Math.min(1,Math.max(0,(l-(e?M-$:t))/$)))}return h}const Hi=(a,l)=>li(si(a,"bendCurve"),l),Fi=(a,l)=>Hi(a,l)+li(si(a,"whammy"),l),ri=new WeakMap,Ee=a=>{let l=ri.get(a);return l===void 0&&ri.set(a,l=Math.max(a.bend||0,...(a.bendCurve??[]).map(([,h])=>h))),l};function Ni(a){if(a.chordSpans)return a.chordSpans;const l=[];for(const h of a.chords){const o=Math.max(h.time+.25,...h.notes.map(m=>a.notes[m].time+a.notes[m].sustain)),t=l.at(-1);t&&h.time-t.end<1&&(h.name?h.name===t.name:h.highDensity)?t.end=Math.max(t.end,o):h.name&&l.push({name:h.name,time:h.time,end:o})}for(const h of a.handShapes??[])h.arpeggio&&h.name&&l.push({name:h.name,time:h.startTime,end:h.endTime});return a.chordSpans=l.sort((h,o)=>h.time-o.time)}function zi(a){if(a.chordRails)return a.chordRails;const l=[],h=o=>Math.max(o.time+.15,...o.notes.map(t=>a.notes[t].time+a.notes[t].sustain));for(let o=0;o<a.chords.length;o++){const t=a.chords[o];if(t.highDensity)continue;let m=h(t),M=o+1;for(;a.chords[M]?.highDensity&&a.chords[M].time-m<1;M++)m=Math.max(m,h(a.chords[M]));m=Math.min(m,a.chords[M]?.time??1/0),m-t.time>.2&&l.push({time:t.time,end:m,frets:t.notes.map(d=>a.notes[d].fret)})}for(const o of a.handShapes??[])o.arpeggio&&l.push({time:o.startTime,end:o.endTime,frets:o.frets,arpeggio:o});return a.chordRails=l}const hi={artificial:"AH",pinch:"PH",tap:"TH",semi:"SH",feedback:"FH"},fi=a=>a<.5?"¼":a===.5?"½":a===1?"full":a%1?`${Math.floor(a)}½`:String(a),ci=(a,l,h,o)=>{if(a===void 0)return l;const t=a+(l-a)*(1-Math.exp(-h/o));return Math.abs(l-t)<1e-6?l:t};function di(a,l,h,o,t){a[l]===void 0&&([a[l],a[l+"Speed"]]=[h,0]);const m=2/o,M=m*t,d=1/(1+M+.48*M*M+.235*M*M*M),e=a[l]-h,$=(a[l+"Speed"]+m*e)*t;a[l+"Speed"]=(a[l+"Speed"]-m*$)*d,a[l]=h+(e+$)*d,Math.abs(a[l]-h)<1e-6&&Math.abs(a[l+"Speed"])<1e-6&&([a[l],a[l+"Speed"]]=[h,0])}function mi(a,l){let h=1/0,o=-1/0;for(const m of a)m.endTime<=l||m.time>=l+Un||(h=Math.min(h,m.fret-1),o=Math.max(o,m.fret-1+m.width));if(h===1/0){const m=gn(a,l);[h,o]=[m.fret-1,m.fret-1+m.width]}const t=Math.max($i,o-h+2)+1;return{lo:h,hi:o,span:t,center:Math.min(25-t/2,Math.max(t/2-1,(h+o)/2))}}function Gi(a,l,h,o){const t=mi(l,h),m=a.target,M=!m||t.lo<m.center-m.span/2||t.hi>m.center+m.span/2,d=m&&m.span-Math.max(t.span,mi(l,h+Un).span)>2;(M||d)&&(a.target=t);const e=Math.min(o-(a.at??o),100);a.at=o,di(a,"span",a.target.span,a.target.span>a.span?.8:1.4,e/1e3),di(a,"center",a.target.center,1,e/1e3);const $=gn(l,h);return a.left=ci(a.left,$.fret-1,e,90),a.right=ci(a.right,$.fret-1+$.width,e,90),$}function gi(a,l,h,o,t,m,M,d){a.beginPath(),a.moveTo(l-o,h-m*t),a.lineTo(l,h),a.lineTo(l+o,h-m*t),a.lineWidth=Math.max(3,t*1.15),a.strokeStyle=d,a.stroke(),a.lineWidth=Math.max(1.5,t*.65),a.strokeStyle=M,a.stroke(),a.lineWidth=Math.max(.6,t*.2),a.strokeStyle="rgba(255, 255, 255, 0.5)",a.stroke()}function Ye(a,l,h,o,t){a.beginPath(),a.moveTo(l,h),a.lineTo(o,t),a.stroke()}function pi(a){const l=devicePixelRatio||1,h=a.clientWidth,o=a.clientHeight;(a.width!==Math.round(h*l)||a.height!==Math.round(o*l))&&(a.width=Math.round(h*l),a.height=Math.round(o*l));const t=a.getContext("2d"),m=o/Ft,M=h/m,d=l*m;return t.setTransform(d,0,0,d,0,0),t.clearRect(0,0,M,Ft),{g:t,W:M,B:d}}function Ki(a,l,h,o,t){const{g:m,W:M,B:d}=pi(a);let e=m;if(!l)return;const $=l.anchors.length?l.anchors:Ii,_=Gi(t,$,h,performance.now()),U=l.strings,ct=Math.min(.5,5*Pi/Math.max(1,U-1)),R=ct*wi*(o.boardHeight??1),ot=R*(U-1),lt=i=>(o.stringOrder==="high"?i:U-1-i)*R,vt=Yn*(o.noteSpeed??1),Q=Ti(o),G=-.22,A=ot+.22,P=G-.06,Mt=Q*vt,tt=i=>Math.max(0,i)*vt,Tt=i=>o.str[i%o.str.length],ge=o.noteLines===0?null:`rgba(255, 255, 255, ${o.noteLines??.5})`,Jt=t.span,rt=[t.center,ct*(U-1)/2,0],Pe=(o.viewAngle??30)*Math.PI/180,Ae=.6*Math.SQRT2*Jt,Be=[rt[0],ot+Ae*Math.sin(Pe),-Ae*Math.cos(Pe)],Kt=Bi(dn([rt[0],0,2.2*Jt],Be)),se=Oi(Kt,[1,0,0]),we=(o.sideAngle??0)*Math.PI/180,[W,K]=[Math.sin(we),Math.cos(we)],j=dn(Be,rt),St=mn(j,Kt),Et=mn(j,se),Wt=[-W,Kt[1]*K,Kt[2]*K],Vt=[K,Kt[1]*W,Kt[2]*W],ve=[rt[0]+Et*se[0]+St*Wt[0],rt[1]+Et*se[1]+St*Wt[1],Et*se[2]+St*Wt[2]],pe=Math.min(M*.88,Ft*(o.fill?1.3:1.05)),ue=pe*mn(dn(rt,ve),Wt)/Jt,pt=Math.min(Ai*(o.fretWidth??1),M*Jt/(pe*Math.max(1,Jt-2.5)));let qe=0,We=0;const[Qt,pn,un]=ve,[Mn,xn,Xe]=Wt,[_e,Me,bn]=Vt,[xe,yn,Ue]=se,D=(i,n,c)=>{const s=i-Qt,r=n-pn,p=c-un,u=ue/Math.max(.05,s*Mn+r*xn+p*Xe);return[M/2+(s*_e+r*Me+p*bn)*pt*u+qe,Ft/2-(s*xe+r*yn+p*Ue)*u+We,u]},[je,Je,xt]=D(...rt);[qe,We]=[M/2-je,Ft*(o.fill?.83:.81)-Je];const[,Ke]=D(t.center-Jt/2,P,0),[,Ve]=D(t.center+Jt/2,P,0),[,x]=D(t.center,P,0);We-=Math.min(Ft*.08,Math.max(0,Ke-x,Ve-x)),fe("setup");const f=(i,n=!0)=>{e.beginPath();for(let c=0;c<i.length;c++){const[s,r]=D(i[c][0],i[c][1],i[c][2]);c?e.lineTo(s,r):e.moveTo(s,r)}n&&e.closePath()},S=(i,n)=>{f([i,n],!1),N()},nt=(i,n,c,s,r)=>{if(o.gem!=="pill")return f([[i-s,n-r,c],[i+s,n-r,c],[i+s,n+r,c],[i-s,n+r,c]]);const[p,u]=D(i-s,n,c),[v,b]=D(i+s,n,c),[,k]=D(i,n+r,c),[,J]=D(i,n-r,c),H=Math.atan2(b-u,v-p),F=Math.min(Math.abs(J-k),Math.hypot(v-p,b-u))/2,[I,B]=[F*Math.cos(H),F*Math.sin(H)];e.beginPath(),e.arc(p+I,u+B,F,H+Math.PI/2,H+Math.PI*1.5),e.arc(v-I,b-B,F,H-Math.PI/2,H+Math.PI/2),e.closePath()},Y=(i,n)=>{const c=gn($,n),s=i.filter(r=>r>0);return[Math.min(c.fret-1,...s.map(r=>r-1))+.05,Math.max(c.fret-1+Math.max(4,c.width),...s)-.05]},et=(i,n,c,s,r)=>{S([i-s,n-r,c],[i+s,n+r,c]),S([i-s,n+r,c],[i+s,n-r,c])},Ot=o.markings==="white",ht=Ot?"#ffffff":o.ink,be=(i,n,c,s,r,p,u,v=null)=>{const[b,k]=u?[r*.85,p*.8]:[Math.min(r,.34)*.4,p*.55],J=u&&!Ot&&!v;v||(e.strokeStyle=L(o.ink,J?.85:.7),e.lineWidth=J?Math.max(2,.06*s):Math.max(3.5,.1*s),et(i,n,c,b,k)),!J&&(e.strokeStyle=v??"#ffffff",e.lineWidth=Math.max(v?2:1.8,.05*s),et(i,n,c,b,k))};let ee=null,Pt=0;const $e=i=>{i!==ee&&(e.font=ee=i)},Ie={},ne=(i,n,c,s,r,p)=>{const u=Ie[r]??=`${r} ${de}px ${o.num}`,v=s/de;return jt(e,u,i),$e(u),e.textAlign=p,e.setTransform(d*v,0,0,d*v,d*n,d*(c-Pt)),jt(e,u,i).middle},qt=()=>e.setTransform(d,0,0,d,0,-d*Pt),ye=(i,n,c)=>{e.fillStyle=i,e.setTransform(d,0,0,d*(c-n),0,d*(n-Pt)),e.fill(),qt()},Dt=(i,n,c,s,r,p,u=700,v="center",b=!0,k=!1)=>{const[J,H,F]=D(n,c,s),I=r*(k?F:Math.sqrt(F*xt));if(I<(k?1:8)||J<-60||J>M+60)return;e.textBaseline="alphabetic";const B=ne(i,J,H,I,u,v);b&&(e.lineWidth=de*.2,e.strokeStyle=L(o.ink,.9),e.strokeText(i,0,B)),e.fillStyle=p,e.fillText(i,0,B),qt(),e.textBaseline="middle"},[,ie]=D(rt[0],P,0),[,Se]=D(rt[0],P,Mt),gt=(i,n,c)=>{const s=`${ie}|${Se}`;(Re.span!==s||Re.size>300)&&(Re.clear(),Re.span=s);const r=`${i}|${n}|${c}`;let p=Re.get(r);return p||(p=e.createLinearGradient(0,ie,0,Se),p.addColorStop(0,L(i,n)),p.addColorStop(1,L(i,c)),Re.set(r,p)),p};let $t=null;const E=(i,n,c=10,s=!1)=>$t=i?{color:n,blur:c,faded:s}:null,Sn=[[.6,.05],[.35,.13],[.15,.27]],He=[[.4,.3]],Le=i=>{if(!$t)return;const{lineWidth:n,globalAlpha:c}=e,s=i?1:Math.min(1,2*n/$t.blur);e.save(),e.strokeStyle=$t.faded?gt($t.color,1,.1):$t.color;for(const[r,p]of $t.blur>4?Sn:He)e.lineWidth=(i?0:n)+2*$t.blur*r,e.globalAlpha=c*p*s,e.stroke();e.restore()},N=()=>{Le(!1),e.stroke()},at=()=>{Le(!0),e.fill()};e.textBaseline="middle",e.lineCap="round",e.lineJoin="round";const{strip:le,near:re}=Ei(o);let[Zt,bt]=[-60,Lt+60];if(we){const i=rt[0]+(1-mn(dn([rt[0],P,0],ve),Wt))/Wt[0];[Zt,bt]=Wt[0]>0?[Math.max(-60,i),Lt+60]:[-60,Math.min(Lt+60,i)]}e.save(),f([[Zt,P,0],[bt,P,0],[bt,P,Mt],[Zt,P,Mt]]),e.clip(),we&&(e.fillStyle=re,e.fillRect(0,ie,M,Ft-ie)),e.imageSmoothingEnabled=!1,e.drawImage(le,0,Se,M,ie-Se),e.restore();const Xt=(i,n)=>{const[c,s]=D(...i),[r,p]=D(...n);e.moveTo(c,s),e.lineTo(r,p)};e.strokeStyle=gt(o.lane,.5,.04),e.lineWidth=Si,e.beginPath();for(let i=0;i<=Lt;i++)Xt([i,P,0],[i,P,Mt]);N();for(const i of[!1,!0]){e.strokeStyle=i?o.measure:o.beat,e.lineWidth=i?1.6:1,e.beginPath();for(let n=Ge(l.beats,h);n<l.beats.length;n++){const c=l.beats[n],s=c.time-h;if(s>Q)break;c.measure>=0===i&&Xt([0,P,tt(s)],[Lt,P,tt(s)])}N()}(o.guides===!1?[]:$.filter(i=>i.endTime>h&&i.time<h+Q)).forEach((i,n)=>{const c=tt(Math.max(0,i.time-h)),s=tt(Math.min(Q,i.endTime-h)),r=i.fret-1,p=r+i.width;e.fillStyle=gt(o.anchorFill,o.anchorOpacity,.02),f([[r,P,c],[p,P,c],[p,P,s],[r,P,s]]),at(),e.strokeStyle=gt(o.anchorLane,.55,.04),e.lineWidth=ki*.6;for(const u of[r,p])S([u,P,c],[u,P,s]);n&&i.time>h&&S([r,P,c],[p,P,c]),n&&i.time>h+.3&&Dt(String(i.fret),r-.2,P,c,.3,o.anchorLane,700,"right")});const dt=new Map,ft=i=>{const n=Math.round(i*100);return dt.has(n)||dt.set(n,{dt:i-h,texts:[],pins:[]}),dt.get(n)};for(const i of l.markers??[])i.time>=h&&i.time<=h+Q&&!ft(i.time).texts.includes(i.text)&&ft(i.time).texts.push(i.text);for(const i of l.hairpins??[])i.time>=h&&i.time<=h+Q&&ft(i.time).pins.push(i.kind);const At=Math.min(t.center-(t.span/2+.5)/pt,-.5);for(const{dt:i,texts:n,pins:c}of dt.values()){const[s,r,p]=D(At,P,tt(i)),u=Math.sqrt(p*xt),v=n.join(" · "),b=.25*u,k=`700 ${de}px ${o.num}`,J=.3*u/de,H=v?jt(e,k,v).width*J:0,F=H+c.length*(.9*u+b);$e(k);let I=Math.max(s-.3*u,16+F);e.globalAlpha=Math.min(1,(Q-i)/.4),v&&(e.save(),e.translate(I,r),e.scale(J,J),e.textAlign="right",e.lineWidth=de*.2,e.strokeStyle=L(o.ink,.9),e.strokeText(v,0,0),e.fillStyle=o.accent,e.fillText(v,0,0),e.restore(),I-=H+b);for(const B of c){const yt=I-.9*u,ut=.14*u,[X,st]=B==="cresc"?[yt,I]:[I,yt];for(const[y,It]of[[L(o.ink,.9),Math.max(3.5,.12*u)],[o.text,Math.max(1.5,.05*u)]])e.strokeStyle=y,e.lineWidth=It,e.beginPath(),e.moveTo(st,r-ut),e.lineTo(X,r),e.lineTo(st,r+ut),N();I=yt-b}}e.globalAlpha=1,fe("floor");const mt=[];for(let i=Ge(l.notes,h-Zn(l).held-.3);i<l.notes.length;i++){const n=l.notes[i];if(n.time>h+Q)break;const c=Math.max(n.sustain,(n.slideTo??n.slideUnpitchTo??null)===null?0:.25,.15);n.time+c>=h-.05&&mt.push(n)}const Ut=i=>i.chord===null||i.chord===void 0?null:l.chords[i.chord],te=i=>o.repeatMarks==="frame"&&(i.repeat||Ut(i)?.highDensity),he=i=>{const n=gn($,i.time),c=i.fret===0;return{a:n,open:c,x:c?n.fret-1+n.width/2:i.fret-.5,y:lt(i.string)}},Qe=(i,n,c)=>{const s=i.slideTo??i.slideUnpitchTo??null,r=Math.min(1,Math.max(0,c/Math.max(i.sustain,.25)));return s===null||i.fret===0?n:n+(s-.5-n)*r*r*(3-2*r)},In=(i,n)=>Fi(i,n)*R*sn,Ln=i=>{const n=h-i.time;return n<0||i.fret===0||!(Ee(i)>0)?0:In(i,Math.min(n,Math.max(i.sustain,.15)))},Ze=new Map;for(const i of mt){const n=i.time-h,c=Math.max(i.sustain,.15);n>0||-n>c||i.fret===0||!(Ee(i)>0)||Ze.set(i.string,{note:i,x:i.fret-.5,dy:Ln(i)})}const kn=(i,n=0,c=!1)=>{const s=Ze.get(i),r=lt(i)+n,p=c?[[0,r,0]]:[en?[en[i][0],en[i][1]+n,0]:[-.6,r,0],[0,r,0]];if(!s)return f([...p,[Lt+.6,r,0]],!1);f([...p,[s.x,r+s.dy,0],[Lt+.6,r,0]],!1)},tn=i=>lt(i.string)+Ln(i),Nt=Di[o.headstock],ke=(A-G)/2,Tn=o.stringOrder==="high"?-1:1,oe=([i,n])=>[-i*ke/pt,ot/2+n*ke*Tn,0],Pn=i=>(lt(i)-ot/2)*Tn/ke,zt=Nt&&Ri(Nt,Array.from({length:U},(i,n)=>Pn(n))),en=zt?.ends.map(oe),kt=(i,n,c=1)=>{i&&(e.fillStyle=i,at()),n&&(e.strokeStyle=n,e.lineWidth=c,N())},Te=(i,n,c)=>{const[s,r]=oe(i),[p,u]=D(s,r,0),[v]=D(s+n*ke/pt,r,0),[,b]=D(s,r+c*ke,0);e.beginPath(),e.ellipse(p,u,Math.abs(v-p),Math.abs(b-u),0,0,Math.PI*2)},De=(i,n,c,s,r)=>f(Vn(`${i},${n},${c},${s},${r}`,()=>Jn(i,n,c,s,r)).map(oe)),Dn=()=>{for(const{u:c,side:s,edge:r}of zt.keys){const p=(u,v)=>[r+s*u,r+s*v];Nt.keys==="machine"?(De(c-.15,c+.15,...p(-.12,.08),.03),kt(L(o.text,.12),L(o.anchorLane,.35)),De(c-.03,c+.03,...p(.06,.22),0),kt(L(o.text,.28)),De(c-.11,c+.11,...p(.2,.68),.1),kt(L(o.text,.18),L(o.anchorLane,.55))):(De(c-.035,c+.035,...p(-.05,.22),0),kt(L(o.text,.28)),Te([c,r+s*.18],.08,.04),kt(L(o.text,.3)),Te([c,r+s*.4],.14,.2),kt(L(o.text,.18),L(o.anchorLane,.55)))}f(zt.outline.map(oe));const[,i]=D(...oe([0,1.6])),[,n]=D(...oe([0,-1.2]));if(kt(ii(e,i,n,o.floor0,o.ink)),e.save(),e.clip(),kt(null,L(o.text,.07),.3*ke*xt),e.restore(),E(!0,o.anchorLane,8),kt(null,L(o.anchorLane,.6),Math.max(1.5,.03*xt)),E(!1),Nt.cover){f(Vn(Nt.cover,()=>Qn(Nt.cover)).map(oe)),kt(L(o.text,.09),L(o.text,.4));for(const c of Nt.screws)Te(c,.04,.04),kt(L(o.nut,.85))}},Cn=i=>qn*(.7+.14*(U-1-i)),Mi=()=>{if(t.plate?.key!==An||t.plate.t!==o)return t.plate={key:An,t:o},Dn();const i=t.plate;if(!i.image){const[n,c]=[[],[]];for(const J of[...zt.outline,...zt.keys.map(({u:H,side:F,edge:I})=>[H,I+F*.8])]){const[H,F]=D(...oe(J));n.push(H),c.push(F)}const s=Math.floor(Math.max(0,Math.min(...n)-24)*d)/d,r=Math.min(M,Math.max(...n)+24),p=Math.floor(Math.max(0,Math.min(...c)-24)*d)/d,u=Math.min(Ft,Math.max(...c)+24);i.image=new OffscreenCanvas(Math.max(1,Math.ceil((r-s)*d)),Math.max(1,Math.ceil((u-p)*d)));const[v,b,k]=[e,Pt,ee];[e,Pt,ee,i.x,i.y]=[i.image.getContext("2d"),0,null,s,p],e.setTransform(d,0,0,d,-s*d,-p*d),e.lineCap=e.lineJoin="round",Dn(),[e,Pt,ee]=[v,b,k]}e.drawImage(i.image,i.x,i.y,i.image.width/d,i.image.height/d)},Rn=()=>{e.fillStyle=o.board,f([[0,G,0],[Lt+.6,G,0],[Lt+.6,A,0],[0,A,0]]),at(),e.fillStyle=L(o.anchorFill,.16),f([[t.left,G,0],[t.right,G,0],[t.right,A,0],[t.left,A,0]]),at(),e.fillStyle=o.inlayDot;const i=s=>(Math.max(0,Math.ceil(s)-1)+.5)*R;e.beginPath();for(const s of jn)for(const r of s%12?[i((U-1)/2)]:[i((U-1)/4),ot-i((U-1)/4)]){const[p,u,v]=D(s-.5,r,0);e.moveTo(p+.1*v,u),e.ellipse(p,u,.1*v,.08*v,0,0,Math.PI*2)}at(),zt&&Mi();const[,n]=D(rt[0],A,0),[,c]=D(rt[0],G,0);e.strokeStyle=ii(e,n,c,L(o.anchorPost,.75),o.post),e.lineWidth=Math.max(1.5,.05*xt),e.beginPath();for(let s=1;s<=Lt;s++)Xt([s,G-.04,0],[s,A+.04,0]);N(),e.strokeStyle=o.nut,e.lineWidth=Math.max(3,.12*xt),S([0,G-.06,0],[0,A+.06,0]),E(!0,o.anchorPost,12),e.strokeStyle=o.anchorPost,e.lineWidth=Math.max(3,.07*xt);for(const s of[t.left,t.right])S([s,G-.14,0],[s,A+.14,0]);E(!1);for(let s=0;s<U;s++){const r=Cn(s);E(!0,Tt(s),3),e.strokeStyle=L(Tt(s),.9),e.lineWidth=r,kn(s),N(),E(!1),e.strokeStyle="rgba(255, 255, 255, 0.25)",e.lineWidth=Math.max(.6,r*.3),kn(s,.012),N()}if(zt&&(zt.ends.forEach(([s,r],p)=>{if(Nt.clamps)De(s-.1,s+.1,r-.1,r+.1,.04),kt(L(o.text,.22),L(o.text,.45)),Te([s,r],.05,.05),kt(o.nut);else{Te([s,r],.17,.17),kt(L(o.ink,.5),L(o.nut,.4)),Te([s,r],.085,.085),kt(o.nut),Te([s,r],.03,.03),kt(L(o.ink,.85));const[u,v,b]=D(...en[p]),[k,J]=D(0,lt(p),0),H=Math.atan2(J-v,k-u);e.beginPath(),e.arc(u,v,.1*ke*b,H-1.3,H+1.3),kt(null,Tt(p),Cn(p))}}),Nt.tree)){const s=[U-2,U-1].map(r=>{const[p,u]=zt.ends[r];return Pn(r)+(u-Pn(r))*Nt.tree/p});De(Nt.tree-.05,Nt.tree+.05,Math.min(...s)-.08,Math.max(...s)+.08,.04),kt(L(o.nut,.7),L(o.ink,.6))}for(const s of[!1,!0])for(let r=1;r<=Lt;r++){const p=r>=_.fret&&r<_.fret+_.width,u=jn.includes(r);(p||u)===s&&Dt(String(r),r-.5,G-.3,0,p?.3:u?.26:.2,p?o.accent:u?o.inlay:o.numOff,s?800:500,"center",!1)}},Fe=(i,n)=>D(i,n,0).slice(0,2).map(c=>Math.round(c*d*10)).join(":"),An=[o.headstock,U,R,Tn,M,d,Math.round(pt*1e4),Fe(0,G),Fe(Lt,G),Fe(0,A),Fe(Lt,A),Fe(-4,ot/2)].join(),nn=!Ze.size&&[An,_.fret,_.width,Math.round(t.left*1e3),Math.round(t.right*1e3)].join();if(!nn||t.board?.key!==nn||t.board.t!==o)t.board=nn&&{key:nn,t:o},Rn();else{const i=t.board;if(!i.drawn){const n=[[0,A+.2],[Lt,A+.2],[0,G-.9],[Lt,G-.9]].map(([u,v])=>D(u,v,0)[1]);zt&&n.push(...[...zt.outline,...zt.keys.map(({u,side:v,edge:b})=>[u,b+v*.8])].map(u=>D(...oe(u))[1]));const c=Math.floor(Math.max(0,Math.min(...n)-24)*d)/d,s=Math.min(Ft,Math.max(...n)+24),[r,p]=[Math.ceil(M*d),Math.max(1,Math.ceil((s-c)*d))];(t.boardImage?.width!==r||t.boardImage.height!==p)&&(t.boardImage=new OffscreenCanvas(r,p)),[e,Pt,ee,i.y,i.drawn]=[t.boardImage.getContext("2d"),c,null,c,!0],e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,r,p),qt(),e.lineCap=e.lineJoin="round",e.textBaseline="middle",Rn(),[e,Pt,ee]=[m,0,null]}e.drawImage(t.boardImage,0,i.y,t.boardImage.width/d,t.boardImage.height/d)}fe("board");const En=(i,n)=>i.letRing&&-n>.25;for(const i of mt){const n=i.time-h;if(n>0||-n>Math.max(i.sustain,.15)||i.mute)continue;const c=Tt(i.string),s=tn(i);if(E(!En(i,n),c,10),e.strokeStyle=c,e.lineWidth=qn+3,kn(i.string,0,!0),N(),E(!1),-n<.2){const[r,p,u]=D(he(i).x,s,0);e.save(),e.translate(r,p),e.scale(1,.4);const v=e.createRadialGradient(0,0,0,0,0,.5*u);v.addColorStop(0,L(o.flash,.8*(1+n/.2))),v.addColorStop(1,L(o.flash,0)),e.fillStyle=v,e.beginPath(),e.arc(0,0,.5*u,0,Math.PI*2),at(),e.restore()}}e.strokeStyle=o.anchorLane,e.lineWidth=2.5,E(!0,o.anchorLane,10);for(const i of l.handShapes??[]){if(i.startTime>h||i.endTime<=h||i.endTime-i.startTime<.3||!i.frets.some((s,r)=>s>=0&&r<U))continue;const[n,c]=Y(i.frets.filter((s,r)=>r<U),i.startTime);f([[n,G,0],[c,G,0],[c,A,0],[n,A,0]]),N()}E(!1),fe("strings");for(const i of mt){const n=i.time-h,c=tt(n),s=Ut(i),{a:r,open:p,x:u,y:v}=he(i),b=Qe(i,u,-n);if(n<-.15||Math.abs(D(b,v,c)[0]-M/2)>M/2+200)continue;const k=p?(r.width-.2)/2:.34;e.globalAlpha=n<0?Math.max(0,1+n/.15):Math.min(1,(Q-n)/.4),!s&&ge&&(e.strokeStyle=ge,e.lineWidth=2,S([b-k,P,c],[b+k,P,c])),!(p||te(i))&&(e.strokeStyle=L(Tt(i.string),i.repeat||s?.highDensity?.35:.75),e.lineWidth=1.5,S([b,Math.min(v,tn(i))-.42*R,c],[b,P,c]))}e.globalAlpha=1;const On=(i,n,c)=>{const s=Array.from({length:13},(r,p)=>{const u=p/12;return[i[0]+(n[0]-i[0])*u,i[1]+(n[1]-i[1])*u+Math.sin(Math.PI*u)*c,i[2]+(n[2]-i[2])*u]});f(s,!1),N()};for(const i of zi(l)){if(i.end<=h||i.time>=h+Q)continue;const[n,c]=Y(i.frets,i.time),s=i.time-h,r=tt(Math.max(s,0)),p=tt(Math.min(i.end-h,Q));e.globalAlpha=Math.min(1,(Q-Math.max(s,0))/.4),E(!i.arpeggio,o.anchorLane,10,!0),e.strokeStyle=gt(o.anchorLane,1,.2),e.lineWidth=3.5;for(const u of[n,c])S([u,P,r],[u,P,p]);E(!1),i.arpeggio&&s>0&&(e.strokeStyle=L(o.anchorLane,.7),e.lineWidth=1.5,f([[n,P,r],[n,A,r],[c,A,r],[c,P,r]],!1),N(),i.arpeggio.name&&r>Ce&&Dt(i.arpeggio.name,n-.12,A/2,r,.34,o.text,600,"right"))}e.globalAlpha=1;const wn=(i,n)=>{const c=he(i);return Math.abs(c.x-n)<(c.open?(c.a.width-.2)/2+.1:.45)};for(const[i,n]of mt.entries()){const c=n.time-h,s=Ut(n),r=n.slideTo??n.slideUnpitchTo??null,{a:p,open:u,x:v,y:b}=he(n),k=Tt(n.string),J=tt(c),H=(u?(p.width-.2)/2:.34)*(n.grace?.6:1),F=(u?.12:.42)*R*(n.grace?.6:1);if(c>-.15&&!s?.highDensity&&!n.repeat){if(e.globalAlpha=Math.min(1,(Q-c)/.4),e.strokeStyle=k,e.lineWidth=2,e.setLineDash([4,4]),n.slideIn&&S([v+(n.slideIn==="below"?-1.4:1.4),b-F,Math.max(0,J-1)],[v+(n.slideIn==="below"?-H:H),b,J]),n.slideOut&&S([v+(n.slideOut==="up"?H:-H),b,J],[v+(n.slideOut==="up"?1.4:-1.4),b-F,J+1]),e.setLineDash([]),typeof n.tieTo=="number"){const C=l.notes[n.tieTo],z=he(C);e.setLineDash([5,4]),On([v,b+F,J],[z.x,z.y+F,tt(C.time-h)],R*.9),e.setLineDash([])}e.globalAlpha=1}const I=r===null?n.sustain:Math.max(n.sustain,.25),B=r!==null||n.bend||n.bendCurve||n.whammy;if(I<=.2||c+I<=0||s&&!B||te(n))continue;u&&r&&(e.strokeStyle=k,e.lineWidth=2.5,e.setLineDash(n.letRing?[7,6]:[]),On([v,b,tt(Math.max(c,0))],[r-.5,b,tt(Math.min(c+I,Q))],R*1.5),e.setLineDash([]));let yt=null;for(let C=i+1;C<mt.length&&mt[C].time<=n.time+I+.02;C++){const z=mt[C];if(!(z.time<=n.time+.005)&&(Ut(z)||z.string===n.string||wn(z,v))){yt=z;break}}const ut=Math.max(c,0),X=n.bend||n.bendCurve||n.whammy;let st=Math.min(c+I,Q,yt?yt.time-h:1/0);if(st<=ut)continue;const y=C=>{const z=C-c,g=tt(C),T=n.bend||n.bendCurve||n.whammy,w=n.vibrato&&!T?Math.sin(g/1.6*Math.PI*2)*R*(n.vibratoWide?.45:.25):0,it=n.tremolo?Math.floor(g/.3)%2?.05:-.05:0,q=sn+(vi-sn)*oi(Math.min(1,g/Wi));return[Qe(n,v,z)+it,b+w+In(n,z)*q/sn,g]},It=yt&&y(st)[0],Ct=yt&&Ut(yt)?.notes.find(C=>wn(l.notes[C],It)),Z=typeof Ct=="number"?l.notes[Ct]:yt;if(yt&&(X||wn(Z,It))){const C=he(Z),z=tt(Z.time-h),g=C.open?(C.a.width-.2)/2:.34,T=D(C.x,C.y-(C.open?.12:.42)*R,z)[1]+3,[w]=D(C.x-g,C.y,z),[it]=D(C.x+g,C.y,z),q=wt=>{const[Yt,V]=D(...y(wt));return V<T&&Yt>Math.min(w,it)-2&&Yt<Math.max(w,it)+2};if(q(st)&&!q(ut)){let wt=ut,Yt=st;for(let V=0;V<24;V++)[wt,Yt]=q((wt+Yt)/2)?[wt,(wt+Yt)/2]:[(wt+Yt)/2,Yt];st=wt}if(st<=ut+.001)continue}const Bt=r===null&&!X&&!n.vibrato&&!n.tremolo?1:Math.min(400,Math.max(12,Math.ceil((st-ut)*vt*8))),Gt=Array.from({length:Bt+1},(C,z)=>y(ut+(st-ut)*z/Bt));if(u&&!s){e.fillStyle=gt(k,n.letRing?.14:.26,.03),f([...Gt.map(([C,z,g])=>[C-H,z,g]),...Gt.slice().reverse().map(([C,z,g])=>[C+H,z,g])]),at(),E(!n.letRing,k,6,!0),e.strokeStyle=gt(k,.95,.3),e.lineWidth=2.5,e.setLineDash(n.letRing?[7,6]:[]);for(const C of[-H,H])f(Gt.map(([z,g,T])=>[z+C,g,T]),!1),N();e.setLineDash([]),E(!1)}else if(n.bend||n.bendCurve||n.whammy){const C=z=>f([...Gt.map(([g,T,w])=>[g-z,T,w]),...Gt.slice().reverse().map(([g,T,w])=>[g+z,T,w])]);C(ln),e.fillStyle=gt(k,1,.6),at(),C(ln*.35),e.fillStyle=gt(Wn(k,-.22),1,.55),at(),E(!0,k,8,!0),e.strokeStyle=gt(Wn(k,.6),1,.5),e.lineWidth=2;for(const z of[-ln,ln])f(Gt.map(([g,T,w])=>[g+z,T,w]),!1),N();E(!1)}else E(!n.letRing,k,6,!0),e.fillStyle=gt(k,n.letRing?.4:.75,n.letRing?.15:.3),f([...Gt.map(([C,z,g])=>[C-.09,z,g]),...Gt.slice().reverse().map(([C,z,g])=>[C+.09,z,g])]),at(),E(!1);if((n.letRing||r!==null||!X&&(n.vibrato||n.tremolo))&&(e.strokeStyle=gt(n.letRing?k:"#ffffff",.75,.3),e.lineWidth=n.letRing?2:1.5,e.setLineDash(n.letRing?[7,6]:[]),f(Gt,!1),N(),e.setLineDash([])),r!==null&&st>=Math.min(c+I,Q)-.001){const[C,z,g]=y(c+I);e.strokeStyle=k,e.lineWidth=2,e.setLineDash(n.slideTo===null?[5,4]:[]),u?nt(r-.5,z,g,.34,.42*R):nt(C,z,g,H,F),N(),e.setLineDash([])}}fe("trails");const Bn=new Set;for(let i=mt.length-1;i>=0;i--){const n=mt[i],c=n.time-h,s=tt(c),r=Ut(n),{a:p,open:u,x:v}=he(n),b=Qe(n,v,-c),k=tn(n),J=n.mute||r?.fretHandMute,H=n.palmMute||r?.palmMute,F=Tt(n.string),I=(u?(p.width-.2)/2:.34)*(n.grace?.6:1),B=(u?.12:.42)*R*(n.grace?.6:1),yt=n.slideTo??n.slideUnpitchTo??null;if(c<-.15)continue;const ut=c<0?Math.max(0,1+c/.15):Math.min(1,(Q-c)/.4);if(e.globalAlpha=ut,r&&!Bn.has(n.chord)){Bn.add(n.chord);const[g,T]=Y(r.notes.map(V=>l.notes[V].fret),n.time),w=e.globalAlpha,it=s<Ce,q=it?.65:r.highDensity&&o.repeatMarks!=="frame"?.18:.5;if(f([[g,P,s],[T,P,s],[T,A,s],[g,A,s]]),o.frames==="gradient"){const[,V]=D(g,P,s),[,_t]=D(g,A,s),Rt=it?o.anchorLane:o.anchorFill;ye(ni(e,`${Rt}|${q}`,[[0,L(Rt,q*.6)],[1,L(Rt,0)]]),V,_t)}else e.globalAlpha=w*q,r.highDensity||(e.fillStyle=o.chordFill,at()),e.strokeStyle=it?o.anchorLane:o.chordBox,e.lineWidth=it||!r.highDensity?1.5:1.2,E(it,o.anchorLane,8),N(),E(!1);if(e.globalAlpha=w,e.strokeStyle=ge,e.lineWidth=2,ge&&S([g,P,s],[T,P,s]),r.highDensity&&(r.palmMute||r.fretHandMute)&&(e.strokeStyle=r.palmMute?o.muted:"#ffffff",et((g+T)/2,P+R*.4,s,r.palmMute?.22:.12,R*(r.palmMute?.35:.22))),r.accent){const V=Math.min(.6,(T-g)*.22),_t=(A-P)*.35,Rt=Math.min(1,D(g,A,s)[2]/D(g,A,Ce)[2]);e.strokeStyle="#ffffff",e.lineWidth=Math.max(1,3.5*Rt*(r.accent==="heavy"?1.4:1)),e.lineCap="square",E(!0,"#ffffff",Math.max(2,12*Rt)),f([[g,A-_t,s],[g,A,s],[g+V,A,s]],!1),N(),f([[T-V,A,s],[T,A,s],[T,A-_t,s]],!1),N(),E(!1),e.lineCap="round"}if(r.barre&&(!r.highDensity||o.repeatMarks==="grey")){const V=r.barre.fret-.5;e.strokeStyle=r.highDensity?o.muted:"rgba(255, 255, 255, 0.7)",e.lineWidth=Math.max(3,.1*D(V,ot/2,s)[2]);const[_t,Rt]=[lt(r.barre.from),lt(r.barre.to)].sort((ae,Ht)=>ae-Ht);S([V,_t-R*.4,s],[V,Rt+R*.4,s]),Dt(r.barre.half?"½B":"B",V,A+.12,s,.22,r.highDensity?o.muted:o.text)}if(r.strum||r.roll){const V=g-.25,_t=lt(0)>lt(U-1)?A-.1:P+.15,Rt=_t>ot/2?P+.15:A-.1,[ae,Ht]=(r.strum??r.roll)==="down"?[_t,Rt]:[Rt,_t];e.strokeStyle=o.text,e.lineWidth=2,r.roll?f(Array.from({length:17},(Ui,Gn)=>[V+Math.sin(Gn/16*Math.PI*6)*.06,ae+(Ht-ae)*Gn/16,s]),!1):f([[V,ae,s],[V,Ht,s]],!1),N();const zn=Ht<ae?.14:-.14;S([V-.08,Ht+zn,s],[V,Ht,s]),S([V+.08,Ht+zn,s],[V,Ht,s])}const wt=l.chords[n.chord-1],Yt=!wt||n.time-wt.time>1||wt.name!==r.name;s>Ce&&r.name&&!r.highDensity&&Yt&&Dt(r.name,g-.12,A/2,s,.34,o.text,600,"right")}const[X,st,y]=D(b,k,s);if(X<-200||X>M+200||te(n)){e.globalAlpha=1;continue}const It=n.repeat||r?.highDensity;if(It){const g=s<Ce;e.globalAlpha*=g?.9:.4,e.strokeStyle=F,e.lineWidth=g?2:1.5,E(g,F,8),nt(b,k,s,I,B),N(),E(!1),(J||H)&&o.repeatMarks!=="hide"&&be(b,k,s,y,u?.34:I,u?R*.3:B,H,o.muted),e.globalAlpha=ut}else{if(!u&&s>1.75&&o.fretNumbers){const g=n.harmonic||n.harmonicPinch?`<${n.fret}>`:n.ghost?`(${n.fret})`:String(n.fret);Dt(g,b,P,s-.55,n.grace?.18:.26,F)}if(n.dynamicLabel&&Dt(n.dynamicLabel,b-.6,P,s,.3,o.text,"italic 700","right"),n.ghost&&(e.globalAlpha=ut*.5),o.gem==="pill")o.notes3d!==!1&&(nt(b,k,s+Xn,I,B),e.fillStyle=F,at(),e.fillStyle="rgba(255, 255, 255, 0.35)",at()),nt(b,k,s,I,B),e.fillStyle=F,at();else{const g=n.harmonic||n.harmonicPinch,T=Xn;if(!g&&o.notes3d!==!1)for(const[q,wt]of[[[[b-I,k+B,s],[b+I,k+B,s],[b+I,k+B,s+T],[b-I,k+B,s+T]],"rgba(255, 255, 255, 0.35)"],[[[b-I,k-B,s],[b-I,k+B,s],[b-I,k+B,s+T],[b-I,k-B,s+T]],"rgba(0, 0, 0, 0.4)"],[[[b+I,k-B,s],[b+I,k+B,s],[b+I,k+B,s+T],[b+I,k-B,s+T]],"rgba(0, 0, 0, 0.4)"]])f(q),e.fillStyle=F,at(),e.fillStyle=wt,at();E(s<Ce,F,8),e.fillStyle=F,g?f([[b,k+B*1.3,s],[b+I*.8,k,s],[b,k-B*1.3,s],[b-I*.8,k,s]]):nt(b,k,s,I,B),at(),E(!1);const[,w]=D(b,k+B,s),[,it]=D(b,k-B,s);ye(ni(e,"shine",[[0,"rgba(255, 255, 255, 0.45)"],[.5,"rgba(255, 255, 255, 0)"],[1,"rgba(0, 0, 0, 0.25)"]]),w,it),e.strokeStyle="rgba(255, 255, 255, 0.6)",e.lineWidth=1,N()}if((J||H)&&be(b,k,s,y,u?.34:I,u?R*.3:B,H,u&&H?F:null),!u&&!J&&!H){const g=n.finger??(r?.fingers?.[n.string]>=0?r.fingers[n.string]:null),T=g!==null?g===0?"T":String(g):"";if(T){const w=e.globalAlpha;e.globalAlpha=w*Math.min(1,Math.max(0,(1-c/Q)/.4)),Dt(T,b,k,s-.01,R*.62,ht,700,"center",Ot,!0),e.globalAlpha=w}}}if(It&&o.repeatMarks==="hide"){e.globalAlpha=1;continue}const Ct=It?o.muted:o.text;if(e.globalAlpha=ut*(It?.8:1)*Math.min(1,Math.max(0,(1-c/Q)/.15)),n.ghost){const[g]=D(b-I,k,s),[T]=D(b+I,k,s),w=B*y*1.5;e.strokeStyle=It?Ct:F,e.lineWidth=Math.max(1.2,.035*y),e.beginPath(),e.arc(g+w*.35,st,w,Math.PI*.7,Math.PI*1.3),N(),e.beginPath(),e.arc(T-w*.35,st,w,-Math.PI*.3,Math.PI*.3),N()}if(n.grace&&(e.strokeStyle=Ct,e.lineWidth=Math.max(1,.03*y),Ye(e,X-I*y*pt*1.2,st+B*y*1.4,X+I*y*pt*1.2,st-B*y*1.4)),n.showString){const[g]=D(b-I,k,s),T=.12*y,w=g-T-.06*y;e.strokeStyle=e.fillStyle=It?Ct:F,e.lineWidth=Math.max(1,.025*y),e.beginPath(),e.arc(w,st,T,0,Math.PI*2),N(),ne(String(U-n.string),w,st,.15*y,700,"center"),e.fillText(String(U-n.string),0,0),qt()}let Z=st-B*y-.18*y;e.strokeStyle=e.fillStyle=Ct,e.lineWidth=Math.max(1.2,.04*y),e.textAlign="center";const on=(g,T,w="700")=>{T*y<2||(ne(g,X,Z,T*y,w,"center"),e.fillText(g,0,0),qt(),Z-=(T+.04)*y)};let Bt=st-B*y;const Gt=n.tap&&!n.tapLeft;if((n.hammerOn||n.pullOff)&&!Gt){const g=n.grace?.6:1,T=.2*y*pt*g,w=.38*R*y*g,[it,q]=n.hammerOn?[Bt+.4*w,Bt-.6*w]:[Bt-.6*w,Bt+.4*w];e.beginPath(),e.moveTo(X-T,q),e.lineTo(X+T,q),e.lineTo(X,it),e.closePath(),e.fillStyle=It?Ct:"#ffffff",e.strokeStyle=L(o.ink,.9),e.lineWidth=Math.max(1.5,.03*y),N(),at(),Bt-=.6*w,Z=Math.min(Z,Bt-.14*y),e.strokeStyle=e.fillStyle=Ct,e.lineWidth=Math.max(1.2,.04*y)}if(Gt){const g=n.grace?.6:1,T=.28*y*pt*g,w=.62*R*y*g,it=Bt+.15*w,q=it-w;e.beginPath(),e.moveTo(X,it),e.lineTo(X+T,q),e.lineTo(X,q+.38*w),e.lineTo(X-T,q),e.closePath(),e.strokeStyle=L(o.ink,.9),e.lineWidth=Math.max(3.5,.1*y),N(),e.fillStyle=It?L(Ct,.4):L(Wn(F,.55),.85),at(),e.strokeStyle=It?Ct:F,e.lineWidth=Math.max(1.8,.05*y),N(),Bt=q,Z=Math.min(Z,Bt-.14*y),e.strokeStyle=e.fillStyle=Ct,e.lineWidth=Math.max(1.2,.04*y)}const C=Ee(n);if(C>0){const g=n.bendCurve?.[0]?.[1]>0,T=(n.bendCurve?.length??0)>1&&n.bendCurve.at(-1)[1]<C,w=Math.min(3,Math.max(1,Math.round(C*2))),it=I*y*pt*.6,q=I*y*.3,wt=q*1.25,Yt=L(o.ink,.9);let V=Bt-.04*y;const _t=ae=>{for(let Ht=0;Ht<w;Ht++)gi(e,X,V-Ht*wt-(ae>0?0:q),it,q,ae,It?Ct:F,Yt);V-=w*wt+.08*y};(!g||!T)&&_t(-1),T&&_t(1);const Rt=`${g?"pre ":""}${fi(C)}`;e.fillStyle=Ct,ne(Rt,X+it+.08*y,(st-B*y+V)/2,.22*y,700,"left"),e.fillText(Rt,0,0),qt(),e.textAlign="center",Z=Math.min(Z,V-.1*y)}n.staccato&&(e.beginPath(),e.arc(X,Z+.04*y,Math.max(1.5,.045*y),0,Math.PI*2),at(),Z-=.16*y),n.accent&&(n.accent==="tenuto"||!r?.accent)&&on({heavy:"^",tenuto:"–"}[n.accent]??">",.3);const z=[n.tapLeft?"m.g.":"",hi[n.harmonicType]??(n.harmonicPinch?"PH":""),n.slap?"slap":n.pop?"pop":"",n.golpe?`golpe (${n.golpe})`:"",n.rasgueado?`rasg. ${n.rasgueado}`:"",typeof n.trill=="number"?`tr ${n.trill}`:"",n.ornament??"",n.fade??"",n.whammy?"w/bar":"",n.wah==="open"?"o":n.wah==="closed"?"+":""];for(const g of z)g&&on(g,g.length>2?.22:.28);if(n.rightFinger&&on(n.rightFinger,.26,"italic 700"),n.vibrato){const g=.24*y,T=(n.vibratoWide?.07:.035)*y;e.beginPath();for(let w=0;w<=20;w++)e[w?"lineTo":"moveTo"](X-g+2*g*w/20,Z+Math.sin(w/20*Math.PI*4)*T);N(),Z-=(.16+(n.vibratoWide?.06:0))*y}if(n.pick){const g=.09*y,T=.13*y;e.beginPath(),n.pick==="down"?[[-g,T/2],[-g,-T/2],[g,-T/2],[g,T/2]].forEach(([w,it],q)=>e[q?"lineTo":"moveTo"](X+w,Z+it)):[[-g,-T/2],[0,T/2],[g,-T/2]].forEach(([w,it],q)=>e[q?"lineTo":"moveTo"](X+w,Z+it)),N(),Z-=.22*y}if(n.fermata&&(e.beginPath(),e.arc(X,Z+.06*y,.14*y,Math.PI,0),N(),e.beginPath(),e.arc(X,Z+.02*y,Math.max(1.5,.03*y),0,Math.PI*2),at(),Z-=.24*y),n.tremolo){for(let g=-1;g<=1;g++)Ye(e,X-.12*y,Z+(g*.08+.05)*y,X+.12*y,Z+(g*.08-.05)*y);Z-=.34*y}if(yt!==null&&!u){const g=Math.sign(yt-n.fret)||1,T=X-g*.16*y,w=X+g*.16*y,it=Z+.07*y,q=Z-.09*y;Ye(e,T,it,w,q),Ye(e,w,q,w-g*.1*y,q),Ye(e,w,q,w,q+.1*y),Z-=.3*y}e.globalAlpha=1}fe("notes");const _n=new Set;for(const i of mt){const n=i.time-h,c=Ut(i);if(!c?.barre||_n.has(c)||n>.06||n<-Math.max(i.sustain,.12))continue;_n.add(c),e.strokeStyle="rgba(255, 255, 255, 0.85)",e.lineWidth=Math.max(4,.12*xt);const[s,r]=[lt(c.barre.from),lt(c.barre.to)].sort((p,u)=>p-u);S([c.barre.fret-.5,s-R*.45,0],[c.barre.fret-.5,r+R*.45,0])}const Hn=new Set,Fn=new Set;for(const i of mt){const n=i.time-h,c=Ut(i),s=Ze.get(i.string),r=i.heldFrom??null,p=n<=.06||r!==null&&h>=r-.06,u=(i.slideTo??i.slideUnpitchTo??null)!==null;if(i.mute||n>an||n<-Math.max(i.sustain,u?.25:.12)||(c?.highDensity||r!==null)&&!p||s&&s.note!==i&&!p||p&&Hn.has(`${i.string}:${i.fret}`))continue;p&&Hn.add(`${i.string}:${i.fret}`),Fn.add(`${i.string}:${i.fret}`);const{a:v,open:b,x:k}=he(i),J=Qe(i,k,-n),H=tn(i),F=Tt(i.string),I=(b?(v.width-.2)/2:.32)+2/xt,B=(b?.1:.36)*R+2/xt;if(nt(J,H,0,I,B),p)E(!En(i,n),F,14),e.fillStyle=F,at(),E(!1),e.strokeStyle="rgba(255, 255, 255, 0.7)",e.lineWidth=1.5,N();else{const ut=(1-n/an)**2;e.globalAlpha=.35*ut,e.fillStyle=F,at(),e.globalAlpha=.25+.75*ut,e.strokeStyle=F,e.lineWidth=2.2,N()}const yt=i.finger??(c?.fingers?.[i.string]>=0?c.fingers[i.string]:null);if(!b&&yt!==null&&Dt(yt===0?"T":String(yt),J,H,0,R*.55,p?ht:o.text,800,"center",!p||Ot),!b&&Ee(i)>0){const[ut,X]=D(J,H+B,0),st=i.bendCurve?.[0]?.[1]>0&&i.bendCurve.at(-1)[1]<Ee(i);gi(e,ut,X-(st?.14:.05)*xt,.17*xt*pt,.085*xt,st?1:-1,"#ffffff",L(o.ink,.9))}e.globalAlpha=1}for(const i of l.handShapes??[])!i.arpeggio||i.startTime-h>an||i.endTime<=h||(e.globalAlpha=.3+.5*Math.min(1,1-(i.startTime-h)/an)**2,i.frets.forEach((n,c)=>{if(n<=0||c>=U||Fn.has(`${c}:${n}`))return;const s=n-.5,r=lt(c),p=i.fingers[c];nt(s,r,0,.32+2/xt,.36*R+2/xt),e.strokeStyle=Tt(c),e.lineWidth=2.2,N(),p>=0&&Dt(p===0?"T":String(p),s,r,0,R*.55,o.text,800)}),e.globalAlpha=1);fe("targets");const Nn=Ni(l),vn=Nn.findLast(i=>i.time<=h&&h<i.end+.3),xi=vn?null:Nn.find(i=>i.time>h&&i.time-h<1.2),Ne=vn??xi;if(Ne){const[i,n]=D(t.right+.4,A+.5,0),c=jt(e,Ie[700]??=`700 ${de}px ${o.num}`,Ne.name).width*52/de;e.globalAlpha=vn?1:Math.max(.35,1-(Ne.time-h)/1.2),e.fillStyle=o.text,ne(Ne.name,Math.min(i,M-24-c),n,52,700,"left"),e.fillText(Ne.name,0,0),qt(),e.globalAlpha=1}fe("labels")}const Yi=240,qi=64,me=100,Oe=24,ui=150;function Xi(a,l){if(a.tabPages?.length===l)return a.tabPages.pages;const h=a.notes.at(-1),o=Math.max(h?h.time+h.sustain:0,a.beats.at(-1)?.time??0)+.5;let t=a.beats.filter(d=>d.measure>=0).map(d=>d.time);t.length<2&&(t=Array.from({length:Math.ceil(o/l)+1},(d,e)=>e*l)),t=[Math.min(0,t[0]),...t.filter(d=>d>0),Math.max(o,t.at(-1)+.01)];const m=[];let M=t[0];for(let d=1;d<t.length;d++)t[d]-M>l&&t[d-1]>M&&m.push({start:M,end:M=t[d-1]});m.push({start:M,end:t.at(-1)});for(let d=0;d<m.length-1;d++)m[d].end=m[d+1].start;return a.tabPages={length:l,pages:m},m}function Vi(a,l,h,o){const{g:t,W:m}=pi(a);if(!l)return;const M=l.strings,d=Math.min(qi,320/Math.max(1,M-1))*(o.boardHeight??1),e=Ft*.62-d*(M-1)/2,$=e+d*(M-1),_=e-d*1.65,U=$+d*1.45,ct=W=>e+(o.stringOrder==="high"?M-1-W:W)*d,R=Yi*(o.noteSpeed??1),ot=o.tabLayout==="pages",lt=me+30,vt=m-Oe-30,Q=ot?Math.min(170,(vt-lt)*.14):0,G=vt-(ot?Q+24:0);let A,P,Mt,tt,Tt=null;if(ot){const W=Xi(l,(G-lt)/R),K=Math.max(0,W.findLastIndex(Et=>Et.start<=h)),j=W[K],St=(G-lt)/(j.end-j.start);A=Et=>lt+(Et-j.start)*St,[Mt,tt]=[j.start,j.end-.001],P=A(Math.min(Math.max(h,j.start),j.end)),W[K+1]&&(Tt={start:W[K+1].start,scale:St})}else P=Math.max(me+ui+60,m*.2),A=W=>P+(W-h)*R,[Mt,tt]=[h-(P-me)/R,h+(m-P)/R];const ge=W=>o.str[W%o.str.length],Jt=W=>W.chord===null||W.chord===void 0?null:l.chords[W.chord],rt=(W,K,j,St)=>{t.beginPath(),t.moveTo(W,K),t.lineTo(j,St),t.stroke()},Pe=(W,K,j,St)=>{const Et=Math.hypot(j,St),[Wt,Vt]=[j/Et,St/Et];rt(W,K,W-6*Wt-4*Vt,K-6*Vt+4*Wt),rt(W,K,W-6*Wt+4*Vt,K-6*Vt-4*Wt)},Ae=W=>W>=P-1?1:.4;t.lineCap="round",t.lineJoin="round",t.textBaseline="alphabetic";const Be=[],Kt=W=>{W&&(t.save(),t.beginPath(),t.rect(W[0],0,W[1]-W[0],Ft),t.clip());const K=`600 ${ce(Math.min(15,d*.26))}px ${o.num}`,j=`700 ${ce(Math.min(13,d*.22))}px ${o.num}`,St=new Map;t.font=K,t.textAlign="left";const Et=new Path2D,Wt=new Path2D;t.fillStyle=o.muted;for(let x=Ge(l.beats,Mt-1);x<l.beats.length;x++){const f=l.beats[x];if(f.time>tt)break;const S=A(f.time),nt=f.measure>=0,Y=nt?Et:Wt;Y.moveTo(S,e-d*.35),Y.lineTo(S,$+d*.35),nt&&(t.fillText(String(f.measure),S+6,_+d*.36),St.set(Math.round(f.time*50),jt(t,K,String(f.measure)).width+16))}t.lineWidth=1,t.strokeStyle=L(o.text,.05),t.stroke(Wt),t.lineWidth=1.5,t.strokeStyle=L(o.text,.16),t.stroke(Et),t.fillStyle=o.accent;const Vt=new Map;for(const x of l.markers??[])x.time>=Mt&&x.time<=tt&&Vt.set(Math.round(x.time*50),[...Vt.get(Math.round(x.time*50))??[],x.text]);for(const[x,f]of Vt)t.fillText([...new Set(f)].join(" · "),A(x/50)+6+(St.get(x)??0),_+d*.36);t.strokeStyle=L(o.text,.14),t.beginPath();for(let x=0;x<M;x++)t.moveTo(me,ct(x)),t.lineTo(m-Oe,ct(x));t.stroke();const ve=$+d*.92,pe=$+d*1.24;if(o.guides!==!1){t.font=K,t.fillStyle=t.strokeStyle=o.anchorLane,t.lineWidth=2;let x=-1/0;const f=l.anchors??[];for(let S=Math.max(1,Ge(f,Mt));S<f.length&&f[S].time<=tt;S++){const nt=f[S],Y=A(nt.time);if(Y<x)continue;const et=`fret ${nt.fret}`;t.globalAlpha=Ae(Y),rt(Y,$+d*.6,Y,ve-2),t.fillText(et,Y+5,ve),x=Y+5+jt(t,K,et).width+8}t.globalAlpha=1}t.strokeStyle=o.text,t.lineWidth=1.5;for(const x of l.hairpins??[]){if(x.endTime<Mt||x.time>tt)continue;const f=A(x.time),S=Math.max(f+30,A(x.endTime)),[nt,Y]=x.kind==="cresc"?[f,S]:[S,f];t.globalAlpha=Ae(S),t.beginPath(),t.moveTo(Y,pe-11),t.lineTo(nt,pe-5),t.lineTo(Y,pe+1),t.stroke()}t.globalAlpha=1;const ue=ce(Math.min(26,d*.42)),pt=ue*1.3,qe=ue*.32,We=o.gem==="pill"?pt/2:5,Qt={note:`700 ${ue}px ${o.num}`,grace:`700 ${ce(ue*.72)}px ${o.num}`,finger:`700 ${ce(ue*.5)}px ${o.num}`},pn=o.markings==="white";for(const x of l.handShapes??[]){if(!x.arpeggio||x.endTime<Mt||x.startTime>tt)continue;const f=x.frets.flatMap((Y,et)=>Y>=0&&et<M?[ct(et)]:[]);if(!f.length)continue;const S=A(x.startTime)-12,nt=A(x.endTime);t.globalAlpha=Ae(nt),t.strokeStyle=L(o.text,.4),t.lineWidth=1.5,t.setLineDash([6,5]),t.beginPath(),t.roundRect(S,Math.min(...f)-pt/2-6,nt-S,Math.max(...f)-Math.min(...f)+pt+12,8),t.stroke(),t.setLineDash([]),x.name&&(t.font=`700 ${ce(Math.min(24,d*.4))}px ${o.num}`,t.fillStyle=o.text,t.fillText(x.name,S,e-d*.72))}t.globalAlpha=1;const un=x=>(x.slideTo??x.slideUnpitchTo??null)!==null||!!x.slideOut,Mn=x=>{const f=Jt(x);return!!f&&!x.repeat&&!f.highDensity&&f.notes.length>1},xn=(x,f)=>4+(un(x)?16:0)+(Mn(f)?10:0)+(f.slideIn?18:0)+(f.showString?20:0);let Xe=0,_e=0;const Me=(x,f)=>{f(_e-x/2),_e-=x+3},bn={"":j,"italic ":`italic ${j}`},xe=(x,f="")=>Me(10,S=>{t.font=bn[f],t.fillText(x,Xe,S+5)}),{next:yn,prev:Ue,held:D}=Zn(l),je=new Map,Je=new Set,xt=[],Ke=[];for(let x=Ge(l.notes,Mt-D-.5);x<l.notes.length;x++){const f=l.notes[x];if(f.time>tt)break;if(A(f.time+f.sustain)<me-40-pt*4||W&&f.time<Mt&&A(f.time+f.sustain)-2<=A(Mt)&&typeof f.tieTo!="number")continue;const S=Jt(f),nt=f.grace?.72:1,Y=pt*nt,et=ct(f.string),Ot=ge(f.string),ht=A(f.time),be=f.mute||S?.fretHandMute,ee=f.palmMute||S?.palmMute,Pt=f.repeat||S?.highDensity,$e=be?"×":f.harmonic||f.harmonicPinch?`<${f.fret}>`:f.ghost?`(${f.fret})`:String(f.fret),Ie=f.finger??(S?.fingers?.[f.string]>=0?S.fingers[f.string]:null),ne=be||f.fret===0||Ie===null?"":Ie===0?"T":String(Ie),qt=f.grace?Qt.grace:Qt.note,ye=jt(t,qt,$e).width,Dt=ne?jt(t,Qt.finger,ne).width+3:0,ie=l.notes[yn[x]],Se=ie?A(ie.time)-xn(f,ie):1/0,gt=Math.min(Math.max(Y,ye+Dt+qe*2*nt),Math.max(10,Se-ht)),$t=Math.max(ht+gt,Math.min(A(f.time+f.sustain)-2,Se)),E=ht+gt/2,Sn=Math.min(1,(gt-4)/(ye+Dt)),He=je.get(f.string)??(Ue[x]>=0?{x0:A(l.notes[Ue[x]].time),w:pt}:null);if(je.set(f.string,{x0:ht,w:gt}),$t<me-40&&typeof f.tieTo!="number")continue;const Le=f.time<=h&&h<f.time+Math.max(f.sustain,.15),N=(Le||ht>=P-1?1:.4)*(f.ghost?.55:1);if(t.globalAlpha=N,S&&!Je.has(S)){Je.add(S);const le=S.notes.map(O=>ct(l.notes[O].string)),re=Math.min(...le)-pt/2,Zt=Math.max(...le)+pt/2,bt=ht-7;if(le.length>1&&!Pt&&(t.strokeStyle=S.accent?"#ffffff":L(o.text,.7),t.lineWidth=S.accent==="heavy"?4:S.accent?3:2,t.beginPath(),t.moveTo(bt+4,re),t.lineTo(bt,re),t.lineTo(bt,Zt),t.lineTo(bt+4,Zt),t.stroke()),t.font=j,t.fillStyle=t.strokeStyle=Pt?o.muted:o.text,t.lineWidth=1.8,t.textAlign="left",S.barre&&!Pt&&t.fillText(`${S.barre.half?"½":""}B${S.barre.fret}`,bt,re-5),S.strum||S.roll){const O=S.notes.map(te=>l.notes[te].string),dt=ct(Math.min(...O)),ft=ct(Math.max(...O)),[At,mt]=(S.strum??S.roll)==="down"?[dt,ft]:[ft,dt],Ut=bt-9;t.beginPath();for(let te=0;te<=16;te++)t.lineTo(Ut+(S.roll?Math.sin(te/16*Math.PI*6)*2.5:0),At+(mt-At)*te/16);t.stroke(),Pe(Ut,mt,0,mt-At||1)}const Xt=l.chords[f.chord-1];S.name&&!Pt&&(!Xt||f.time-Xt.time>1||Xt.name!==S.name)&&(t.font=`700 ${ce(Math.min(24,d*.4))}px ${o.num}`,t.fillStyle=o.text,t.fillText(S.name,ht,e-d*.72))}t.beginPath(),t.roundRect(ht,et-Y/2,$t-ht,Y,We*nt),Le&&!Pt&&(t.shadowColor=Ot,t.shadowBlur=18),Pt?(t.strokeStyle=Ot,t.lineWidth=2,t.stroke()):f.letRing&&$t>ht+gt+2?(t.fillStyle=L(Ot,.3),t.fill(),t.shadowBlur=0,t.strokeStyle=Ot,t.lineWidth=2,t.setLineDash([6,5]),rt(ht+gt+4,et,$t-4,et),t.setLineDash([]),t.beginPath(),t.roundRect(ht,et-Y/2,gt,Y,We*nt),t.fillStyle=Ot,t.fill()):(t.fillStyle=be?L(o.text,.22):Ot,t.fill()),t.shadowBlur=0,Le&&Be.push({y:et,c:Ot});const at=Pt?Ot:be?o.text:pn?"#ffffff":o.ink;xt.push({text:$e,font:qt,finger:ne,fill:at,shown:N,squeeze:Sn,x:E,y:et+jt(t,qt,$e).middle,left:-(ye+Dt)/2,textWidth:ye}),Ke.push(()=>{t.globalAlpha=N;const le=Pt?o.muted:o.text;t.strokeStyle=t.fillStyle=le,t.lineWidth=1.6;const re=f.slideTo??f.slideUnpitchTo??null,Zt=re===null?f.slideOut==="up"?1:f.slideOut?-1:0:Math.sign(re-f.fret)||1;if(Zt){const O=f.slideTo===null&&f.slideUnpitchTo!==null&&f.slideUnpitchTo!==void 0;O&&t.setLineDash([3,3]),rt($t+4,et+Zt*Y*.3,$t+14,et-Zt*Y*.3),O&&t.setLineDash([])}if(f.slideIn&&rt(ht-16,et+(f.slideIn==="below"?1:-1)*Y*.3,ht-6,et-(f.slideIn==="below"?1:-1)*Y*.3),typeof f.tieTo=="number"){const O=A(l.notes[f.tieTo].time)+Y/2;t.setLineDash([4,3]),t.beginPath(),t.moveTo(E,et+Y/2+3),t.quadraticCurveTo((E+O)/2,et+Y/2+14,O,et+Y/2+3),t.stroke(),t.setLineDash([])}if(f.showString){const O=ht-(S?26:13);t.beginPath(),t.arc(O,et,8,0,Math.PI*2),t.stroke(),t.font=Qt.finger,t.textAlign="center",t.fillText(String(M-f.string),O,et+jt(t,Qt.finger,"1").middle)}f.dynamicLabel&&(t.font=`italic ${j}`,t.textAlign="left",t.fillStyle=o.text,t.fillText(f.dynamicLabel,ht,pe),t.fillStyle=le);let bt=et-Y/2-6;if(f.vibrato){t.beginPath();for(let O=ht+2;O<=Math.max($t,ht+24)-2;O+=2)t.lineTo(O,bt+Math.sin((O-ht)/3)*(f.vibratoWide?3:1.8));t.stroke(),bt-=f.vibratoWide?10:8}if(t.textAlign="center",t.font=j,(f.hammerOn||f.pullOff)&&He){const O=He.x0+He.w/2,dt=(O+E)/2;t.beginPath(),t.moveTo(O,bt),t.quadraticCurveTo(dt,bt-12,E,bt),t.stroke(),t.fillText(f.hammerOn?"H":"P",dt,bt-9),bt-=10}const Xt=Ee(f);if(Xt>0){const O=f.bendCurve?.[0]?.[1]>0,dt=(f.bendCurve?.length??0)>1&&f.bendCurve.at(-1)[1]<Xt,ft=ht+gt-2,At=et-Y/2,mt=At-16;t.beginPath(),O?(t.moveTo(ft,At),t.lineTo(ft,mt)):(t.moveTo(ft-4,At+2),t.quadraticCurveTo(ft+4,At,ft+6,mt)),t.stroke(),Pe(O?ft:ft+6,mt,O?0:.3,-1),dt&&(t.beginPath(),t.moveTo(ft+12,mt),t.quadraticCurveTo(ft+16,At-6,ft+16,At),t.stroke(),Pe(ft+16,At,0,1)),t.textAlign="left",t.fillText(`${O?"pre ":""}${fi(Xt)}`,ft+(dt?20:10),mt+4),t.textAlign="center"}[Xe,_e]=[E,bt],f.tap&&!f.tapLeft&&xe("T"),f.staccato&&Me(4,O=>{t.beginPath(),t.arc(E,O,2,0,Math.PI*2),t.fill()}),f.accent&&(f.accent==="tenuto"||!S?.accent)&&xe({heavy:"^",tenuto:"–"}[f.accent]??">"),ee&&xe("PM");for(const O of[f.tapLeft?"m.g.":"",hi[f.harmonicType]??(f.harmonicPinch?"PH":""),f.slap?"slap":f.pop?"pop":"",f.golpe?`golpe (${f.golpe})`:"",f.rasgueado?`rasg. ${f.rasgueado}`:"",typeof f.trill=="number"?`tr ${f.trill}`:"",f.ornament??"",f.fade??"",f.whammy?"w/bar":"",f.wah==="open"?"o":f.wah==="closed"?"+":""])O&&xe(O);f.rightFinger&&xe(f.rightFinger,"italic "),f.pick&&Me(9,O=>{t.beginPath(),f.pick==="down"?[[-4,4.5],[-4,-4.5],[4,-4.5],[4,4.5]].forEach(([dt,ft],At)=>t[At?"lineTo":"moveTo"](E+dt,O+ft)):[[-4,-4.5],[0,4.5],[4,-4.5]].forEach(([dt,ft],At)=>t[At?"lineTo":"moveTo"](E+dt,O+ft)),t.stroke()}),f.fermata&&Me(9,O=>{t.beginPath(),t.arc(E,O+4,7,Math.PI,0),t.stroke(),t.beginPath(),t.arc(E,O+3,1.5,0,Math.PI*2),t.fill()}),f.tremolo&&Me(12,O=>{for(let dt=-1;dt<=1;dt++)rt(E-6,O+dt*4+2.5,E+6,O+dt*4-2.5)})})}const Ve=(x,f,S,nt)=>{if(t.globalAlpha=x.shown*nt,t.fillStyle=x.fill,x.squeeze===1)return t.fillText(f,x.x+x.left+S,x.y);t.save(),t.translate(x.x,x.y),t.scale(x.squeeze,1),t.fillText(f,x.left+S,0),t.restore()};t.textAlign="left";for(const x of[Qt.note,Qt.grace]){t.font=x;for(const f of xt)f.font===x&&Ve(f,f.text,0,1)}t.font=Qt.finger;for(const x of xt)x.finger&&Ve(x,x.finger,x.textWidth+3,.7);for(const x of Ke)x();t.globalAlpha=1,W&&t.restore()};if(!ot)Kt(null);else if(Kt([lt-40,G+4]),Tt){const W=G+24,K=P;A=j=>W+(j-Tt.start)*Tt.scale,[Mt,tt,P]=[Tt.start,Tt.start+Q/Tt.scale,-1/0],Kt([W-8,vt+4]),t.save(),t.globalCompositeOperation="destination-out",t.fillStyle="rgba(0, 0, 0, 0.55)",t.fillRect(W-8,0,vt+12-(W-8),Ft),t.restore(),t.strokeStyle=L(o.text,.22),t.lineWidth=1.5,t.setLineDash([3,5]),rt(G+12,e-d*.6,G+12,$+d*.6),t.setLineDash([]),P=K}t.shadowColor=o.accent,t.shadowBlur=16,t.strokeStyle=o.accent,t.lineWidth=3,rt(P,e-d*.7,P,$+d*.7);for(const{y:W,c:K}of Be)t.shadowColor=K,t.fillStyle="#ffffff",t.beginPath(),t.arc(P,W,4,0,Math.PI*2),t.fill();t.shadowBlur=0,t.globalCompositeOperation="destination-out";for(const[W,K,j]of ot?[]:[[me+10,1,ui],[m-Oe,-1,80]]){const St=t.createLinearGradient(W,0,W+K*j,0);St.addColorStop(0,"rgba(0, 0, 0, 1)"),St.addColorStop(1,"rgba(0, 0, 0, 0)"),t.fillStyle=St,t.fillRect(K>0?0:W-j,0,K>0?W+j:m-W+j,Ft)}t.globalCompositeOperation="destination-over",t.beginPath(),t.roundRect(Oe,_,m-Oe*2,U-_,16),t.fillStyle=L(o.ink,.72),t.fill(),t.globalCompositeOperation="source-over",t.strokeStyle=o.chipBorder,t.lineWidth=1,t.stroke();const se=`700 ${ce(Math.min(14,d*.24))}px ${o.num}`,we=Math.min(13,d*.22);t.font=se,t.textAlign="center";for(let W=0;W<M&&l.open;W++){const K=(Oe+me)/2,j=ct(W);t.strokeStyle=t.fillStyle=ge(W),t.lineWidth=1.8,t.beginPath(),t.arc(K,j,we,0,Math.PI*2),t.stroke(),t.fillText(bi(l.open[W]),K,j+jt(t,se,"E").middle)}}export{Di as HEADSTOCKS,Hi as bendAt,Ki as drawHighway,Vi as drawTab,Ci as headstockParts,Ti as lookAhead,Gi as moveCamera,Jn as rounded,Qn as spline};
|