abcjs 6.0.0-beta.9 → 6.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/.github/workflows/tests.yml +29 -0
  2. package/CODE_OF_CONDUCT.md +76 -0
  3. package/CONTRIBUTING.md +1 -0
  4. package/LICENSE.md +1 -1
  5. package/README.md +88 -7
  6. package/RELEASE.md +961 -1
  7. package/abcjs-audio.css +14 -5
  8. package/dist/.gitignore +1 -2
  9. package/dist/abcjs-basic-min.js +3 -0
  10. package/dist/abcjs-basic-min.js.LICENSE +23 -0
  11. package/dist/abcjs-basic.js +28232 -0
  12. package/dist/abcjs-basic.js.map +1 -0
  13. package/dist/abcjs-plugin-min.js +3 -0
  14. package/dist/abcjs-plugin-min.js.LICENSE +23 -0
  15. package/index.js +27 -2
  16. package/{static-wrappers/license.js → license.js} +1 -1
  17. package/package.json +26 -29
  18. package/{src/plugin/abc_plugin.js → plugin.js} +31 -19
  19. package/src/api/abc_animation.js +1 -17
  20. package/src/api/abc_tablatures.js +144 -0
  21. package/src/api/abc_timing_callbacks.js +216 -117
  22. package/src/api/abc_tunebook.js +18 -67
  23. package/src/api/abc_tunebook_svg.js +40 -48
  24. package/src/data/abc_tune.js +232 -972
  25. package/src/data/deline-tune.js +199 -0
  26. package/src/edit/abc_editarea.js +112 -0
  27. package/src/edit/abc_editor.js +95 -221
  28. package/src/midi/abc_midi_create.js +48 -50
  29. package/src/parse/abc_common.js +0 -14
  30. package/src/parse/abc_parse.js +167 -1321
  31. package/src/parse/abc_parse_book.js +62 -0
  32. package/src/parse/abc_parse_directive.js +164 -41
  33. package/src/parse/abc_parse_header.js +116 -145
  34. package/src/parse/abc_parse_key_voice.js +26 -20
  35. package/src/parse/abc_parse_music.js +1337 -0
  36. package/src/parse/abc_tokenizer.js +21 -15
  37. package/src/parse/abc_transpose.js +3 -15
  38. package/src/parse/tune-builder.js +896 -0
  39. package/src/parse/wrap_lines.js +205 -453
  40. package/src/synth/abc_midi_flattener.js +1292 -0
  41. package/src/{midi → synth}/abc_midi_renderer.js +44 -17
  42. package/src/synth/abc_midi_sequencer.js +648 -0
  43. package/src/synth/active-audio-context.js +3 -14
  44. package/src/synth/cents-to-factor.js +10 -0
  45. package/src/synth/create-note-map.js +21 -32
  46. package/src/synth/create-synth-control.js +20 -103
  47. package/src/synth/create-synth.js +185 -77
  48. package/src/synth/download-buffer.js +7 -21
  49. package/src/synth/get-midi-file.js +13 -20
  50. package/src/synth/images/{loading.svg → loading.svg.js} +4 -0
  51. package/src/synth/images/loop.svg.js +65 -0
  52. package/src/synth/images/pause.svg.js +10 -0
  53. package/src/synth/images/play.svg.js +9 -0
  54. package/src/synth/images/{reset.svg → reset.svg.js} +5 -1
  55. package/src/synth/instrument-index-to-name.js +1 -16
  56. package/src/synth/load-note.js +37 -76
  57. package/src/synth/pitch-to-note-name.js +0 -15
  58. package/src/synth/pitches-to-perc.js +64 -0
  59. package/src/synth/place-note.js +78 -68
  60. package/src/synth/play-event.js +17 -18
  61. package/src/synth/register-audio-context.js +11 -23
  62. package/src/synth/sounds-cache.js +0 -15
  63. package/src/synth/supports-audio.js +9 -23
  64. package/src/synth/synth-controller.js +80 -49
  65. package/src/synth/synth-sequence.js +20 -34
  66. package/src/tablatures/instruments/guitar/guitar-fonts.js +19 -0
  67. package/src/tablatures/instruments/guitar/guitar-patterns.js +23 -0
  68. package/src/tablatures/instruments/guitar/tab-guitar.js +50 -0
  69. package/src/tablatures/instruments/string-patterns.js +277 -0
  70. package/src/tablatures/instruments/string-tablature.js +56 -0
  71. package/src/tablatures/instruments/tab-note.js +282 -0
  72. package/src/tablatures/instruments/tab-notes.js +41 -0
  73. package/src/tablatures/instruments/violin/tab-violin.js +47 -0
  74. package/src/tablatures/instruments/violin/violin-fonts.js +19 -0
  75. package/src/tablatures/instruments/violin/violin-patterns.js +23 -0
  76. package/src/tablatures/tab-absolute-elements.js +310 -0
  77. package/src/tablatures/tab-common.js +29 -0
  78. package/src/tablatures/tab-renderer.js +243 -0
  79. package/src/tablatures/transposer.js +110 -0
  80. package/src/test/abc_midi_lint.js +5 -22
  81. package/src/test/abc_midi_sequencer_lint.js +11 -14
  82. package/src/test/abc_parser_lint.js +136 -32
  83. package/src/test/abc_vertical_lint.js +94 -32
  84. package/src/test/rendering-lint.js +38 -5
  85. package/src/write/abc_absolute_element.js +112 -120
  86. package/src/write/abc_abstract_engraver.js +102 -253
  87. package/src/write/abc_beam_element.js +30 -290
  88. package/src/write/abc_brace_element.js +12 -121
  89. package/src/write/abc_create_clef.js +21 -32
  90. package/src/write/abc_create_key_signature.js +8 -26
  91. package/src/write/abc_create_note_head.js +107 -0
  92. package/src/write/abc_create_time_signature.js +2 -21
  93. package/src/write/abc_crescendo_element.js +3 -50
  94. package/src/write/abc_decoration.js +7 -30
  95. package/src/write/abc_dynamic_decoration.js +3 -37
  96. package/src/write/abc_ending_element.js +1 -57
  97. package/src/write/abc_engraver_controller.js +111 -234
  98. package/src/write/abc_glyphs.js +8 -18
  99. package/src/write/abc_relative_element.js +57 -97
  100. package/src/write/abc_renderer.js +10 -832
  101. package/src/write/abc_spacing.js +0 -15
  102. package/src/write/abc_staff_group_element.js +14 -349
  103. package/src/write/abc_tempo_element.js +9 -117
  104. package/src/write/abc_tie_element.js +5 -68
  105. package/src/write/abc_triplet_element.js +6 -124
  106. package/src/write/abc_voice_element.js +7 -222
  107. package/src/write/add-chord.js +103 -0
  108. package/src/write/add-text-if.js +33 -0
  109. package/src/write/bottom-text.js +79 -0
  110. package/src/write/calcHeight.js +17 -0
  111. package/src/write/classes.js +100 -0
  112. package/src/write/draw/absolute.js +68 -0
  113. package/src/write/draw/beam.js +56 -0
  114. package/src/write/draw/brace.js +106 -0
  115. package/src/write/draw/crescendo.js +38 -0
  116. package/src/write/draw/debug-box.js +8 -0
  117. package/src/write/draw/draw.js +56 -0
  118. package/src/write/draw/dynamics.js +20 -0
  119. package/src/write/draw/ending.js +46 -0
  120. package/src/write/draw/group-elements.js +66 -0
  121. package/src/write/draw/horizontal-line.js +25 -0
  122. package/src/write/draw/non-music.js +50 -0
  123. package/src/write/draw/print-line.js +24 -0
  124. package/src/write/draw/print-path.js +7 -0
  125. package/src/write/draw/print-stem.js +30 -0
  126. package/src/write/draw/print-symbol.js +59 -0
  127. package/src/write/draw/print-vertical-line.js +18 -0
  128. package/src/write/draw/relative.js +77 -0
  129. package/src/write/draw/round-number.js +5 -0
  130. package/src/write/draw/selectables.js +59 -0
  131. package/src/write/draw/separator.js +16 -0
  132. package/src/write/draw/set-paper-size.js +45 -0
  133. package/src/write/{sprintf.js → draw/sprintf.js} +0 -0
  134. package/src/write/draw/staff-group.js +226 -0
  135. package/src/write/draw/staff-line.js +9 -0
  136. package/src/write/draw/staff.js +33 -0
  137. package/src/write/draw/tab-line.js +40 -0
  138. package/src/write/draw/tempo.js +45 -0
  139. package/src/write/draw/text.js +71 -0
  140. package/src/write/draw/tie.js +97 -0
  141. package/src/write/draw/triplet.js +46 -0
  142. package/src/write/draw/voice.js +102 -0
  143. package/src/write/format-jazz-chord.js +15 -0
  144. package/src/write/free-text.js +41 -0
  145. package/src/write/get-font-and-attr.js +37 -0
  146. package/src/write/get-text-size.js +56 -0
  147. package/src/write/highlight.js +11 -0
  148. package/src/write/layout/VoiceElements.js +121 -0
  149. package/src/write/layout/beam.js +213 -0
  150. package/src/write/layout/get-left-edge-of-staff.js +56 -0
  151. package/src/write/layout/getBarYAt.js +6 -0
  152. package/src/write/layout/layout.js +94 -0
  153. package/src/write/layout/setUpperAndLowerElements.js +232 -0
  154. package/src/write/layout/staffGroup.js +146 -0
  155. package/src/write/layout/triplet.js +75 -0
  156. package/src/write/layout/voice.js +137 -0
  157. package/src/write/selection.js +188 -70
  158. package/src/write/separator.js +10 -0
  159. package/src/write/set-class.js +21 -0
  160. package/src/write/subtitle.js +12 -0
  161. package/src/write/svg.js +95 -43
  162. package/src/write/top-text.js +54 -0
  163. package/src/write/unhighlight.js +11 -0
  164. package/test.js +27 -64
  165. package/types/index.d.ts +1095 -0
  166. package/version.js +1 -1
  167. package/.babelrc +0 -5
  168. package/.eslintrc +0 -3
  169. package/.gitmodules +0 -3
  170. package/Dockerfile +0 -8
  171. package/abcjs-midi.css +0 -166
  172. package/build-utils/loadPresets.js +0 -14
  173. package/build-utils/presets/webpack.analyze.js +0 -6
  174. package/build-utils/presets/webpack.optimize.js +0 -30
  175. package/build-utils/webpack.development.js +0 -14
  176. package/build-utils/webpack.production.js +0 -35
  177. package/deploy-docs.sh +0 -25
  178. package/docker-compose.yml +0 -13
  179. package/docs/README.md +0 -33
  180. package/fix-versions.sh +0 -23
  181. package/midi.js +0 -62
  182. package/src/api/abc_tunebook_midi.js +0 -116
  183. package/src/midi/abc_midi_controls.js +0 -701
  184. package/src/midi/abc_midi_flattener.js +0 -1119
  185. package/src/midi/abc_midi_js_preparer.js +0 -243
  186. package/src/midi/abc_midi_sequencer.js +0 -401
  187. package/src/midi/abc_midi_ui_generator.js +0 -86
  188. package/src/plugin/abc_plugin_midi.js +0 -220
  189. package/src/synth/images/loop.svg +0 -61
  190. package/src/synth/images/pause.svg +0 -6
  191. package/src/synth/images/play.svg +0 -5
  192. package/src/transform/abc2abc_write.js +0 -395
  193. package/static-wrappers/basic.js +0 -2
  194. package/static-wrappers/midi.js +0 -2
  195. package/static-wrappers/plugin-midi.js +0 -6
  196. package/static-wrappers/plugin.js +0 -6
  197. package/webpack.config.js +0 -29
@@ -1,18 +1,4 @@
1
1
  // abc_relative_element.js: Definition of the RelativeElement class.
2
- // Copyright (C) 2010-2020 Gregory Dyke (gregdyke at gmail dot com) and Paul Rosen
3
- //
4
- // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5
- // documentation files (the "Software"), to deal in the Software without restriction, including without limitation
6
- // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
7
- // to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
- //
9
- // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
- //
11
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
12
- // BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
13
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
14
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
2
 
17
3
  var RelativeElement = function RelativeElement(c, dx, w, pitch, opt) {
18
4
  opt = opt || {};
@@ -41,12 +27,25 @@ var RelativeElement = function RelativeElement(c, dx, w, pitch, opt) {
41
27
  else
42
28
  this.bottom += opt.stemHeight;
43
29
  }
44
- //if (this.type === "symbol") {
45
- // var offset = glyphs.getYCorr(this.c);
46
- // this.top += offset;
47
- // this.bottom += offset;
48
- //}
30
+ if (opt.dim)
31
+ this.dim = opt.dim;
32
+ if (opt.position)
33
+ this.position = opt.position;
49
34
  this.height = opt.height ? opt.height : 4; // The +1 is to give a little bit of padding.
35
+ if (opt.top)
36
+ this.top = opt.top;
37
+ if (opt.bottom)
38
+ this.bottom = opt.bottom;
39
+ if (opt.name)
40
+ this.name = opt.name;
41
+ else if (this.c)
42
+ this.name = this.c;
43
+ else
44
+ this.name = this.type;
45
+ if (opt.realWidth)
46
+ this.realWidth = opt.realWidth;
47
+ else
48
+ this.realWidth = this.w;
50
49
  this.centerVertically = false;
51
50
  switch (this.type) {
52
51
  case "debug":
@@ -77,88 +76,49 @@ var RelativeElement = function RelativeElement(c, dx, w, pitch, opt) {
77
76
  }
78
77
  };
79
78
 
80
- RelativeElement.prototype.setX = function (x) {
81
- this.x = x+this.dx;
79
+ RelativeElement.prototype.getChordDim = function () {
80
+ if (this.type === "debug")
81
+ return null;
82
+ if (!this.chordHeightAbove && !this.chordHeightBelow)
83
+ return null;
84
+ // Chords are centered, annotations are left justified.
85
+ // NOTE: the font reports extra space to the left and right anyway, so there is a built in margin.
86
+ // We add a little margin so that items can't touch - we use half the font size as the margin, so that is 1/4 on each side.
87
+ // if there is only one character that we're printing, use half of that margin.
88
+ // var margin = this.dim.font.size/4;
89
+ // if (this.c.length === 1)
90
+ // margin = margin / 2;
91
+ var margin = 0;
92
+
93
+ var offset = this.type === "chord" ? this.realWidth/2 : 0;
94
+ var left = this.x - offset - margin;
95
+ var right = left + this.realWidth + margin;
96
+ return { left: left, right: right};
82
97
  };
83
98
 
84
- RelativeElement.prototype.setUpperAndLowerElements = function(positionY) {
85
- switch(this.type) {
86
- case "part":
87
- this.top = positionY.partHeightAbove + this.height;
88
- this.bottom = positionY.partHeightAbove;
89
- break;
90
- case "text":
91
- case "chord":
92
- if (this.chordHeightAbove) {
93
- this.top = positionY.chordHeightAbove;
94
- this.bottom = positionY.chordHeightAbove;
95
- } else {
96
- this.top = positionY.chordHeightBelow;
97
- this.bottom = positionY.chordHeightBelow;
98
- }
99
- break;
100
- case "lyric":
101
- if (this.lyricHeightAbove) {
102
- this.top = positionY.lyricHeightAbove;
103
- this.bottom = positionY.lyricHeightAbove;
104
- } else {
105
- this.top = positionY.lyricHeightBelow;
106
- this.bottom = positionY.lyricHeightBelow;
107
- }
108
- break;
109
- case "debug":
110
- this.top = positionY.chordHeightAbove;
111
- this.bottom = positionY.chordHeightAbove;
112
- break;
113
- }
114
- if (this.pitch === undefined || this.top === undefined)
115
- window.console.error("RelativeElement position not set.", this.type, this.pitch, this.top, positionY);
99
+ RelativeElement.prototype.invertLane = function (total) {
100
+ if (this.lane === undefined)
101
+ this.lane = 0;
102
+ this.lane = total - this.lane - 1;
116
103
  };
117
104
 
118
- RelativeElement.prototype.draw = function (renderer, bartop) {
119
- if (this.pitch === undefined)
120
- window.console.error(this.type + " Relative Element y-coordinate not set.");
121
- var y = renderer.calcY(this.pitch);
122
- switch(this.type) {
123
- case "symbol":
124
- if (this.c===null) return null;
125
- var klass = "symbol";
126
- if (this.klass) klass += " " + this.klass;
127
- this.graphelem = renderer.printSymbol(this.x, this.pitch, this.c, this.scalex, this.scaley, renderer.addClasses(klass)); break;
128
- case "debug":
129
- this.graphelem = renderer.renderText({ x: this.x, y: renderer.calcY(15), text: ""+this.c, type: "debugfont", klass: 'debug-msg', anchor: 'start', centerVertically: false, history: 'not-selectable'}); break;
130
- case "barNumber":
131
- this.graphelem = renderer.renderText({ x: this.x, y: y, text: ""+this.c, type: "measurefont", klass: 'bar-number', anchor: "middle", history: 'ignore'});
132
- break;
133
- case "lyric":
134
- this.graphelem = renderer.renderText({ x: this.x, y: y, text: this.c, type: "vocalfont", klass: 'lyric', anchor: "middle"});
135
- break;
136
- case "chord":
137
- this.graphelem = renderer.renderText({ x: this.x, y: y, text: this.c, type: 'gchordfont', klass: "chord", anchor: "middle"});
138
- break;
139
- case "decoration":
140
- this.graphelem = renderer.renderText({ x: this.x, y: y, text: this.c, type: 'annotationfont', klass: "annotation", anchor: "middle", centerVertically: true});
141
- break;
142
- case "text":
143
- this.graphelem = renderer.renderText({ x: this.x, y: y, text: this.c, type: 'annotationfont', klass: "annotation", anchor: "start", centerVertically: this.centerVertically});
144
- break;
145
- case "multimeasure-text":
146
- this.graphelem = renderer.renderText({ x: this.x+this.w/2, y: y, text: this.c, type: 'tempofont', klass: "rest", anchor: "middle", centerVertically: false});
147
- break;
148
- case "part":
149
- this.graphelem = renderer.renderText({ x: this.x, y: y, text: this.c, type: 'partsfont', klass: "part", anchor: "start"});
150
- break;
151
- case "bar":
152
- this.graphelem = renderer.printStem(this.x, this.linewidth, y, (bartop)?bartop:renderer.calcY(this.pitch2)); break; // bartop can't be 0
153
- case "stem":
154
- this.graphelem = renderer.printStem(this.x, this.linewidth, y, renderer.calcY(this.pitch2)); break;
155
- case "ledger":
156
- this.graphelem = renderer.printStaveLine(this.x, this.x+this.w, this.pitch, renderer.addClasses("ledger")); break;
157
- }
158
- if (this.scalex!==1 && this.graphelem) {
159
- renderer.scaleExistingElem(this.graphelem, this.scalex, this.scaley, this.x, y);
160
- }
161
- return this.graphelem;
105
+ RelativeElement.prototype.putChordInLane = function (i) {
106
+ this.lane = i;
107
+ // Add some extra space to account for the character's descenders.
108
+ if (this.chordHeightAbove)
109
+ this.chordHeightAbove = (this.height*1.25)*this.lane;
110
+ else
111
+ this.chordHeightBelow = (this.height*1.25)*this.lane;
112
+ };
113
+
114
+ RelativeElement.prototype.getLane = function () {
115
+ if (this.lane === undefined)
116
+ return 0;
117
+ return this.lane;
118
+ };
119
+
120
+ RelativeElement.prototype.setX = function (x) {
121
+ this.x = x+this.dx;
162
122
  };
163
123
 
164
124
  module.exports = RelativeElement;