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,19 +1,6 @@
|
|
|
1
1
|
// abc_midi_renderer.js: Create the actual format for the midi.
|
|
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
|
|
|
3
|
+
var centsToFactor = require("./cents-to-factor");
|
|
17
4
|
var rendererFactory;
|
|
18
5
|
|
|
19
6
|
(function() {
|
|
@@ -44,6 +31,7 @@ var rendererFactory;
|
|
|
44
31
|
if (this.trackcount === 0) {
|
|
45
32
|
this.startTrack();
|
|
46
33
|
var divisions = Math.round(60000000 / qpm);
|
|
34
|
+
// Add the tempo
|
|
47
35
|
this.track += "%00%FF%51%03" + toHex(divisions, 6);
|
|
48
36
|
|
|
49
37
|
if (key)
|
|
@@ -58,6 +46,7 @@ var rendererFactory;
|
|
|
58
46
|
};
|
|
59
47
|
|
|
60
48
|
Midi.prototype.startTrack = function() {
|
|
49
|
+
this.noteWarped = {};
|
|
61
50
|
this.track = "";
|
|
62
51
|
this.trackName = "";
|
|
63
52
|
this.trackInstrument = "";
|
|
@@ -98,15 +87,36 @@ var rendererFactory;
|
|
|
98
87
|
this.instrument = number;
|
|
99
88
|
};
|
|
100
89
|
|
|
101
|
-
Midi.prototype.setChannel = function(number) {
|
|
90
|
+
Midi.prototype.setChannel = function(number, pan) {
|
|
102
91
|
this.channel = number;
|
|
92
|
+
var ccPrefix = "%00%B" + this.channel.toString(16);
|
|
93
|
+
// Reset midi, in case it was set previously.
|
|
94
|
+
this.track += ccPrefix + "%79%00"; // Reset All Controllers
|
|
95
|
+
this.track += ccPrefix + "%40%00"; // Damper pedal
|
|
96
|
+
this.track += ccPrefix + "%5B%30"; // Effect 1 Depth (reverb)
|
|
97
|
+
// Translate pan as -1 to 1 to 0 to 127
|
|
98
|
+
if (!pan)
|
|
99
|
+
pan = 0;
|
|
100
|
+
pan = Math.round((pan + 1) * 64);
|
|
101
|
+
this.track += ccPrefix + "%0A" + toHex(pan, 2); // Pan
|
|
102
|
+
this.track += ccPrefix + "%07%64"; // Channel Volume
|
|
103
|
+
|
|
103
104
|
this.noteOnAndChannel = "%9" + this.channel.toString(16);
|
|
104
105
|
this.noteOffAndChannel = "%8" + this.channel.toString(16);
|
|
105
106
|
};
|
|
106
107
|
|
|
107
|
-
|
|
108
|
+
var HALF_STEP = 4096; // For the pitch wheel - (i.e. the distance from C to C#)
|
|
109
|
+
Midi.prototype.startNote = function(pitch, loudness, cents) {
|
|
108
110
|
this.track += toDurationHex(this.silencelength); // only need to shift by amount of silence (if there is any)
|
|
109
111
|
this.silencelength = 0;
|
|
112
|
+
if (cents) {
|
|
113
|
+
// the pitch is altered so send a midi pitch wheel event
|
|
114
|
+
this.track += "%e" + this.channel.toString(16);
|
|
115
|
+
var bend = Math.round(centsToFactor(cents)*HALF_STEP);
|
|
116
|
+
this.track += to7BitHex(0x2000 + bend);
|
|
117
|
+
this.track += toDurationHex(0); // this all happens at once so there is a zero length here
|
|
118
|
+
this.noteWarped[pitch] = true;
|
|
119
|
+
}
|
|
110
120
|
this.track += this.noteOnAndChannel;
|
|
111
121
|
this.track += "%" + pitch.toString(16) + toHex(loudness, 2); //note
|
|
112
122
|
};
|
|
@@ -114,7 +124,13 @@ var rendererFactory;
|
|
|
114
124
|
Midi.prototype.endNote = function(pitch) {
|
|
115
125
|
this.track += toDurationHex(this.silencelength); // only need to shift by amount of silence (if there is any)
|
|
116
126
|
this.silencelength = 0;
|
|
117
|
-
|
|
127
|
+
if (this.noteWarped[pitch]) {
|
|
128
|
+
// the pitch was altered so alter it back.
|
|
129
|
+
this.track += "%e" + this.channel.toString(16);
|
|
130
|
+
this.track += to7BitHex(0x2000);
|
|
131
|
+
this.track += toDurationHex(0); // this all happens at once so there is a zero length here
|
|
132
|
+
this.noteWarped[pitch] = false;
|
|
133
|
+
}
|
|
118
134
|
this.track += this.noteOffAndChannel;
|
|
119
135
|
this.track += "%" + pitch.toString(16) + "%00";//end note
|
|
120
136
|
};
|
|
@@ -229,12 +245,23 @@ var rendererFactory;
|
|
|
229
245
|
|
|
230
246
|
function toHex(n, padding) {
|
|
231
247
|
var s = n.toString(16);
|
|
248
|
+
s = s.split(".")[0];
|
|
232
249
|
while (s.length < padding) {
|
|
233
250
|
s = "0" + s;
|
|
234
251
|
}
|
|
252
|
+
if (s.length > padding)
|
|
253
|
+
s = s.substring(0,padding)
|
|
235
254
|
return encodeHex(s);
|
|
236
255
|
}
|
|
237
256
|
|
|
257
|
+
function to7BitHex(n) {
|
|
258
|
+
// this takes a number and shifts all digits from the 7th one to the left.
|
|
259
|
+
n = Math.round(n);
|
|
260
|
+
var lower = n % 128;
|
|
261
|
+
var higher = n - lower;
|
|
262
|
+
return toHex(higher*2+lower, 4);
|
|
263
|
+
}
|
|
264
|
+
|
|
238
265
|
function toDurationHex(n) {
|
|
239
266
|
var res = 0;
|
|
240
267
|
var a = [];
|