abcjs 6.2.1 → 6.2.3
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 +3 -0
- package/RELEASE.md +54 -0
- package/abc2xml_239/abc2xml.html +769 -0
- package/abc2xml_239/abc2xml.py +2248 -0
- package/abc2xml_239/abc2xml_changelog.html +124 -0
- package/abc2xml_239/lazy-river.abc +26 -0
- package/abc2xml_239/lazy-river.xml +3698 -0
- package/abc2xml_239/mean-to-me.abc +22 -0
- package/abc2xml_239/mean-to-me.xml +2954 -0
- package/abc2xml_239/pyparsing.py +3672 -0
- package/abc2xml_239/pyparsing.pyc +0 -0
- package/dist/abcjs-basic-min.js +2 -2
- package/dist/abcjs-basic.js +205 -91
- package/dist/abcjs-basic.js.map +1 -1
- package/dist/abcjs-plugin-min.js +2 -2
- package/package.json +1 -1
- package/src/api/abc_tablatures.js +5 -0
- package/src/api/abc_tunebook_svg.js +5 -3
- package/src/parse/abc_parse_music.js +18 -53
- package/src/parse/abc_parse_settings.js +165 -0
- package/src/synth/create-synth.js +4 -0
- package/src/synth/place-note.js +6 -0
- package/src/synth/play-event.js +7 -5
- package/src/tablatures/tab-absolute-elements.js +3 -2
- package/src/tablatures/tab-renderer.js +3 -1
- package/src/test/abc_parser_lint.js +12 -12
- package/src/write/creation/abstract-engraver.js +6 -0
- package/src/write/creation/decoration.js +2 -0
- package/src/write/creation/glyphs.js +1 -1
- package/src/write/draw/glissando.js +1 -0
- package/src/write/draw/print-line.js +16 -7
- package/src/write/draw/print-stem.js +16 -8
- package/src/write/draw/set-paper-size.js +1 -1
- package/src/write/draw/tie.js +9 -1
- package/src/write/engraver-controller.js +12 -4
- package/src/write/interactive/selection.js +6 -0
- package/src/write/layout/layout.js +33 -3
- package/src/write/svg.js +10 -0
- package/types/index.d.ts +29 -21
- package/version.js +1 -1
|
@@ -127,6 +127,8 @@ function keyboardSelection(ev) {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
function findElementInHistory(selectables, el) {
|
|
130
|
+
if (!el)
|
|
131
|
+
return -1;
|
|
130
132
|
for (var i = 0; i < selectables.length; i++) {
|
|
131
133
|
if (el.dataset.index === selectables[i].svgEl.dataset.index)
|
|
132
134
|
return i;
|
|
@@ -195,9 +197,13 @@ function getBestMatchCoordinates(dim, ev, scale) {
|
|
|
195
197
|
|
|
196
198
|
function getTarget(target) {
|
|
197
199
|
// This searches up the dom for the first item containing the attribute "selectable", or stopping at the SVG.
|
|
200
|
+
if (!target)
|
|
201
|
+
return null;
|
|
198
202
|
if (target.tagName === "svg")
|
|
199
203
|
return target;
|
|
200
204
|
|
|
205
|
+
if (!target.getAttribute)
|
|
206
|
+
return null;
|
|
201
207
|
var found = target.getAttribute("selectable");
|
|
202
208
|
while (!found) {
|
|
203
209
|
if (!target.parentElement)
|
|
@@ -3,7 +3,7 @@ var setUpperAndLowerElements = require('./set-upper-and-lower-elements');
|
|
|
3
3
|
var layoutStaffGroup = require('./staff-group');
|
|
4
4
|
var getLeftEdgeOfStaff = require('./get-left-edge-of-staff');
|
|
5
5
|
|
|
6
|
-
var layout = function (renderer, abctune, width, space) {
|
|
6
|
+
var layout = function (renderer, abctune, width, space, expandToWidest) {
|
|
7
7
|
var i;
|
|
8
8
|
var abcLine;
|
|
9
9
|
// Adjust the x-coordinates to their absolute positions
|
|
@@ -11,8 +11,14 @@ var layout = function (renderer, abctune, width, space) {
|
|
|
11
11
|
for (i = 0; i < abctune.lines.length; i++) {
|
|
12
12
|
abcLine = abctune.lines[i];
|
|
13
13
|
if (abcLine.staff) {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
// console.log("=== line", i)
|
|
15
|
+
var thisWidth = setXSpacing(renderer, maxWidth, space, abcLine.staffGroup, abctune.formatting, i === abctune.lines.length - 1, false);
|
|
16
|
+
// console.log(thisWidth, maxWidth)
|
|
17
|
+
if (Math.round(thisWidth) > Math.round(maxWidth)) { // to take care of floating point weirdness
|
|
18
|
+
maxWidth = thisWidth
|
|
19
|
+
if (expandToWidest)
|
|
20
|
+
i = -1 // do the calculations over with the new width
|
|
21
|
+
}
|
|
16
22
|
}
|
|
17
23
|
}
|
|
18
24
|
|
|
@@ -41,15 +47,39 @@ var setXSpacing = function (renderer, width, space, staffGroup, formatting, isLa
|
|
|
41
47
|
var leftEdge = getLeftEdgeOfStaff(renderer, staffGroup.getTextSize, staffGroup.voices, staffGroup.brace, staffGroup.bracket);
|
|
42
48
|
var newspace = space;
|
|
43
49
|
for (var it = 0; it < 8; it++) { // TODO-PER: shouldn't need multiple passes, but each pass gets it closer to the right spacing. (Only affects long lines: normal lines break out of this loop quickly.)
|
|
50
|
+
// console.log("iteration", it)
|
|
51
|
+
// dumpGroup("before", staffGroup)
|
|
44
52
|
var ret = layoutStaffGroup(newspace, renderer, debug, staffGroup, leftEdge);
|
|
53
|
+
// dumpGroup("after",staffGroup)
|
|
45
54
|
newspace = calcHorizontalSpacing(isLastLine, formatting.stretchlast, width + renderer.padding.left, staffGroup.w, newspace, ret.spacingUnits, ret.minSpace, renderer.padding.left + renderer.padding.right);
|
|
46
55
|
if (debug)
|
|
47
56
|
console.log("setXSpace", it, staffGroup.w, newspace, staffGroup.minspace);
|
|
48
57
|
if (newspace === null) break;
|
|
49
58
|
}
|
|
50
59
|
centerWholeRests(staffGroup.voices);
|
|
60
|
+
return staffGroup.w - leftEdge
|
|
51
61
|
};
|
|
52
62
|
|
|
63
|
+
// function dumpGroup(label, staffGroup) {
|
|
64
|
+
// var output = {
|
|
65
|
+
// line: staffGroup.line,
|
|
66
|
+
// w: staffGroup.w,
|
|
67
|
+
// voice: {
|
|
68
|
+
// i: staffGroup.voices[0].i,
|
|
69
|
+
// minx: staffGroup.voices[0].minx,
|
|
70
|
+
// nextx: staffGroup.voices[0].nextx,
|
|
71
|
+
// spacingduration: staffGroup.voices[0].spacingduration,
|
|
72
|
+
// w: staffGroup.voices[0].w,
|
|
73
|
+
// children: [],
|
|
74
|
+
// }
|
|
75
|
+
// }
|
|
76
|
+
// for (var i = 0; i < staffGroup.voices[0].children.length; i++) {
|
|
77
|
+
// var child = staffGroup.voices[0].children[i]
|
|
78
|
+
// output.voice.children.push({ fixedW: child.fixed.w, w: child.w, x: child.x, type: child.type })
|
|
79
|
+
// }
|
|
80
|
+
// console.log(label,output)
|
|
81
|
+
// }
|
|
82
|
+
|
|
53
83
|
function calcHorizontalSpacing(isLastLine, stretchLast, targetWidth, lineWidth, spacing, spacingUnits, minSpace, padding) {
|
|
54
84
|
if (isLastLine) {
|
|
55
85
|
if (stretchLast === undefined) {
|
package/src/write/svg.js
CHANGED
|
@@ -345,6 +345,16 @@ Svg.prototype.pathToBack = function (attr) {
|
|
|
345
345
|
return el;
|
|
346
346
|
};
|
|
347
347
|
|
|
348
|
+
Svg.prototype.lineToBack = function (attr) {
|
|
349
|
+
var el = document.createElementNS(svgNS, 'line');
|
|
350
|
+
var keys = Object.keys(attr)
|
|
351
|
+
for (var i = 0; i < keys.length; i++)
|
|
352
|
+
el.setAttribute(keys[i], attr[keys[i]]);
|
|
353
|
+
this.prepend(el);
|
|
354
|
+
return el;
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
|
|
348
358
|
Svg.prototype.append = function (el) {
|
|
349
359
|
if (this.currentGroup.length > 0)
|
|
350
360
|
this.currentGroup[0].appendChild(el);
|
package/types/index.d.ts
CHANGED
|
@@ -71,6 +71,8 @@ declare module 'abcjs' {
|
|
|
71
71
|
"mark" | "marcato" | "umarcato" |
|
|
72
72
|
"D.C.alcoda" | "D.C.alfine" | "D.S.alcoda" | "D.S.alfine" | "editorial" | "courtesy"
|
|
73
73
|
|
|
74
|
+
export type TablatureInstrument = 'guitar' | 'mandolin' | 'fiddle' | 'violin' | '';
|
|
75
|
+
|
|
74
76
|
//
|
|
75
77
|
// Basic types
|
|
76
78
|
//
|
|
@@ -251,6 +253,14 @@ declare module 'abcjs' {
|
|
|
251
253
|
minSpacingLimit?: number;
|
|
252
254
|
}
|
|
253
255
|
|
|
256
|
+
export interface Tablature {
|
|
257
|
+
instrument?: TablatureInstrument,
|
|
258
|
+
capo?: number
|
|
259
|
+
label?: string,
|
|
260
|
+
tuning?: Array<string>,
|
|
261
|
+
highestNote?: string,
|
|
262
|
+
}
|
|
263
|
+
|
|
254
264
|
export interface AbcVisualParams {
|
|
255
265
|
add_classes?: boolean;
|
|
256
266
|
afterParsing?: AfterParsing;
|
|
@@ -258,8 +268,9 @@ declare module 'abcjs' {
|
|
|
258
268
|
clickListener?: ClickListener;
|
|
259
269
|
dragColor?: string;
|
|
260
270
|
dragging?: boolean;
|
|
271
|
+
expandToWidest?: boolean;
|
|
261
272
|
foregroundColor?: string;
|
|
262
|
-
format?: { [attr in FormatAttributes]
|
|
273
|
+
format?: { [attr in FormatAttributes]?: any };
|
|
263
274
|
header_only?: boolean;
|
|
264
275
|
initialClef?: boolean;
|
|
265
276
|
jazzchords?: boolean;
|
|
@@ -282,6 +293,7 @@ declare module 'abcjs' {
|
|
|
282
293
|
staffwidth?: number;
|
|
283
294
|
startingTune?: number;
|
|
284
295
|
stop_on_warning?: boolean;
|
|
296
|
+
tablature?: Array<Tablature>;
|
|
285
297
|
textboxpadding?: number;
|
|
286
298
|
viewportHorizontal?: boolean;
|
|
287
299
|
viewportVertical?: boolean;
|
|
@@ -399,7 +411,7 @@ declare module 'abcjs' {
|
|
|
399
411
|
//
|
|
400
412
|
|
|
401
413
|
// renderAbc
|
|
402
|
-
interface NoteTimingEvent {
|
|
414
|
+
export interface NoteTimingEvent {
|
|
403
415
|
milliseconds: number;
|
|
404
416
|
millisecondsPerMeasure: number;
|
|
405
417
|
type: NoteTimingEventType;
|
|
@@ -421,6 +433,11 @@ declare module 'abcjs' {
|
|
|
421
433
|
measureStart?: boolean;
|
|
422
434
|
}
|
|
423
435
|
|
|
436
|
+
// make an alias for backwards compatibility
|
|
437
|
+
export interface TimingEvent extends NoteTimingEvent {
|
|
438
|
+
|
|
439
|
+
}
|
|
440
|
+
|
|
424
441
|
export interface PercMapElement {
|
|
425
442
|
sound: number;
|
|
426
443
|
noteHead: NoteHeadType;
|
|
@@ -571,6 +588,7 @@ declare module 'abcjs' {
|
|
|
571
588
|
wordsfont: Font;
|
|
572
589
|
}
|
|
573
590
|
|
|
591
|
+
// Caution: The contents of this object may change at any time. If you reference this, be sure you retest for each abcjs release.
|
|
574
592
|
export interface EngraverController {
|
|
575
593
|
classes: any;
|
|
576
594
|
dragColor: string;
|
|
@@ -679,6 +697,7 @@ declare module 'abcjs' {
|
|
|
679
697
|
|
|
680
698
|
export interface VoiceItemBar {
|
|
681
699
|
el_type: "bar";
|
|
700
|
+
type: 'bar_dbl_repeat' | 'bar_right_repeat' | 'bar_left_repeat' |'bar_invisible' | 'bar_thick_thin' | 'bar_thin_thin' | 'bar_thin' | 'bar_thin_thick';
|
|
682
701
|
barNumber?: number;
|
|
683
702
|
chord?: Array<ChordProperties>;
|
|
684
703
|
decoration: Array<Decorations>;
|
|
@@ -829,6 +848,7 @@ declare module 'abcjs' {
|
|
|
829
848
|
setTiming: (bpm?: number, measuresOfDelay? : number) => void;
|
|
830
849
|
setUpAudio: (options: SynthOptions) => AudioTracks;
|
|
831
850
|
makeVoicesArray: () => Array<Selectable[]>
|
|
851
|
+
deline: () => Array<TuneLine>;
|
|
832
852
|
lineBreaks?: Array<number>;
|
|
833
853
|
visualTranspose?: number;
|
|
834
854
|
}
|
|
@@ -913,22 +933,6 @@ declare module 'abcjs' {
|
|
|
913
933
|
endTimings: Array<LineEndInfo>;
|
|
914
934
|
}
|
|
915
935
|
|
|
916
|
-
export interface TimingEvent {
|
|
917
|
-
type: "event";
|
|
918
|
-
milliseconds: number;
|
|
919
|
-
millisecondsPerMeasure: number;
|
|
920
|
-
line: number;
|
|
921
|
-
measureNumber: number;
|
|
922
|
-
top: number;
|
|
923
|
-
height: number;
|
|
924
|
-
left: number;
|
|
925
|
-
width: number;
|
|
926
|
-
elements: Array< HTMLElement>;
|
|
927
|
-
startCharArray: Array<number>;
|
|
928
|
-
endCharArray: Array<number>;
|
|
929
|
-
midiPitches: MidiPitches
|
|
930
|
-
}
|
|
931
|
-
|
|
932
936
|
export interface TimingCallbacksPosition {
|
|
933
937
|
top: number;
|
|
934
938
|
left: number;
|
|
@@ -1068,9 +1072,11 @@ declare module 'abcjs' {
|
|
|
1068
1072
|
// TimingCallbacks
|
|
1069
1073
|
export type BeatCallback = (beatNumber: number, totalBeats: number, totalTime: number, position: TimingCallbacksPosition, debugInfo: TimingCallbacksDebug) => void;
|
|
1070
1074
|
|
|
1071
|
-
|
|
1075
|
+
type EventCallbackReturn = "continue" | Promise<"continue"> | undefined
|
|
1076
|
+
|
|
1077
|
+
export type EventCallback = (event: NoteTimingEvent | null) => EventCallbackReturn;
|
|
1072
1078
|
|
|
1073
|
-
export type LineEndCallback = (info : LineEndInfo, event:
|
|
1079
|
+
export type LineEndCallback = (info : LineEndInfo, event: NoteTimingEvent, details: LineEndDetails) => void;
|
|
1074
1080
|
|
|
1075
1081
|
// Editor
|
|
1076
1082
|
export type OnChange = (editor: Editor) => void;
|
|
@@ -1125,6 +1131,7 @@ declare module 'abcjs' {
|
|
|
1125
1131
|
pause(shouldPause: boolean): void;
|
|
1126
1132
|
millisecondsPerMeasure(): number;
|
|
1127
1133
|
pauseMidi(shouldPause: boolean): void;
|
|
1134
|
+
fireChanged():void;
|
|
1128
1135
|
}
|
|
1129
1136
|
|
|
1130
1137
|
//
|
|
@@ -1149,6 +1156,7 @@ declare module 'abcjs' {
|
|
|
1149
1156
|
seek(position: number, units?: ProgressUnit): void
|
|
1150
1157
|
stop(): number
|
|
1151
1158
|
download(): string // returns audio buffer in wav format as a reference to a blob
|
|
1159
|
+
getIsRunning(): boolean
|
|
1152
1160
|
}
|
|
1153
1161
|
|
|
1154
1162
|
export interface SynthInitResponse {
|
|
@@ -1192,7 +1200,7 @@ declare module 'abcjs' {
|
|
|
1192
1200
|
export function activeAudioContext(): AudioContext
|
|
1193
1201
|
export function CreateSynthControl(element: Selector, options: AbcVisualParams): AudioControl
|
|
1194
1202
|
export function getMidiFile(source: string | TuneObject, options?: MidiFileOptions): MidiFile;
|
|
1195
|
-
export function playEvent(pitches: MidiPitches, graceNotes: MidiGracePitches | undefined, milliSecondsPerMeasure: number): Promise<void>;
|
|
1203
|
+
export function playEvent(pitches: MidiPitches, graceNotes: MidiGracePitches | undefined, milliSecondsPerMeasure: number, soundFontUrl? : string, debugCallback?: (message: string) => void): Promise<void>;
|
|
1196
1204
|
export function sequence(visualObj: TuneObject, options: AbcVisualParams): AudioSequence
|
|
1197
1205
|
}
|
|
1198
1206
|
|
package/version.js
CHANGED