jpfun 0.2.0 → 0.4.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/README.md +141 -11
- package/dist/converter/midi/convert.d.ts +50 -0
- package/dist/converter/midi/convert.js +700 -0
- package/dist/converter/midi/index.d.ts +5 -0
- package/dist/converter/midi/index.js +11 -0
- package/dist/converter/midi/json.d.ts +38 -0
- package/dist/converter/midi/json.js +1 -0
- package/dist/converter/midi/triplet.d.ts +30 -0
- package/dist/converter/midi/triplet.js +75 -0
- package/dist/converter/musicxml/dom.d.ts +25 -0
- package/dist/converter/musicxml/dom.js +65 -0
- package/dist/converter/musicxml/features.d.ts +51 -0
- package/dist/converter/musicxml/features.js +232 -0
- package/dist/converter/musicxml/index.d.ts +9 -0
- package/dist/converter/musicxml/index.js +1140 -0
- package/dist/converter/musicxml/model.d.ts +123 -0
- package/dist/converter/musicxml/model.js +1 -0
- package/dist/converter/source.d.ts +22 -0
- package/dist/converter/source.js +51 -0
- package/dist/core.d.ts +22 -0
- package/dist/core.js +22 -0
- package/dist/diagnostic.js +5 -2
- package/dist/fraction.d.ts +24 -0
- package/dist/fraction.js +132 -0
- package/dist/functions/ASTtypes.d.ts +51 -31
- package/dist/functions/ASTtypes.js +59 -38
- package/dist/functions/adjust/index.d.ts +2 -0
- package/dist/functions/adjust/index.js +193 -0
- package/dist/functions/arpeggio/index.d.ts +2 -0
- package/dist/functions/arpeggio/index.js +180 -0
- package/dist/functions/arpeggio/shape.d.ts +7 -0
- package/dist/functions/arpeggio/shape.js +122 -0
- package/dist/functions/bar/index.d.ts +8 -0
- package/dist/functions/bar/index.js +62 -25
- package/dist/functions/beam/auto.d.ts +1 -1
- package/dist/functions/beam/auto.js +33 -16
- package/dist/functions/beam/index.js +10 -6
- package/dist/functions/beam/layout.d.ts +4 -3
- package/dist/functions/beam/layout.js +43 -65
- package/dist/functions/box/index.js +37 -36
- package/dist/functions/br/index.js +10 -8
- package/dist/functions/dash/index.js +40 -7
- package/dist/functions/default.js +19 -8
- package/dist/functions/div/index.d.ts +16 -0
- package/dist/functions/div/index.js +45 -17
- package/dist/functions/dot/index.js +23 -25
- package/dist/functions/dyn/index.d.ts +2 -0
- package/dist/functions/dyn/index.js +242 -0
- package/dist/functions/grace/index.d.ts +8 -11
- package/dist/functions/grace/index.js +84 -79
- package/dist/functions/head/index.d.ts +2 -0
- package/dist/functions/head/index.js +496 -0
- package/dist/functions/key/index.js +98 -3
- package/dist/functions/meter/index.d.ts +2 -0
- package/dist/functions/meter/index.js +155 -0
- package/dist/functions/note/accidentals.d.ts +24 -3
- package/dist/functions/note/accidentals.js +31 -1
- package/dist/functions/note/index.js +106 -79
- package/dist/functions/note/noteNameFSM.js +52 -63
- package/dist/functions/page/index.d.ts +11 -2
- package/dist/functions/page/index.js +65 -4
- package/dist/functions/program/index.d.ts +2 -0
- package/dist/functions/program/index.js +30 -0
- package/dist/functions/set/index.js +43 -32
- package/dist/functions/stack/index.js +26 -22
- package/dist/functions/symbol/index.d.ts +31 -0
- package/dist/functions/symbol/index.js +139 -0
- package/dist/functions/symbol/ornament.d.ts +15 -0
- package/dist/functions/symbol/ornament.js +73 -0
- package/dist/functions/symbol/shape.d.ts +24 -0
- package/dist/functions/symbol/shape.js +52 -0
- package/dist/functions/symbol/symbols/accent.d.ts +2 -0
- package/dist/functions/symbol/symbols/accent.js +24 -0
- package/dist/functions/symbol/symbols/dc.d.ts +4 -0
- package/dist/functions/symbol/symbols/dc.js +82 -0
- package/dist/functions/symbol/symbols/ds.d.ts +2 -0
- package/dist/functions/symbol/symbols/ds.js +93 -0
- package/dist/functions/symbol/symbols/dynamics.d.ts +3 -0
- package/dist/functions/symbol/symbols/dynamics.js +168 -0
- package/dist/functions/symbol/symbols/fermata.d.ts +2 -0
- package/dist/functions/symbol/symbols/fermata.js +24 -0
- package/dist/functions/symbol/symbols/fine.d.ts +2 -0
- package/dist/functions/symbol/symbols/fine.js +12 -0
- package/dist/functions/symbol/symbols/mordent.d.ts +2 -0
- package/dist/functions/symbol/symbols/mordent.js +56 -0
- package/dist/functions/symbol/symbols/prall.d.ts +2 -0
- package/dist/functions/symbol/symbols/prall.js +42 -0
- package/dist/functions/symbol/symbols/segno.d.ts +4 -0
- package/dist/functions/symbol/symbols/segno.js +82 -0
- package/dist/functions/symbol/symbols/tr.d.ts +2 -0
- package/dist/functions/symbol/symbols/tr.js +71 -0
- package/dist/functions/tempo/glyph.d.ts +12 -0
- package/dist/functions/tempo/glyph.js +30 -0
- package/dist/functions/tempo/index.js +57 -4
- package/dist/functions/temporal.d.ts +138 -0
- package/dist/functions/temporal.js +101 -0
- package/dist/functions/text/index.js +86 -27
- package/dist/functions/tie/index.js +136 -152
- package/dist/functions/tuplet/index.d.ts +2 -0
- package/dist/functions/tuplet/index.js +218 -0
- package/dist/functions/up/index.d.ts +1 -0
- package/dist/functions/up/index.js +258 -182
- package/dist/functions/voice/index.js +203 -109
- package/dist/functions/volta/index.d.ts +2 -0
- package/dist/functions/volta/index.js +230 -0
- package/dist/iife/core.d.ts +1 -0
- package/dist/iife/core.js +3 -0
- package/dist/iife/from-midi.d.ts +1 -0
- package/dist/iife/from-midi.js +15 -0
- package/dist/iife/from-musicxml.d.ts +1 -0
- package/dist/iife/from-musicxml.js +3 -0
- package/dist/iife/full.d.ts +1 -0
- package/dist/iife/full.js +3 -0
- package/dist/index.d.ts +3 -17
- package/dist/index.js +3 -17
- package/dist/jpfun.core.min.js +153 -0
- package/dist/jpfun.from-midi.min.js +9 -0
- package/dist/jpfun.from-musicxml.min.js +12 -0
- package/dist/jpfun.min.js +166 -0
- package/dist/layout/default.js +2 -3
- package/dist/layout/engine.d.ts +6 -12
- package/dist/layout/engine.js +115 -64
- package/dist/layout/model.d.ts +12 -5
- package/dist/layout/model.js +31 -18
- package/dist/layout/page.js +5 -4
- package/dist/layout/path.d.ts +19 -0
- package/dist/layout/path.js +101 -0
- package/dist/layout/types.d.ts +71 -20
- package/dist/layout/types.js +3 -1
- package/dist/lowering/loweringContext.d.ts +20 -20
- package/dist/lowering/loweringContext.js +153 -101
- package/dist/lowering/track.d.ts +5 -9
- package/dist/lowering/track.js +7 -2
- package/dist/lowering/types.d.ts +26 -112
- package/dist/lowering/types.js +1 -92
- package/dist/parser/parse-utils/call-utils.d.ts +0 -2
- package/dist/parser/parse-utils/call-utils.js +0 -6
- package/dist/parser/parse-utils/note-utils.d.ts +8 -0
- package/dist/parser/parse-utils/note-utils.js +35 -13
- package/dist/parser/parse-utils/string-utils.d.ts +10 -0
- package/dist/parser/parse-utils/string-utils.js +24 -0
- package/dist/parser/parserContext.d.ts +11 -9
- package/dist/parser/parserContext.js +65 -55
- package/dist/parser/preprocess.js +17 -11
- package/dist/pipeline.d.ts +6 -5
- package/dist/pipeline.js +4 -5
- package/dist/playback/compile.d.ts +18 -0
- package/dist/playback/compile.js +414 -0
- package/dist/playback/event.d.ts +105 -0
- package/dist/playback/event.js +105 -0
- package/dist/playback/time.d.ts +14 -0
- package/dist/playback/time.js +81 -0
- package/dist/playback/types.d.ts +129 -0
- package/dist/playback/types.js +3 -0
- package/dist/render/canvas.d.ts +4 -4
- package/dist/render/canvas.js +20 -5
- package/dist/render/index.d.ts +1 -0
- package/dist/render/index.js +1 -0
- package/dist/render/paint.d.ts +8 -0
- package/dist/render/paint.js +101 -0
- package/dist/render/svg.d.ts +3 -3
- package/dist/render/svg.js +10 -8
- package/dist/render/text.d.ts +22 -0
- package/dist/render/text.js +42 -0
- package/dist/render/types.d.ts +1 -1
- package/grammar.md +132 -13
- package/package.json +19 -6
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 力度记号族:八个记号由 m / f / p 三个字母横向拼接而成
|
|
3
|
+
*
|
|
4
|
+
* 三个字母抠自同一套字体的 mp / mf 连字,坐标同属一套字体坐标系(共基线、同字号),
|
|
5
|
+
* 所以拼接只需要横向位移,字距也是从连字上量出来的。
|
|
6
|
+
*/
|
|
7
|
+
const GLYPHS = {
|
|
8
|
+
m: [
|
|
9
|
+
{ op: "M", x: 1.13, y: 10.3672 },
|
|
10
|
+
{ op: "L", x: 2.9911, y: 5.3125 },
|
|
11
|
+
{ op: "C", cx1: 3.0585, cy1: 5.0607, cx2: 3.0955, cy2: 4.8889, x: 3.0955, y: 4.8089 },
|
|
12
|
+
{ op: "C", cx1: 3.0955, cy1: 4.6248, cx2: 2.9972, cy2: 4.5327, x: 2.7944, y: 4.5327 },
|
|
13
|
+
{ op: "C", cx1: 2.5489, cy1: 4.5327, cx2: 2.217, cy2: 4.7782, x: 1.7994, y: 5.2758 },
|
|
14
|
+
{ op: "C", cx1: 1.3881, cy1: 5.7671, cx2: 0.9766, cy2: 6.4856, x: 0.5774, y: 7.4254 },
|
|
15
|
+
{ op: "L", x: 0, y: 7.4254 },
|
|
16
|
+
{ op: "C", cx1: 0.4976, cy1: 6.3628, cx2: 1.0133, cy2: 5.4783, x: 1.5476, y: 4.7782 },
|
|
17
|
+
{ op: "C", cx1: 2.0882, cy1: 4.0781, cx2: 2.7576, cy2: 3.7279, x: 3.5498, y: 3.7279 },
|
|
18
|
+
{ op: "C", cx1: 4.1518, cy1: 3.7279, cx2: 4.4773, cy2: 4.0534, x: 4.5264, y: 4.7045 },
|
|
19
|
+
{ op: "C", cx1: 5.2818, cy1: 4.0167, cx2: 5.9512, cy2: 3.6728, x: 6.5409, y: 3.6728 },
|
|
20
|
+
{ op: "C", cx1: 7.1796, cy1: 3.6728, cx2: 7.5235, cy2: 4.0167, x: 7.5728, y: 4.7045 },
|
|
21
|
+
{ op: "C", cx1: 7.8797, cy1: 4.3976, cx2: 8.2483, cy2: 4.1518, x: 8.6843, y: 3.9614 },
|
|
22
|
+
{ op: "C", cx1: 9.1205, cy1: 3.7709, cx2: 9.5197, cy2: 3.6728, x: 9.8882, y: 3.6728 },
|
|
23
|
+
{ op: "C", cx1: 10.5393, cy1: 3.6728, cx2: 10.8645, cy2: 3.943, x: 10.8645, y: 4.4834 },
|
|
24
|
+
{ op: "C", cx1: 10.8645, cy1: 4.6001, cx2: 10.8339, cy2: 4.7905, x: 10.7664, y: 5.0607 },
|
|
25
|
+
{ op: "L", x: 9.3846, y: 9.0345 },
|
|
26
|
+
{ op: "C", cx1: 9.3109, cy1: 9.3353, cx2: 9.2616, cy2: 9.4951, x: 9.2309, y: 9.6364 },
|
|
27
|
+
{ op: "C", cx1: 9.2309, cy1: 9.7959, cx2: 9.3169, cy2: 9.9066, x: 9.4827, y: 9.9619 },
|
|
28
|
+
{ op: "C", cx1: 10.011, cy1: 9.8943, cx2: 10.6988, cy2: 9.1512, x: 11.5463, y: 7.7263 },
|
|
29
|
+
{ op: "L", x: 12.0499, y: 7.7263 },
|
|
30
|
+
{ op: "C", cx1: 11.7981, cy1: 8.1502, cx2: 11.5279, cy2: 8.6045, x: 11.227, y: 9.0958 },
|
|
31
|
+
{ op: "C", cx1: 10.9322, cy1: 9.5811, cx2: 10.6006, cy2: 9.9864, x: 10.2381, y: 10.2996 },
|
|
32
|
+
{ op: "C", cx1: 9.8759, cy1: 10.613, cx2: 9.4583, cy2: 10.7725, x: 8.9791, y: 10.7725 },
|
|
33
|
+
{ op: "C", cx1: 8.1499, cy1: 10.7725, cx2: 7.6279, cy2: 10.3919, x: 7.4191, y: 9.6365 },
|
|
34
|
+
{ op: "C", cx1: 7.4437, cy1: 9.397, cx2: 7.5235, cy2: 9.0775, x: 7.6649, y: 8.6783 },
|
|
35
|
+
{ op: "C", cx1: 7.806, cy1: 8.279, cx2: 7.8797, cy2: 8.0395, x: 7.8981, y: 7.9535 },
|
|
36
|
+
{ op: "L", x: 8.9054, y: 5.3619 },
|
|
37
|
+
{ op: "C", cx1: 8.924, cy1: 5.2572, cx2: 8.9791, cy2: 5.0117, x: 8.9791, y: 4.9073 },
|
|
38
|
+
{ op: "C", cx1: 8.9791, cy1: 4.6922, cx2: 8.887, cy2: 4.5818, x: 8.7028, y: 4.5818 },
|
|
39
|
+
{ op: "C", cx1: 8.1992, cy1: 4.5818, cx2: 7.8246, cy2: 4.9257, x: 7.5728, y: 5.6137 },
|
|
40
|
+
{ op: "L", x: 5.8838, y: 10.3673 },
|
|
41
|
+
{ op: "L", x: 4.0781, y: 10.3673 },
|
|
42
|
+
{ op: "L", x: 5.9389, y: 5.2635 },
|
|
43
|
+
{ op: "C", cx1: 5.9696, cy1: 5.1591, cx2: 5.9882, cy2: 5.0424, x: 5.9882, y: 4.9073 },
|
|
44
|
+
{ op: "C", cx1: 5.9882, cy1: 4.6922, cx2: 5.8592, cy2: 4.5818, x: 5.6073, y: 4.5818 },
|
|
45
|
+
{ op: "C", cx1: 5.159, cy1: 4.6002, cx2: 4.8335, cy2: 4.944, x: 4.6308, y: 5.6137 },
|
|
46
|
+
{ op: "L", x: 2.8927, y: 10.3673 },
|
|
47
|
+
{ op: "L", x: 1.13, y: 10.3673 },
|
|
48
|
+
{ op: "L", x: 1.13, y: 10.3672 },
|
|
49
|
+
{ op: "Z" },
|
|
50
|
+
],
|
|
51
|
+
f: [
|
|
52
|
+
{ op: "M", x: 6.1601, y: 4.0781 },
|
|
53
|
+
{ op: "C", cx1: 6.4302, cy1: 3.3717, cx2: 6.8234, cy2: 2.7086, x: 7.3391, y: 2.0882 },
|
|
54
|
+
{ op: "C", cx1: 7.8551, cy1: 1.4679, cx2: 8.4754, cy2: 0.9642, x: 9.2062, y: 0.5773 },
|
|
55
|
+
{ op: "C", cx1: 9.937, cy1: 0.1904, cx2: 10.7355, cy2: 0, x: 11.5953, y: 0 },
|
|
56
|
+
{ op: "C", cx1: 12.0559, cy1: 0.043, cx2: 12.4061, cy2: 0.2088, x: 12.6333, y: 0.4913 },
|
|
57
|
+
{ op: "C", cx1: 12.8607, cy1: 0.7678, cx2: 12.9772, cy2: 1.1117, x: 12.9772, y: 1.5109 },
|
|
58
|
+
{ op: "C", cx1: 12.9772, cy1: 1.9345, cx2: 12.8421, cy2: 2.3154, x: 12.5659, y: 2.6472 },
|
|
59
|
+
{ op: "C", cx1: 12.2954, cy1: 2.9788, cx2: 11.9578, cy2: 3.1446, x: 11.5463, y: 3.1446 },
|
|
60
|
+
{ op: "C", cx1: 11.0487, cy1: 3.1446, cx2: 10.7662, cy2: 2.9174, x: 10.7111, y: 2.4691 },
|
|
61
|
+
{ op: "C", cx1: 10.7418, cy1: 2.1743, cx2: 10.8522, cy2: 1.8918, x: 11.0427, y: 1.6276 },
|
|
62
|
+
{ op: "C", cx1: 11.2331, cy1: 1.3635, cx2: 11.4666, cy2: 1.1793, x: 11.7428, y: 1.087 },
|
|
63
|
+
{ op: "C", cx1: 11.8472, cy1: 1.087, cx2: 11.8965, cy2: 1.0379, x: 11.8965, y: 0.9335 },
|
|
64
|
+
{ op: "C", cx1: 11.8965, cy1: 0.8108, cx2: 11.614, cy2: 0.6327, x: 11.2147, y: 0.6327 },
|
|
65
|
+
{ op: "C", cx1: 10.0908, cy1: 0.6327, cx2: 9.237, cy2: 1.7811, x: 8.6535, y: 4.0781 },
|
|
66
|
+
{ op: "L", x: 10.8646, y: 4.0781 },
|
|
67
|
+
{ op: "L", x: 10.8646, y: 4.9073 },
|
|
68
|
+
{ op: "L", x: 8.4508, y: 4.9073 },
|
|
69
|
+
{ op: "C", cx1: 8.2483, cy1: 5.7918, cx2: 7.9902, cy2: 6.6944, x: 7.671, y: 7.6156 },
|
|
70
|
+
{ op: "C", cx1: 7.3577, cy1: 8.5308, cx2: 7.026, cy2: 9.3723, x: 6.676, y: 10.1401 },
|
|
71
|
+
{ op: "C", cx1: 6.3319, cy1: 10.9076, cx2: 6.0064, cy2: 11.5156, x: 5.7055, y: 11.9762 },
|
|
72
|
+
{ op: "C", cx1: 5.2632, cy1: 12.658, cx2: 4.7966, cy2: 13.2353, x: 4.299, y: 13.7145 },
|
|
73
|
+
{ op: "C", cx1: 3.8016, cy1: 14.1995, cx2: 3.206, cy2: 14.5067, x: 2.5119, y: 14.6418 },
|
|
74
|
+
{ op: "C", cx1: 2.211, cy1: 14.6788, cx2: 2.0266, cy2: 14.6972, x: 1.9592, y: 14.6972 },
|
|
75
|
+
{ op: "C", cx1: 1.3632, cy1: 14.6972, cx2: 0.8905, cy2: 14.5128, x: 0.5527, y: 14.1382 },
|
|
76
|
+
{ op: "C", cx1: 0.2149, cy1: 13.7636, cx2: 0.0307, cy2: 13.3276, x: 0, y: 12.83 },
|
|
77
|
+
{ op: "C", cx1: 0.0428, cy1: 12.3941, cx2: 0.1718, cy2: 12.0623, x: 0.3869, y: 11.8351 },
|
|
78
|
+
{ op: "C", cx1: 0.6017, cy1: 11.6079, cx2: 0.9149, cy2: 11.4298, x: 1.3326, y: 11.3008 },
|
|
79
|
+
{ op: "C", cx1: 1.6458, cy1: 11.3254, cx2: 1.9039, cy2: 11.4359, x: 2.1066, y: 11.6324 },
|
|
80
|
+
{ op: "C", cx1: 2.3091, cy1: 11.8352, cx2: 2.4135, cy2: 12.0809, x: 2.4135, y: 12.3818 },
|
|
81
|
+
{ op: "C", cx1: 2.4135, cy1: 12.9405, cx2: 1.8548, cy2: 13.4134, x: 1.4309, y: 13.8127 },
|
|
82
|
+
{ op: "C", cx1: 1.4309, cy1: 13.9171, cx2: 1.5476, cy2: 13.9664, x: 1.7811, y: 13.9664 },
|
|
83
|
+
{ op: "C", cx1: 2.7453, cy1: 13.9664, cx2: 3.5129, cy2: 12.9405, x: 4.0718, y: 10.8955 },
|
|
84
|
+
{ op: "C", cx1: 4.2683, cy1: 10.3426, cx2: 4.4404, cy2: 9.8083, x: 4.5938, y: 9.2926 },
|
|
85
|
+
{ op: "C", cx1: 4.7475, cy1: 8.7703, cx2: 4.9624, cy2: 8.0028, x: 5.2449, y: 6.9832 },
|
|
86
|
+
{ op: "C", cx1: 5.5337, cy1: 5.9575, cx2: 5.7362, cy2: 5.2695, x: 5.8592, y: 4.9073 },
|
|
87
|
+
{ op: "L", x: 4.1702, y: 4.9073 },
|
|
88
|
+
{ op: "L", x: 4.1702, y: 4.0781 },
|
|
89
|
+
{ op: "L", x: 6.1601, y: 4.0781 },
|
|
90
|
+
{ op: "Z" },
|
|
91
|
+
],
|
|
92
|
+
p: [
|
|
93
|
+
{ op: "M", x: 3.767, y: 8.5573 },
|
|
94
|
+
{ op: "L", x: 5.0097, y: 5.0738 },
|
|
95
|
+
{ op: "C", cx1: 5.0804, cy1: 4.7969, cx2: 5.1126, cy2: 4.5909, x: 5.1126, y: 4.443 },
|
|
96
|
+
{ op: "C", cx1: 5.1126, cy1: 4.2497, cx2: 5.0224, cy2: 4.1531, x: 4.8486, y: 4.1531 },
|
|
97
|
+
{ op: "C", cx1: 4.7262, cy1: 4.1531, cx2: 4.5653, cy2: 4.2497, x: 4.3786, y: 4.443 },
|
|
98
|
+
{ op: "C", cx1: 3.9471, cy1: 4.9001, cx2: 3.6059, cy2: 5.383, x: 3.3484, y: 5.8917 },
|
|
99
|
+
{ op: "L", x: 2.6851, y: 5.8917 },
|
|
100
|
+
{ op: "C", cx1: 2.8138, cy1: 5.5117, cx2: 3.0264, cy2: 5.1126, x: 3.3163, y: 4.7004 },
|
|
101
|
+
{ op: "C", cx1: 3.6059, cy1: 4.2818, cx2: 3.9471, cy2: 3.9406, x: 4.3335, y: 3.6702 },
|
|
102
|
+
{ op: "C", cx1: 4.7262, cy1: 3.3933, cx2: 5.1192, cy2: 3.258, x: 5.5119, y: 3.258 },
|
|
103
|
+
{ op: "C", cx1: 6.1623, cy1: 3.258, cx2: 6.613, cy2: 3.5671, x: 6.8575, y: 4.179 },
|
|
104
|
+
{ op: "C", cx1: 7.1987, cy1: 3.8891, cx2: 7.6044, cy2: 3.6444, x: 8.0617, y: 3.4447 },
|
|
105
|
+
{ op: "C", cx1: 8.5188, cy1: 3.2454, cx2: 8.9632, cy2: 3.1486, x: 9.388, y: 3.1486 },
|
|
106
|
+
{ op: "C", cx1: 10.1286, cy1: 3.1486, cx2: 10.7017, cy2: 3.4447, x: 11.1008, y: 4.0437 },
|
|
107
|
+
{ op: "C", cx1: 11.5064, cy1: 4.636, cx2: 11.706, cy2: 5.3249, x: 11.706, y: 6.104 },
|
|
108
|
+
{ op: "C", cx1: 11.706, cy1: 6.8187, cx2: 11.5322, cy2: 7.5464, x: 11.178, y: 8.274 },
|
|
109
|
+
{ op: "C", cx1: 10.8304, cy1: 9.0017, cx2: 10.3538, cy2: 9.6004, x: 9.7422, y: 10.0704 },
|
|
110
|
+
{ op: "C", cx1: 9.1306, cy1: 10.5406, cx2: 8.4607, cy2: 10.7724, x: 7.7267, y: 10.7724 },
|
|
111
|
+
{ op: "C", cx1: 7.0442, cy1: 10.7724, cx2: 6.4133, cy2: 10.5148, x: 5.8273, y: 10.006 },
|
|
112
|
+
{ op: "L", x: 4.7972, y: 12.9614 },
|
|
113
|
+
{ op: "C", cx1: 4.765, cy1: 13.0453, cx2: 4.7133, cy2: 13.1998, x: 4.6426, y: 13.4122 },
|
|
114
|
+
{ op: "C", cx1: 4.6684, cy1: 13.6377, cx2: 4.7842, cy2: 13.7922, x: 4.9902, y: 13.8695 },
|
|
115
|
+
{ op: "C", cx1: 5.2028, cy1: 13.9531, cx2: 5.5504, cy2: 13.9919, x: 6.0399, y: 13.9919 },
|
|
116
|
+
{ op: "L", x: 6.0399, y: 14.8095 },
|
|
117
|
+
{ op: "L", x: 0, y: 14.8095 },
|
|
118
|
+
{ op: "L", x: 0, y: 13.9919 },
|
|
119
|
+
{ op: "C", cx1: 0.7469, cy1: 13.9919, cx2: 1.2815, cy2: 13.8759, x: 1.5969, y: 13.6506 },
|
|
120
|
+
{ op: "C", cx1: 1.9124, cy1: 13.4251, cx2: 2.1379, cy2: 13.1289, x: 2.2666, y: 12.7491 },
|
|
121
|
+
{ op: "L", x: 3.767, y: 8.5573 },
|
|
122
|
+
{ op: "Z" },
|
|
123
|
+
{ op: "M", x: 7.0637, y: 6.3166 },
|
|
124
|
+
{ op: "C", cx1: 6.7802, cy1: 6.9604, cx2: 6.6064, cy2: 7.8104, x: 6.5357, y: 8.8727 },
|
|
125
|
+
{ op: "C", cx1: 6.6064, cy1: 9.5619, cx2: 6.7609, cy2: 9.9031, x: 7.012, y: 9.9031 },
|
|
126
|
+
{ op: "C", cx1: 7.8879, cy1: 9.7356, cx2: 8.609, cy2: 8.7248, x: 9.1755, y: 6.8704 },
|
|
127
|
+
{ op: "C", cx1: 9.3495, cy1: 6.2071, cx2: 9.4395, cy2: 5.6084, x: 9.4395, y: 5.0738 },
|
|
128
|
+
{ op: "C", cx1: 9.4395, cy1: 4.4108, cx2: 9.2657, cy2: 4.05, x: 8.9115, y: 3.9923 },
|
|
129
|
+
{ op: "C", cx1: 8.332, cy1: 3.9923, cx2: 7.7139, cy2: 4.7647, x: 7.0637, y: 6.3166 },
|
|
130
|
+
{ op: "Z" },
|
|
131
|
+
],
|
|
132
|
+
};
|
|
133
|
+
/** 相邻字母墨迹左边界之间的距离;斜体字母互相交错,所以比前一个字母窄 */
|
|
134
|
+
const ADVANCE = {
|
|
135
|
+
mf: 8.0028,
|
|
136
|
+
mp: 9.523,
|
|
137
|
+
ff: 6.67866,
|
|
138
|
+
pp: 8.8083, // 没有 pp 连字可量,沿用 m 与 p 的墨迹重叠量
|
|
139
|
+
};
|
|
140
|
+
const INK = { fill: "#000" };
|
|
141
|
+
/** size 是 f 的全高;p 系没有升部、盒子只有 f 的这么高,不按此缩小就会被放大 1.26 倍 */
|
|
142
|
+
const P_WEIGHT = 0.79341;
|
|
143
|
+
function dynamic(name, velocity, description) {
|
|
144
|
+
let dx = 0;
|
|
145
|
+
const shapes = Array.from(name, (letter, index) => {
|
|
146
|
+
const shape = { path: GLYPHS[letter], style: INK, dx };
|
|
147
|
+
dx += ADVANCE[letter + name[index + 1]] ?? 0;
|
|
148
|
+
return shape;
|
|
149
|
+
});
|
|
150
|
+
return {
|
|
151
|
+
name,
|
|
152
|
+
description,
|
|
153
|
+
shapes,
|
|
154
|
+
weight: name.includes("f") ? 1 : P_WEIGHT,
|
|
155
|
+
onTimeState: state => { state.velocity = velocity; },
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/** 力度阶梯是 16 的整数倍,末级钳到 127;mf 恰好等于 DEFAULT_VELOCITY */
|
|
159
|
+
export const dynamicSymbols = [
|
|
160
|
+
dynamic("ppp", 16, "极弱"),
|
|
161
|
+
dynamic("pp", 32, "很弱"),
|
|
162
|
+
dynamic("p", 48, "弱"),
|
|
163
|
+
dynamic("mp", 64, "中弱"),
|
|
164
|
+
dynamic("mf", 80, "中强"),
|
|
165
|
+
dynamic("f", 96, "强"),
|
|
166
|
+
dynamic("ff", 112, "很强"),
|
|
167
|
+
dynamic("fff", 127, "极强"),
|
|
168
|
+
];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const fermataSymbol = {
|
|
2
|
+
name: "fermata",
|
|
3
|
+
description: "延长记号:覆盖区间速度减半,目标音实际时长翻倍",
|
|
4
|
+
weight: 0.6,
|
|
5
|
+
shapes: [
|
|
6
|
+
{
|
|
7
|
+
path: [
|
|
8
|
+
{ op: "M", x: 0, y: 7.46666 },
|
|
9
|
+
{ op: "C", cx1: 3.65834, cy1: 0, cx2: 8.53611, cy2: 0, x: 12.19445, y: 7.46666 },
|
|
10
|
+
{ op: "M", x: 12.19445, y: 7.46666 },
|
|
11
|
+
{ op: "C", cx1: 8.53611, cy1: 0.74666, cx2: 3.65833, cy2: 0.74666, x: 0, y: 7.46666 },
|
|
12
|
+
],
|
|
13
|
+
style: { fill: "#000", stroke: "#000", strokeWidth: 1 },
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
circle: { cx: 6.09723, cy: 6.26666, r: 1.2 },
|
|
17
|
+
style: { fill: "#000" },
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
emitPlayback: emitter => {
|
|
21
|
+
emitter.control(emitter.start, state => state.bpmScale.div(2));
|
|
22
|
+
emitter.control(emitter.end, state => state.bpmScale.mul(2));
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { JUMP_MARK } from "./dc.js";
|
|
2
|
+
export const fineSymbol = {
|
|
3
|
+
name: "fine",
|
|
4
|
+
description: "终止记号:回跳之后经过这里就结束乐曲",
|
|
5
|
+
weight: 1.4,
|
|
6
|
+
text: { content: "Fine.", fontFamily: '"Times New Roman", serif' },
|
|
7
|
+
// 判据是回跳已经发生,不是“第二次经过”;否则写在 |: :| 里会被反复线提前触发
|
|
8
|
+
onVisit: (cursor, at) => {
|
|
9
|
+
const jump = cursor.seek(JUMP_MARK, at, 1);
|
|
10
|
+
return jump !== undefined && cursor.visits(jump) > 0 ? { kind: "stop" } : undefined;
|
|
11
|
+
},
|
|
12
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ornament } from "../ornament.js";
|
|
2
|
+
export const mordentSymbol = {
|
|
3
|
+
name: "mordent",
|
|
4
|
+
description: "下波音:本音、调内下方二度、本音",
|
|
5
|
+
// = prall 的 0.55 × 10.0123/7.5001:竖线让字形更高,按这个比例放大波浪笔画才等大
|
|
6
|
+
weight: 0.73423,
|
|
7
|
+
shapes: [
|
|
8
|
+
{
|
|
9
|
+
path: [
|
|
10
|
+
{ op: "M", x: 7.29541, y: 0.05944 },
|
|
11
|
+
{ op: "C", cx1: 7.56541, cy1: -0.09056, cx2: 7.92541, cy2: 0.05944, x: 8.04541, y: 0.32944 },
|
|
12
|
+
{ op: "C", cx1: 8.10541, cy1: 0.44944, cx2: 8.10541, cy2: 0.56944, x: 8.10541, y: 1.76943 },
|
|
13
|
+
{ op: "L", x: 8.10541, y: 3.05943 },
|
|
14
|
+
{ op: "L", x: 8.67541, y: 2.21943 },
|
|
15
|
+
{ op: "C", cx1: 9.18541, cy1: 1.46943, cx2: 9.24541, cy2: 1.37943, x: 9.36541, y: 1.31943 },
|
|
16
|
+
{ op: "C", cx1: 9.42541, cy1: 1.28943, cx2: 9.54541, cy2: 1.25943, x: 9.60541, y: 1.25943 },
|
|
17
|
+
{ op: "C", cx1: 9.90541, cy1: 1.25943, cx2: 9.87541, cy2: 1.22943, x: 11.49541, y: 3.20943 },
|
|
18
|
+
{ op: "L", x: 13.02541, y: 5.03943 },
|
|
19
|
+
{ op: "L", x: 13.50541, y: 4.34943 },
|
|
20
|
+
{ op: "C", cx1: 14.01541, cy1: 3.56943, cx2: 14.04541, cy2: 3.50943, x: 14.19541, y: 3.44943 },
|
|
21
|
+
{ op: "C", cx1: 14.61541, cy1: 3.26943, cx2: 15.06541, cy2: 3.59943, x: 15.00541, y: 4.04943 },
|
|
22
|
+
{ op: "C", cx1: 14.97541, cy1: 4.16943, cx2: 14.70541, cy2: 4.55943, x: 13.50541, y: 6.41943 },
|
|
23
|
+
{ op: "C", cx1: 12.12541, cy1: 8.48943, cx2: 12.00541, cy2: 8.63943, x: 11.88541, y: 8.69943 },
|
|
24
|
+
{ op: "C", cx1: 11.82541, cy1: 8.72943, cx2: 11.70541, cy2: 8.75943, x: 11.64541, y: 8.75943 },
|
|
25
|
+
{ op: "C", cx1: 11.34541, cy1: 8.75943, cx2: 11.37541, cy2: 8.78943, x: 9.81541, y: 6.86943 },
|
|
26
|
+
{ op: "C", cx1: 9.00541, cy1: 5.87943, cx2: 8.31541, cy2: 5.06943, x: 8.28541, y: 5.00943 },
|
|
27
|
+
{ op: "C", cx1: 8.22541, cy1: 4.97943, cx2: 8.22541, cy2: 4.97943, x: 8.16541, y: 5.03943 },
|
|
28
|
+
{ op: "C", cx1: 8.10541, cy1: 5.09943, cx2: 8.10541, cy2: 5.18943, x: 8.10541, y: 7.31943 },
|
|
29
|
+
{ op: "C", cx1: 8.10541, cy1: 9.26943, cx2: 8.10541, cy2: 9.56943, x: 8.04541, y: 9.65943 },
|
|
30
|
+
{ op: "C", cx1: 7.86541, cy1: 10.10943, cx2: 7.23541, cy2: 10.13943, x: 6.99541, y: 9.68943 },
|
|
31
|
+
{ op: "C", cx1: 6.96541, cy1: 9.62943, cx2: 6.93541, cy2: 9.44943, x: 6.93541, y: 8.27943 },
|
|
32
|
+
{ op: "L", x: 6.93541, y: 6.92943 },
|
|
33
|
+
{ op: "L", x: 6.36541, y: 7.76943 },
|
|
34
|
+
{ op: "C", cx1: 5.82541, cy1: 8.54943, cx2: 5.76541, cy2: 8.63943, x: 5.64541, y: 8.69943 },
|
|
35
|
+
{ op: "C", cx1: 5.58541, cy1: 8.72943, cx2: 5.46541, cy2: 8.75943, x: 5.40541, y: 8.75943 },
|
|
36
|
+
{ op: "C", cx1: 5.10541, cy1: 8.75943, cx2: 5.13541, cy2: 8.78943, x: 3.51541, y: 6.80943 },
|
|
37
|
+
{ op: "L", x: 1.98541, y: 4.97943 },
|
|
38
|
+
{ op: "L", x: 1.50541, y: 5.66943 },
|
|
39
|
+
{ op: "C", cx1: 0.99541, cy1: 6.44943, cx2: 0.96541, cy2: 6.50943, x: 0.81541, y: 6.56943 },
|
|
40
|
+
{ op: "C", cx1: 0.39541, cy1: 6.74943, cx2: -0.05459, cy2: 6.41943, x: 0.00541, y: 5.96943 },
|
|
41
|
+
{ op: "C", cx1: 0.03541, cy1: 5.84943, cx2: 0.30541, cy2: 5.45943, x: 1.50541, y: 3.59943 },
|
|
42
|
+
{ op: "C", cx1: 2.88541, cy1: 1.52943, cx2: 3.00541, cy2: 1.37943, x: 3.12541, y: 1.31943 },
|
|
43
|
+
{ op: "C", cx1: 3.18541, cy1: 1.28943, cx2: 3.30541, cy2: 1.25943, x: 3.36541, y: 1.25943 },
|
|
44
|
+
{ op: "C", cx1: 3.66541, cy1: 1.25943, cx2: 3.63541, cy2: 1.22943, x: 5.25541, y: 3.20943 },
|
|
45
|
+
{ op: "L", x: 6.78541, y: 5.03943 },
|
|
46
|
+
{ op: "C", cx1: 6.81541, cy1: 5.03943, cx2: 6.84541, cy2: 4.97943, x: 6.87541, y: 4.94943 },
|
|
47
|
+
{ op: "C", cx1: 6.93541, cy1: 4.82943, cx2: 6.93541, cy2: 4.79943, x: 6.93541, y: 2.66943 },
|
|
48
|
+
{ op: "C", cx1: 6.93541, cy1: 0.74943, cx2: 6.93541, cy2: 0.44943, x: 6.99541, y: 0.35943 },
|
|
49
|
+
{ op: "C", cx1: 7.05541, cy1: 0.20943, cx2: 7.14541, cy2: 0.11943, x: 7.29541, y: 0.05943 },
|
|
50
|
+
{ op: "Z" },
|
|
51
|
+
],
|
|
52
|
+
style: { fill: "#000" },
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
emitPlayback: emitter => emitter.affectFollowing(ornament({ body: [0, -1, 0] })),
|
|
56
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ornament } from "../ornament.js";
|
|
2
|
+
export const prallSymbol = {
|
|
3
|
+
name: "prall",
|
|
4
|
+
description: "上波音:本音、调内上方二度、本音",
|
|
5
|
+
weight: 0.55,
|
|
6
|
+
shapes: [
|
|
7
|
+
{
|
|
8
|
+
path: [
|
|
9
|
+
{ op: "M", x: 3.12541, y: 0.06003 },
|
|
10
|
+
{ op: "C", cx1: 3.18541, cy1: 0.03003, cx2: 3.30541, cy2: 0.00003, x: 3.36541, y: 0.00003 },
|
|
11
|
+
{ op: "C", cx1: 3.66541, cy1: 0.00003, cx2: 3.63541, cy2: -0.02997, x: 5.25541, y: 1.95003 },
|
|
12
|
+
{ op: "L", x: 6.78541, y: 3.78003 },
|
|
13
|
+
{ op: "C", cx1: 6.81541, cy1: 3.78003, cx2: 7.35541, cy2: 2.94003, x: 8.01541, y: 1.95003 },
|
|
14
|
+
{ op: "C", cx1: 9.15541, cy1: 0.27003, cx2: 9.24541, cy2: 0.12003, x: 9.36541, y: 0.06003 },
|
|
15
|
+
{ op: "C", cx1: 9.42541, cy1: 0.03003, cx2: 9.54541, cy2: 0.00003, x: 9.60541, y: 0.00003 },
|
|
16
|
+
{ op: "C", cx1: 9.90541, cy1: 0.00003, cx2: 9.87541, cy2: -0.02997, x: 11.49541, y: 1.95003 },
|
|
17
|
+
{ op: "L", x: 13.02541, y: 3.78003 },
|
|
18
|
+
{ op: "L", x: 13.50541, y: 3.09003 },
|
|
19
|
+
{ op: "C", cx1: 14.01541, cy1: 2.31003, cx2: 14.04541, cy2: 2.25003, x: 14.19541, y: 2.19003 },
|
|
20
|
+
{ op: "C", cx1: 14.61541, cy1: 2.01003, cx2: 15.06541, cy2: 2.34003, x: 15.00541, y: 2.79003 },
|
|
21
|
+
{ op: "C", cx1: 14.97541, cy1: 2.91003, cx2: 14.70541, cy2: 3.30003, x: 13.50541, y: 5.16003 },
|
|
22
|
+
{ op: "C", cx1: 12.12541, cy1: 7.23003, cx2: 12.00541, cy2: 7.38003, x: 11.88541, y: 7.44003 },
|
|
23
|
+
{ op: "C", cx1: 11.82541, cy1: 7.47003, cx2: 11.70541, cy2: 7.50003, x: 11.64541, y: 7.50003 },
|
|
24
|
+
{ op: "C", cx1: 11.34541, cy1: 7.50003, cx2: 11.37541, cy2: 7.53003, x: 9.75541, y: 5.55003 },
|
|
25
|
+
{ op: "L", x: 8.22541, y: 3.72003 },
|
|
26
|
+
{ op: "C", cx1: 8.19541, cy1: 3.72003, cx2: 7.65541, cy2: 4.56003, x: 6.99541, y: 5.55003 },
|
|
27
|
+
{ op: "C", cx1: 5.85541, cy1: 7.23003, cx2: 5.76541, cy2: 7.38003, x: 5.64541, y: 7.44003 },
|
|
28
|
+
{ op: "C", cx1: 5.58541, cy1: 7.47003, cx2: 5.46541, cy2: 7.50003, x: 5.40541, y: 7.50003 },
|
|
29
|
+
{ op: "C", cx1: 5.10541, cy1: 7.50003, cx2: 5.13541, cy2: 7.53003, x: 3.51541, y: 5.55003 },
|
|
30
|
+
{ op: "L", x: 1.98541, y: 3.72003 },
|
|
31
|
+
{ op: "L", x: 1.50541, y: 4.41003 },
|
|
32
|
+
{ op: "C", cx1: 0.99541, cy1: 5.19003, cx2: 0.96541, cy2: 5.25003, x: 0.81541, y: 5.31003 },
|
|
33
|
+
{ op: "C", cx1: 0.39541, cy1: 5.49003, cx2: -0.05459, cy2: 5.16003, x: 0.00541, y: 4.71004 },
|
|
34
|
+
{ op: "C", cx1: 0.03541, cy1: 4.59004, cx2: 0.30541, cy2: 4.20004, x: 1.50541, y: 2.34004 },
|
|
35
|
+
{ op: "C", cx1: 2.88541, cy1: 0.27004, cx2: 3.00541, cy2: 0.12004, x: 3.12541, y: 0.06004 },
|
|
36
|
+
{ op: "Z" },
|
|
37
|
+
],
|
|
38
|
+
style: { fill: "#000" },
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
emitPlayback: emitter => emitter.affectFollowing(ornament({ body: [0, 1, 0] })),
|
|
42
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/** D.S. 的回跳目标;符号之间本不该有依赖,但「从记号处反复」的语义要求两者认识同一个标记 */
|
|
2
|
+
export const SEGNO_MARK = "repeat.segno";
|
|
3
|
+
export const segnoSymbol = {
|
|
4
|
+
name: "segno",
|
|
5
|
+
description: "反复记号:D.S. 的回跳目标",
|
|
6
|
+
weight: 1.15,
|
|
7
|
+
playbackMarks: () => [SEGNO_MARK],
|
|
8
|
+
shapes: [
|
|
9
|
+
{
|
|
10
|
+
path: [
|
|
11
|
+
{ op: "M", x: 3.75502, y: 7.52938 },
|
|
12
|
+
{ op: "C", cx1: 1.3411, cy1: 6.32492, cx2: 0.10249, cy2: 4.89115, x: 0.03897, y: 3.23307 },
|
|
13
|
+
{ op: "C", cx1: 0.06833, cy1: 2.69176, cx2: 0.20975, cy2: 2.17002, x: 0.45843, y: 1.67267 },
|
|
14
|
+
{ op: "C", cx1: 0.71191, cy1: 1.1751, cx2: 1.05826, cy2: 0.77042, x: 1.49231, y: 0.46321 },
|
|
15
|
+
{ op: "C", cx1: 1.93115, cy1: 0.156, cx2: 2.41873, cy2: 0, x: 2.95524, y: 0 },
|
|
16
|
+
{ op: "C", cx1: 3.6136, cy1: 0, cx2: 4.17428, cy2: 0.17538, x: 4.64747, y: 0.52174 },
|
|
17
|
+
{ op: "C", cx1: 5.12047, cy1: 0.8679, cx2: 5.35457, cy2: 1.36047, x: 5.35457, y: 1.99925 },
|
|
18
|
+
{ op: "C", cx1: 5.33499, cy1: 2.26751, cx2: 5.21315, cy2: 2.49182, x: 4.98384, y: 2.66739 },
|
|
19
|
+
{ op: "C", cx1: 4.75473, cy1: 2.83817, cx2: 4.50106, cy2: 2.93565, x: 4.21343, y: 2.95502 },
|
|
20
|
+
{ op: "C", cx1: 3.67691, cy1: 2.90629, cx2: 3.35013, cy2: 2.68696, x: 3.23807, y: 2.29686 },
|
|
21
|
+
{ op: "L", x: 3.06249, y: 1.73119 },
|
|
22
|
+
{ op: "C", cx1: 2.93086, cy1: 1.31652, cx2: 2.71134, cy2: 1.0191, x: 2.29687, y: 1.0191 },
|
|
23
|
+
{ op: "C", cx1: 1.99446, cy1: 1.0191, cx2: 1.74578, cy2: 1.16551, x: 1.55561, y: 1.46293 },
|
|
24
|
+
{ op: "C", cx1: 1.36544, cy1: 1.76035, cx2: 1.26798, cy2: 2.06276, x: 1.25819, y: 2.37476 },
|
|
25
|
+
{ op: "C", cx1: 1.28735, cy1: 2.79902, cx2: 1.42398, cy2: 3.17954, x: 1.66287, y: 3.50612 },
|
|
26
|
+
{ op: "C", cx1: 1.90677, cy1: 3.8329, cx2: 2.20418, cy2: 4.11094, x: 2.56012, y: 4.34984 },
|
|
27
|
+
{ op: "C", cx1: 2.91627, cy1: 4.58394, cx2: 3.31116, cy2: 4.79846, x: 3.73542, y: 4.99841 },
|
|
28
|
+
{ op: "C", cx1: 4.15967, cy1: 5.19835, cx2: 4.57914, cy2: 5.38851, x: 4.99361, y: 5.57387 },
|
|
29
|
+
{ op: "L", x: 8.62659, y: 0.12183 },
|
|
30
|
+
{ op: "L", x: 9.70919, y: 0.12183 },
|
|
31
|
+
{ op: "L", x: 5.85194, y: 5.97376 },
|
|
32
|
+
{ op: "C", cx1: 6.5005, cy1: 6.29076, cx2: 7.09535, cy2: 6.65649, x: 7.62705, y: 7.06117 },
|
|
33
|
+
{ op: "C", cx1: 8.15855, cy1: 7.47085, cx2: 8.60221, cy2: 7.95363, x: 8.95835, y: 8.50473 },
|
|
34
|
+
{ op: "C", cx1: 9.3143, cy1: 9.05562, cx2: 9.48985, cy2: 9.65546, x: 9.48985, y: 10.30403 },
|
|
35
|
+
{ op: "C", cx1: 9.48985, cy1: 10.86491, cx2: 9.35822, cy2: 11.39164, x: 9.08996, y: 11.88421 },
|
|
36
|
+
{ op: "C", cx1: 8.82652, cy1: 12.37658, cx2: 8.44618, cy2: 12.77167, x: 7.9488, y: 13.0643 },
|
|
37
|
+
{ op: "C", cx1: 7.45147, cy1: 13.35691, cx2: 6.871, cy2: 13.50314, x: 6.21285, y: 13.50314 },
|
|
38
|
+
{ op: "C", cx1: 5.62259, cy1: 13.44461, cx2: 5.1448, cy2: 13.23009, x: 4.78386, y: 12.85457 },
|
|
39
|
+
{ op: "C", cx1: 4.42791, cy1: 12.47906, cx2: 4.23776, cy2: 12.06938, x: 4.21338, y: 11.62572 },
|
|
40
|
+
{ op: "C", cx1: 4.23275, cy1: 11.35746, cx2: 4.33043, cy2: 11.12338, x: 4.5108, y: 10.92821 },
|
|
41
|
+
{ op: "C", cx1: 4.69118, cy1: 10.73326, cx2: 4.94485, cy2: 10.626, x: 5.27163, y: 10.60644 },
|
|
42
|
+
{ op: "C", cx1: 5.63239, cy1: 10.60644, cx2: 5.88605, cy2: 10.68931, x: 6.03726, y: 10.85033 },
|
|
43
|
+
{ op: "C", cx1: 6.18828, cy1: 11.01611, cx2: 6.31031, cy2: 11.26001, x: 6.3932, y: 11.58656 },
|
|
44
|
+
{ op: "C", cx1: 6.48092, cy1: 11.91335, cx2: 6.56377, cy2: 12.14745, x: 6.64186, y: 12.2791 },
|
|
45
|
+
{ op: "C", cx1: 6.72476, cy1: 12.41573, cx2: 6.88578, cy2: 12.48404, x: 7.12944, y: 12.48404 },
|
|
46
|
+
{ op: "C", cx1: 7.50019, cy1: 12.48404, cx2: 7.78783, cy2: 12.35718, x: 7.99756, y: 12.10353 },
|
|
47
|
+
{ op: "C", cx1: 8.20729, cy1: 11.85485, cx2: 8.30974, cy2: 11.52805, x: 8.30974, y: 11.12338 },
|
|
48
|
+
{ op: "C", cx1: 8.30974, cy1: 10.57728, cx2: 8.11459, cy2: 10.11887, x: 7.72451, y: 9.74812 },
|
|
49
|
+
{ op: "C", cx1: 7.33918, cy1: 9.38239, cx2: 6.75395, cy2: 9.00689, x: 5.97375, y: 8.62657 },
|
|
50
|
+
{ op: "C", cx1: 5.19353, cy1: 8.25105, cx2: 4.73513, cy2: 8.01693, x: 4.59371, y: 7.92926 },
|
|
51
|
+
{ op: "L", x: 1.05823, y: 13.42024 },
|
|
52
|
+
{ op: "L", x: 0, y: 13.42024 },
|
|
53
|
+
{ op: "L", x: 3.755, y: 7.52937 },
|
|
54
|
+
{ op: "L", x: 3.75502, y: 7.52938 },
|
|
55
|
+
{ op: "Z" },
|
|
56
|
+
{ op: "M", x: 0.07812, y: 8.54848 },
|
|
57
|
+
{ op: "C", cx1: 0.07812, cy1: 8.20711, cx2: 0.18039, cy2: 7.95364, x: 0.38033, y: 7.78285 },
|
|
58
|
+
{ op: "C", cx1: 0.58028, cy1: 7.61227, cx2: 0.81937, cy2: 7.5294, x: 1.09721, y: 7.5294 },
|
|
59
|
+
{ op: "C", cx1: 1.36068, cy1: 7.55377, cx2: 1.58499, cy2: 7.65124, x: 1.76535, y: 7.822 },
|
|
60
|
+
{ op: "C", cx1: 1.94572, cy1: 7.99259, cx2: 2.03841, cy2: 8.25105, x: 2.03841, y: 8.58763 },
|
|
61
|
+
{ op: "C", cx1: 2.03841, cy1: 8.79736, cx2: 1.93594, cy2: 8.99731, x: 1.736, y: 9.19226 },
|
|
62
|
+
{ op: "C", cx1: 1.53606, cy1: 9.39222, cx2: 1.32153, cy2: 9.48971, x: 1.09721, y: 9.48971 },
|
|
63
|
+
{ op: "C", cx1: 0.81936, cy1: 9.48971, cx2: 0.57548, cy2: 9.41181, x: 0.37553, y: 9.25081 },
|
|
64
|
+
{ op: "C", cx1: 0.17558, cy1: 9.08978, cx2: 0.07811, cy2: 8.85588, x: 0.07811, y: 8.54849 },
|
|
65
|
+
{ op: "L", x: 0.07812, y: 8.54848 },
|
|
66
|
+
{ op: "Z" },
|
|
67
|
+
{ op: "M", x: 8.3098, y: 5.11547 },
|
|
68
|
+
{ op: "C", cx1: 8.3098, cy1: 4.7789, cx2: 8.4023, cy2: 4.51564, x: 8.58285, y: 4.33027 },
|
|
69
|
+
{ op: "C", cx1: 8.76803, cy1: 4.14508, cx2: 9.00212, cy2: 4.05242, x: 9.28995, y: 4.05242 },
|
|
70
|
+
{ op: "C", cx1: 9.57758, cy1: 4.05242, cx2: 9.82145, cy2: 4.14011, x: 10.01644, y: 4.31568 },
|
|
71
|
+
{ op: "C", cx1: 10.21158, cy1: 4.48627, cx2: 10.30902, cy2: 4.73994, x: 10.30902, y: 5.07152 },
|
|
72
|
+
{ op: "C", cx1: 10.30902, cy1: 5.30083, cx2: 10.20677, cy2: 5.51036, x: 10.00184, y: 5.69572 },
|
|
73
|
+
{ op: "C", cx1: 9.7971, cy1: 5.88108, cx2: 9.57279, cy2: 5.97376, x: 9.32892, y: 5.97376 },
|
|
74
|
+
{ op: "C", cx1: 9.07043, cy1: 5.97376, cx2: 8.83156, cy2: 5.88587, x: 8.62182, y: 5.71529 },
|
|
75
|
+
{ op: "C", cx1: 8.41209, cy1: 5.53971, cx2: 8.3098, cy2: 5.33977, x: 8.3098, y: 5.11546 },
|
|
76
|
+
{ op: "L", x: 8.3098, y: 5.11547 },
|
|
77
|
+
{ op: "Z" },
|
|
78
|
+
],
|
|
79
|
+
style: { fill: "#000" },
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ornament } from "../ornament.js";
|
|
2
|
+
export const trSymbol = {
|
|
3
|
+
name: "tr",
|
|
4
|
+
description: "颤音:本音与调内上方二度交替",
|
|
5
|
+
shapes: [
|
|
6
|
+
{
|
|
7
|
+
path: [
|
|
8
|
+
{ op: "M", x: 3.17992, y: 5.46383 },
|
|
9
|
+
{ op: "L", x: 3.61827, y: 3.91711 },
|
|
10
|
+
{ op: "C", cx1: 3.10024, cy1: 3.49862, cx2: 2.52947, cy2: 3.29304, x: 1.90541, y: 3.29304 },
|
|
11
|
+
{ op: "C", cx1: 1.50051, cy1: 3.29304, cx2: 1.18833, cy2: 3.40589, x: 0.95611, y: 3.63812 },
|
|
12
|
+
{ op: "C", cx1: 0.72361, cy1: 3.87061, cx2: 0.59743, cy2: 4.14281, x: 0.57105, y: 4.46152 },
|
|
13
|
+
{ op: "C", cx1: 0.57105, cy1: 4.91944, cx2: 0.71707, cy2: 5.25147, x: 1.00913, y: 5.47036 },
|
|
14
|
+
{ op: "C", cx1: 1.30118, cy1: 5.68954, cx2: 1.61988, cy2: 5.79586, x: 1.95843, y: 5.79586 },
|
|
15
|
+
{ op: "C", cx1: 1.9916, cy1: 5.79586, cx2: 2.03157, cy2: 5.8157, x: 2.06475, y: 5.84888 },
|
|
16
|
+
{ op: "C", cx1: 2.24394, cy1: 5.82904, cx2: 2.61568, cy2: 5.69632, x: 3.17992, y: 5.46383 },
|
|
17
|
+
{ op: "Z" },
|
|
18
|
+
{ op: "M", x: 6.579, y: 9.87204 },
|
|
19
|
+
{ op: "L", x: 8.40472, y: 3.75096 },
|
|
20
|
+
{ op: "C", cx1: 8.40472, cy1: 3.59162, cx2: 8.35167, cy2: 3.51193, x: 8.23884, y: 3.51193 },
|
|
21
|
+
{ op: "C", cx1: 7.98647, cy1: 3.51193, cx2: 7.4554, cy2: 3.77761, x: 6.63883, y: 4.3152 },
|
|
22
|
+
{ op: "C", cx1: 5.82223, cy1: 4.84655, cx2: 5.37735, cy2: 5.15845, x: 5.30448, y: 5.25145 },
|
|
23
|
+
{ op: "C", cx1: 5.33764, cy1: 5.21147, cx2: 5.39068, cy2: 5.15845, x: 5.46383, y: 5.0853 },
|
|
24
|
+
{ op: "C", cx1: 6.13441, cy1: 6.06127, cx2: 6.47294, cy2: 6.98417, x: 6.47294, y: 7.86061 },
|
|
25
|
+
{ op: "C", cx1: 6.41313, cy1: 8.53088, cx2: 6.18062, cy2: 9.12181, x: 5.7692, y: 9.61968 },
|
|
26
|
+
{ op: "C", cx1: 5.3643, cy1: 10.11758, cx2: 4.85308, cy2: 10.3634, x: 4.24233, y: 10.3634 },
|
|
27
|
+
{ op: "C", cx1: 3.71778, cy1: 10.3634, cx2: 3.25306, cy2: 10.23719, x: 2.83483, y: 9.99138 },
|
|
28
|
+
{ op: "C", cx1: 2.42314, cy1: 9.74586, cx2: 2.20396, cy2: 9.39396, x: 2.17759, y: 8.92271 },
|
|
29
|
+
{ op: "C", cx1: 2.21077, cy1: 8.80986, cx2: 2.23061, cy2: 8.66384, x: 2.23061, y: 8.48436 },
|
|
30
|
+
{ op: "L", x: 2.85469, y: 6.0944 },
|
|
31
|
+
{ op: "C", cx1: 2.58903, cy1: 6.2339, cx2: 2.21729, cy2: 6.30702, x: 1.73924, y: 6.30702 },
|
|
32
|
+
{ op: "C", cx1: 1.22829, cy1: 6.2804, cx2: 0.81007, cy2: 6.1012, x: 0.48458, y: 5.76917 },
|
|
33
|
+
{ op: "C", cx1: 0.15935, cy1: 5.43065, cx2: 0, cy2: 4.97926, x: 0, y: 4.4082 },
|
|
34
|
+
{ op: "C", cx1: 0.03318, cy1: 3.89045, cx2: 0.20586, cy2: 3.46543, x: 0.53107, y: 3.13369 },
|
|
35
|
+
{ op: "C", cx1: 0.8563, cy1: 2.80166, cx2: 1.32782, cy2: 2.63579, x: 1.95843, y: 2.63579 },
|
|
36
|
+
{ op: "C", cx1: 2.55585, cy1: 2.63579, cx2: 3.17992, cy2: 2.87481, x: 3.83716, y: 3.34606 },
|
|
37
|
+
{ op: "L", x: 4.89277, y: 0 },
|
|
38
|
+
{ op: "L", x: 6.85119, y: 0 },
|
|
39
|
+
{ op: "L", x: 5.41053, y: 4.51453 },
|
|
40
|
+
{ op: "C", cx1: 6.28694, cy1: 3.83064, cx2: 7.02389, cy2: 3.34606, x: 7.62128, y: 3.06054 },
|
|
41
|
+
{ op: "C", cx1: 8.21899, cy1: 2.77502, cx2: 8.86943, cy2: 2.63579, x: 9.57321, y: 2.63579 },
|
|
42
|
+
{ op: "C", cx1: 10.05773, cy1: 2.63579, cx2: 10.30358, cy2: 2.83484, x: 10.30358, y: 3.23974 },
|
|
43
|
+
{ op: "C", cx1: 10.30358, cy1: 3.44559, cx2: 10.17738, cy2: 3.89046, x: 10.09093, y: 4.18931 },
|
|
44
|
+
{ op: "C", cx1: 10.7283, cy1: 3.15354, cx2: 11.45195, cy2: 2.63579, x: 12.26199, y: 2.63579 },
|
|
45
|
+
{ op: "C", cx1: 12.6272, cy1: 2.63579, cx2: 12.91925, cy2: 2.76849, x: 13.14497, y: 3.03417 },
|
|
46
|
+
{ op: "C", cx1: 13.37717, cy1: 3.29957, cx2: 13.49001, cy2: 3.61175, x: 13.49001, y: 3.97014 },
|
|
47
|
+
{ op: "C", cx1: 13.49001, cy1: 4.62739, cx2: 13.09844, cy2: 5.03228, x: 12.53419, y: 5.03228 },
|
|
48
|
+
{ op: "C", cx1: 12.16899, cy1: 5.03228, cx2: 11.85709, cy2: 4.79327, x: 11.80382, y: 4.29536 },
|
|
49
|
+
{ op: "C", cx1: 11.89029, cy1: 3.91031, cx2: 11.98982, cy2: 3.55191, x: 11.98982, y: 3.34606 },
|
|
50
|
+
{ op: "C", cx1: 11.98982, cy1: 3.27291, cx2: 11.94329, cy2: 3.23973, x: 11.85709, y: 3.23973 },
|
|
51
|
+
{ op: "C", cx1: 11.74403, cy1: 3.23973, cx2: 11.53162, cy2: 3.34606, x: 11.20637, y: 3.56522 },
|
|
52
|
+
{ op: "C", cx1: 10.90752, cy1: 3.7708, cx2: 10.61547, cy2: 4.11615, x: 10.31666, y: 4.61405 },
|
|
53
|
+
{ op: "C", cx1: 10.01808, cy1: 5.11195, cx2: 9.77253, cy2: 5.69632, x: 9.57321, y: 6.36662 },
|
|
54
|
+
{ op: "L", x: 8.45798, y: 9.87203 },
|
|
55
|
+
{ op: "L", x: 6.57899, y: 9.87203 },
|
|
56
|
+
{ op: "L", x: 6.579, y: 9.87204 },
|
|
57
|
+
{ op: "Z" },
|
|
58
|
+
{ op: "M", x: 5.05893, y: 5.62971 },
|
|
59
|
+
{ op: "L", x: 3.94348, y: 8.92274 },
|
|
60
|
+
{ op: "C", cx1: 3.94348, cy1: 9.0288, cx2: 3.92364, cy2: 9.12179, x: 3.89045, y: 9.19495 },
|
|
61
|
+
{ op: "C", cx1: 3.89045, cy1: 9.48047, cx2: 4.06285, cy2: 9.65287, x: 4.40821, y: 9.70617 },
|
|
62
|
+
{ op: "C", cx1: 5.404, cy1: 9.22134, cx2: 5.9019, cy2: 8.51787, x: 5.9019, y: 7.58841 },
|
|
63
|
+
{ op: "C", cx1: 5.9019, cy1: 6.99751, cx2: 5.62318, cy2: 6.34681, x: 5.05893, y: 5.62972 },
|
|
64
|
+
{ op: "L", x: 5.05893, y: 5.62971 },
|
|
65
|
+
{ op: "Z" },
|
|
66
|
+
],
|
|
67
|
+
style: { fill: "#000" },
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
emitPlayback: emitter => emitter.affectFollowing(ornament({ body: [0, 1], repeat: true })),
|
|
71
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PathCommand } from "../../render/types.js";
|
|
2
|
+
/** 已按字号固化的四分音符字形 */
|
|
3
|
+
export interface PreparedQuarterNote {
|
|
4
|
+
w: number;
|
|
5
|
+
h: number;
|
|
6
|
+
/** 符干中线到字形左边界的距离;它是这个字形的竖笔,对齐点取这里 */
|
|
7
|
+
stemCenterX: number;
|
|
8
|
+
commands: readonly PathCommand[];
|
|
9
|
+
/** 传给 PathTransform 的等比缩放,倾斜的符头不能被非等比拉伸 */
|
|
10
|
+
scale: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function prepareQuarterNote(size: number): PreparedQuarterNote;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// 轮廓直接照抄成品字模,坐标单位是 em;y=0 是符干顶端,y=HEIGHT 是符头底端(对齐文字基线)
|
|
2
|
+
const GLYPH_EM = 11;
|
|
3
|
+
const WIDTH = 3.864;
|
|
4
|
+
const HEIGHT = 10.88;
|
|
5
|
+
const STEM_LEFT = 3.304;
|
|
6
|
+
const QUARTER_NOTE_COMMANDS = [
|
|
7
|
+
{ op: "M", x: 3.864, y: 8.5 },
|
|
8
|
+
{ op: "Q", cx: 3.864, cy: 9.228, x: 3.5, y: 9.76 },
|
|
9
|
+
{ op: "Q", cx: 3.136, cy: 10.292, x: 2.555, y: 10.586 },
|
|
10
|
+
{ op: "Q", cx: 1.974, cy: 10.88, x: 1.302, y: 10.88 },
|
|
11
|
+
{ op: "Q", cx: 0.826, cy: 10.88, x: 0.413, y: 10.621 },
|
|
12
|
+
{ op: "Q", cx: 0, cy: 10.362, x: 0, y: 9.844 },
|
|
13
|
+
{ op: "Q", cx: 0, cy: 9.34, x: 0.364, y: 8.899 },
|
|
14
|
+
{ op: "Q", cx: 0.728, cy: 8.458, x: 1.288, y: 8.185 },
|
|
15
|
+
{ op: "Q", cx: 1.848, cy: 7.912, x: 2.422, y: 7.912 },
|
|
16
|
+
{ op: "Q", cx: 2.968, cy: 7.912, x: 3.304, y: 8.094 },
|
|
17
|
+
{ op: "L", x: 3.304, y: 0 },
|
|
18
|
+
{ op: "L", x: 3.864, y: 0 },
|
|
19
|
+
{ op: "Z" },
|
|
20
|
+
];
|
|
21
|
+
export function prepareQuarterNote(size) {
|
|
22
|
+
const scale = size / GLYPH_EM;
|
|
23
|
+
return {
|
|
24
|
+
w: WIDTH * scale,
|
|
25
|
+
h: HEIGHT * scale,
|
|
26
|
+
stemCenterX: (STEM_LEFT + WIDTH) / 2 * scale,
|
|
27
|
+
commands: QUARTER_NOTE_COMMANDS,
|
|
28
|
+
scale,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { TemporalNodeBase } from "
|
|
1
|
+
import { TemporalNodeBase } from "../temporal.js";
|
|
2
2
|
import { ASTFunctionNode } from "../ASTtypes.js";
|
|
3
|
+
import { prepareQuarterNote } from "./glyph.js";
|
|
3
4
|
class TempoFunction extends ASTFunctionNode {
|
|
4
5
|
static def = {
|
|
5
6
|
name: ["tempo"],
|
|
@@ -12,25 +13,77 @@ class TempoFunction extends ASTFunctionNode {
|
|
|
12
13
|
type: "number",
|
|
13
14
|
default: null,
|
|
14
15
|
},
|
|
16
|
+
{
|
|
17
|
+
name: "size",
|
|
18
|
+
type: "length",
|
|
19
|
+
default: {
|
|
20
|
+
value: 1,
|
|
21
|
+
unit: "em",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
15
24
|
],
|
|
16
25
|
};
|
|
17
26
|
bpm;
|
|
27
|
+
size;
|
|
28
|
+
font;
|
|
18
29
|
constructor(sourceSpan, args, ctx, parent = null) {
|
|
19
30
|
super(sourceSpan, parent);
|
|
20
|
-
[
|
|
31
|
+
const [bpm, size] = this.getArgValue(args, ctx);
|
|
32
|
+
this.bpm = bpm;
|
|
33
|
+
this.size = ctx.length2px(size);
|
|
34
|
+
this.font = ctx.variables.font;
|
|
21
35
|
}
|
|
22
36
|
loweringEnter() {
|
|
23
37
|
return [new TempoTemporalNode(this)];
|
|
24
38
|
}
|
|
25
|
-
toString() { return `@tempo(${this.bpm})`; }
|
|
39
|
+
toString() { return `@tempo(${this.bpm}, size=${this.size}px)`; }
|
|
26
40
|
}
|
|
27
41
|
export const TempoNode = TempoFunction;
|
|
28
42
|
class TempoTemporalNode extends TemporalNodeBase {
|
|
43
|
+
/** 字号和 bpm 在解析时已经固化,字形、文本、样式随之不再变 */
|
|
44
|
+
glyph;
|
|
45
|
+
text;
|
|
46
|
+
style;
|
|
47
|
+
glyphY = 0;
|
|
48
|
+
textX = 0;
|
|
49
|
+
textBaselineY = 0;
|
|
29
50
|
constructor(ast) {
|
|
30
51
|
super();
|
|
31
52
|
this.ast = ast;
|
|
53
|
+
this.glyph = prepareQuarterNote(ast.size);
|
|
54
|
+
this.text = `= ${ast.bpm}`;
|
|
55
|
+
this.style = { fontSize: ast.size, fontFamily: ast.font, fill: "#000" };
|
|
56
|
+
// 非法值不入时间状态,也不告知播放系统,效果是保持上一个速度
|
|
57
|
+
if (Number.isFinite(ast.bpm) && ast.bpm > 0)
|
|
58
|
+
this.playbackState = { bpm: ast.bpm };
|
|
59
|
+
this.initLayoutBox();
|
|
32
60
|
}
|
|
33
61
|
onTimeState(state) {
|
|
34
|
-
|
|
62
|
+
const bpm = this.playbackState?.bpm;
|
|
63
|
+
if (bpm !== undefined)
|
|
64
|
+
state.bpm = bpm;
|
|
65
|
+
}
|
|
66
|
+
prepareLayout(context) {
|
|
67
|
+
const glyph = this.glyph;
|
|
68
|
+
const metrics = context.textMeasurer.measureText(this.text, this.style);
|
|
69
|
+
// 符头底端坐在文字基线上;符干比文字高时整块文字下移
|
|
70
|
+
const textTop = Math.max(0, glyph.h - metrics.baseline);
|
|
71
|
+
this.textX = glyph.w + this.ast.size * 0.26;
|
|
72
|
+
this.textBaselineY = textTop + metrics.baseline;
|
|
73
|
+
this.glyphY = this.textBaselineY - glyph.h;
|
|
74
|
+
this.box.w = this.textX + metrics.w;
|
|
75
|
+
this.box.h = textTop + metrics.h;
|
|
76
|
+
this.box.anchor = glyph.stemCenterX;
|
|
77
|
+
// Tempo 与同轨文字按等号所在的文字行对齐;符干只向上扩展占用,不参与对齐轴。
|
|
78
|
+
this.box.visualAxis = textTop + metrics.h / 2;
|
|
79
|
+
}
|
|
80
|
+
paint(painter) {
|
|
81
|
+
painter.drawPath(this.glyph.commands, { fill: "#000" }, {
|
|
82
|
+
x: this.box.x,
|
|
83
|
+
y: this.box.y + this.glyphY,
|
|
84
|
+
scaleX: this.glyph.scale,
|
|
85
|
+
scaleY: this.glyph.scale,
|
|
86
|
+
});
|
|
87
|
+
painter.drawText(this.text, this.box.x + this.textX, this.box.y + this.textBaselineY, this.style);
|
|
35
88
|
}
|
|
36
89
|
}
|