abcjs 6.1.8 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/RELEASE.md +66 -0
  2. package/dist/abcjs-basic-min.js +2 -2
  3. package/dist/abcjs-basic.js +4373 -4424
  4. package/dist/abcjs-basic.js.map +1 -1
  5. package/dist/abcjs-plugin-min.js +2 -2
  6. package/index.js +1 -1
  7. package/package.json +6 -6
  8. package/plugin.js +1 -1
  9. package/src/api/abc_timing_callbacks.js +7 -3
  10. package/src/api/abc_tunebook_svg.js +1 -2
  11. package/src/data/abc_tune.js +2 -2
  12. package/src/midi/abc_midi_create.js +8 -2
  13. package/src/parse/abc_common.js +0 -47
  14. package/src/parse/abc_parse.js +16 -16
  15. package/src/parse/abc_parse_book.js +3 -3
  16. package/src/parse/abc_parse_directive.js +26 -7
  17. package/src/parse/abc_parse_header.js +11 -9
  18. package/src/parse/abc_parse_key_voice.js +17 -17
  19. package/src/parse/abc_parse_music.js +89 -106
  20. package/src/parse/abc_tokenizer.js +60 -60
  21. package/src/parse/abc_transpose.js +14 -3
  22. package/src/parse/tune-builder.js +19 -14
  23. package/src/synth/abc_midi_flattener.js +25 -9
  24. package/src/synth/abc_midi_sequencer.js +1 -1
  25. package/src/synth/create-synth.js +41 -0
  26. package/src/synth/note-to-midi.js +50 -0
  27. package/src/tablatures/instruments/guitar/tab-guitar.js +0 -2
  28. package/src/tablatures/instruments/string-patterns.js +46 -28
  29. package/src/tablatures/instruments/tab-note.js +26 -103
  30. package/src/tablatures/instruments/violin/tab-violin.js +0 -2
  31. package/src/tablatures/tab-absolute-elements.js +9 -31
  32. package/src/tablatures/tab-renderer.js +2 -2
  33. package/src/test/abc_parser_lint.js +8 -5
  34. package/src/write/README.md +31 -0
  35. package/src/write/creation/abstract-engraver.js +1036 -0
  36. package/src/write/creation/add-chord.js +102 -0
  37. package/src/write/{add-text-if.js → creation/add-text-if.js} +6 -6
  38. package/src/write/{calcHeight.js → creation/calc-height.js} +2 -2
  39. package/src/write/creation/create-clef.js +72 -0
  40. package/src/write/creation/create-key-signature.js +31 -0
  41. package/src/write/creation/create-note-head.js +107 -0
  42. package/src/write/creation/create-time-signature.js +55 -0
  43. package/src/write/creation/decoration.js +357 -0
  44. package/src/write/{abc_absolute_element.js → creation/elements/absolute-element.js} +14 -15
  45. package/src/write/creation/elements/beam-element.js +113 -0
  46. package/src/write/{bottom-text.js → creation/elements/bottom-text.js} +14 -15
  47. package/src/write/{abc_brace_element.js → creation/elements/brace-element.js} +5 -5
  48. package/src/write/creation/elements/free-text.js +41 -0
  49. package/src/write/{abc_relative_element.js → creation/elements/relative-element.js} +8 -7
  50. package/src/write/{separator.js → creation/elements/separator.js} +2 -2
  51. package/src/write/{abc_staff_group_element.js → creation/elements/staff-group-element.js} +4 -4
  52. package/src/write/{subtitle.js → creation/elements/subtitle.js} +3 -3
  53. package/src/write/creation/elements/tempo-element.js +63 -0
  54. package/src/write/{abc_tie_element.js → creation/elements/tie-element.js} +15 -11
  55. package/src/write/{top-text.js → creation/elements/top-text.js} +12 -12
  56. package/src/write/creation/elements/triplet-element.js +28 -0
  57. package/src/write/{abc_voice_element.js → creation/elements/voice-element.js} +3 -3
  58. package/src/write/creation/glyphs.js +226 -0
  59. package/src/write/creation/translate-chord.js +37 -0
  60. package/src/write/draw/absolute.js +5 -5
  61. package/src/write/draw/beam.js +8 -8
  62. package/src/write/draw/brace.js +33 -33
  63. package/src/write/draw/crescendo.js +4 -4
  64. package/src/write/draw/debug-box.js +1 -1
  65. package/src/write/draw/draw.js +7 -7
  66. package/src/write/draw/dynamics.js +2 -2
  67. package/src/write/draw/ending.js +6 -6
  68. package/src/write/draw/glissando.js +17 -17
  69. package/src/write/draw/group-elements.js +51 -51
  70. package/src/write/draw/horizontal-line.js +9 -9
  71. package/src/write/draw/non-music.js +1 -1
  72. package/src/write/draw/print-line.js +15 -16
  73. package/src/write/draw/print-stem.js +5 -5
  74. package/src/write/draw/print-symbol.js +12 -12
  75. package/src/write/draw/print-vertical-line.js +8 -8
  76. package/src/write/draw/relative.js +17 -16
  77. package/src/write/draw/selectables.js +5 -5
  78. package/src/write/draw/separator.js +4 -4
  79. package/src/write/draw/set-paper-size.js +2 -2
  80. package/src/write/draw/sprintf.js +31 -31
  81. package/src/write/draw/staff-group.js +36 -30
  82. package/src/write/draw/staff-line.js +2 -2
  83. package/src/write/draw/staff.js +4 -4
  84. package/src/write/draw/tab-line.js +26 -26
  85. package/src/write/draw/tempo.js +30 -30
  86. package/src/write/draw/text.js +5 -5
  87. package/src/write/draw/tie.js +18 -18
  88. package/src/write/draw/triplet.js +6 -6
  89. package/src/write/draw/voice.js +16 -17
  90. package/src/write/{abc_engraver_controller.js → engraver-controller.js} +58 -51
  91. package/src/write/{classes.js → helpers/classes.js} +6 -6
  92. package/src/write/{get-font-and-attr.js → helpers/get-font-and-attr.js} +9 -7
  93. package/src/write/{get-text-size.js → helpers/get-text-size.js} +5 -5
  94. package/src/write/{set-class.js → helpers/set-class.js} +1 -1
  95. package/src/write/{abc_spacing.js → helpers/spacing.js} +1 -1
  96. package/src/write/{highlight.js → interactive/highlight.js} +1 -1
  97. package/src/write/{selection.js → interactive/selection.js} +27 -27
  98. package/src/write/{unhighlight.js → interactive/unhighlight.js} +1 -1
  99. package/src/write/layout/beam.js +13 -13
  100. package/src/write/layout/get-left-edge-of-staff.js +4 -4
  101. package/src/write/layout/layout.js +74 -74
  102. package/src/write/layout/{setUpperAndLowerElements.js → set-upper-and-lower-elements.js} +8 -8
  103. package/src/write/layout/{staffGroup.js → staff-group.js} +32 -32
  104. package/src/write/layout/triplet.js +4 -4
  105. package/src/write/layout/{VoiceElements.js → voice-elements.js} +23 -23
  106. package/src/write/layout/voice.js +6 -6
  107. package/src/write/{abc_renderer.js → renderer.js} +35 -32
  108. package/src/write/svg.js +35 -35
  109. package/test.js +1 -1
  110. package/types/index.d.ts +99 -22
  111. package/version.js +1 -1
  112. package/src/tablatures/instruments/guitar/guitar-fonts.js +0 -19
  113. package/src/tablatures/instruments/violin/violin-fonts.js +0 -19
  114. package/src/tablatures/transposer.js +0 -110
  115. package/src/write/abc_abstract_engraver.js +0 -1026
  116. package/src/write/abc_beam_element.js +0 -113
  117. package/src/write/abc_create_clef.js +0 -72
  118. package/src/write/abc_create_key_signature.js +0 -33
  119. package/src/write/abc_create_note_head.js +0 -107
  120. package/src/write/abc_create_time_signature.js +0 -55
  121. package/src/write/abc_decoration.js +0 -341
  122. package/src/write/abc_glyphs.js +0 -224
  123. package/src/write/abc_tempo_element.js +0 -63
  124. package/src/write/abc_triplet_element.js +0 -28
  125. package/src/write/add-chord.js +0 -103
  126. package/src/write/format-jazz-chord.js +0 -15
  127. package/src/write/free-text.js +0 -41
  128. /package/src/write/{abc_crescendo_element.js → creation/elements/crescendo-element.js} +0 -0
  129. /package/src/write/{abc_dynamic_decoration.js → creation/elements/dynamic-decoration.js} +0 -0
  130. /package/src/write/{abc_ending_element.js → creation/elements/ending-element.js} +0 -0
  131. /package/src/write/{abc_glissando_element.js → creation/elements/glissando-element.js} +0 -0
  132. /package/src/write/layout/{getBarYAt.js → get-bar-y-at.js} +0 -0
@@ -1,28 +0,0 @@
1
- // abc_triplet_element.js: Definition of the TripletElem class.
2
-
3
- var TripletElem = function TripletElem(number, anchor1, options) {
4
- this.type = "TripletElem";
5
- this.anchor1 = anchor1; // must have a .x and a .parent property or be null (means starts at the "beginning" of the line - after key signature)
6
- this.number = number;
7
- this.durationClass = ('d'+(Math.round(anchor1.parent.durationClass*1000)/1000)).replace(/\./, '-');
8
- this.middleElems = []; // This is to calculate the highest interior pitch. It is used to make sure that the drawn bracket never crosses a really high middle note.
9
- this.flatBeams = options.flatBeams;
10
- };
11
-
12
- TripletElem.prototype.isClosed = function() {
13
- return !!this.anchor2;
14
- };
15
-
16
- TripletElem.prototype.middleNote = function(elem) {
17
- this.middleElems.push(elem);
18
- };
19
-
20
- TripletElem.prototype.setCloseAnchor = function(anchor2) {
21
- this.anchor2 = anchor2;
22
- // TODO-PER: This used to be just for beamed triplets but it looks like bracketed triplets need extra room, too. The only one that doesn't is stem down and beamed
23
- //if (this.anchor1.parent.beam)
24
- if (!this.anchor1.parent.beam || this.anchor1.stemDir === 'up')
25
- this.endingHeightAbove = 4;
26
- };
27
-
28
- module.exports = TripletElem;
@@ -1,103 +0,0 @@
1
- var RelativeElement = require('./abc_relative_element');
2
- var spacing = require('./abc_spacing');
3
- const formatJazzChord = require("./format-jazz-chord");
4
-
5
- var addChord = function (getTextSize, abselem, elem, roomTaken, roomTakenRight, noteheadWidth, jazzchords) {
6
- for (var i = 0; i < elem.chord.length; i++) {
7
- var pos = elem.chord[i].position;
8
- var rel_position = elem.chord[i].rel_position;
9
- var chords = elem.chord[i].name.split("\n");
10
- for (var j = chords.length-1; j >= 0; j--) { // parse these in opposite order because we place them from bottom to top.
11
- var chord = chords[j];
12
- var x = 0;
13
- var y;
14
- var font;
15
- var klass;
16
- if (pos === "left" || pos === "right" || pos === "below" || pos === "above" || !!rel_position) {
17
- font = 'annotationfont';
18
- klass = "annotation";
19
- } else {
20
- font = 'gchordfont';
21
- klass = "chord";
22
- if (jazzchords)
23
- chord = formatJazzChord(chord);
24
- }
25
- var attr = getTextSize.attr(font, klass);
26
- var dim = getTextSize.calc(chord, font, klass);
27
- var chordWidth = dim.width;
28
- var chordHeight = dim.height / spacing.STEP;
29
- switch (pos) {
30
- case "left":
31
- roomTaken += chordWidth + 7;
32
- x = -roomTaken; // TODO-PER: This is just a guess from trial and error
33
- y = elem.averagepitch;
34
- abselem.addExtra(new RelativeElement(chord, x, chordWidth + 4, y, {
35
- type: "text",
36
- height: chordHeight,
37
- dim: attr,
38
- position: "left"
39
- }));
40
- break;
41
- case "right":
42
- roomTakenRight += 4;
43
- x = roomTakenRight;// TODO-PER: This is just a guess from trial and error
44
- y = elem.averagepitch;
45
- abselem.addRight(new RelativeElement(chord, x, chordWidth + 4, y, {
46
- type: "text",
47
- height: chordHeight,
48
- dim: attr,
49
- position: "right"
50
- }));
51
- break;
52
- case "below":
53
- // setting the y-coordinate to undefined for now: it will be overwritten later on, after we figure out what the highest element on the line is.
54
- abselem.addRight(new RelativeElement(chord, 0, 0, undefined, {
55
- type: "text",
56
- position: "below",
57
- height: chordHeight,
58
- dim: attr,
59
- realWidth: chordWidth
60
- }));
61
- break;
62
- case "above":
63
- // setting the y-coordinate to undefined for now: it will be overwritten later on, after we figure out what the highest element on the line is.
64
- abselem.addRight(new RelativeElement(chord, 0, 0, undefined, {
65
- type: "text",
66
- position: "above",
67
- height: chordHeight,
68
- dim: attr,
69
- realWidth: chordWidth
70
- }));
71
- break;
72
- default:
73
- if (rel_position) {
74
- var relPositionY = rel_position.y + 3 * spacing.STEP; // TODO-PER: this is a fudge factor to make it line up with abcm2ps
75
- abselem.addRight(new RelativeElement(chord, x + rel_position.x, 0, elem.minpitch + relPositionY / spacing.STEP, {
76
- position: "relative",
77
- type: "text",
78
- height: chordHeight,
79
- dim: attr
80
- }));
81
- } else {
82
- // setting the y-coordinate to undefined for now: it will be overwritten later on, after we figure out what the highest element on the line is.
83
- var pos2 = 'above';
84
- if (elem.positioning && elem.positioning.chordPosition)
85
- pos2 = elem.positioning.chordPosition;
86
-
87
- if (pos2 !== 'hidden') {
88
- abselem.addCentered(new RelativeElement(chord, noteheadWidth/2, chordWidth, undefined, {
89
- type: "chord",
90
- position: pos2,
91
- height: chordHeight,
92
- dim: attr,
93
- realWidth: chordWidth
94
- }));
95
- }
96
- }
97
- }
98
- }
99
- }
100
- return {roomTaken: roomTaken, roomTakenRight: roomTakenRight};
101
- };
102
-
103
- module.exports = addChord;
@@ -1,15 +0,0 @@
1
- function formatJazzChord(chordString) {
2
- // This puts markers in the pieces of the chord that are read by the svg creator.
3
- // After the main part of the chord (the letter, a sharp or flat, and "m") a marker is added. Before a slash a marker is added.
4
- var lines = chordString.split("\n");
5
- for (var i = 0; i < lines.length; i++) {
6
- var chord = lines[i];
7
- // If the chord isn't in a recognizable format then just skip the formatting.
8
- var reg = chord.match(/^([ABCDEFG][♯♭]?)?([^\/]+)?(\/[ABCDEFG][#b♯♭]?)?/);
9
- if (reg)
10
- lines[i] = (reg[1]?reg[1]:'') + "\x03" + (reg[2]?reg[2]:'') + "\x03" + (reg[3]?reg[3]:'');
11
- }
12
- return lines.join("\n");
13
- }
14
-
15
- module.exports = formatJazzChord;
@@ -1,41 +0,0 @@
1
- function FreeText(info, vskip, getFontAndAttr, paddingLeft, width, getTextSize) {
2
- var text = info.text;
3
- this.rows = [];
4
- var size;
5
- if (vskip)
6
- this.rows.push({move: vskip});
7
- var hash = getFontAndAttr.calc('textfont', 'defined-text');
8
- if (text === "") { // we do want to print out blank lines if they have been specified.
9
- this.rows.push({move: hash.attr['font-size'] * 2}); // move the distance of the line, plus the distance of the margin, which is also one line.
10
- } else if (typeof text === 'string') {
11
- this.rows.push({move: hash.attr['font-size']/2}); // TODO-PER: move down some - the y location should be the top of the text, but we output text specifying the center line.
12
- this.rows.push({left: paddingLeft, text: text, font: 'textfont', klass: 'defined-text', anchor: "start", startChar: info.startChar, endChar: info.endChar, absElemType: "freeText", name: "free-text"});
13
- size = getTextSize.calc(text, 'textfont', 'defined-text');
14
- this.rows.push({move: size.height});
15
- } else if (text) {
16
- var maxHeight = 0;
17
- var leftSide = paddingLeft;
18
- var currentFont = 'textfont';
19
- for (var i = 0; i < text.length; i++) {
20
- if (text[i].font) {
21
- currentFont = text[i].font;
22
- } else
23
- currentFont = 'textfont';
24
- this.rows.push({left: leftSide, text: text[i].text, font: currentFont, klass: 'defined-text', anchor: 'start', startChar: info.startChar, endChar: info.endChar, absElemType: "freeText", name: "free-text"});
25
- size = getTextSize.calc(text[i].text, getFontAndAttr.calc(currentFont, 'defined-text').font, 'defined-text');
26
- leftSide += size.width + size.height/2; // add a little padding to the right side. The height of the font is probably a close enough approximation.
27
- maxHeight = Math.max(maxHeight, size.height)
28
- }
29
- this.rows.push({move: maxHeight});
30
- } else {
31
- // The structure is wrong here: it requires an array to do centering, but it shouldn't have.
32
- if (info.length === 1) {
33
- var x = width / 2;
34
- this.rows.push({left: x, text: info[0].text, font: 'textfont', klass: 'defined-text', anchor: 'middle', startChar: info.startChar, endChar: info.endChar, absElemType: "freeText", name: "free-text"});
35
- size = getTextSize.calc(info[0].text, 'textfont', 'defined-text');
36
- this.rows.push({move: size.height});
37
- }
38
- }
39
- }
40
-
41
- module.exports = FreeText;