abcjs 6.4.4 → 6.5.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/RELEASE.md +50 -0
- package/dist/abcjs-basic-min.js +2 -2
- package/dist/abcjs-basic.js +337 -125
- package/dist/abcjs-basic.js.map +1 -1
- package/dist/abcjs-plugin-min.js +2 -2
- package/package.json +1 -1
- package/src/parse/abc_parse_directive.js +36 -4
- package/src/parse/abc_parse_header.js +3 -3
- package/src/parse/abc_parse_key_voice.js +41 -6
- package/src/parse/abc_parse_music.js +2 -0
- package/src/parse/abc_parse_settings.js +1 -0
- package/src/parse/abc_tokenizer.js +11 -3
- package/src/parse/abc_transpose.js +1 -1
- package/src/parse/transpose-chord.js +9 -1
- package/src/parse/tune-builder.js +3 -1
- package/src/str/output.js +4 -4
- package/src/synth/abc_midi_flattener.js +52 -11
- package/src/synth/abc_midi_sequencer.js +27 -6
- package/src/synth/chord-track.js +1 -1
- package/src/synth/create-synth.js +74 -65
- package/src/synth/place-note.js +1 -1
- package/src/test/abc_parser_lint.js +1 -1
- package/src/write/creation/abstract-engraver.js +9 -6
- package/src/write/creation/decoration.js +2 -0
- package/src/write/creation/elements/free-text.js +6 -1
- package/src/write/draw/draw.js +8 -0
- package/src/write/draw/ending.js +12 -3
- package/src/write/draw/text.js +8 -1
- package/src/write/interactive/selection.js +7 -1
- package/src/write/svg.js +23 -2
- package/types/index.d.ts +1 -1
- package/version.js +1 -1
package/src/synth/place-note.js
CHANGED
|
@@ -101,7 +101,7 @@ function placeNote(outputAudioBuffer, sampleRate, sound, startArray, volumeMulti
|
|
|
101
101
|
.catch(function (error) {
|
|
102
102
|
if (debugCallback)
|
|
103
103
|
debugCallback('placeNote catch: '+error.message)
|
|
104
|
-
return Promise.
|
|
104
|
+
return Promise.reject(error)
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -53,7 +53,7 @@ var JSONSchema = require('./jsonschema-b4');
|
|
|
53
53
|
var ParserLint = function() {
|
|
54
54
|
"use strict";
|
|
55
55
|
var decorationList = { type: 'array', optional: true, items: { type: 'string', Enum: [
|
|
56
|
-
"trill", "lowermordent", "uppermordent", "mordent", "pralltriller", "accent",
|
|
56
|
+
"trill", "trillh", "lowermordent", "uppermordent", "mordent", "pralltriller", "accent",
|
|
57
57
|
"fermata", "invertedfermata", "tenuto", "0", "1", "2", "3", "4", "5", "+", "wedge",
|
|
58
58
|
"open", "thumb", "snap", "turn", "roll", "irishroll", "breath", "shortphrase", "mediumphrase", "longphrase",
|
|
59
59
|
"segno", "coda", "D.S.", "D.C.", "fine", "crescendo(", "crescendo)", "diminuendo(", "diminuendo)", "glissando(", "glissando)",
|
|
@@ -1026,13 +1026,16 @@ AbstractEngraver.prototype.createBarLine = function (voice, elem, isFirstStaff)
|
|
|
1026
1026
|
abselem.addRight(new RelativeElement("dots.dot", dx, 1, 5));
|
|
1027
1027
|
} // 2 is hardcoded
|
|
1028
1028
|
|
|
1029
|
-
if (elem.startEnding && isFirstStaff) {
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1029
|
+
if (elem.startEnding && isFirstStaff) {
|
|
1030
|
+
// MAE 17 May 2025 - Fixes drawing issue
|
|
1031
|
+
if (voice.voicenumber === 0){
|
|
1032
|
+
// only put the first & second ending marks on the first staff
|
|
1033
|
+
var textWidth = this.getTextSize.calc(elem.startEnding, "repeatfont", '').width;
|
|
1034
|
+
abselem.minspacing += textWidth + 10; // Give plenty of room for the ending number.
|
|
1035
|
+
this.partstartelem = new EndingElem(elem.startEnding, anchor, null);
|
|
1036
|
+
voice.addOther(this.partstartelem);
|
|
1037
|
+
}
|
|
1034
1038
|
}
|
|
1035
|
-
|
|
1036
1039
|
// Add a little space to the left of the bar line so that nothing can crowd it.
|
|
1037
1040
|
abselem.extraw -= 5;
|
|
1038
1041
|
|
|
@@ -175,6 +175,7 @@ var stackedDecoration = function (decoration, width, abselem, yPos, positioning,
|
|
|
175
175
|
"mediumphrase": "scripts.mediumphrase",
|
|
176
176
|
"longphrase": "scripts.longphrase",
|
|
177
177
|
"trill": "scripts.trill",
|
|
178
|
+
"trillh": "scripts.trill",
|
|
178
179
|
"roll": "scripts.roll",
|
|
179
180
|
"irishroll": "scripts.roll",
|
|
180
181
|
"marcato": "scripts.umarcato",
|
|
@@ -237,6 +238,7 @@ var stackedDecoration = function (decoration, width, abselem, yPos, positioning,
|
|
|
237
238
|
case "mediumphrase":
|
|
238
239
|
case "longphrase":
|
|
239
240
|
case "trill":
|
|
241
|
+
case "trillh":
|
|
240
242
|
case "roll":
|
|
241
243
|
case "irishroll":
|
|
242
244
|
case "marcato":
|
|
@@ -10,7 +10,12 @@ function FreeText(info, vskip, getFontAndAttr, paddingLeft, width, getTextSize)
|
|
|
10
10
|
} else if (typeof text === 'string') {
|
|
11
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
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
|
-
|
|
13
|
+
// MAE 9 May 2025 - Force blank text lines in a text block to have height
|
|
14
|
+
function replaceStandaloneNewlinesForTextBlocks(input) {
|
|
15
|
+
return input.replace(/^[ \t]*\n/gm, 'X\n');;
|
|
16
|
+
}
|
|
17
|
+
var textForSize = replaceStandaloneNewlinesForTextBlocks(text);
|
|
18
|
+
size = getTextSize.calc(textForSize, 'textfont', 'defined-text'); // was text
|
|
14
19
|
this.rows.push({ move: size.height });
|
|
15
20
|
} else if (text) {
|
|
16
21
|
var maxHeight = 0;
|
package/src/write/draw/draw.js
CHANGED
|
@@ -15,10 +15,18 @@ function draw(renderer, classes, abcTune, width, maxWidth, responsive, scale, se
|
|
|
15
15
|
renderer.paper.closeGroup()
|
|
16
16
|
renderer.moveY(renderer.spacing.music);
|
|
17
17
|
var staffgroups = [];
|
|
18
|
+
var nStaves = 0;
|
|
18
19
|
for (var line = 0; line < abcTune.lines.length; line++) {
|
|
19
20
|
classes.incrLine();
|
|
20
21
|
var abcLine = abcTune.lines[line];
|
|
21
22
|
if (abcLine.staff) {
|
|
23
|
+
// MAE 26 May 2025 - for incipits staff count limiting
|
|
24
|
+
nStaves++;
|
|
25
|
+
if (abcTune.formatting.maxStaves){
|
|
26
|
+
if (nStaves > abcTune.formatting.maxStaves){
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
22
30
|
if (classes.shouldAddClasses)
|
|
23
31
|
groupClasses.klass = "abcjs-staff-wrapper abcjs-l" + classes.lineNumber
|
|
24
32
|
renderer.paper.openGroup(groupClasses)
|
package/src/write/draw/ending.js
CHANGED
|
@@ -24,9 +24,18 @@ function drawEnding(renderer, params, linestartx, lineendx, selectables) {
|
|
|
24
24
|
|
|
25
25
|
pathString += sprintf("M %f %f L %f %f ",
|
|
26
26
|
linestartx, y, lineendx, y);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
renderer.paper.openGroup({
|
|
28
|
+
klass: renderer.controller.classes.generate("ending"),
|
|
29
|
+
// MAE 17 May 2025 - Ending numbers not being drawn in correct color
|
|
30
|
+
fill: renderer.foregroundColor,
|
|
31
|
+
"data-name": "ending"
|
|
32
|
+
});
|
|
33
|
+
printPath(renderer, {
|
|
34
|
+
path: pathString,
|
|
35
|
+
stroke: renderer.foregroundColor,
|
|
36
|
+
fill: renderer.foregroundColor,
|
|
37
|
+
"data-name": "line"
|
|
38
|
+
});
|
|
30
39
|
if (params.anchor1)
|
|
31
40
|
renderText(renderer, {
|
|
32
41
|
x: roundNumber(linestartx + 5),
|
package/src/write/draw/text.js
CHANGED
|
@@ -37,7 +37,14 @@ function renderText(renderer, params, alreadyInGroup) {
|
|
|
37
37
|
hash.attr.cursor = params.cursor;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
// MAE 9 May 2025 for free text blocks
|
|
41
|
+
var text;
|
|
42
|
+
if (params.name == "free-text"){
|
|
43
|
+
text = params.text.replace(/^[ \t]*\n/gm, ' \n');
|
|
44
|
+
}
|
|
45
|
+
else{
|
|
46
|
+
text = params.text.replace(/\n\n/g, "\n \n");
|
|
47
|
+
}
|
|
41
48
|
text = text.replace(/^\n/, "\xA0\n");
|
|
42
49
|
|
|
43
50
|
if (hash.font.box) {
|
|
@@ -130,8 +130,14 @@ function keyboardSelection(ev) {
|
|
|
130
130
|
function findElementInHistory(selectables, el) {
|
|
131
131
|
if (!el)
|
|
132
132
|
return -1;
|
|
133
|
+
// This should always exist, but it occasionally causes an exception, so check first.
|
|
134
|
+
var dataset = el.dataset
|
|
135
|
+
if (!dataset)
|
|
136
|
+
return -1
|
|
137
|
+
var index = dataset.index
|
|
133
138
|
for (var i = 0; i < selectables.length; i++) {
|
|
134
|
-
|
|
139
|
+
var svgDataset = selectables[i].svgEl.dataset
|
|
140
|
+
if (svgDataset && index === svgDataset.index)
|
|
135
141
|
return i;
|
|
136
142
|
}
|
|
137
143
|
return -1;
|
package/src/write/svg.js
CHANGED
|
@@ -176,8 +176,14 @@ Svg.prototype.text = function (text, attr, target) {
|
|
|
176
176
|
el.setAttribute(key, attr[key]);
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
+
var isFreeText = (attr["data-name"] == "free-text");
|
|
179
180
|
var lines = ("" + text).split("\n");
|
|
180
181
|
for (var i = 0; i < lines.length; i++) {
|
|
182
|
+
if (isFreeText && (lines[i] == "")){
|
|
183
|
+
// Don't draw empty lines
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
|
|
181
187
|
var line = document.createElementNS(svgNS, 'tspan');
|
|
182
188
|
line.setAttribute("x", attr.x ? attr.x : 0);
|
|
183
189
|
if (i !== 0)
|
|
@@ -200,8 +206,23 @@ Svg.prototype.text = function (text, attr, target) {
|
|
|
200
206
|
ts3.textContent = parts[2];
|
|
201
207
|
line.appendChild(ts3);
|
|
202
208
|
}
|
|
203
|
-
}
|
|
204
|
-
|
|
209
|
+
}
|
|
210
|
+
else
|
|
211
|
+
{
|
|
212
|
+
// MAE 9 May 2025 - For improved block text
|
|
213
|
+
if (isFreeText){
|
|
214
|
+
// Fixes issue where blank lines in text blocks didn't take up any vertical
|
|
215
|
+
if (lines[i].trim() == ""){
|
|
216
|
+
line.innerHTML = " ";
|
|
217
|
+
}
|
|
218
|
+
else{
|
|
219
|
+
line.textContent = lines[i];
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
else{
|
|
223
|
+
line.textContent = lines[i];
|
|
224
|
+
}
|
|
225
|
+
}
|
|
205
226
|
el.appendChild(line);
|
|
206
227
|
}
|
|
207
228
|
if (target)
|
package/types/index.d.ts
CHANGED
|
@@ -61,7 +61,7 @@ declare module 'abcjs' {
|
|
|
61
61
|
|
|
62
62
|
export type NoteHeadType = 'normal' | 'harmonic' | 'rhythm' | 'x' | 'triangle';
|
|
63
63
|
|
|
64
|
-
export type Decorations = "trill" | "lowermordent" | "uppermordent" | "mordent" | "pralltriller" | "accent" |
|
|
64
|
+
export type Decorations = "trill" | "trillh" | "lowermordent" | "uppermordent" | "mordent" | "pralltriller" | "accent" |
|
|
65
65
|
"fermata" | "invertedfermata" | "tenuto" | "0" | "1" | "2" | "3" | "4" | "5" | "+" | "wedge" |
|
|
66
66
|
"open" | "thumb" | "snap" | "turn" | "roll" | "irishroll" | "breath" | "shortphrase" | "mediumphrase" | "longphrase" |
|
|
67
67
|
"segno" | "coda" | "D.S." | "D.C." | "fine" | "crescendo(" | "crescendo)" | "diminuendo(" | "diminuendo)" |"glissando(" | "glissando)" |
|
package/version.js
CHANGED