abcjs 6.1.8 → 6.1.9
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 +24 -0
- package/dist/abcjs-basic-min.js +2 -2
- package/dist/abcjs-basic.js +58 -16
- package/dist/abcjs-basic.js.map +1 -1
- package/dist/abcjs-plugin-min.js +2 -2
- package/package.json +6 -6
- package/src/midi/abc_midi_create.js +8 -2
- package/src/parse/abc_parse_music.js +1 -1
- package/src/parse/abc_transpose.js +14 -3
- package/src/synth/abc_midi_sequencer.js +1 -1
- package/src/test/abc_parser_lint.js +1 -1
- package/src/write/abc_decoration.js +20 -4
- package/src/write/abc_relative_element.js +1 -0
- package/src/write/draw/relative.js +1 -1
- package/src/write/selection.js +3 -3
- package/types/index.d.ts +64 -16
- package/version.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "abcjs",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.9",
|
|
4
4
|
"description": "Renderer for abc music notation",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -44,16 +44,16 @@
|
|
|
44
44
|
},
|
|
45
45
|
"homepage": "https://abcjs.net",
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@babel/core": "7.20.
|
|
47
|
+
"@babel/core": "7.20.12",
|
|
48
48
|
"@babel/preset-env": "7.20.2",
|
|
49
49
|
"@tarp/require": "1.4.3",
|
|
50
|
-
"babel-loader": "9.1.
|
|
50
|
+
"babel-loader": "9.1.2",
|
|
51
51
|
"chai": "4.3.7",
|
|
52
|
-
"concurrently": "7.
|
|
52
|
+
"concurrently": "7.6.0",
|
|
53
53
|
"http-server": "14.1.1",
|
|
54
|
-
"mocha": "10.
|
|
54
|
+
"mocha": "10.2.0",
|
|
55
55
|
"opener": "1.5.2",
|
|
56
|
-
"vuepress": "2.0.0-beta.
|
|
56
|
+
"vuepress": "2.0.0-beta.60",
|
|
57
57
|
"vuex": "4.1.0",
|
|
58
58
|
"webpack-bundle-analyzer": "4.7.0",
|
|
59
59
|
"webpack-cli": "4.10.0"
|
|
@@ -36,8 +36,14 @@ var create;
|
|
|
36
36
|
var pan = 0;
|
|
37
37
|
if (options.pan && options.pan.length > i)
|
|
38
38
|
pan = options.pan[i];
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
if (event.instrument === 128) {
|
|
40
|
+
// If we're using the percussion voice, change to Channel 10
|
|
41
|
+
midi.setChannel(9, pan);
|
|
42
|
+
midi.setInstrument(0);
|
|
43
|
+
} else {
|
|
44
|
+
midi.setChannel(event.channel, pan);
|
|
45
|
+
midi.setInstrument(event.instrument);
|
|
46
|
+
}
|
|
41
47
|
break;
|
|
42
48
|
case 'note':
|
|
43
49
|
var gapLengthInBeats = event.gap * beatsPerSecond;
|
|
@@ -724,7 +724,7 @@ var legalAccents = [
|
|
|
724
724
|
"slide", "marcato",
|
|
725
725
|
"upbow", "downbow", "/", "//", "///", "////", "trem1", "trem2", "trem3", "trem4",
|
|
726
726
|
"turnx", "invertedturn", "invertedturnx", "trill(", "trill)", "arpeggio", "xstem", "mark", "umarcato",
|
|
727
|
-
"style=normal", "style=harmonic", "style=rhythm", "style=x", "style=triangle"
|
|
727
|
+
"style=normal", "style=harmonic", "style=rhythm", "style=x", "style=triangle", "D.C.alcoda", "D.C.alfine", "D.S.alcoda", "D.S.alfine", "editorial", "courtesy"
|
|
728
728
|
];
|
|
729
729
|
|
|
730
730
|
var volumeDecorations = [
|
|
@@ -51,7 +51,15 @@ transpose.keySignature = function(multilineVars, keyName, root, acc, localTransp
|
|
|
51
51
|
keyName = keyName.substr(2);
|
|
52
52
|
} else
|
|
53
53
|
keyName = keyName.substr(1);
|
|
54
|
-
var
|
|
54
|
+
var thisKeyIndex = keyIndex[baseKey]
|
|
55
|
+
var recognized = thisKeyIndex !== undefined
|
|
56
|
+
if (!recognized) {
|
|
57
|
+
// Either the key sig is "none" or we don't recognize it. Either way we don't change it, and we assume key of C for the purposes of this calculation.
|
|
58
|
+
thisKeyIndex = 0
|
|
59
|
+
baseKey = "C"
|
|
60
|
+
keyName = ""
|
|
61
|
+
}
|
|
62
|
+
var index = thisKeyIndex + multilineVars.localTranspose;
|
|
55
63
|
while (index < 0) index += 12;
|
|
56
64
|
if (index > 11) index = index % 12;
|
|
57
65
|
var newKeyName = (keyName[0] === 'm' ? newKeyMinor[index] : newKey[index]);
|
|
@@ -87,7 +95,10 @@ transpose.keySignature = function(multilineVars, keyName, root, acc, localTransp
|
|
|
87
95
|
multilineVars.localTransposeVerticalMovement = distance + Math.floor(multilineVars.localTranspose / 12) * 7;
|
|
88
96
|
else
|
|
89
97
|
multilineVars.localTransposeVerticalMovement = distance + Math.ceil(multilineVars.localTranspose / 12) * 7;
|
|
90
|
-
|
|
98
|
+
if (recognized)
|
|
99
|
+
return { accidentals: newKeySig, root: newKeyName[0], acc: newKeyName.length > 1 ? newKeyName[1] : "" };
|
|
100
|
+
else
|
|
101
|
+
return { accidentals: [], root: root, acc: acc };
|
|
91
102
|
};
|
|
92
103
|
|
|
93
104
|
transpose.chordName = function(multilineVars, chord) {
|
|
@@ -145,7 +156,7 @@ var accidentals3 = {
|
|
|
145
156
|
"1": "^",
|
|
146
157
|
"2": "^^"
|
|
147
158
|
};
|
|
148
|
-
var count = 0
|
|
159
|
+
//var count = 0
|
|
149
160
|
transpose.note = function(multilineVars, el) {
|
|
150
161
|
// the "el" that is passed in has el.name, el.accidental, and el.pitch. "pitch" is the vertical position (0=middle C)
|
|
151
162
|
// localTranspose is the number of half steps
|
|
@@ -6,7 +6,7 @@ var parseCommon = require("../parse/abc_common");
|
|
|
6
6
|
(function() {
|
|
7
7
|
"use strict";
|
|
8
8
|
|
|
9
|
-
var measureLength;
|
|
9
|
+
var measureLength = 1; // This should be set by the meter, but just in case that is missing, we'll take a guess.
|
|
10
10
|
// The abc is provided to us line by line. It might have repeats in it. We want to re arrange the elements to
|
|
11
11
|
// be an array of voices with all the repeats embedded, and no lines. Then it is trivial to go through the events
|
|
12
12
|
// one at a time and turn it into midi.
|
|
@@ -61,7 +61,7 @@ var ParserLint = function() {
|
|
|
61
61
|
"p", "pp", "f", "ff", "mf", "mp", "ppp", "pppp", "fff", "ffff", "sfz", "repeatbar", "repeatbar2", "slide",
|
|
62
62
|
"upbow", "downbow", "staccato", "trem1", "trem2", "trem3", "trem4",
|
|
63
63
|
"/", "//", "///", "////", "turnx", "invertedturn", "invertedturnx", "arpeggio", "trill(", "trill)", "xstem",
|
|
64
|
-
"mark", "marcato", "umarcato"
|
|
64
|
+
"mark", "marcato", "umarcato", "D.C.alcoda", "D.C.alfine", "D.S.alcoda", "D.S.alfine", "editorial", "courtesy"
|
|
65
65
|
] } };
|
|
66
66
|
|
|
67
67
|
var tempoProperties = {
|
|
@@ -143,12 +143,12 @@ var Decoration = function Decoration() {
|
|
|
143
143
|
}
|
|
144
144
|
return y;
|
|
145
145
|
}
|
|
146
|
-
function textDecoration(text, placement) {
|
|
146
|
+
function textDecoration(text, placement, anchor) {
|
|
147
147
|
var y = getPlacement(placement);
|
|
148
148
|
var textFudge = 2;
|
|
149
149
|
var textHeight = 5;
|
|
150
150
|
// TODO-PER: Get the height of the current font and use that for the thickness.
|
|
151
|
-
abselem.addFixedX(new RelativeElement(text, width/2, 0, y+textFudge, {type:"decoration", klass: 'ornament', thickness: 3}));
|
|
151
|
+
abselem.addFixedX(new RelativeElement(text, width/2, 0, y+textFudge, {type:"decoration", klass: 'ornament', thickness: 3, anchor: anchor}));
|
|
152
152
|
|
|
153
153
|
incrementPlacement(placement, textHeight);
|
|
154
154
|
}
|
|
@@ -205,11 +205,27 @@ var Decoration = function Decoration() {
|
|
|
205
205
|
case "5":
|
|
206
206
|
case "D.C.":
|
|
207
207
|
case "D.S.":
|
|
208
|
-
textDecoration(decoration[i], positioning);
|
|
208
|
+
textDecoration(decoration[i], positioning, 'middle');
|
|
209
|
+
hasOne = true;
|
|
210
|
+
break;
|
|
211
|
+
case "D.C.alcoda":
|
|
212
|
+
textDecoration("D.C. al coda", positioning, 'left');
|
|
213
|
+
hasOne = true;
|
|
214
|
+
break;
|
|
215
|
+
case "D.C.alfine":
|
|
216
|
+
textDecoration("D.C. al fine", positioning, 'left');
|
|
217
|
+
hasOne = true;
|
|
218
|
+
break;
|
|
219
|
+
case "D.S.alcoda":
|
|
220
|
+
textDecoration("D.S. al coda", positioning, 'left');
|
|
221
|
+
hasOne = true;
|
|
222
|
+
break;
|
|
223
|
+
case "D.S.alfine":
|
|
224
|
+
textDecoration("D.S. al fine", positioning, 'left');
|
|
209
225
|
hasOne = true;
|
|
210
226
|
break;
|
|
211
227
|
case "fine":
|
|
212
|
-
textDecoration("FINE", positioning);
|
|
228
|
+
textDecoration("FINE", positioning, 'middle');
|
|
213
229
|
hasOne = true;
|
|
214
230
|
break;
|
|
215
231
|
case "+":
|
|
@@ -13,6 +13,7 @@ var RelativeElement = function RelativeElement(c, dx, w, pitch, opt) {
|
|
|
13
13
|
this.pitch2 = opt.pitch2;
|
|
14
14
|
this.linewidth = opt.linewidth;
|
|
15
15
|
this.klass = opt.klass;
|
|
16
|
+
this.anchor = opt.anchor ? opt.anchor : 'middle'
|
|
16
17
|
this.top = pitch;
|
|
17
18
|
if (this.pitch2 !== undefined && this.pitch2 > this.top) this.top = this.pitch2;
|
|
18
19
|
this.bottom = pitch;
|
|
@@ -46,7 +46,7 @@ function drawRelativeElement(renderer, params, bartop) {
|
|
|
46
46
|
break;
|
|
47
47
|
case "decoration":
|
|
48
48
|
// The +6 is to compensate for the placement of text in svg: to be on the same row as symbols, the y-coord needs to compensate for the center line.
|
|
49
|
-
params.graphelem = renderText(renderer, { x: params.x, y: y+6, text: params.c, type: 'annotationfont', klass: renderer.controller.classes.generate("annotation"), anchor:
|
|
49
|
+
params.graphelem = renderText(renderer, { x: params.x, y: y+6, text: params.c, type: 'annotationfont', klass: renderer.controller.classes.generate("annotation"), anchor: params.anchor, centerVertically: true, dim: params.dim}, false);
|
|
50
50
|
break;
|
|
51
51
|
case "text":
|
|
52
52
|
params.graphelem = renderText(renderer, { x: params.x, y: y, text: params.c, type: 'annotationfont', klass: renderer.controller.classes.generate("annotation"), anchor: "start", centerVertically: params.centerVertically, dim: params.dim, lane: params.getLane(), name: "annotation"}, false);
|
package/src/write/selection.js
CHANGED
|
@@ -15,9 +15,9 @@ function setupSelection(engraver, svgs) {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
for (var i = 0; i < svgs.length; i++) {
|
|
18
|
-
svgs[i].addEventListener('touchstart', mouseDown.bind(engraver));
|
|
19
|
-
svgs[i].addEventListener('touchmove', mouseMove.bind(engraver));
|
|
20
|
-
svgs[i].addEventListener('touchend', mouseUp.bind(engraver));
|
|
18
|
+
svgs[i].addEventListener('touchstart', mouseDown.bind(engraver), {passive: true});
|
|
19
|
+
svgs[i].addEventListener('touchmove', mouseMove.bind(engraver), {passive: true});
|
|
20
|
+
svgs[i].addEventListener('touchend', mouseUp.bind(engraver), {passive: true});
|
|
21
21
|
svgs[i].addEventListener('mousedown', mouseDown.bind(engraver));
|
|
22
22
|
svgs[i].addEventListener('mousemove', mouseMove.bind(engraver));
|
|
23
23
|
svgs[i].addEventListener('mouseup', mouseUp.bind(engraver));
|
package/types/index.d.ts
CHANGED
|
@@ -68,7 +68,8 @@ declare module 'abcjs' {
|
|
|
68
68
|
"p" | "pp" | "f" | "ff" | "mf" | "mp" | "ppp" | "pppp" | "fff" | "ffff" | "sfz" | "repeatbar" | "repeatbar2" | "slide" |
|
|
69
69
|
"upbow" | "downbow" | "staccato" | "trem1" | "trem2" | "trem3" | "trem4" |
|
|
70
70
|
"/" | "//" | "///" | "////" | "turnx" | "invertedturn" | "invertedturnx" | "arpeggio" | "trill(" | "trill)" | "xstem" |
|
|
71
|
-
"mark" | "marcato" | "umarcato"
|
|
71
|
+
"mark" | "marcato" | "umarcato" |
|
|
72
|
+
"D.C.alcoda" | "D.C.alfine" | "D.S.alcoda" | "D.S.alfine" | "editorial" | "courtesy"
|
|
72
73
|
|
|
73
74
|
//
|
|
74
75
|
// Basic types
|
|
@@ -157,19 +158,54 @@ declare module 'abcjs' {
|
|
|
157
158
|
|
|
158
159
|
export type MidiParam = Array<string|number>;
|
|
159
160
|
|
|
160
|
-
export type MidiGracePitches = Array<{instrument:
|
|
161
|
+
export type MidiGracePitches = Array<{instrument: number; pitch: number; volume: number; cents?: number; durationInMeasures: number}>;
|
|
161
162
|
|
|
162
163
|
export interface MidiPitch {
|
|
163
|
-
instrument:
|
|
164
|
+
instrument: number;
|
|
164
165
|
pitch: number;
|
|
165
166
|
duration: number;
|
|
166
167
|
volume: number;
|
|
167
|
-
cents?: number
|
|
168
|
+
cents?: number;
|
|
169
|
+
start: number;
|
|
170
|
+
gap: number;
|
|
168
171
|
}
|
|
169
172
|
|
|
170
173
|
export type MidiPitches = Array<MidiPitch>;
|
|
171
174
|
|
|
172
|
-
export
|
|
175
|
+
export interface AbsoluteElement {
|
|
176
|
+
abcelem : AbcElem;
|
|
177
|
+
bottom : number;
|
|
178
|
+
children : Array<RelativeElement>
|
|
179
|
+
duration : number;
|
|
180
|
+
durationClass : number;
|
|
181
|
+
elemset : Array<SVGElement>
|
|
182
|
+
extra : Array<RelativeElement>
|
|
183
|
+
extraw : number;
|
|
184
|
+
fixed : {w: number, t: number, b: number}
|
|
185
|
+
heads : Array<RelativeElement>
|
|
186
|
+
invisible : boolean;
|
|
187
|
+
minspacing : number;
|
|
188
|
+
notePositions : Array<{x:number; y:number;}>
|
|
189
|
+
right : Array<RelativeElement>
|
|
190
|
+
specialY : Array<{
|
|
191
|
+
chordHeightAbove : number;
|
|
192
|
+
chordHeightBelow : number;
|
|
193
|
+
dynamicHeightAbove : number;
|
|
194
|
+
dynamicHeightBelow : number;
|
|
195
|
+
endingHeightAbove : number;
|
|
196
|
+
lyricHeightAbove : number;
|
|
197
|
+
lyricHeightBelow : number;
|
|
198
|
+
partHeightAbove : number;
|
|
199
|
+
tempoHeightAbove : number;
|
|
200
|
+
volumeHeightAbove : number;
|
|
201
|
+
volumeHeightBelow : number;
|
|
202
|
+
}>
|
|
203
|
+
top : number;
|
|
204
|
+
tuneNumber : number;
|
|
205
|
+
type : "symbol" | "tempo" | "part" | "rest" | "note" | "bar" | "staff-extra clef" | "staff-extra key-signature" | "staff-extra time-signature";
|
|
206
|
+
w : number;
|
|
207
|
+
x : number;
|
|
208
|
+
}
|
|
173
209
|
|
|
174
210
|
export type AbstractEngraver = any;
|
|
175
211
|
|
|
@@ -340,7 +376,7 @@ declare module 'abcjs' {
|
|
|
340
376
|
millisecondsPerMeasure: number;
|
|
341
377
|
type: NoteTimingEventType;
|
|
342
378
|
|
|
343
|
-
elements?: Array<HTMLElement
|
|
379
|
+
elements?: Array<Array<HTMLElement>>;
|
|
344
380
|
endChar?: number;
|
|
345
381
|
endCharArray?: Array<number>;
|
|
346
382
|
endX?: number;
|
|
@@ -349,6 +385,7 @@ declare module 'abcjs' {
|
|
|
349
385
|
line?: number;
|
|
350
386
|
measureNumber?: number;
|
|
351
387
|
midiPitches?: MidiPitches;
|
|
388
|
+
midiGraceNotePitches?: MidiGracePitches;
|
|
352
389
|
startChar?: number;
|
|
353
390
|
startCharArray?: Array<number>;
|
|
354
391
|
top?: number;
|
|
@@ -781,21 +818,32 @@ declare module 'abcjs' {
|
|
|
781
818
|
}
|
|
782
819
|
|
|
783
820
|
export interface AbcElem {
|
|
784
|
-
el_type: string //TODO enumerate these
|
|
785
|
-
abselem:
|
|
821
|
+
el_type: string; //TODO enumerate these
|
|
822
|
+
abselem: AbsoluteElement;
|
|
786
823
|
beambr?: number;
|
|
787
|
-
chord?: Array<
|
|
788
|
-
decoration: Array<
|
|
824
|
+
chord?: Array<{name: string; position: ChordPlacement}>
|
|
825
|
+
decoration: Array<string> //TODO enumerate these
|
|
789
826
|
duration: number
|
|
790
827
|
endBeam?: boolean
|
|
791
828
|
endSlur?: number
|
|
792
829
|
endTriplet?: true
|
|
793
|
-
gracenotes?: Array<
|
|
794
|
-
lyric?: Array<
|
|
830
|
+
gracenotes?: Array<{duration: number; name:string; pitch: number; verticalPosition: number;}>
|
|
831
|
+
lyric?: Array<{syllable: string; divider: ' ' | '-' | '_';}>
|
|
795
832
|
noStem?: boolean
|
|
796
|
-
|
|
833
|
+
midiPitches?: MidiPitches;
|
|
834
|
+
midiGraceNotePitches?: MidiGracePitches;
|
|
835
|
+
pitches?: Array<{
|
|
836
|
+
pitch: number;
|
|
837
|
+
name: string;
|
|
838
|
+
startSlur?: Array<{label: number}>;
|
|
839
|
+
endSlur?: Array<number>;
|
|
840
|
+
startTie?: {};
|
|
841
|
+
endTie?: boolean;
|
|
842
|
+
verticalPos: number;
|
|
843
|
+
highestVert: number;
|
|
844
|
+
}>
|
|
797
845
|
positioning?: any
|
|
798
|
-
rest?:
|
|
846
|
+
rest?: {"type": "rest"}
|
|
799
847
|
startBeam?: boolean
|
|
800
848
|
startTriplet?: number
|
|
801
849
|
tripletMultiplier?: number
|
|
@@ -1086,8 +1134,8 @@ declare module 'abcjs' {
|
|
|
1086
1134
|
|
|
1087
1135
|
export interface SynthObjectController {
|
|
1088
1136
|
disable(isDisabled: boolean): void
|
|
1089
|
-
setTune(visualObj: TuneObject, userAction: boolean, audioParams?:
|
|
1090
|
-
load(selector: string, cursorControl?:
|
|
1137
|
+
setTune(visualObj: TuneObject, userAction: boolean, audioParams?: SynthOptions): Promise<SynthInitResponse>
|
|
1138
|
+
load(selector: string, cursorControl?: CursorControl | null, visualOptions?: SynthVisualOptions): void
|
|
1091
1139
|
play(): void
|
|
1092
1140
|
pause(): void
|
|
1093
1141
|
toggleLoop(): void
|
package/version.js
CHANGED