abcjs 6.0.0-beta.9 → 6.0.2
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/.github/workflows/tests.yml +29 -0
- package/CODE_OF_CONDUCT.md +76 -0
- package/CONTRIBUTING.md +1 -0
- package/LICENSE.md +1 -1
- package/README.md +88 -7
- package/RELEASE.md +961 -1
- package/abcjs-audio.css +14 -5
- package/dist/.gitignore +1 -2
- package/dist/abcjs-basic-min.js +3 -0
- package/dist/abcjs-basic-min.js.LICENSE +23 -0
- package/dist/abcjs-basic.js +28232 -0
- package/dist/abcjs-basic.js.map +1 -0
- package/dist/abcjs-plugin-min.js +3 -0
- package/dist/abcjs-plugin-min.js.LICENSE +23 -0
- package/index.js +27 -2
- package/{static-wrappers/license.js → license.js} +1 -1
- package/package.json +26 -29
- package/{src/plugin/abc_plugin.js → plugin.js} +31 -19
- package/src/api/abc_animation.js +1 -17
- package/src/api/abc_tablatures.js +144 -0
- package/src/api/abc_timing_callbacks.js +216 -117
- package/src/api/abc_tunebook.js +18 -67
- package/src/api/abc_tunebook_svg.js +40 -48
- package/src/data/abc_tune.js +232 -972
- package/src/data/deline-tune.js +199 -0
- package/src/edit/abc_editarea.js +112 -0
- package/src/edit/abc_editor.js +95 -221
- package/src/midi/abc_midi_create.js +48 -50
- package/src/parse/abc_common.js +0 -14
- package/src/parse/abc_parse.js +167 -1321
- package/src/parse/abc_parse_book.js +62 -0
- package/src/parse/abc_parse_directive.js +164 -41
- package/src/parse/abc_parse_header.js +116 -145
- package/src/parse/abc_parse_key_voice.js +26 -20
- package/src/parse/abc_parse_music.js +1337 -0
- package/src/parse/abc_tokenizer.js +21 -15
- package/src/parse/abc_transpose.js +3 -15
- package/src/parse/tune-builder.js +896 -0
- package/src/parse/wrap_lines.js +205 -453
- package/src/synth/abc_midi_flattener.js +1292 -0
- package/src/{midi → synth}/abc_midi_renderer.js +44 -17
- package/src/synth/abc_midi_sequencer.js +648 -0
- package/src/synth/active-audio-context.js +3 -14
- package/src/synth/cents-to-factor.js +10 -0
- package/src/synth/create-note-map.js +21 -32
- package/src/synth/create-synth-control.js +20 -103
- package/src/synth/create-synth.js +185 -77
- package/src/synth/download-buffer.js +7 -21
- package/src/synth/get-midi-file.js +13 -20
- package/src/synth/images/{loading.svg → loading.svg.js} +4 -0
- package/src/synth/images/loop.svg.js +65 -0
- package/src/synth/images/pause.svg.js +10 -0
- package/src/synth/images/play.svg.js +9 -0
- package/src/synth/images/{reset.svg → reset.svg.js} +5 -1
- package/src/synth/instrument-index-to-name.js +1 -16
- package/src/synth/load-note.js +37 -76
- package/src/synth/pitch-to-note-name.js +0 -15
- package/src/synth/pitches-to-perc.js +64 -0
- package/src/synth/place-note.js +78 -68
- package/src/synth/play-event.js +17 -18
- package/src/synth/register-audio-context.js +11 -23
- package/src/synth/sounds-cache.js +0 -15
- package/src/synth/supports-audio.js +9 -23
- package/src/synth/synth-controller.js +80 -49
- package/src/synth/synth-sequence.js +20 -34
- package/src/tablatures/instruments/guitar/guitar-fonts.js +19 -0
- package/src/tablatures/instruments/guitar/guitar-patterns.js +23 -0
- package/src/tablatures/instruments/guitar/tab-guitar.js +50 -0
- package/src/tablatures/instruments/string-patterns.js +277 -0
- package/src/tablatures/instruments/string-tablature.js +56 -0
- package/src/tablatures/instruments/tab-note.js +282 -0
- package/src/tablatures/instruments/tab-notes.js +41 -0
- package/src/tablatures/instruments/violin/tab-violin.js +47 -0
- package/src/tablatures/instruments/violin/violin-fonts.js +19 -0
- package/src/tablatures/instruments/violin/violin-patterns.js +23 -0
- package/src/tablatures/tab-absolute-elements.js +310 -0
- package/src/tablatures/tab-common.js +29 -0
- package/src/tablatures/tab-renderer.js +243 -0
- package/src/tablatures/transposer.js +110 -0
- package/src/test/abc_midi_lint.js +5 -22
- package/src/test/abc_midi_sequencer_lint.js +11 -14
- package/src/test/abc_parser_lint.js +136 -32
- package/src/test/abc_vertical_lint.js +94 -32
- package/src/test/rendering-lint.js +38 -5
- package/src/write/abc_absolute_element.js +112 -120
- package/src/write/abc_abstract_engraver.js +102 -253
- package/src/write/abc_beam_element.js +30 -290
- package/src/write/abc_brace_element.js +12 -121
- package/src/write/abc_create_clef.js +21 -32
- package/src/write/abc_create_key_signature.js +8 -26
- package/src/write/abc_create_note_head.js +107 -0
- package/src/write/abc_create_time_signature.js +2 -21
- package/src/write/abc_crescendo_element.js +3 -50
- package/src/write/abc_decoration.js +7 -30
- package/src/write/abc_dynamic_decoration.js +3 -37
- package/src/write/abc_ending_element.js +1 -57
- package/src/write/abc_engraver_controller.js +111 -234
- package/src/write/abc_glyphs.js +8 -18
- package/src/write/abc_relative_element.js +57 -97
- package/src/write/abc_renderer.js +10 -832
- package/src/write/abc_spacing.js +0 -15
- package/src/write/abc_staff_group_element.js +14 -349
- package/src/write/abc_tempo_element.js +9 -117
- package/src/write/abc_tie_element.js +5 -68
- package/src/write/abc_triplet_element.js +6 -124
- package/src/write/abc_voice_element.js +7 -222
- package/src/write/add-chord.js +103 -0
- package/src/write/add-text-if.js +33 -0
- package/src/write/bottom-text.js +79 -0
- package/src/write/calcHeight.js +17 -0
- package/src/write/classes.js +100 -0
- package/src/write/draw/absolute.js +68 -0
- package/src/write/draw/beam.js +56 -0
- package/src/write/draw/brace.js +106 -0
- package/src/write/draw/crescendo.js +38 -0
- package/src/write/draw/debug-box.js +8 -0
- package/src/write/draw/draw.js +56 -0
- package/src/write/draw/dynamics.js +20 -0
- package/src/write/draw/ending.js +46 -0
- package/src/write/draw/group-elements.js +66 -0
- package/src/write/draw/horizontal-line.js +25 -0
- package/src/write/draw/non-music.js +50 -0
- package/src/write/draw/print-line.js +24 -0
- package/src/write/draw/print-path.js +7 -0
- package/src/write/draw/print-stem.js +30 -0
- package/src/write/draw/print-symbol.js +59 -0
- package/src/write/draw/print-vertical-line.js +18 -0
- package/src/write/draw/relative.js +77 -0
- package/src/write/draw/round-number.js +5 -0
- package/src/write/draw/selectables.js +59 -0
- package/src/write/draw/separator.js +16 -0
- package/src/write/draw/set-paper-size.js +45 -0
- package/src/write/{sprintf.js → draw/sprintf.js} +0 -0
- package/src/write/draw/staff-group.js +226 -0
- package/src/write/draw/staff-line.js +9 -0
- package/src/write/draw/staff.js +33 -0
- package/src/write/draw/tab-line.js +40 -0
- package/src/write/draw/tempo.js +45 -0
- package/src/write/draw/text.js +71 -0
- package/src/write/draw/tie.js +97 -0
- package/src/write/draw/triplet.js +46 -0
- package/src/write/draw/voice.js +102 -0
- package/src/write/format-jazz-chord.js +15 -0
- package/src/write/free-text.js +41 -0
- package/src/write/get-font-and-attr.js +37 -0
- package/src/write/get-text-size.js +56 -0
- package/src/write/highlight.js +11 -0
- package/src/write/layout/VoiceElements.js +121 -0
- package/src/write/layout/beam.js +213 -0
- package/src/write/layout/get-left-edge-of-staff.js +56 -0
- package/src/write/layout/getBarYAt.js +6 -0
- package/src/write/layout/layout.js +94 -0
- package/src/write/layout/setUpperAndLowerElements.js +232 -0
- package/src/write/layout/staffGroup.js +146 -0
- package/src/write/layout/triplet.js +75 -0
- package/src/write/layout/voice.js +137 -0
- package/src/write/selection.js +188 -70
- package/src/write/separator.js +10 -0
- package/src/write/set-class.js +21 -0
- package/src/write/subtitle.js +12 -0
- package/src/write/svg.js +95 -43
- package/src/write/top-text.js +54 -0
- package/src/write/unhighlight.js +11 -0
- package/test.js +27 -64
- package/types/index.d.ts +1095 -0
- package/version.js +1 -1
- package/.babelrc +0 -5
- package/.eslintrc +0 -3
- package/.gitmodules +0 -3
- package/Dockerfile +0 -8
- package/abcjs-midi.css +0 -166
- package/build-utils/loadPresets.js +0 -14
- package/build-utils/presets/webpack.analyze.js +0 -6
- package/build-utils/presets/webpack.optimize.js +0 -30
- package/build-utils/webpack.development.js +0 -14
- package/build-utils/webpack.production.js +0 -35
- package/deploy-docs.sh +0 -25
- package/docker-compose.yml +0 -13
- package/docs/README.md +0 -33
- package/fix-versions.sh +0 -23
- package/midi.js +0 -62
- package/src/api/abc_tunebook_midi.js +0 -116
- package/src/midi/abc_midi_controls.js +0 -701
- package/src/midi/abc_midi_flattener.js +0 -1119
- package/src/midi/abc_midi_js_preparer.js +0 -243
- package/src/midi/abc_midi_sequencer.js +0 -401
- package/src/midi/abc_midi_ui_generator.js +0 -86
- package/src/plugin/abc_plugin_midi.js +0 -220
- package/src/synth/images/loop.svg +0 -61
- package/src/synth/images/pause.svg +0 -6
- package/src/synth/images/play.svg +0 -5
- package/src/transform/abc2abc_write.js +0 -395
- package/static-wrappers/basic.js +0 -2
- package/static-wrappers/midi.js +0 -2
- package/static-wrappers/plugin-midi.js +0 -6
- package/static-wrappers/plugin.js +0 -6
- package/webpack.config.js +0 -29
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
var glyphs = require('./abc_glyphs');
|
|
2
|
+
var RelativeElement = require('./abc_relative_element');
|
|
3
|
+
|
|
4
|
+
var createNoteHead = function(abselem, c, pitchelem, options) {
|
|
5
|
+
if (!options) options = {};
|
|
6
|
+
var dir = (options.dir !== undefined) ? options.dir : null;
|
|
7
|
+
var headx = (options.headx !== undefined) ? options.headx : 0;
|
|
8
|
+
var extrax = (options.extrax !== undefined) ? options.extrax : 0;
|
|
9
|
+
var flag = (options.flag !== undefined) ? options.flag : null;
|
|
10
|
+
var dot = (options.dot !== undefined) ? options.dot : 0;
|
|
11
|
+
var dotshiftx = (options.dotshiftx !== undefined) ? options.dotshiftx : 0;
|
|
12
|
+
var scale = (options.scale !== undefined) ? options.scale : 1;
|
|
13
|
+
var accidentalSlot = (options.accidentalSlot !== undefined) ? options.accidentalSlot : [];
|
|
14
|
+
var shouldExtendStem = (options.shouldExtendStem !== undefined) ? options.shouldExtendStem : false;
|
|
15
|
+
var printAccidentals = (options.printAccidentals !== undefined) ? options.printAccidentals : true;
|
|
16
|
+
|
|
17
|
+
// TODO scale the dot as well
|
|
18
|
+
var pitch = pitchelem.verticalPos;
|
|
19
|
+
var notehead;
|
|
20
|
+
var accidentalshiftx = 0;
|
|
21
|
+
var newDotShiftX = 0;
|
|
22
|
+
var extraLeft = 0;
|
|
23
|
+
if (c === undefined)
|
|
24
|
+
abselem.addFixed(new RelativeElement("pitch is undefined", 0, 0, 0, {type:"debug"}));
|
|
25
|
+
else if (c==="") {
|
|
26
|
+
notehead = new RelativeElement(null, 0, 0, pitch);
|
|
27
|
+
} else {
|
|
28
|
+
var shiftheadx = headx;
|
|
29
|
+
if (pitchelem.printer_shift) {
|
|
30
|
+
var adjust = (pitchelem.printer_shift==="same")?1:0;
|
|
31
|
+
shiftheadx = (dir==="down")?-glyphs.getSymbolWidth(c)*scale+adjust:glyphs.getSymbolWidth(c)*scale-adjust;
|
|
32
|
+
}
|
|
33
|
+
var opts = {scalex:scale, scaley: scale, thickness: glyphs.symbolHeightInPitches(c)*scale, name: pitchelem.name };
|
|
34
|
+
notehead = new RelativeElement(c, shiftheadx, glyphs.getSymbolWidth(c)*scale, pitch, opts);
|
|
35
|
+
notehead.stemDir = dir;
|
|
36
|
+
if (flag) {
|
|
37
|
+
var pos = pitch+((dir==="down")?-7:7)*scale;
|
|
38
|
+
// if this is a regular note, (not grace or tempo indicator) then the stem will have been stretched to the middle line if it is far from the center.
|
|
39
|
+
if (shouldExtendStem) {
|
|
40
|
+
if (dir==="down" && pos > 6)
|
|
41
|
+
pos = 6;
|
|
42
|
+
if (dir==="up" && pos < 6)
|
|
43
|
+
pos = 6;
|
|
44
|
+
}
|
|
45
|
+
//if (scale===1 && (dir==="down")?(pos>6):(pos<6)) pos=6;
|
|
46
|
+
var xdelta = (dir==="down")?headx:headx+notehead.w-0.6;
|
|
47
|
+
abselem.addRight(new RelativeElement(flag, xdelta, glyphs.getSymbolWidth(flag)*scale, pos, {scalex:scale, scaley: scale}));
|
|
48
|
+
}
|
|
49
|
+
newDotShiftX = notehead.w+dotshiftx-2+5*dot;
|
|
50
|
+
for (;dot>0;dot--) {
|
|
51
|
+
var dotadjusty = (1-Math.abs(pitch)%2); //PER: take abs value of the pitch. And the shift still happens on ledger lines.
|
|
52
|
+
abselem.addRight(new RelativeElement("dots.dot", notehead.w+dotshiftx-2+5*dot, glyphs.getSymbolWidth("dots.dot"), pitch+dotadjusty));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (notehead)
|
|
56
|
+
notehead.highestVert = pitchelem.highestVert;
|
|
57
|
+
|
|
58
|
+
if (printAccidentals && pitchelem.accidental) {
|
|
59
|
+
var symb;
|
|
60
|
+
switch (pitchelem.accidental) {
|
|
61
|
+
case "quartersharp":
|
|
62
|
+
symb = "accidentals.halfsharp";
|
|
63
|
+
break;
|
|
64
|
+
case "dblsharp":
|
|
65
|
+
symb = "accidentals.dblsharp";
|
|
66
|
+
break;
|
|
67
|
+
case "sharp":
|
|
68
|
+
symb = "accidentals.sharp";
|
|
69
|
+
break;
|
|
70
|
+
case "quarterflat":
|
|
71
|
+
symb = "accidentals.halfflat";
|
|
72
|
+
break;
|
|
73
|
+
case "flat":
|
|
74
|
+
symb = "accidentals.flat";
|
|
75
|
+
break;
|
|
76
|
+
case "dblflat":
|
|
77
|
+
symb = "accidentals.dblflat";
|
|
78
|
+
break;
|
|
79
|
+
case "natural":
|
|
80
|
+
symb = "accidentals.nat";
|
|
81
|
+
}
|
|
82
|
+
// if a note is at least a sixth away, it can share a slot with another accidental
|
|
83
|
+
var accSlotFound = false;
|
|
84
|
+
var accPlace = extrax;
|
|
85
|
+
for (var j = 0; j < accidentalSlot.length; j++) {
|
|
86
|
+
if (pitch - accidentalSlot[j][0] >= 6) {
|
|
87
|
+
accidentalSlot[j][0] = pitch;
|
|
88
|
+
accPlace = accidentalSlot[j][1];
|
|
89
|
+
accSlotFound = true;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (accSlotFound === false) {
|
|
94
|
+
accPlace -= (glyphs.getSymbolWidth(symb)*scale+2);
|
|
95
|
+
accidentalSlot.push([pitch,accPlace]);
|
|
96
|
+
accidentalshiftx = (glyphs.getSymbolWidth(symb)*scale+2);
|
|
97
|
+
}
|
|
98
|
+
var h = glyphs.symbolHeightInPitches(symb);
|
|
99
|
+
abselem.addExtra(new RelativeElement(symb, accPlace, glyphs.getSymbolWidth(symb), pitch, {scalex:scale, scaley: scale, top: pitch+h/2, bottom: pitch-h/2}));
|
|
100
|
+
extraLeft = glyphs.getSymbolWidth(symb) / 2; // TODO-PER: We need a little extra width if there is an accidental, but I'm not sure why it isn't the full width of the accidental.
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return { notehead: notehead, accidentalshiftx: accidentalshiftx, dotshiftx: newDotShiftX, extraLeft: extraLeft };
|
|
104
|
+
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
module.exports = createNoteHead;
|
|
@@ -1,29 +1,11 @@
|
|
|
1
1
|
// abc_create_time_signature.js
|
|
2
|
-
// Copyright (C) 2010-2020 Gregory Dyke (gregdyke at gmail dot com) and Paul Rosen
|
|
3
|
-
//
|
|
4
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
5
|
-
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation
|
|
6
|
-
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
|
|
7
|
-
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
8
|
-
//
|
|
9
|
-
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
10
|
-
//
|
|
11
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
|
12
|
-
// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
13
|
-
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
14
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
15
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
16
2
|
|
|
17
3
|
var AbsoluteElement = require('./abc_absolute_element');
|
|
18
4
|
var glyphs = require('./abc_glyphs');
|
|
19
5
|
var RelativeElement = require('./abc_relative_element');
|
|
20
6
|
|
|
21
|
-
var createTimeSignature
|
|
22
|
-
|
|
23
|
-
(function() {
|
|
24
|
-
"use strict";
|
|
25
|
-
|
|
26
|
-
createTimeSignature = function(elem, tuneNumber) {
|
|
7
|
+
var createTimeSignature = function(elem, tuneNumber) {
|
|
8
|
+
elem.el_type = "timeSignature";
|
|
27
9
|
var abselem = new AbsoluteElement(elem,0,10, 'staff-extra time-signature', tuneNumber);
|
|
28
10
|
if (elem.type === "specified") {
|
|
29
11
|
var x = 0;
|
|
@@ -69,6 +51,5 @@ var createTimeSignature;
|
|
|
69
51
|
}
|
|
70
52
|
return abselem;
|
|
71
53
|
};
|
|
72
|
-
})();
|
|
73
54
|
|
|
74
55
|
module.exports = createTimeSignature;
|
|
@@ -1,62 +1,15 @@
|
|
|
1
1
|
// abc_crescendo_element.js: Definition of the CrescendoElem class.
|
|
2
|
-
// Copyright (C) 2010-2020 Gregory Dyke (gregdyke at gmail dot com) and Paul Rosen
|
|
3
|
-
//
|
|
4
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
5
|
-
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation
|
|
6
|
-
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
|
|
7
|
-
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
8
|
-
//
|
|
9
|
-
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
10
|
-
//
|
|
11
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
|
12
|
-
// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
13
|
-
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
14
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
15
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
16
|
-
|
|
17
|
-
var sprintf = require('./sprintf');
|
|
18
2
|
|
|
19
3
|
var CrescendoElem = function CrescendoElem(anchor1, anchor2, dir, positioning) {
|
|
4
|
+
this.type = "CrescendoElem";
|
|
20
5
|
this.anchor1 = anchor1; // must have a .x and a .parent property or be null (means starts at the "beginning" of the line - after keysig)
|
|
21
6
|
this.anchor2 = anchor2; // must have a .x property or be null (means ends at the end of the line)
|
|
22
7
|
this.dir = dir; // either "<" or ">"
|
|
23
8
|
if (positioning === 'above')
|
|
24
|
-
this.dynamicHeightAbove =
|
|
9
|
+
this.dynamicHeightAbove = 6;
|
|
25
10
|
else
|
|
26
|
-
this.dynamicHeightBelow =
|
|
11
|
+
this.dynamicHeightBelow = 6;
|
|
27
12
|
this.pitch = undefined; // This will be set later
|
|
28
13
|
};
|
|
29
14
|
|
|
30
|
-
CrescendoElem.prototype.setUpperAndLowerElements = function(positionY) {
|
|
31
|
-
if (this.dynamicHeightAbove)
|
|
32
|
-
this.pitch = positionY.dynamicHeightAbove;
|
|
33
|
-
else
|
|
34
|
-
this.pitch = positionY.dynamicHeightBelow;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
CrescendoElem.prototype.draw = function (renderer) {
|
|
38
|
-
if (this.pitch === undefined)
|
|
39
|
-
window.console.error("Crescendo Element y-coordinate not set.");
|
|
40
|
-
var y = renderer.calcY(this.pitch) + 4; // This is the top pixel to use (it is offset a little so that it looks good with the volume marks.)
|
|
41
|
-
var height = 8;
|
|
42
|
-
if (this.dir === "<") {
|
|
43
|
-
this.drawLine(renderer, y+height/2, y, y+height/2, y+height);
|
|
44
|
-
} else {
|
|
45
|
-
this.drawLine(renderer, y, y+height/2, y+height, y+height/2);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
CrescendoElem.prototype.drawLine = function (renderer, y1, y2, y3, y4) {
|
|
50
|
-
// TODO-PER: This is just a quick hack to make the dynamic marks not crash if they are mismatched. See the slur treatment for the way to get the beginning and end.
|
|
51
|
-
var left = this.anchor1 ? this.anchor1.x : 0;
|
|
52
|
-
var right = this.anchor2 ? this.anchor2.x : 800;
|
|
53
|
-
|
|
54
|
-
var type = this.dir === "<" ? "crescendo" : "diminuendo";
|
|
55
|
-
var pathString = sprintf("M %f %f L %f %f M %f %f L %f %f",
|
|
56
|
-
left, y1, right, y2, left, y3, right, y4);
|
|
57
|
-
renderer.controller.currentAbsEl = { tuneNumber: renderer.controller.engraver.tuneNumber, elemset: [], abcelem: { el_type: type, startChar: -1, endChar: -1 }};
|
|
58
|
-
var el = renderer.printPath({path:pathString, stroke:"#000000", 'class': renderer.addClasses('dynamics decoration')});
|
|
59
|
-
renderer.controller.currentAbsEl.elemset.push(el);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
15
|
module.exports = CrescendoElem;
|
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
// abc_decoration.js: Creates a data structure suitable for printing a line of abc
|
|
2
|
-
// Copyright (C) 2010-2020 Gregory Dyke (gregdyke at gmail dot com) & Paul Rosen
|
|
3
|
-
//
|
|
4
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
5
|
-
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation
|
|
6
|
-
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
|
|
7
|
-
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
8
|
-
//
|
|
9
|
-
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
10
|
-
//
|
|
11
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
|
12
|
-
// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
13
|
-
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
14
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
15
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
16
|
-
|
|
17
|
-
/*global window */
|
|
18
2
|
|
|
19
3
|
var DynamicDecoration = require('./abc_dynamic_decoration');
|
|
20
4
|
var CrescendoElem = require('./abc_crescendo_element');
|
|
@@ -22,12 +6,7 @@ var glyphs = require('./abc_glyphs');
|
|
|
22
6
|
var RelativeElement = require('./abc_relative_element');
|
|
23
7
|
var TieElem = require('./abc_tie_element');
|
|
24
8
|
|
|
25
|
-
var Decoration
|
|
26
|
-
|
|
27
|
-
(function() {
|
|
28
|
-
"use strict";
|
|
29
|
-
|
|
30
|
-
Decoration = function Decoration() {
|
|
9
|
+
var Decoration = function Decoration() {
|
|
31
10
|
this.startDiminuendoX = undefined;
|
|
32
11
|
this.startCrescendoX = undefined;
|
|
33
12
|
this.minTop = 12; // TODO-PER: this is assuming a 5-line staff. Pass that info in.
|
|
@@ -66,15 +45,15 @@ var Decoration;
|
|
|
66
45
|
if (glyphs.getSymbolAlign(symbol)!=="center") {
|
|
67
46
|
deltaX -= (glyphs.getSymbolWidth(symbol)/2);
|
|
68
47
|
}
|
|
69
|
-
abselem.
|
|
48
|
+
abselem.addFixedX(new RelativeElement(symbol, deltaX, glyphs.getSymbolWidth(symbol), yPos));
|
|
70
49
|
}
|
|
71
50
|
if (decoration[i]==="slide" && abselem.heads[0]) {
|
|
72
51
|
var yPos2 = abselem.heads[0].pitch;
|
|
73
52
|
yPos2 -= 2; // TODO-PER: not sure what this fudge factor is.
|
|
74
53
|
var blank1 = new RelativeElement("", -roomtaken-15, 0, yPos2-1);
|
|
75
54
|
var blank2 = new RelativeElement("", -roomtaken-5, 0, yPos2+1);
|
|
76
|
-
abselem.
|
|
77
|
-
abselem.
|
|
55
|
+
abselem.addFixedX(blank1);
|
|
56
|
+
abselem.addFixedX(blank2);
|
|
78
57
|
voice.addOther(new TieElem({ anchor1: blank1, anchor2: blank2, fixedY: true}));
|
|
79
58
|
}
|
|
80
59
|
}
|
|
@@ -129,7 +108,7 @@ var Decoration;
|
|
|
129
108
|
deltaX += (dir === 'down') ? -5 : 3;
|
|
130
109
|
for (var i = 0; i < count; i++) {
|
|
131
110
|
placement -= 1;
|
|
132
|
-
abselem.
|
|
111
|
+
abselem.addFixedX(new RelativeElement(symbol, deltaX, glyphs.getSymbolWidth(symbol), placement));
|
|
133
112
|
}
|
|
134
113
|
}
|
|
135
114
|
|
|
@@ -168,7 +147,7 @@ var Decoration;
|
|
|
168
147
|
var textFudge = 2;
|
|
169
148
|
var textHeight = 5;
|
|
170
149
|
// TODO-PER: Get the height of the current font and use that for the thickness.
|
|
171
|
-
abselem.
|
|
150
|
+
abselem.addFixedX(new RelativeElement(text, width/2, 0, y+textFudge, {type:"decoration", klass: 'ornament', thickness: 3}));
|
|
172
151
|
|
|
173
152
|
incrementPlacement(placement, textHeight);
|
|
174
153
|
}
|
|
@@ -180,7 +159,7 @@ var Decoration;
|
|
|
180
159
|
var height = glyphs.symbolHeightInPitches(symbol) + 1; // adding a little padding so nothing touches.
|
|
181
160
|
var y = getPlacement(placement);
|
|
182
161
|
y = (placement === 'above') ? y + height/2 : y - height/2;// Center the element vertically.
|
|
183
|
-
abselem.
|
|
162
|
+
abselem.addFixedX(new RelativeElement(symbol, deltaX, glyphs.getSymbolWidth(symbol), y, { klass: 'ornament', thickness: glyphs.symbolHeightInPitches(symbol) }));
|
|
184
163
|
|
|
185
164
|
incrementPlacement(placement, height);
|
|
186
165
|
}
|
|
@@ -346,6 +325,4 @@ var Decoration;
|
|
|
346
325
|
leftDecoration(decoration, abselem, roomtaken);
|
|
347
326
|
};
|
|
348
327
|
|
|
349
|
-
})();
|
|
350
|
-
|
|
351
328
|
module.exports = Decoration;
|
|
@@ -1,48 +1,14 @@
|
|
|
1
1
|
// abc_dynamic_decoration.js: Definition of the DynamicDecoration class.
|
|
2
|
-
// Copyright (C) 2010-2020 Gregory Dyke (gregdyke at gmail dot com) and Paul Rosen
|
|
3
|
-
//
|
|
4
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
5
|
-
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation
|
|
6
|
-
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
|
|
7
|
-
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
8
|
-
//
|
|
9
|
-
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
10
|
-
//
|
|
11
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
|
12
|
-
// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
13
|
-
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
14
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
15
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
16
|
-
|
|
17
|
-
var spacing = require('./abc_spacing');
|
|
18
2
|
|
|
19
3
|
var DynamicDecoration = function DynamicDecoration(anchor, dec, position) {
|
|
4
|
+
this.type = "DynamicDecoration";
|
|
20
5
|
this.anchor = anchor;
|
|
21
6
|
this.dec = dec;
|
|
22
7
|
if (position === 'below')
|
|
23
|
-
this.volumeHeightBelow =
|
|
8
|
+
this.volumeHeightBelow = 6;
|
|
24
9
|
else
|
|
25
|
-
this.volumeHeightAbove =
|
|
10
|
+
this.volumeHeightAbove = 6;
|
|
26
11
|
this.pitch = undefined; // This will be set later
|
|
27
12
|
};
|
|
28
13
|
|
|
29
|
-
DynamicDecoration.prototype.setUpperAndLowerElements = function(positionY) {
|
|
30
|
-
if (this.volumeHeightAbove)
|
|
31
|
-
this.pitch = positionY.volumeHeightAbove;
|
|
32
|
-
else
|
|
33
|
-
this.pitch = positionY.volumeHeightBelow;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
DynamicDecoration.prototype.draw = function(renderer) {
|
|
37
|
-
if (this.pitch === undefined)
|
|
38
|
-
window.console.error("Dynamic Element y-coordinate not set.");
|
|
39
|
-
var scalex = 1;
|
|
40
|
-
var scaley = 1;
|
|
41
|
-
var self = this;
|
|
42
|
-
var ret = renderer.wrapInAbsElem({el_type: "dynamic-decoration", startChar: -1, endChar: -1, decoration: this.dec}, 'abcjs-decoration', function () {
|
|
43
|
-
var el = renderer.printSymbol(self.anchor.x, self.pitch, self.dec, scalex, scaley, renderer.addClasses('decoration'));
|
|
44
|
-
return el;
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
|
|
48
14
|
module.exports = DynamicDecoration;
|
|
@@ -1,22 +1,7 @@
|
|
|
1
1
|
// abc_ending_element.js: Definition of the EndingElement class.
|
|
2
|
-
// Copyright (C) 2010-2020 Gregory Dyke (gregdyke at gmail dot com) and Paul Rosen
|
|
3
|
-
//
|
|
4
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
5
|
-
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation
|
|
6
|
-
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
|
|
7
|
-
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
8
|
-
//
|
|
9
|
-
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
10
|
-
//
|
|
11
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
|
12
|
-
// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
13
|
-
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
14
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
15
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
16
|
-
|
|
17
|
-
var sprintf = require('./sprintf');
|
|
18
2
|
|
|
19
3
|
var EndingElem = function EndingElem(text, anchor1, anchor2) {
|
|
4
|
+
this.type = "EndingElem";
|
|
20
5
|
this.text = text; // text to be displayed top left
|
|
21
6
|
this.anchor1 = anchor1; // must have a .x property or be null (means starts at the "beginning" of the line - after keysig)
|
|
22
7
|
this.anchor2 = anchor2; // must have a .x property or be null (means ends at the end of the line)
|
|
@@ -24,45 +9,4 @@ var EndingElem = function EndingElem(text, anchor1, anchor2) {
|
|
|
24
9
|
this.pitch = undefined; // This will be set later
|
|
25
10
|
};
|
|
26
11
|
|
|
27
|
-
EndingElem.prototype.setUpperAndLowerElements = function(positionY) {
|
|
28
|
-
this.pitch = positionY.endingHeightAbove - 2;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
EndingElem.prototype.draw = function (renderer, linestartx, lineendx) {
|
|
32
|
-
if (this.pitch === undefined)
|
|
33
|
-
window.console.error("Ending Element y-coordinate not set.");
|
|
34
|
-
var y = renderer.calcY(this.pitch);
|
|
35
|
-
var height = 20;
|
|
36
|
-
var pathString = '';
|
|
37
|
-
|
|
38
|
-
if (this.anchor1) {
|
|
39
|
-
linestartx = this.anchor1.x+this.anchor1.w;
|
|
40
|
-
pathString += sprintf("M %f %f L %f %f ",
|
|
41
|
-
linestartx, y, linestartx, y+height);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (this.anchor2) {
|
|
45
|
-
lineendx = this.anchor2.x;
|
|
46
|
-
pathString += sprintf("M %f %f L %f %f ",
|
|
47
|
-
lineendx, y, lineendx, y+height);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
pathString += sprintf("M %f %f L %f %f ",
|
|
51
|
-
linestartx, y, lineendx, y);
|
|
52
|
-
|
|
53
|
-
var self = this;
|
|
54
|
-
var g;
|
|
55
|
-
var ret = renderer.wrapInAbsElem({el_type: "ending", startChar: -1, endChar: -1}, 'abcjs-ending', function () {
|
|
56
|
-
|
|
57
|
-
renderer.createElemSet({klass: renderer.addClasses("ending")});
|
|
58
|
-
renderer.printPath({path: pathString, stroke: "#000000", fill: "#000000"}, { history: 'ignore'});
|
|
59
|
-
if (self.anchor1)
|
|
60
|
-
renderer.renderText({x: linestartx + 5, y: renderer.calcY(self.pitch - 0.5), text: self.text, type: 'repeatfont', klass: 'ending', anchor: "start", noClass: true, history: 'ignore'});
|
|
61
|
-
g = renderer.closeElemSet();
|
|
62
|
-
renderer.controller.recordHistory(g, false);
|
|
63
|
-
return g;
|
|
64
|
-
});
|
|
65
|
-
return g;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
12
|
module.exports = EndingElem;
|