abcjs 6.0.0-beta.7 → 6.0.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/.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 +92 -3
- package/RELEASE.md +957 -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 +28231 -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/dist/report-basic.html +37 -0
- package/dist/report-before-glyph-compress.html +37 -0
- package/dist/report-brown-ts-target-es5.html +37 -0
- package/dist/report-dev-orig-no-babel.html +37 -0
- package/dist/report-synth.html +37 -0
- package/docker-build.sh +1 -0
- package/glyphs.json +1 -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 +234 -116
- package/src/api/abc_tunebook.js +18 -67
- package/src/api/abc_tunebook_svg.js +38 -46
- 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 +9 -19
- 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/temp.txt +17 -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/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/docs/README.md +0 -33
- package/fix-versions.sh +0 -23
- package/mei.js +0 -43
- 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
|
@@ -1,395 +0,0 @@
|
|
|
1
|
-
// abc2abc_write.js: Prints an abc file in text format parsed by abc_parse.js
|
|
2
|
-
// Copyright (C) 2010-2020 Gregory Dyke (gregdyke at gmail dot com)
|
|
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 TextPrinter = function(elem, reposition) {
|
|
18
|
-
this.elem = elem;
|
|
19
|
-
this.text = "";
|
|
20
|
-
this.l = 1/8;
|
|
21
|
-
this.reposition = reposition || false;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
TextPrinter.prototype.printString = function(str, elem) {
|
|
25
|
-
if (this.reposition && elem) elem.startChar = this.text.length;
|
|
26
|
-
this.text += str;
|
|
27
|
-
if (this.reposition && elem) elem.endChar = this.text.length;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
TextPrinter.prototype.printNewLine = function () {
|
|
31
|
-
this.text += "\n";
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
TextPrinter.prototype.printSpace = function () {
|
|
35
|
-
if (this.text[this.text.length-1].match(/\s/)) return; //TODO match whitespace
|
|
36
|
-
this.text += " ";
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
TextPrinter.prototype.printABC = function(abctune) {
|
|
40
|
-
this.text = "";
|
|
41
|
-
this.abctune = abctune;
|
|
42
|
-
//TODO formatting
|
|
43
|
-
this.printHeader();
|
|
44
|
-
this.printBody();
|
|
45
|
-
this.elem.value=this.text;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
TextPrinter.prototype.printHeader = function() {
|
|
49
|
-
// much of this info is duplicated in metaTextHEaders in abc_parse_header.js
|
|
50
|
-
this.printHeaderLine("x","X","1");
|
|
51
|
-
this.printHeaderLine("title","T");
|
|
52
|
-
this.printHeaderLine("composer","C");
|
|
53
|
-
this.printHeaderLine("history","H");
|
|
54
|
-
this.printHeaderLine("author","A");
|
|
55
|
-
this.printHeaderLine("book","B");
|
|
56
|
-
this.printHeaderLine("discography","D");
|
|
57
|
-
this.printHeaderLine("url","F");
|
|
58
|
-
this.printHeaderLine("group","G");
|
|
59
|
-
this.printHeaderLine("instruction","I");
|
|
60
|
-
this.printHeaderLine("notes","N");
|
|
61
|
-
this.printHeaderLine("origin","O");
|
|
62
|
-
this.printHeaderLine("rhythm","R");
|
|
63
|
-
this.printHeaderLine("source","S");
|
|
64
|
-
this.printHeaderLine("unalignedwords","W");
|
|
65
|
-
this.printHeaderLine("transcription","Z");
|
|
66
|
-
//TODO part order
|
|
67
|
-
//TODO Q tempo
|
|
68
|
-
//TODO textBlock
|
|
69
|
-
this.printHeaderLine("NULL","L","1/8"); //TODO L
|
|
70
|
-
|
|
71
|
-
this.printHeaderLine("NULL","M",this.getMeterString(this.abctune.lines[0].staff[0].meter));
|
|
72
|
-
this.printHeaderLine("NULL","K",this.getKeyString(this.abctune.lines[0].staff[0].key));//TODO K
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
TextPrinter.prototype.getKeyString = function(key) {
|
|
76
|
-
return key.root+key.acc+key.mode;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
TextPrinter.prototype.getMeterString = function(meter) {
|
|
80
|
-
switch (meter.type) {
|
|
81
|
-
case "cut_time": return "C|";
|
|
82
|
-
case "common_time": return "C";
|
|
83
|
-
case "specified":
|
|
84
|
-
if (meter.value[0].den)
|
|
85
|
-
return meter.value[0].num+"/"+meter.value[0].den;
|
|
86
|
-
else
|
|
87
|
-
return meter.value[0].num;
|
|
88
|
-
}
|
|
89
|
-
return "";
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
TextPrinter.prototype.printHeaderLine = function(fieldname, abcfield, defaut) {
|
|
93
|
-
var val = this.abctune.metaText[fieldname] || defaut;
|
|
94
|
-
if (val !== undefined) {
|
|
95
|
-
var valarray = val.split("\n");
|
|
96
|
-
for (var i=0; i<valarray.length; i++) {
|
|
97
|
-
this.printString(abcfield+": "+valarray[i]);
|
|
98
|
-
this.printNewLine();
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
TextPrinter.prototype.getElem = function() {
|
|
104
|
-
if (this.abcline.length <= this.pos)
|
|
105
|
-
return null;
|
|
106
|
-
return this.abcline[this.pos];
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
TextPrinter.prototype.getNextElem = function() {
|
|
110
|
-
if (this.abcline.length <= this.pos+1)
|
|
111
|
-
return null;
|
|
112
|
-
return this.abcline[this.pos+1];
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
TextPrinter.prototype.printBody = function() {
|
|
116
|
-
for(var line=0; line<this.abctune.lines.length; line++) {
|
|
117
|
-
var abcline = this.abctune.lines[line];
|
|
118
|
-
if (abcline.staff) {
|
|
119
|
-
this.printABCLine(abcline.staff);
|
|
120
|
-
} else if (abcline.subtitle && line!==0) {
|
|
121
|
-
//TODO
|
|
122
|
-
} else if (abcline.text) {
|
|
123
|
-
//TODO
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
TextPrinter.prototype.printABCLine = function(staffs) {
|
|
129
|
-
for (this.s = 0; this.s < staffs.length; this.s++) {
|
|
130
|
-
this.printABCStaff(staffs[this.s]);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
TextPrinter.prototype.printABCStaff = function(abcstaff) {
|
|
135
|
-
|
|
136
|
-
for (this.v = 0; this.v < abcstaff.voices.length; this.v++) {
|
|
137
|
-
// TODO stuff about voices
|
|
138
|
-
|
|
139
|
-
// TODO this is where key sig is this.voice.addChild(this.printClef(abcstaff.clef));
|
|
140
|
-
// this.voice.addChild(this.printKeySignature(abcstaff.key));
|
|
141
|
-
// if (abcstaff.meter) this.voice.addChild(this.printTimeSignature(abcstaff.meter));
|
|
142
|
-
this.printABCVoice(abcstaff.voices[this.v]);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
TextPrinter.prototype.printABCVoice = function(abcline) {
|
|
148
|
-
this.abcline = abcline;
|
|
149
|
-
for (this.pos=0; this.pos<this.abcline.length; this.pos++) {
|
|
150
|
-
this.printABCElement();
|
|
151
|
-
}
|
|
152
|
-
this.printNewLine();
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
TextPrinter.prototype.printABCElement = function() {
|
|
156
|
-
var elem = this.getElem();
|
|
157
|
-
switch (elem.el_type) {
|
|
158
|
-
case "note":
|
|
159
|
-
this.printBeam();
|
|
160
|
-
break;
|
|
161
|
-
case "bar":
|
|
162
|
-
this.printBarLine(elem);
|
|
163
|
-
break;
|
|
164
|
-
case "meter":
|
|
165
|
-
//TODO this.printTimeSignature(elem);
|
|
166
|
-
break;
|
|
167
|
-
case "clef":
|
|
168
|
-
//TODO this.printClef(elem);
|
|
169
|
-
break;
|
|
170
|
-
case "key":
|
|
171
|
-
//TODO this.printKeySignature(elem);
|
|
172
|
-
case "stem":
|
|
173
|
-
//TODO do nothing?
|
|
174
|
-
break;
|
|
175
|
-
case "part":
|
|
176
|
-
//TODO print part
|
|
177
|
-
break;
|
|
178
|
-
default:
|
|
179
|
-
//TODO show we're missing something
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
TextPrinter.prototype.printBeam = function() {
|
|
184
|
-
this.printSpace();
|
|
185
|
-
if (this.getElem().startBeam && !this.getElem().endBeam) {
|
|
186
|
-
while (this.getElem()) {
|
|
187
|
-
this.printNote(this.getElem());
|
|
188
|
-
if (this.getElem().endBeam) {
|
|
189
|
-
break;
|
|
190
|
-
}
|
|
191
|
-
this.pos++;
|
|
192
|
-
}
|
|
193
|
-
} else {
|
|
194
|
-
this.printNote(this.getElem());
|
|
195
|
-
}
|
|
196
|
-
this.printSpace();
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
TextPrinter.prototype.printNote = function(elem) {
|
|
200
|
-
var str = "";
|
|
201
|
-
var i;
|
|
202
|
-
if (elem.chord !== undefined) {
|
|
203
|
-
for (i=0; i<elem.chord.length; i++) {
|
|
204
|
-
str+= '"'+elem.chord[i].name+'"';
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
//TODO unify map between names and symbols (to be used with abcparse?)
|
|
209
|
-
var decorations = {
|
|
210
|
-
"staccato" : ".",
|
|
211
|
-
"upbow" : "u",
|
|
212
|
-
"downbow" : "v",
|
|
213
|
-
"roll" : "~",
|
|
214
|
-
"fermata" : "H",
|
|
215
|
-
"slide" : "J",
|
|
216
|
-
"accent" : "L",
|
|
217
|
-
"mordent" : "M",
|
|
218
|
-
"pralltriller" : "P",
|
|
219
|
-
"trill" : "T",
|
|
220
|
-
"lower" : "."
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
if (elem.decoration !== undefined) {
|
|
224
|
-
for (i=0; i<elem.decoration.length; i++) {
|
|
225
|
-
var dec = elem.decoration[i];
|
|
226
|
-
if (decorations[dec]) {
|
|
227
|
-
str+=decorations[dec];
|
|
228
|
-
} else {
|
|
229
|
-
str+="!"; //TODO hardcoded
|
|
230
|
-
str+=dec;
|
|
231
|
-
str+="!"; //TODO hardcoded
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
if (elem.gracenotes !== undefined) {
|
|
237
|
-
str+="{";
|
|
238
|
-
for (i=0; i<elem.gracenotes.length; i++) {
|
|
239
|
-
str+=this.getNoteString(elem.gracenotes[i]);
|
|
240
|
-
}
|
|
241
|
-
str+="}";
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
var ignoreslur = false;
|
|
245
|
-
if (elem.pitches.length === 1 && elem.pitches[0].startSlur) {
|
|
246
|
-
ignoreslur = true;
|
|
247
|
-
str+=this.multiplyString("(",elem.pitches[0].startSlur.length);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
if (elem.startSlur) {
|
|
251
|
-
str+=this.multiplyString("(",elem.startSlur.length);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
if ((elem.pitches.length === 1 && elem.pitches[0].endSlur) || elem.endSlur) {
|
|
255
|
-
ignoreslur = true;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
if (elem.startTriplet) {
|
|
259
|
-
str+="(3";
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
if (elem.pitches) {
|
|
263
|
-
if (elem.pitches.length > 1) str+="[";
|
|
264
|
-
for (i=0; i<elem.pitches.length; i++) {
|
|
265
|
-
elem.pitches[i].duration = elem.duration;
|
|
266
|
-
str+=this.getNoteString(elem.pitches[i], ignoreslur);
|
|
267
|
-
}
|
|
268
|
-
if (elem.pitches.length > 1) str+="]";
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
if (elem.pitches.length === 1 && elem.pitches[0].endSlur) {
|
|
272
|
-
str+=this.multiplyString(")",elem.pitches[0].endSlur.length);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
if (elem.endSlur) {
|
|
276
|
-
str+=this.multiplyString(")",elem.endSlur.length);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
this.printString(str,elem);
|
|
280
|
-
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
// accidentals, ties and sometimes slurs, sometimes duration
|
|
284
|
-
TextPrinter.prototype.getNoteString = function(pitchelem, ignoreslur) {
|
|
285
|
-
var str = "";
|
|
286
|
-
if (!ignoreslur && pitchelem.startSlur) {
|
|
287
|
-
str+="(";
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
var symb = "";
|
|
291
|
-
switch (pitchelem.accidental) {
|
|
292
|
-
case "quartersharp":
|
|
293
|
-
symb = "^/";
|
|
294
|
-
break;
|
|
295
|
-
case "dblsharp":
|
|
296
|
-
symb = "^^";
|
|
297
|
-
break;
|
|
298
|
-
case "sharp":
|
|
299
|
-
symb = "^";
|
|
300
|
-
break;
|
|
301
|
-
case "quarterflat":
|
|
302
|
-
symb = "_/";
|
|
303
|
-
break;
|
|
304
|
-
case "flat":
|
|
305
|
-
symb = "_";
|
|
306
|
-
break;
|
|
307
|
-
case "dblflat":
|
|
308
|
-
symb = "__";
|
|
309
|
-
break;
|
|
310
|
-
case "natural":
|
|
311
|
-
symb = "=";
|
|
312
|
-
}
|
|
313
|
-
str+=symb;
|
|
314
|
-
|
|
315
|
-
var pitches = ["C","D","E","F","G","A","B"];
|
|
316
|
-
var pitchstr = pitches[this.extractNote(pitchelem.pitch)];
|
|
317
|
-
var octave = this.extractOctave(pitchelem.pitch);
|
|
318
|
-
if (octave>0) {
|
|
319
|
-
pitchstr = pitchstr.toLowerCase();
|
|
320
|
-
octave--;
|
|
321
|
-
while (octave>0) {
|
|
322
|
-
pitchstr+="'";
|
|
323
|
-
octave--;
|
|
324
|
-
}
|
|
325
|
-
} else {
|
|
326
|
-
while (octave<0) {
|
|
327
|
-
pitchstr+=",";
|
|
328
|
-
octave++;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
str+=pitchstr;
|
|
333
|
-
|
|
334
|
-
if (pitchelem.duration) {
|
|
335
|
-
str+=this.getDurationString(pitchelem.duration);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
if (!ignoreslur && pitchelem.endSlur) {
|
|
339
|
-
str+=")";
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
if (pitchelem.startTie) {
|
|
343
|
-
str+="-";
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
return str;
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
TextPrinter.prototype.getDurationString = function(duration) {
|
|
350
|
-
//TODO detect crooked rhythm
|
|
351
|
-
if (duration/this.l > 1) {
|
|
352
|
-
return duration/this.l;
|
|
353
|
-
}
|
|
354
|
-
var ret = "";
|
|
355
|
-
if (this.l/duration>1) {
|
|
356
|
-
ret+="/";
|
|
357
|
-
if (this.l/duration>2) {
|
|
358
|
-
ret+=this.l/duration;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
return ret;
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
TextPrinter.prototype.extractNote = function(pitch) {
|
|
365
|
-
var pitch2 = pitch%7;
|
|
366
|
-
if (pitch2<0) pitch2+=7;
|
|
367
|
-
return pitch2;
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
TextPrinter.prototype.extractOctave = function(pitch) {
|
|
371
|
-
return Math.floor(pitch/7);
|
|
372
|
-
};
|
|
373
|
-
|
|
374
|
-
TextPrinter.prototype.printBarLine = function(elem) {
|
|
375
|
-
var barstr = "";
|
|
376
|
-
switch (elem.type) {
|
|
377
|
-
case "bar_thin": barstr+="|"; break;
|
|
378
|
-
case "bar_thin_thick": barstr+="|]"; break;
|
|
379
|
-
case "bar_thin_thin": barstr+="||"; break;
|
|
380
|
-
case "bar_thick_thin": barstr+="[|"; break;
|
|
381
|
-
case "bar_dbl_repeat": barstr+=":||:"; break;
|
|
382
|
-
case "bar_left_repeat": barstr+="|:"; break;
|
|
383
|
-
case "bar_right_repeat": barstr+=":|"; break;
|
|
384
|
-
case "bar_invisible": barstr+=""; break;
|
|
385
|
-
}
|
|
386
|
-
this.printString(barstr,elem);
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
TextPrinter.prototype.multiplyString = function (s, n) {
|
|
390
|
-
var ret = "";
|
|
391
|
-
for (;n>0;n--) ret+=s;
|
|
392
|
-
return ret;
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
module.exports = TextPrinter;
|
package/static-wrappers/basic.js
DELETED
package/static-wrappers/midi.js
DELETED
package/webpack.config.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const webpackMerge = require("webpack-merge");
|
|
2
|
-
const modeConfig = env => require(`./build-utils/webpack.${env.mode}`)(env);
|
|
3
|
-
const presetConfig = require("./build-utils/loadPresets");
|
|
4
|
-
|
|
5
|
-
module.exports = ({mode, presets, type} = {mode: "production", presets: []}) => {
|
|
6
|
-
return webpackMerge(
|
|
7
|
-
{
|
|
8
|
-
entry: `./static-wrappers/${type}.js`,
|
|
9
|
-
mode,
|
|
10
|
-
module: {
|
|
11
|
-
rules: [
|
|
12
|
-
{
|
|
13
|
-
test: /\.js$/,
|
|
14
|
-
exclude: /node_modules/,
|
|
15
|
-
use: "babel-loader"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
test: /\.svg$/,
|
|
19
|
-
loader: 'svg-inline-loader'
|
|
20
|
-
}
|
|
21
|
-
]
|
|
22
|
-
},
|
|
23
|
-
plugins: [
|
|
24
|
-
]
|
|
25
|
-
},
|
|
26
|
-
modeConfig({mode, type}),
|
|
27
|
-
presetConfig({mode, presets, type})
|
|
28
|
-
);
|
|
29
|
-
};
|