abcjs 6.1.9 → 6.2.1

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.
Files changed (135) hide show
  1. package/LICENSE.md +1 -1
  2. package/RELEASE.md +58 -0
  3. package/dist/abcjs-basic-min.js +2 -2
  4. package/dist/abcjs-basic-min.js.LICENSE +1 -1
  5. package/dist/abcjs-basic.js +4505 -4556
  6. package/dist/abcjs-basic.js.map +1 -1
  7. package/dist/abcjs-plugin-min.js +2 -2
  8. package/dist/abcjs-plugin-min.js.LICENSE +1 -1
  9. package/index.js +2 -2
  10. package/license.js +1 -1
  11. package/package.json +1 -1
  12. package/plugin.js +2 -2
  13. package/src/api/abc_timing_callbacks.js +8 -4
  14. package/src/api/abc_tunebook_svg.js +1 -2
  15. package/src/data/abc_tune.js +3 -3
  16. package/src/parse/abc_common.js +0 -47
  17. package/src/parse/abc_parse.js +16 -16
  18. package/src/parse/abc_parse_book.js +3 -3
  19. package/src/parse/abc_parse_directive.js +26 -7
  20. package/src/parse/abc_parse_header.js +11 -9
  21. package/src/parse/abc_parse_key_voice.js +17 -17
  22. package/src/parse/abc_parse_music.js +88 -105
  23. package/src/parse/abc_tokenizer.js +60 -60
  24. package/src/parse/tune-builder.js +19 -14
  25. package/src/synth/abc_midi_flattener.js +25 -9
  26. package/src/synth/create-synth.js +71 -4
  27. package/src/synth/load-note.js +1 -1
  28. package/src/synth/note-to-midi.js +50 -0
  29. package/src/synth/place-note.js +10 -2
  30. package/src/tablatures/instruments/guitar/tab-guitar.js +0 -2
  31. package/src/tablatures/instruments/string-patterns.js +47 -29
  32. package/src/tablatures/instruments/tab-note.js +26 -103
  33. package/src/tablatures/instruments/violin/tab-violin.js +0 -2
  34. package/src/tablatures/tab-absolute-elements.js +9 -31
  35. package/src/tablatures/tab-renderer.js +2 -2
  36. package/src/test/abc_parser_lint.js +7 -4
  37. package/src/write/README.md +31 -0
  38. package/src/write/creation/abstract-engraver.js +1036 -0
  39. package/src/write/creation/add-chord.js +102 -0
  40. package/src/write/{add-text-if.js → creation/add-text-if.js} +6 -6
  41. package/src/write/{calcHeight.js → creation/calc-height.js} +2 -2
  42. package/src/write/creation/create-clef.js +72 -0
  43. package/src/write/creation/create-key-signature.js +31 -0
  44. package/src/write/creation/create-note-head.js +107 -0
  45. package/src/write/creation/create-time-signature.js +55 -0
  46. package/src/write/creation/decoration.js +357 -0
  47. package/src/write/{abc_absolute_element.js → creation/elements/absolute-element.js} +14 -15
  48. package/src/write/creation/elements/beam-element.js +113 -0
  49. package/src/write/{bottom-text.js → creation/elements/bottom-text.js} +14 -15
  50. package/src/write/{abc_brace_element.js → creation/elements/brace-element.js} +5 -5
  51. package/src/write/creation/elements/free-text.js +41 -0
  52. package/src/write/{abc_relative_element.js → creation/elements/relative-element.js} +7 -7
  53. package/src/write/{separator.js → creation/elements/separator.js} +2 -2
  54. package/src/write/{abc_staff_group_element.js → creation/elements/staff-group-element.js} +4 -4
  55. package/src/write/{subtitle.js → creation/elements/subtitle.js} +3 -3
  56. package/src/write/creation/elements/tempo-element.js +63 -0
  57. package/src/write/{abc_tie_element.js → creation/elements/tie-element.js} +15 -11
  58. package/src/write/{top-text.js → creation/elements/top-text.js} +12 -12
  59. package/src/write/creation/elements/triplet-element.js +28 -0
  60. package/src/write/{abc_voice_element.js → creation/elements/voice-element.js} +3 -3
  61. package/src/write/creation/glyphs.js +226 -0
  62. package/src/write/creation/translate-chord.js +37 -0
  63. package/src/write/draw/absolute.js +5 -5
  64. package/src/write/draw/beam.js +8 -8
  65. package/src/write/draw/brace.js +33 -33
  66. package/src/write/draw/crescendo.js +4 -4
  67. package/src/write/draw/debug-box.js +1 -1
  68. package/src/write/draw/draw.js +7 -7
  69. package/src/write/draw/dynamics.js +2 -2
  70. package/src/write/draw/ending.js +6 -6
  71. package/src/write/draw/glissando.js +17 -17
  72. package/src/write/draw/group-elements.js +51 -51
  73. package/src/write/draw/horizontal-line.js +9 -9
  74. package/src/write/draw/non-music.js +1 -1
  75. package/src/write/draw/print-line.js +25 -16
  76. package/src/write/draw/print-stem.js +15 -5
  77. package/src/write/draw/print-symbol.js +12 -12
  78. package/src/write/draw/print-vertical-line.js +8 -8
  79. package/src/write/draw/relative.js +17 -16
  80. package/src/write/draw/selectables.js +5 -5
  81. package/src/write/draw/separator.js +4 -4
  82. package/src/write/draw/set-paper-size.js +2 -2
  83. package/src/write/draw/sprintf.js +31 -31
  84. package/src/write/draw/staff-group.js +36 -30
  85. package/src/write/draw/staff-line.js +2 -2
  86. package/src/write/draw/staff.js +4 -4
  87. package/src/write/draw/tab-line.js +26 -26
  88. package/src/write/draw/tempo.js +30 -30
  89. package/src/write/draw/text.js +5 -5
  90. package/src/write/draw/tie.js +18 -18
  91. package/src/write/draw/triplet.js +6 -6
  92. package/src/write/draw/voice.js +16 -17
  93. package/src/write/{abc_engraver_controller.js → engraver-controller.js} +58 -51
  94. package/src/write/{classes.js → helpers/classes.js} +6 -6
  95. package/src/write/{get-font-and-attr.js → helpers/get-font-and-attr.js} +9 -7
  96. package/src/write/{get-text-size.js → helpers/get-text-size.js} +5 -5
  97. package/src/write/{set-class.js → helpers/set-class.js} +1 -1
  98. package/src/write/{abc_spacing.js → helpers/spacing.js} +1 -1
  99. package/src/write/{highlight.js → interactive/highlight.js} +1 -1
  100. package/src/write/{selection.js → interactive/selection.js} +34 -31
  101. package/src/write/{unhighlight.js → interactive/unhighlight.js} +1 -1
  102. package/src/write/layout/beam.js +13 -13
  103. package/src/write/layout/get-left-edge-of-staff.js +4 -4
  104. package/src/write/layout/layout.js +74 -74
  105. package/src/write/layout/{setUpperAndLowerElements.js → set-upper-and-lower-elements.js} +8 -8
  106. package/src/write/layout/{staffGroup.js → staff-group.js} +32 -32
  107. package/src/write/layout/triplet.js +4 -4
  108. package/src/write/layout/{VoiceElements.js → voice-elements.js} +23 -23
  109. package/src/write/layout/voice.js +6 -6
  110. package/src/write/{abc_renderer.js → renderer.js} +36 -32
  111. package/src/write/svg.js +35 -35
  112. package/test.js +2 -2
  113. package/types/index.d.ts +37 -8
  114. package/version.js +1 -1
  115. package/src/tablatures/instruments/guitar/guitar-fonts.js +0 -19
  116. package/src/tablatures/instruments/violin/violin-fonts.js +0 -19
  117. package/src/tablatures/transposer.js +0 -110
  118. package/src/write/abc_abstract_engraver.js +0 -1026
  119. package/src/write/abc_beam_element.js +0 -113
  120. package/src/write/abc_create_clef.js +0 -72
  121. package/src/write/abc_create_key_signature.js +0 -33
  122. package/src/write/abc_create_note_head.js +0 -107
  123. package/src/write/abc_create_time_signature.js +0 -55
  124. package/src/write/abc_decoration.js +0 -357
  125. package/src/write/abc_glyphs.js +0 -224
  126. package/src/write/abc_tempo_element.js +0 -63
  127. package/src/write/abc_triplet_element.js +0 -28
  128. package/src/write/add-chord.js +0 -103
  129. package/src/write/format-jazz-chord.js +0 -15
  130. package/src/write/free-text.js +0 -41
  131. /package/src/write/{abc_crescendo_element.js → creation/elements/crescendo-element.js} +0 -0
  132. /package/src/write/{abc_dynamic_decoration.js → creation/elements/dynamic-decoration.js} +0 -0
  133. /package/src/write/{abc_ending_element.js → creation/elements/ending-element.js} +0 -0
  134. /package/src/write/{abc_glissando_element.js → creation/elements/glissando-element.js} +0 -0
  135. /package/src/write/layout/{getBarYAt.js → get-bar-y-at.js} +0 -0
package/types/index.d.ts CHANGED
@@ -51,7 +51,7 @@ declare module 'abcjs' {
51
51
  "wordsfont" | "annotationfont" | "scale" | "partsbox" | "freegchord" | "fontboxpadding" | "stretchlast" | "tablabelfont" | "tabnumberfont" | "tabgracefont";
52
52
 
53
53
  export type MidiCommands = "nobarlines" | "barlines" | "beataccents" | "nobeataccents" | "droneon" | "droneoff" | "noportamento" | "channel" | "c" |
54
- "drumon" | "drumoff" | "fermatafixed" | "fermataproportional" | "gchordon" | "gchordoff" | "bassvol" | "chordvol" |
54
+ "drumon" | "drumoff" | "fermatafixed" | "fermataproportional" | "gchordon" | "gchordoff" | "bassvol" | "chordvol" | "bassprog" | "chordprog" |
55
55
  "controlcombo" | "temperamentnormal" | "gchord" | "ptstress" | "beatmod" | "deltaloudness" | "drumbars" | "pitchbend" |
56
56
  "gracedivider" | "makechordchannels" | "randomchordattack" | "chordattack" | "stressmodel" | "transpose" |
57
57
  "rtranspose" | "volinc" | "program" | "ratio" | "snt" | "bendvelocity" | "control" | "temperamentlinear" | "beat" | "beatstring" |
@@ -172,6 +172,32 @@ declare module 'abcjs' {
172
172
 
173
173
  export type MidiPitches = Array<MidiPitch>;
174
174
 
175
+ export interface RelativeElement {
176
+ x: number;
177
+ c: string;
178
+ dx: number;
179
+ w: number;
180
+ pitch: number;
181
+ pitch2?: number;
182
+ scaleX: number;
183
+ scaleY: number;
184
+ type: string;
185
+ name: string;
186
+ linewidth?: number;
187
+ klass?: string;
188
+ anchor?: "start" | "middle" | "end";
189
+ top: number;
190
+ bottom: number;
191
+ dim?: number;
192
+ position?: number;
193
+ realWidth?: number;
194
+ partHeightAbove?: number;
195
+ chordHeightAbove?: number;
196
+ chordHeightBelow?: number;
197
+ lyricHeightAbove?: number;
198
+ lyricHeightBelow?: number;
199
+ }
200
+
175
201
  export interface AbsoluteElement {
176
202
  abcelem : AbcElem;
177
203
  bottom : number;
@@ -233,11 +259,13 @@ declare module 'abcjs' {
233
259
  dragColor?: string;
234
260
  dragging?: boolean;
235
261
  foregroundColor?: string;
236
- format?: { [attr: FormatAttributes]: any };
262
+ format?: { [attr in FormatAttributes]: any };
237
263
  header_only?: boolean;
238
264
  initialClef?: boolean;
239
265
  jazzchords?: boolean;
266
+ germanAlphabet?: boolean;
240
267
  lineBreaks?: Array<number>;
268
+ lineThickness?: number;
241
269
  minPadding?: number;
242
270
  oneSvgPerLine?: boolean;
243
271
  paddingbottom?: number;
@@ -797,7 +825,7 @@ declare module 'abcjs' {
797
825
  getPickupLength: NumberFunction;
798
826
  getKeySignature: () => KeySignature;
799
827
  getElementFromChar: (charPos: number) => VoiceItem | null;
800
- millisecondsPerMeasure: NumberFunction;
828
+ millisecondsPerMeasure: (bpm?: number) => number;
801
829
  setTiming: (bpm?: number, measuresOfDelay? : number) => void;
802
830
  setUpAudio: (options: SynthOptions) => AudioTracks;
803
831
  makeVoicesArray: () => Array<Selectable[]>
@@ -913,7 +941,7 @@ declare module 'abcjs' {
913
941
  ev: NoteTimingEvent;
914
942
  endMs: number;
915
943
  offMs: number;
916
- offPs: number;
944
+ offPx: number;
917
945
  gapMs: number;
918
946
  gapPx: number;
919
947
  }
@@ -1114,7 +1142,7 @@ declare module 'abcjs' {
1114
1142
 
1115
1143
  export interface MidiBuffer {
1116
1144
  init(params?: MidiBufferOptions): Promise<MidiBufferPromise>
1117
- prime(): Promise<void>
1145
+ prime(): Promise<{ status: string, duration: number}>
1118
1146
  start(): void
1119
1147
  pause(): number
1120
1148
  resume(): void
@@ -1135,14 +1163,15 @@ declare module 'abcjs' {
1135
1163
  export interface SynthObjectController {
1136
1164
  disable(isDisabled: boolean): void
1137
1165
  setTune(visualObj: TuneObject, userAction: boolean, audioParams?: SynthOptions): Promise<SynthInitResponse>
1138
- load(selector: string, cursorControl?: CursorControl | null, visualOptions?: SynthVisualOptions): void
1166
+ load(selector: Selector, cursorControl?: CursorControl | null, visualOptions?: SynthVisualOptions): void
1139
1167
  play(): void
1140
1168
  pause(): void
1141
1169
  toggleLoop(): void
1142
1170
  restart(): void
1143
1171
  setProgress(ev: number): void
1144
- setWarp(percent: number): void
1172
+ setWarp(percent: number): Promise<void>
1145
1173
  download(fName: string): void
1174
+ getAudioBuffer(): AudioBuffer | undefined
1146
1175
  }
1147
1176
 
1148
1177
  export interface SynthSequenceClass {
@@ -1163,7 +1192,7 @@ declare module 'abcjs' {
1163
1192
  export function activeAudioContext(): AudioContext
1164
1193
  export function CreateSynthControl(element: Selector, options: AbcVisualParams): AudioControl
1165
1194
  export function getMidiFile(source: string | TuneObject, options?: MidiFileOptions): MidiFile;
1166
- export function playEvent(pitches: MidiPitches, graceNotes: MidiGracePitches, milliSecondsPerMeasure: number): Promise<void>;
1195
+ export function playEvent(pitches: MidiPitches, graceNotes: MidiGracePitches | undefined, milliSecondsPerMeasure: number): Promise<void>;
1167
1196
  export function sequence(visualObj: TuneObject, options: AbcVisualParams): AudioSequence
1168
1197
  }
1169
1198
 
package/version.js CHANGED
@@ -1,3 +1,3 @@
1
- var version = '6.1.9';
1
+ var version = '6.2.1';
2
2
 
3
3
  module.exports = version;
@@ -1,19 +0,0 @@
1
-
2
- /**
3
- * Dedicated fonts for violin tabs
4
- */
5
-
6
- /**
7
- * Set here the fonts used by renderer/drawer
8
- * for the violin plugin
9
- * @param {} tune
10
- */
11
- // eslint-disable-next-line no-unused-vars
12
- function setGuitarFonts(tune) {
13
- /* enhance or change instrument fonts here */
14
- // tune.formatting.tabnumberfont = { face: "\"Times New Roman\"", size: 9, weight: "normal", style: "normal", decoration: "none" };
15
- // tune.formatting.tabgracefont = { face: "\"Times New Roman\"", size: 7, weight: "normal", style: "normal", decoration: "none" };
16
- }
17
-
18
- module.exports = setGuitarFonts;
19
-
@@ -1,19 +0,0 @@
1
-
2
- /**
3
- * Dedicated fonts for violin tabs
4
- */
5
-
6
- /**
7
- * Set here the fonts used by renderer/drawer
8
- * for the violin plugin
9
- * @param {} tune
10
- */
11
- // eslint-disable-next-line no-unused-vars
12
- function setViolinFonts(tune) {
13
- /* enhance or change instrument fonts here */
14
- // tune.formatting.tabnumberfont = { face: "\"Times New Roman\"", size: 9, weight: "normal", style: "normal", decoration: "none" };
15
- // tune.formatting.tabgracefont = { face: "\"Times New Roman\"", size: 7, weight: "normal", style: "normal", decoration: "none" };
16
- }
17
-
18
- module.exports = setViolinFonts;
19
-
@@ -1,110 +0,0 @@
1
- /**
2
- *
3
- * generic transposer
4
- *
5
- */
6
- var TabNote = require('./instruments/tab-note');
7
-
8
-
9
-
10
- function buildAccEquiv(acc,note) {
11
- var equiv = note.getAccidentalEquiv();
12
- if (acc.note.toUpperCase() == equiv.name.toUpperCase()) {
13
- equiv.isSharp = false;
14
- equiv.isFlat = false;
15
- return equiv;
16
- }
17
- return note;
18
- }
19
-
20
- function adjustNoteToKey(acc, note) {
21
- if (acc.acc == 'sharp') {
22
- if (note.isFlat) {
23
- return buildAccEquiv(acc, note);
24
- } else if (note.isSharp) {
25
- if (acc.note.toUpperCase() == note.name.toUpperCase()) {
26
- note.isSharp = false;
27
- note.isKeySharp = true;
28
- } else {
29
- if (acc.note.toUpperCase() == note.name.toUpperCase()) {
30
- note.natural = true;
31
- }
32
- }
33
- }
34
- } else if (acc.acc == 'flat') {
35
- if (note.isSharp) {
36
- return buildAccEquiv(acc, note);
37
- } else if (note.isFlat) {
38
- if (acc.note.toUpperCase() == note.name.toUpperCase()) {
39
- note.isFlat = false;
40
- note.isKeyFlat = true;
41
- }
42
- } else {
43
- if (acc.note.toUpperCase() == note.name.toUpperCase()) {
44
- note.natural = true;
45
- }
46
- }
47
- }
48
- return note;
49
- }
50
-
51
-
52
- function replaceNote(self, newNote, start, end) {
53
- if (self.lastEnd) {
54
- while (start > self.lastEnd) {
55
- self.updatedSrc.push(self.abcSrc[self.lastEnd]);
56
- self.lastEnd++;
57
- }
58
- }
59
- var nNote = newNote.split('');
60
- for (var ii = 0; ii < nNote.length; ii++) {
61
- self.updatedSrc.push(nNote[ii]);
62
- }
63
- var curPos = start + ii;
64
- while (end >= curPos) {
65
- self.updatedSrc.push(nNote[curPos]);
66
- curPos++;
67
- }
68
- self.lastEnd = end;
69
- }
70
-
71
-
72
- function checkKeys(self, note) {
73
- var accs = self.transposedKey;
74
- for (var ii = 0; ii < accs.length; ii++) {
75
- note = adjustNoteToKey(accs[ii], note);
76
- }
77
- return note;
78
- }
79
-
80
- Transposer.prototype.transposeNote = function (note) {
81
- var returned = note;
82
- var curNote = new TabNote.TabNote(returned.name);
83
- if (this.transposeBy > 0) {
84
- for (var ii = 0; ii < this.transposeBy; ii++) {
85
- curNote = checkKeys(this,curNote.nextNote());
86
- }
87
-
88
- } else if ( this.transposeBy < 0) {
89
- for (var jj = this.transposeBy; jj < 0; jj++) {
90
- curNote = checkKeys(this,curNote.prevNote());
91
- }
92
- }
93
- returned.name = curNote.emit();
94
- return returned;
95
- };
96
-
97
- Transposer.prototype.upgradeSource = function (note, startChar, endChar ) {
98
- var n = new TabNote.TabNote(note.name);
99
- var newNote = n.emit();
100
- replaceNote(this, newNote, startChar, endChar-1);
101
- };
102
-
103
- function Transposer(transposedKey , transposeBy ) {
104
- this.transposeBy = transposeBy;
105
- this.transposedKey = transposedKey;
106
- this.lastEnd = this.kEnd+1;
107
- }
108
-
109
-
110
- module.exports = Transposer;