abcjs 6.5.2 → 6.6.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.
- package/README.md +6 -0
- package/RELEASE.md +26 -0
- package/dist/abcjs-basic-min.js +2 -2
- package/dist/abcjs-basic.js +1177 -170
- 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_timing_callbacks.js +88 -13
- package/src/const/relative-major.js +24 -19
- package/src/data/abc_tune.js +12 -1
- package/src/data/deline-tune.js +1 -1
- package/src/midi/abc_midi_create.js +2 -2
- package/src/parse/abc_parse.js +20 -0
- package/src/parse/chord-grid.js +364 -0
- package/src/parse/tune-builder.js +1 -1
- package/src/str/output.js +98 -62
- package/src/synth/abc_midi_sequencer.js +20 -30
- package/src/synth/create-synth.js +1 -1
- package/src/synth/repeats.js +200 -0
- package/src/write/creation/abstract-engraver.js +4 -1
- package/src/write/draw/chord-grid.js +252 -0
- package/src/write/draw/draw.js +48 -35
- package/src/write/draw/text.js +1 -1
- package/src/write/engraver-controller.js +4 -2
- package/src/write/layout/beam.js +16 -1
- package/src/write/renderer.js +4 -0
- package/src/write/svg.js +8 -1
- package/types/index.d.ts +25 -0
- package/version.js +1 -1
package/src/write/draw/text.js
CHANGED
|
@@ -74,6 +74,8 @@ var EngraverController = function (paper, params) {
|
|
|
74
74
|
this.germanAlphabet = params.germanAlphabet;
|
|
75
75
|
if (params.lineThickness)
|
|
76
76
|
this.lineThickness = params.lineThickness;
|
|
77
|
+
if (params.chordGrid)
|
|
78
|
+
this.chordGrid = params.chordGrid;
|
|
77
79
|
this.renderer.controller = this; // TODO-GD needed for highlighting
|
|
78
80
|
this.renderer.foregroundColor = params.foregroundColor ? params.foregroundColor : "currentColor";
|
|
79
81
|
if (params.ariaLabel !== undefined)
|
|
@@ -251,7 +253,7 @@ EngraverController.prototype.engraveTune = function (abcTune, tuneNumber, lineOf
|
|
|
251
253
|
|
|
252
254
|
var origJazzChords = this.jazzchords
|
|
253
255
|
var scale = this.setupTune(abcTune, tuneNumber);
|
|
254
|
-
|
|
256
|
+
|
|
255
257
|
// Create all of the element objects that will appear on the page.
|
|
256
258
|
this.constructTuneElements(abcTune);
|
|
257
259
|
|
|
@@ -300,7 +302,7 @@ EngraverController.prototype.engraveTune = function (abcTune, tuneNumber, lineOf
|
|
|
300
302
|
}
|
|
301
303
|
|
|
302
304
|
// Do all the writing to the SVG
|
|
303
|
-
var ret = draw(this.renderer, this.classes, abcTune, this.width, maxWidth, this.responsive, scale, this.selectTypes, tuneNumber, lineOffset);
|
|
305
|
+
var ret = draw(this.renderer, this.classes, abcTune, this.width, maxWidth, this.responsive, scale, this.selectTypes, tuneNumber, lineOffset, this.chordGrid);
|
|
304
306
|
this.staffgroups = ret.staffgroups;
|
|
305
307
|
this.selectables = ret.selectables;
|
|
306
308
|
if (this.oneSvgPerLine) {
|
package/src/write/layout/beam.js
CHANGED
|
@@ -189,7 +189,22 @@ function createAdditionalBeams(elems, asc, beam, isGrace, dy) {
|
|
|
189
189
|
|
|
190
190
|
|
|
191
191
|
if (auxBeams[j].single) {
|
|
192
|
-
|
|
192
|
+
if(i === 0) {
|
|
193
|
+
// This is the first note in the group, always draw the beam to the right
|
|
194
|
+
auxBeamEndX = x + 5;
|
|
195
|
+
} else if (i === elems.length - 1) {
|
|
196
|
+
// This is the last note in the group, always draw the beam to the left
|
|
197
|
+
auxBeamEndX = x - 5;
|
|
198
|
+
} else {
|
|
199
|
+
// This is a middle note, check the note durations of the notes to the left and right
|
|
200
|
+
if(elems[i-1].duration === elems[i+1].duration) {
|
|
201
|
+
// The notes on either side are the same duration, alternate which side the beam goes to
|
|
202
|
+
auxBeamEndX = i%2 === 0 ? x + 5 : x - 5;
|
|
203
|
+
} else {
|
|
204
|
+
// The notes on either side are different durations, draw the beam to the shorter note
|
|
205
|
+
auxBeamEndX = elems[i-1].duration > elems[i+1].duration ? x + 5 : x - 5;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
193
208
|
auxBeamEndY = getBarYAt(beam.startX, beam.startY, beam.endX, beam.endY, auxBeamEndX) + sy * (j + 1);
|
|
194
209
|
}
|
|
195
210
|
var b = { startX: auxBeams[j].x, endX: auxBeamEndX, startY: auxBeams[j].y, endY: auxBeamEndY, dy: dy }
|
package/src/write/renderer.js
CHANGED
|
@@ -179,6 +179,10 @@ Renderer.prototype.calcY = function (ofs) {
|
|
|
179
179
|
return this.y - ofs * spacing.STEP;
|
|
180
180
|
};
|
|
181
181
|
|
|
182
|
+
Renderer.prototype.yToPitch = function (ofs) {
|
|
183
|
+
return ofs / spacing.STEP;
|
|
184
|
+
};
|
|
185
|
+
|
|
182
186
|
Renderer.prototype.moveY = function (em, numLines) {
|
|
183
187
|
if (numLines === undefined) numLines = 1;
|
|
184
188
|
this.y += em * numLines;
|
package/src/write/svg.js
CHANGED
|
@@ -168,7 +168,7 @@ Svg.prototype.rectBeneath = function (attr) {
|
|
|
168
168
|
this.svg.insertBefore(el, this.svg.firstChild);
|
|
169
169
|
};
|
|
170
170
|
|
|
171
|
-
Svg.prototype.text = function (text, attr, target) {
|
|
171
|
+
Svg.prototype.text = function (text, attr, target, spanAttr) {
|
|
172
172
|
var el = document.createElementNS(svgNS, 'text');
|
|
173
173
|
el.setAttribute("stroke", "none");
|
|
174
174
|
for (var key in attr) {
|
|
@@ -185,6 +185,13 @@ Svg.prototype.text = function (text, attr, target) {
|
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
var line = document.createElementNS(svgNS, 'tspan');
|
|
188
|
+
if (spanAttr) {
|
|
189
|
+
for (var skey in spanAttr) {
|
|
190
|
+
if (spanAttr.hasOwnProperty(skey)) {
|
|
191
|
+
line.setAttribute(skey, spanAttr[skey]);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
188
195
|
line.setAttribute("x", attr.x ? attr.x : 0);
|
|
189
196
|
if (i !== 0)
|
|
190
197
|
line.setAttribute("dy", "1.2em");
|
package/types/index.d.ts
CHANGED
|
@@ -266,6 +266,7 @@ declare module 'abcjs' {
|
|
|
266
266
|
add_classes?: boolean;
|
|
267
267
|
afterParsing?: AfterParsing;
|
|
268
268
|
ariaLabel?: string;
|
|
269
|
+
chordGrid?:'noMusic'|'withMusic';
|
|
269
270
|
clickListener?: ClickListener;
|
|
270
271
|
dragColor?: string;
|
|
271
272
|
dragging?: boolean;
|
|
@@ -872,6 +873,29 @@ declare module 'abcjs' {
|
|
|
872
873
|
}
|
|
873
874
|
}
|
|
874
875
|
|
|
876
|
+
interface ChordGridSubtitle {
|
|
877
|
+
type: "subtitle";
|
|
878
|
+
subtitle: string;
|
|
879
|
+
}
|
|
880
|
+
interface ChordGridText {
|
|
881
|
+
type: "text";
|
|
882
|
+
text: string;
|
|
883
|
+
}
|
|
884
|
+
interface ChordGridMeasure {
|
|
885
|
+
chord: [string,string,string,string];
|
|
886
|
+
hasStartRepeat?:boolean;
|
|
887
|
+
hasEndRepeat?:boolean;
|
|
888
|
+
noBorder?:boolean; // for when the line isn't complete, this is a placeholder
|
|
889
|
+
ending?:number; // This bar starts an ending
|
|
890
|
+
annotations?: Array<string>;
|
|
891
|
+
}
|
|
892
|
+
interface ChordGridPart {
|
|
893
|
+
type: "part";
|
|
894
|
+
name: string;
|
|
895
|
+
lines: Array<ChordGridMeasure>;
|
|
896
|
+
}
|
|
897
|
+
type ChordGrid = ChordGridSubtitle | ChordGridText | ChordGridPart;
|
|
898
|
+
|
|
875
899
|
export interface TuneObject {
|
|
876
900
|
formatting: Formatting;
|
|
877
901
|
engraver?: EngraverController;
|
|
@@ -881,6 +905,7 @@ declare module 'abcjs' {
|
|
|
881
905
|
metaTextInfo: MetaTextInfo;
|
|
882
906
|
version: string;
|
|
883
907
|
warnings?: Array<string>;
|
|
908
|
+
chordGrid?: Array<ChordGrid>;
|
|
884
909
|
|
|
885
910
|
getTotalTime: NumberFunction;
|
|
886
911
|
getTotalBeats: NumberFunction;
|
package/version.js
CHANGED