abcjs 6.0.0-beta.32 → 6.0.0-beta.36

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 (97) hide show
  1. package/README.md +13 -7
  2. package/RELEASE.md +130 -0
  3. package/dist/abcjs-basic-min.js +2 -2
  4. package/dist/abcjs-basic.js +3763 -825
  5. package/dist/abcjs-basic.js.map +1 -1
  6. package/dist/abcjs-plugin-min.js +2 -2
  7. package/dist/report-basic.html +37 -0
  8. package/dist/report-before-glyph-compress.html +37 -0
  9. package/dist/report-brown-ts-target-es5.html +37 -0
  10. package/dist/report-dev-orig-no-babel.html +37 -0
  11. package/dist/report-synth.html +37 -0
  12. package/docker-build.sh +1 -0
  13. package/glyphs.json +1 -0
  14. package/package.json +9 -9
  15. package/src/api/abc_tablatures.js +144 -0
  16. package/src/api/abc_timing_callbacks.js +49 -26
  17. package/src/api/abc_tunebook.js +10 -1
  18. package/src/api/abc_tunebook_svg.js +16 -22
  19. package/src/data/abc_tune.js +90 -25
  20. package/src/data/deline-tune.js +199 -0
  21. package/src/edit/abc_editor.js +33 -11
  22. package/src/midi/abc_midi_create.js +6 -2
  23. package/src/parse/abc_parse.js +10 -6
  24. package/src/parse/abc_parse_directive.js +19 -12
  25. package/src/parse/abc_parse_header.js +12 -12
  26. package/src/parse/abc_parse_music.js +15 -5
  27. package/src/parse/tune-builder.js +23 -30
  28. package/src/parse/wrap_lines.js +13 -36
  29. package/src/synth/abc_midi_flattener.js +44 -29
  30. package/src/synth/abc_midi_sequencer.js +52 -13
  31. package/src/synth/create-synth.js +22 -7
  32. package/src/synth/load-note.js +31 -65
  33. package/src/synth/place-note.js +59 -60
  34. package/src/synth/register-audio-context.js +4 -1
  35. package/src/synth/supports-audio.js +9 -8
  36. package/src/synth/synth-controller.js +5 -3
  37. package/src/tablatures/instruments/guitar/guitar-fonts.js +19 -0
  38. package/src/tablatures/instruments/guitar/guitar-patterns.js +23 -0
  39. package/src/tablatures/instruments/guitar/tab-guitar.js +50 -0
  40. package/src/tablatures/instruments/string-patterns.js +277 -0
  41. package/src/tablatures/instruments/string-tablature.js +56 -0
  42. package/src/tablatures/instruments/tab-note.js +282 -0
  43. package/src/tablatures/instruments/tab-notes.js +41 -0
  44. package/src/tablatures/instruments/violin/tab-violin.js +47 -0
  45. package/src/tablatures/instruments/violin/violin-fonts.js +19 -0
  46. package/src/tablatures/instruments/violin/violin-patterns.js +23 -0
  47. package/src/tablatures/tab-absolute-elements.js +310 -0
  48. package/src/tablatures/tab-common.js +29 -0
  49. package/src/tablatures/tab-renderer.js +243 -0
  50. package/src/tablatures/transposer.js +110 -0
  51. package/src/test/abc_parser_lint.js +62 -6
  52. package/src/write/abc_absolute_element.js +2 -2
  53. package/src/write/abc_abstract_engraver.js +9 -7
  54. package/src/write/abc_create_key_signature.js +1 -0
  55. package/src/write/abc_create_note_head.js +1 -1
  56. package/src/write/abc_engraver_controller.js +22 -9
  57. package/src/write/abc_glyphs.js +5 -2
  58. package/src/write/abc_relative_element.js +11 -3
  59. package/src/write/abc_renderer.js +5 -1
  60. package/src/write/add-chord.js +5 -2
  61. package/src/write/add-text-if.js +33 -0
  62. package/src/write/bottom-text.js +8 -29
  63. package/src/write/draw/absolute.js +12 -14
  64. package/src/write/draw/brace.js +3 -3
  65. package/src/write/draw/crescendo.js +1 -1
  66. package/src/write/draw/draw.js +3 -4
  67. package/src/write/draw/dynamics.js +8 -1
  68. package/src/write/draw/ending.js +4 -3
  69. package/src/write/draw/group-elements.js +10 -8
  70. package/src/write/draw/non-music.js +11 -6
  71. package/src/write/draw/print-line.js +24 -0
  72. package/src/write/draw/print-stem.js +12 -11
  73. package/src/write/draw/print-symbol.js +11 -10
  74. package/src/write/draw/relative.js +33 -13
  75. package/src/write/draw/selectables.js +9 -6
  76. package/src/write/draw/staff-group.js +45 -9
  77. package/src/write/draw/staff-line.js +3 -17
  78. package/src/write/draw/staff.js +15 -2
  79. package/src/write/draw/tab-line.js +40 -0
  80. package/src/write/draw/tempo.js +7 -7
  81. package/src/write/draw/text.js +11 -4
  82. package/src/write/draw/tie.js +2 -2
  83. package/src/write/draw/triplet.js +3 -3
  84. package/src/write/draw/voice.js +10 -2
  85. package/src/write/format-jazz-chord.js +15 -0
  86. package/src/write/free-text.js +20 -12
  87. package/src/write/layout/VoiceElements.js +33 -1
  88. package/src/write/layout/beam.js +2 -0
  89. package/src/write/layout/staffGroup.js +37 -2
  90. package/src/write/layout/voice.js +2 -1
  91. package/src/write/selection.js +15 -5
  92. package/src/write/separator.js +1 -1
  93. package/src/write/subtitle.js +3 -3
  94. package/src/write/svg.js +41 -14
  95. package/src/write/top-text.js +19 -25
  96. package/types/index.d.ts +1007 -39
  97. package/version.js +1 -1
package/types/index.d.ts CHANGED
@@ -1,50 +1,1002 @@
1
1
  declare module 'abcjs' {
2
2
  //
3
- // Global syntactic sugar types
3
+ // Enumerations
4
+ //
5
+
6
+ export type Clef = 'treble' | 'tenor' | 'bass' | 'alto' | 'treble+8' | 'tenor+8' | 'bass+8' | 'alto+8' | 'treble-8' | 'tenor-8' | 'bass-8' | 'alto-8' | 'none' | 'perc';
7
+
8
+ export type Bar = 'bar_dbl_repeat' | 'bar_right_repeat' | 'bar_left_repeat' | 'bar_invisible' | 'bar_thick_thin' | 'bar_thin_thin' | 'bar_thin' | 'bar_thin_thick';
9
+
10
+ export type MeterType = 'common_time' | 'cut_time' | 'specified' | 'tempus_perfectum' | 'tempus_imperfectum' | 'tempus_perfectum_prolatio' | 'tempus_imperfectum_prolatio';
11
+
12
+ export type NoteLetter = 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g';
13
+
14
+ export type AccidentalName = 'flat' | 'natural' | 'sharp' | 'dblsharp' | 'dblflat' | 'quarterflat' | 'quartersharp';
15
+
16
+ export type ChordRoot = 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G';
17
+
18
+ export type KeyRoot = 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'HP' | 'Hp' | 'none';
19
+
20
+ export type KeyAccidentalName = '' | '#' | 'b';
21
+
22
+ export type Mode = '' | 'm' | 'Dor' | 'Mix' | 'Loc' | 'Phr' | 'Lyd';
23
+
24
+ export type ChordType = '' | 'm' | '7' | 'm7' | 'maj7' | 'M7' | '6' | 'm6' | 'aug' | '+' | 'aug7' | 'dim' | 'dim7' | '9' |
25
+ 'm9' | 'maj9' | 'M9' | '11' | 'dim9' | 'sus' | 'sus9' | '7sus4' | '7sus9' | '5';
26
+
27
+ export type Placement = 'above' | 'below';
28
+
29
+ export type ChordPlacement = 'above' | 'below' | 'left' | 'right' | 'default';
30
+
31
+ export type BracePosition = "start" | "continue" | "end";
32
+
33
+ export type Alignment = 'left' | 'center' |'right';
34
+
35
+ export type Media = 'screen' | 'print';
36
+
37
+ export type ProgressUnit = "seconds" | "beats" | "percent";
38
+
39
+ export type NoteTimingEventType = "end" | "event";
40
+
41
+ export type MidiOutputType = 'encoded' | 'binary' | 'link';
42
+
43
+ export type Responsive = 'resize';
44
+
45
+ export type DragTypes = "author" | "bar" | "brace" | "clef" | "composer" | "dynamicDecoration" | "ending" | "extraText" |
46
+ "freeText" | "keySignature" | "note" | "part" | "partOrder" | "rhythm" | "slur" | "subtitle" | "tempo" | "timeSignature" | "title" |
47
+ "unalignedWords" | "voiceName";
48
+
49
+ export type FormatAttributes = "titlefont" | "gchordfont" | "composerfont" | "footerfont" | "headerfont" | "historyfont" | "infofont" |
50
+ "measurefont" | "partsfont" | "repeatfont" | "subtitlefont" | "tempofont" | "textfont" | "voicefont" | "tripletfont" | "vocalfont" |
51
+ "wordsfont" | "annotationfont" | "scale" | "partsbox" | "freegchord" | "fontboxpadding" | "stretchlast" | "tablabelfont" | "tabnumberfont" | "tabgracefont";
52
+
53
+ export type MidiCommands = "nobarlines" | "barlines" | "beataccents" | "nobeataccents" | "droneon" | "droneoff" | "noportamento" | "channel" | "c" |
54
+ "drumon" | "drumoff" | "fermatafixed" | "fermataproportional" | "gchordon" | "gchordoff" | "bassvol" | "chordvol" |
55
+ "controlcombo" | "temperamentnormal" | "gchord" | "ptstress" | "beatmod" | "deltaloudness" | "drumbars" | "pitchbend" |
56
+ "gracedivider" | "makechordchannels" | "randomchordattack" | "chordattack" | "stressmodel" | "transpose" |
57
+ "rtranspose" | "volinc" | "program" | "ratio" | "snt" | "bendvelocity" | "control" | "temperamentlinear" | "beat" | "beatstring" |
58
+ "drone" | "bassprog" | "chordprog" | "drummap" | "portamento" | "expand" | "grace" | "trim" | "drum" | "chordname";
59
+
60
+ export type StemDirection = 'up' | 'down' | 'auto' | 'none';
61
+
62
+ export type NoteHeadType = 'normal' | 'harmonic' | 'rhythm' | 'x' | 'triangle';
63
+
64
+ export type Decorations = "trill" | "lowermordent" | "uppermordent" | "mordent" | "pralltriller" | "accent" |
65
+ "fermata" | "invertedfermata" | "tenuto" | "0" | "1" | "2" | "3" | "4" | "5" | "+" | "wedge" |
66
+ "open" | "thumb" | "snap" | "turn" | "roll" | "irishroll" | "breath" | "shortphrase" | "mediumphrase" | "longphrase" |
67
+ "segno" | "coda" | "D.S." | "D.C." | "fine" | "crescendo(" | "crescendo)" | "diminuendo(" | "diminuendo)" |
68
+ "p" | "pp" | "f" | "ff" | "mf" | "mp" | "ppp" | "pppp" | "fff" | "ffff" | "sfz" | "repeatbar" | "repeatbar2" | "slide" |
69
+ "upbow" | "downbow" | "staccato" | "trem1" | "trem2" | "trem3" | "trem4" |
70
+ "/" | "//" | "///" | "////" | "turnx" | "invertedturn" | "invertedturnx" | "arpeggio" | "trill(" | "trill)" | "xstem" |
71
+ "mark" | "marcato" | "umarcato"
72
+
73
+ //
74
+ // Basic types
4
75
  //
5
- export type TuneObject = any
6
- export type TuneObjectArray = [TuneObject]
7
- export type AudioContext = any
8
- export type AudioControl = any
9
- export type AudioSequence = any
10
76
  export type Selector = String | HTMLElement
11
- export type MidiFile = any
12
77
 
13
- // TODO : to be detailed and enhanced later
14
- export type Pitches = [any]
78
+ type NumberFunction = () => number;
79
+
80
+ export interface MeterFraction {
81
+ num: string;
82
+ den?: string;
83
+ }
84
+
85
+ export interface ClefProperties {
86
+ stafflines?: number;
87
+ staffscale?: number;
88
+ transpose?: number;
89
+ type: Clef;
90
+ verticalPos: number;
91
+ clefPos?: number;
92
+ }
93
+
94
+ export interface Meter {
95
+ type: MeterType;
96
+ value?: Array<MeterFraction>;
97
+ beat_division?: Array<MeterFraction>;
98
+ }
99
+
100
+ export interface Accidental {
101
+ acc: AccidentalName;
102
+ note: NoteLetter;
103
+ verticalPos: number;
104
+ }
105
+
106
+ export interface KeySignature {
107
+ accidentals?: Array<Accidental>;
108
+ root: KeyRoot;
109
+ acc: KeyAccidentalName;
110
+ mode: Mode;
111
+ }
112
+
113
+ export interface Font {
114
+ face: string;
115
+ size: number;
116
+ weight: 'normal' | 'bold';
117
+ style: 'normal' | 'italic';
118
+ decoration: 'none' | 'underline';
119
+ }
120
+
121
+ export interface TempoProperties {
122
+ duration?: Array<number>;
123
+ bpm?: number;
124
+ endChar: number;
125
+ preString?: string;
126
+ postString?: string;
127
+ startChar: number;
128
+ suppress?: boolean;
129
+ suppressBpm?: boolean;
130
+ }
131
+
132
+ export interface TextFieldProperties {
133
+ endChar?: number;
134
+ font: Font;
135
+ text: string;
136
+ center?: boolean;
137
+ startChar?: number;
138
+ }
139
+
140
+ export interface ChordProperties {
141
+ name: string;
142
+ chord: {
143
+ root: ChordRoot;
144
+ type: ChordType;
145
+ },
146
+ position?: ChordPlacement
147
+ rel_position?: {
148
+ x: number;
149
+ y: number;
150
+ }
151
+ }
152
+
153
+ export interface CharRange {
154
+ startChar: number;
155
+ endChar: number;
156
+ }
157
+
158
+ export type MidiParam = Array<string|number>;
159
+
160
+ export type MidiGracePitches = Array<{instrument: string; pitch: number; volume: number; cents?: number}>;
161
+
162
+ export interface MidiPitch {
163
+ instrument: string;
164
+ pitch: number;
165
+ duration: number;
166
+ volume: number;
167
+ cents?: number
168
+ }
169
+
170
+ export type MidiPitches = Array<MidiPitch>;
171
+
172
+ export type AbsoluteElement = any; // TODO
173
+
174
+ export type NoteProperties = any; // TODO
175
+
176
+ export type AudioTrackCommand = 'program' | 'text' | 'note';
177
+ //
178
+ // Input Types
179
+ //
180
+
181
+ // renderAbc
182
+ export interface Wrap {
183
+ preferredMeasuresPerLine: number;
184
+ minSpacing: number;
185
+ maxSpacing: number;
186
+ lastLineLimit?: number;
187
+ minSpacingLimit?: number;
188
+ }
189
+
190
+ export interface AbcVisualParams {
191
+ add_classes?: boolean;
192
+ afterParsing?: AfterParsing;
193
+ ariaLabel?: string;
194
+ clickListener?: ClickListener;
195
+ dragColor?: string;
196
+ dragging?: boolean;
197
+ foregroundColor?: string;
198
+ format?: { [attr: FormatAttributes]: any };
199
+ header_only?: boolean;
200
+ initialClef?: boolean;
201
+ jazzchords?: boolean;
202
+ lineBreaks?: Array<number>;
203
+ minPadding?: number;
204
+ oneSvgPerLine?: boolean;
205
+ paddingbottom?: number;
206
+ paddingleft?: number;
207
+ paddingright?: number;
208
+ paddingtop?: number;
209
+ print?: boolean;
210
+ responsive?: Responsive;
211
+ scale?: number;
212
+ scrollHorizontal?: boolean;
213
+ selectionColor?: string;
214
+ selectTypes?: boolean | Array<DragTypes>;
215
+ showDebug?: Array<"grid" | "box">;
216
+ staffwidth?: number;
217
+ startingTune?: number;
218
+ stop_on_warning?: boolean;
219
+ textboxpadding?: number;
220
+ viewportHorizontal?: boolean;
221
+ viewportVertical?: boolean;
222
+ visualTranspose?: number;
223
+ wrap?: Wrap;
224
+ }
225
+
226
+ // TimingCallbacks
227
+ export interface AnimationOptions {
228
+ qpm?: number;
229
+ extraMeasuresAtBeginning?: number;
230
+ lineEndAnticipation?: number;
231
+ beatSubdivisions?: number;
232
+ beatCallback?: BeatCallback;
233
+ eventCallback?: EventCallback;
234
+ lineEndCallback?: LineEndCallback;
235
+ }
236
+
237
+ // Editor
238
+
239
+ export interface EditorSynth {
240
+ synthControl?: SynthObjectController;
241
+ el: Selector;
242
+ cursorControl: CursorControl;
243
+ options: SynthOptions;
244
+ }
245
+
246
+ export interface EditorOptions {
247
+ canvas_id?: Selector;
248
+ paper_id?: Selector;
249
+ generate_warnings?: boolean;
250
+ warnings_id?: Selector;
251
+ onchange?: OnChange;
252
+ selectionChangeCallback?: SelectionChangeCallback;
253
+ abcjsParams?: AbcVisualParams;
254
+ indicate_changed?: boolean;
255
+ synth?: EditorSynth;
256
+ }
257
+
258
+ // Audio
259
+ export interface NoteMapTrackItem {
260
+ pitch: number;
261
+ instrument: number;
262
+ start: number;
263
+ end: number;
264
+ volume: number;
265
+ style?: string;
266
+ cents?: number;
267
+ }
268
+ export type NoteMapTrack = Array<NoteMapTrackItem>
269
+
270
+ export interface SynthOptions {
271
+ soundFontUrl?: string;
272
+ soundFontVolumeMultiplier?: number;
273
+ programOffsets?: {[instrument: string]: number}
274
+ fadeLength?: number;
275
+ sequenceCallback?: (sequence: Array<NoteMapTrack>, context: any) => Array<NoteMapTrack>;
276
+ callbackContext?: any; // Anything is ok. It is just passed back in the callback
277
+ onEnded?: (context: any) => void;
278
+ pan?: Array<number>;
279
+ voicesOff?: boolean | Array<number>;
280
+ drum?: string;
281
+ drumBars?: number;
282
+ drumIntro?: number;
283
+ program?: number;
284
+ midiTranspose?: number;
285
+ visualTranspose?: number;
286
+ channel?: number;
287
+ qpm?: number;
288
+ defaultQpm?: number;
289
+ chordsOff?: boolean;
290
+ detuneOctave?: boolean;
291
+ }
292
+
293
+ export interface SynthVisualOptions {
294
+ displayLoop?: boolean;
295
+ displayRestart?: boolean;
296
+ displayPlay?: boolean;
297
+ displayProgress?: boolean;
298
+ displayWarp?: boolean;
299
+ }
300
+
301
+ export type DownloadLabelFn = (visualObj: TuneObject, index: number) => string;
302
+
303
+ export interface MidiFileOptions extends SynthOptions {
304
+ midiOutputType?: MidiOutputType
305
+ downloadClass?: string
306
+ preTextDownload?: string
307
+ downloadLabel?: string | DownloadLabelFn
308
+ postTextDownload?: string
309
+ fileName?: string
310
+ }
311
+
312
+ export interface MidiBufferOptions {
313
+ audioContext? : AudioContext;
314
+ visualObj?: TuneObject;
315
+ sequence?: AudioSequence;
316
+ millisecondsPerMeasure?: number;
317
+ debugCallback? : (message: string) => void;
318
+ options?: SynthOptions;
319
+ onEnded?: (context: any) => void;
320
+ }
321
+
322
+ // Glyph
323
+ export interface GlyphDef {
324
+ d: Array<[string, ...number[]]>;
325
+ w: number;
326
+ h: number;
327
+ }
328
+
329
+ //
330
+ // Return Types
331
+ //
332
+
333
+ // renderAbc
334
+ interface NoteTimingEvent {
335
+ milliseconds: number;
336
+ millisecondsPerMeasure: number;
337
+ type: NoteTimingEventType;
338
+
339
+ elements?: Array<HTMLElement>;
340
+ endChar?: number;
341
+ endCharArray?: Array<number>;
342
+ endX?: number;
343
+ height?: number;
344
+ left?: number;
345
+ line?: number;
346
+ measureNumber?: number;
347
+ midiPitches?: MidiPitches;
348
+ startChar?: number;
349
+ startCharArray?: Array<number>;
350
+ top?: number;
351
+ width?: number;
352
+ measureStart?: boolean;
353
+ }
354
+
355
+ export interface Formatting {
356
+ alignbars?: number;
357
+ aligncomposer?: Alignment;
358
+ auquality?: string;
359
+ bagpipes?: boolean;
360
+ botmargin?: number;
361
+ botspace?: number;
362
+ bstemdown?: boolean;
363
+ composerspace?: number;
364
+ continueall?: boolean;
365
+ continuous?: string;
366
+ dynalign?: boolean;
367
+ exprabove?: boolean;
368
+ exprbelow?: boolean;
369
+ flatbeams?: boolean;
370
+ footer?: string;
371
+ freegchord?: boolean;
372
+ gchordbox?: boolean;
373
+ graceSlurs?: boolean;
374
+ gracespacebefore?: number;
375
+ gracespaceinside?: number;
376
+ gracespaceafter?: number;
377
+ header?: string;
378
+ indent?: number;
379
+ infoline?: boolean;
380
+ infospace?: number;
381
+ leftmargin?: number;
382
+ linesep?: number;
383
+ lineskipfac?: number;
384
+ map?: string;
385
+ maxshrink?: number;
386
+ maxstaffsep?: number;
387
+ maxsysstaffsep?: number;
388
+ measurebox?: boolean;
389
+ midi?: {
390
+ barlines?: MidiParam;
391
+ bassprog?: MidiParam;
392
+ bassvol?: MidiParam;
393
+ beat?: MidiParam;
394
+ beataccents?: MidiParam;
395
+ beatmod?: MidiParam;
396
+ beatstring?: MidiParam;
397
+ bendvelocity?: MidiParam;
398
+ c?: MidiParam;
399
+ channel?: MidiParam;
400
+ chordattack?: MidiParam;
401
+ chordname?: MidiParam;
402
+ chordprog?: MidiParam;
403
+ chordvol?: MidiParam;
404
+ control?: MidiParam;
405
+ controlcombo?: MidiParam;
406
+ deltaloudness?: MidiParam;
407
+ drone?: MidiParam;
408
+ droneoff?: MidiParam;
409
+ droneon?: MidiParam;
410
+ drum?: MidiParam;
411
+ drumbars?: MidiParam;
412
+ drummap: MidiParam;
413
+ drumoff?: MidiParam;
414
+ drumon?: MidiParam;
415
+ expand?: MidiParam;
416
+ fermatafixed?: MidiParam;
417
+ fermataproportional?: MidiParam;
418
+ gchord?: MidiParam;
419
+ gchordon?: MidiParam;
420
+ gchordoff?: MidiParam;
421
+ grace?: MidiParam;
422
+ gracedivider?: MidiParam;
423
+ makechordchannels?: MidiParam;
424
+ nobarlines?: MidiParam;
425
+ nobeataccents?: MidiParam;
426
+ noportamento?: MidiParam;
427
+ pitchbend?: MidiParam;
428
+ program?: MidiParam;
429
+ portamento?: MidiParam;
430
+ ptstress?: MidiParam;
431
+ randomchordattack?: MidiParam;
432
+ ratio?: MidiParam;
433
+ rtranspose?: MidiParam;
434
+ snt?: MidiParam;
435
+ stressmodel?: MidiParam;
436
+ temperamentlinear?: MidiParam;
437
+ temperamentnormal?: MidiParam;
438
+ transpose?: MidiParam;
439
+ trim?: MidiParam;
440
+ volinc: MidiParam;
441
+ }
442
+ musicspace?: number;
443
+ nobarcheck?: string;
444
+ notespacingfactor?: number;
445
+ parskipfac?: number;
446
+ partsbox?: boolean;
447
+ partsspace?: number;
448
+ percmap?: any; // TODO
449
+ playtempo?: string;
450
+ rightmargin?: number;
451
+ scale?: number;
452
+ score?: string;
453
+ slurheight?: number;
454
+ splittune?: boolean;
455
+ squarebreve?: boolean;
456
+ staffsep?: number;
457
+ staffwidth?: number;
458
+ stemheight?: number;
459
+ straightflags?: boolean;
460
+ stretchlast?: number;
461
+ stretchstaff?: boolean;
462
+ subtitlespace?: number;
463
+ sysstaffsep?: number;
464
+ systemsep?: number;
465
+ textspace?: number;
466
+ titleformat?: string;
467
+ titleleft?: boolean;
468
+ titlespace?: number;
469
+ topmargin?: number;
470
+ topspace?: number;
471
+ vocalabove?: boolean;
472
+ vocalspace?: number;
473
+ wordsspace?: number;
474
+
475
+ annotationfont: Font;
476
+ composerfont: Font;
477
+ footerfont: Font;
478
+ gchordfont: Font;
479
+ headerfont: Font;
480
+ historyfont: Font;
481
+ infofont: Font;
482
+ measurefont: Font;
483
+ pageheight: number;
484
+ pagewidth: number;
485
+ partsfont: Font;
486
+ repeatfont: Font;
487
+ subtitlefont: Font;
488
+ tabgracefont: Font;
489
+ tablabelfont: Font;
490
+ tabnumberfont: Font;
491
+ tempofont: Font;
492
+ textfont: Font;
493
+ titlefont: Font;
494
+ tripletfont: Font;
495
+ vocalfont: Font;
496
+ voicefont: Font;
497
+ wordsfont: Font;
498
+ }
499
+
500
+ export interface MetaText {
501
+ "abc-copyright"?: string;
502
+ "abc-creator"?: string;
503
+ "abc-version"?: string;
504
+ "abc-charset"?: string;
505
+ "abc-edited-by"?: string;
506
+ author?: string;
507
+ book?: string;
508
+ composer?: string;
509
+ decorationPlacement?: Placement;
510
+ discography?: string;
511
+ footer?: {
512
+ left: string;
513
+ center: string;
514
+ right: string;
515
+ };
516
+ group?: string;
517
+ header?: {
518
+ left: string;
519
+ center: string;
520
+ right: string;
521
+ }
522
+ history?: string;
523
+ instruction?: string;
524
+ measurebox?: boolean;
525
+ notes?: string;
526
+ origin?: string;
527
+ partOrder?: string;
528
+ rhythm?: string;
529
+ source?: string;
530
+ tempo?: TempoProperties;
531
+ textBlock?: string;
532
+ title?: string;
533
+ transcription?: string;
534
+ unalignedWords?: Array<TextFieldProperties|string>;
535
+ url?: string;
536
+ }
537
+
538
+ export interface MetaTextInfo {
539
+ "abc-copyright": CharRange;
540
+ "abc-creator": CharRange;
541
+ "abc-version": CharRange;
542
+ "abc-charset": CharRange;
543
+ "abc-edited-by": CharRange;
544
+ author: CharRange;
545
+ book: CharRange;
546
+ composer: CharRange;
547
+ discography: CharRange;
548
+ footer: CharRange;
549
+ group: CharRange;
550
+ header: CharRange;
551
+ history: CharRange;
552
+ instruction: CharRange;
553
+ notes: CharRange;
554
+ origin: CharRange;
555
+ partOrder: CharRange;
556
+ rhythm: CharRange;
557
+ source: CharRange;
558
+ tempo: CharRange;
559
+ textBlock: CharRange;
560
+ title: CharRange;
561
+ transcription: CharRange;
562
+ unalignedWords: CharRange;
563
+ url: CharRange;
564
+ }
565
+
566
+ export interface VoiceItemClef {
567
+ el_type: "clef";
568
+ stafflines?: number;
569
+ staffscale?: number;
570
+ transpose?: number;
571
+ type: Clef;
572
+ verticalPos: number;
573
+ clefPos?: number;
574
+ startChar: number;
575
+ endChar: number;
576
+ }
577
+
578
+ export interface VoiceItemBar {
579
+ el_type: "bar";
580
+ barNumber?: number;
581
+ chord?: Array<ChordProperties>;
582
+ decoration: Array<Decorations>;
583
+ endEnding?: boolean;
584
+ startEnding?: string;
585
+ startChar: number;
586
+ endChar: number;
587
+ }
588
+
589
+ export interface VoiceItemGap {
590
+ el_type: "gap";
591
+ gap: number;
592
+ }
593
+
594
+ export interface VoiceItemKey extends KeySignature {
595
+ el_type: "key";
596
+ startChar: number;
597
+ endChar: number;
598
+ }
599
+
600
+ export interface VoiceItemMeter extends Meter {
601
+ el_type: "meter";
602
+ startChar: number;
603
+ endChar: number;
604
+ }
605
+
606
+ export interface VoiceItemMidi {
607
+ el_type: "midi";
608
+ cmd: MidiCommands;
609
+ params: Array<string|number>;
610
+ startChar: number;
611
+ endChar: number;
612
+ }
613
+
614
+ export interface VoiceItemOverlay {
615
+ el_type: "overlay";
616
+ startChar: number;
617
+ endChar: number;
618
+ overlay: Array<NoteProperties>;
619
+ }
620
+
621
+ export interface VoiceItemPart {
622
+ el_type: "part";
623
+ startChar: number;
624
+ endChar: number;
625
+ title: string;
626
+ }
627
+
628
+ export interface VoiceItemScale {
629
+ el_type: "scale";
630
+ size: number;
631
+ }
632
+
633
+ export interface VoiceItemStem {
634
+ el_type: "stem";
635
+ direction: StemDirection;
636
+ }
637
+
638
+ export interface VoiceItemStyle {
639
+ el_type: "style";
640
+ head: NoteHeadType;
641
+ }
642
+
643
+ export interface VoiceItemTempo extends TempoProperties {
644
+ el_type: "tempo";
645
+ startChar: number;
646
+ endChar: number;
647
+ }
648
+
649
+ export interface VoiceItemTranspose {
650
+ el_type: "transpose";
651
+ steps: number;
652
+ }
653
+
654
+ export interface VoiceItemNote extends NoteProperties {
655
+ el_type: "note";
656
+ startChar: number;
657
+ endChar: number;
658
+ }
659
+
660
+ export type VoiceItem = VoiceItemClef | VoiceItemBar | VoiceItemGap | VoiceItemKey | VoiceItemMeter | VoiceItemMidi | VoiceItemOverlay | VoiceItemPart | VoiceItemScale | VoiceItemStem | VoiceItemStyle | VoiceItemTempo | VoiceItemTranspose | VoiceItemNote;
661
+
662
+ export interface TuneLine {
663
+ columns?: { formatting: any, lines: any };
664
+ image?: string;
665
+ newpage?: number;
666
+ staffbreak?: number;
667
+ // Only one of separator, subtitle, text, or staff will be present
668
+ separator?: {
669
+ endChar: number;
670
+ lineLength?: number;
671
+ spaceAbove?: number;
672
+ spaceBelow?: number;
673
+ startChar: number;
674
+ };
675
+ subtitle?: {
676
+ endChar: number;
677
+ startChar: number;
678
+ text: string;
679
+ };
680
+ text?: {
681
+ endChar: number;
682
+ startChar: number;
683
+ text: TextFieldProperties;
684
+ };
685
+ staff?: Array<{
686
+ barNumber?: number;
687
+ brace: BracePosition;
688
+ bracket: BracePosition;
689
+ clef?: ClefProperties;
690
+ connectBarLines: BracePosition;
691
+ gchordfont: Font;
692
+ tripletfont: Font;
693
+ vocalfont: Font;
694
+ key?: KeySignature;
695
+ meter?: Meter;
696
+ spacingAbove?: number;
697
+ spacingBelow?: number;
698
+ stafflines?: number;
699
+ staffscale?: number;
700
+ title?: Array<string>;
701
+ voices?: Array<Array<VoiceItem>>;
702
+ }>
703
+ vskip?: number;
704
+ }
705
+
706
+ export interface TuneObject {
707
+ formatting: Formatting;
708
+ lines: Array<TuneLine>;
709
+ media: Media;
710
+ metaText: MetaText;
711
+ metaTextInfo: MetaTextInfo;
712
+ version: string;
15
713
 
16
- export type AbcParams = any
17
- export interface AudioContextPromise {
18
- cached: [any]
19
- error: [any]
20
- loaded: [any]
714
+ getTotalTime: NumberFunction;
715
+ getTotalBeats: NumberFunction;
716
+ getBarLength: NumberFunction;
717
+ getBeatLength: NumberFunction;
718
+ getBeatsPerMeasure: NumberFunction;
719
+ getBpm: NumberFunction;
720
+ getMeter: () => Meter;
721
+ getMeterFraction: () => MeterFraction;
722
+ getPickupLength: NumberFunction;
723
+ getKeySignature: () => KeySignature;
724
+ getElementFromChar: (charPos: number) => VoiceItem | null;
725
+ millisecondsPerMeasure: NumberFunction;
726
+ setTiming: (bpm?: number, measuresOfDelay? : number) => void;
727
+ setUpAudio: (options: SynthOptions) => AudioTracks;
728
+ lineBreaks?: Array<number>;
729
+ visualTranspose?: number;
21
730
  }
22
731
 
732
+ export type TuneObjectArray = [TuneObject]
733
+
734
+ export type AbcElem = any // TODO
735
+
736
+ export interface ClickListenerDrag {
737
+ step: number;
738
+ max: number;
739
+ index: number;
740
+ setSelection: (index: number) => void;
741
+ }
742
+
743
+ export interface ClickListenerAnalysis {
744
+ staffPos: number;
745
+ name: string;
746
+ clickedName: string;
747
+ parentClasses: Array<string>;
748
+ clickedClasses: Array<string>;
749
+ voice: number;
750
+ line: number;
751
+ measure: number;
752
+ }
753
+
754
+ // TimingCallbacks
755
+ export interface LineEndInfo {
756
+ milliseconds: number;
757
+ top: number;
758
+ bottom: number;
759
+ }
760
+
761
+ export interface LineEndDetails {
762
+ line: number;
763
+ endTimings: Array<LineEndInfo>;
764
+ }
765
+
766
+ export interface TimingEvent {
767
+ type: "event";
768
+ milliseconds: number;
769
+ millisecondsPerMeasure: number;
770
+ line: number;
771
+ measureNumber: number;
772
+ top: number;
773
+ height: number;
774
+ left: number;
775
+ width: number;
776
+ elements: Array< any>; // TODO
777
+ startCharArray: Array<number>;
778
+ endCharArray: Array<number>;
779
+ midiPitches: MidiPitches
780
+ }
781
+
782
+ export interface TimingCallbacksPosition {
783
+ top: number;
784
+ left: number;
785
+ height: number
786
+ }
787
+
788
+ export interface TimingCallbacksDebug {
789
+ timestamp: number;
790
+ startTime: number;
791
+ ev: NoteTimingEvent;
792
+ endMs: number;
793
+ offMs: number;
794
+ offPs: number;
795
+ gapMs: number;
796
+ gapPx: number;
797
+ }
798
+
799
+ // Audio
800
+ export interface SequenceInstrument {
801
+ el_type: "instrument";
802
+ program: number;
803
+ pickupLength: number;
804
+ }
805
+
806
+ export interface SequenceChannel {
807
+ el_type: "channel";
808
+ channel: number;
809
+ }
810
+
811
+ export interface SequenceTranspose {
812
+ el_type: "transpose";
813
+ transpose: number;
814
+ }
815
+
816
+ export interface SequenceName {
817
+ el_type: "name";
818
+ trackName: string;
819
+ }
820
+
821
+ export interface SequenceDrum {
822
+ el_type: "drum";
823
+ pattern: string;
824
+ on: boolean;
825
+ bars?: number;
826
+ intro?: number;
827
+ }
828
+
829
+ export interface SequenceTempo {
830
+ el_type: "tempo";
831
+ qpm: number;
832
+ }
833
+
834
+ export interface SequenceKey {
835
+ el_type: "key";
836
+ accidentals: Array<Accidental>;
837
+ }
838
+
839
+ export interface SequenceBeat {
840
+ el_type: "beat";
841
+ beats: any; // TODO
842
+ }
843
+
844
+ export interface SequenceBeatAccents {
845
+ el_type: "beataccents";
846
+ value: boolean;
847
+ }
848
+
849
+ export interface SequenceBagpipes {
850
+ el_type: "bagpipes";
851
+ }
852
+
853
+ export interface SequenceNote {
854
+ el_type: "note";
855
+ duration: number;
856
+ elem: AbsoluteElement;
857
+ pitches: {pitch: number; name: NoteLetter};
858
+ timing: number;
859
+ }
860
+
861
+ export type AudioSequenceElement = SequenceInstrument | SequenceChannel | SequenceTranspose | SequenceName | SequenceDrum | SequenceTempo | SequenceKey | SequenceBeat | SequenceBeatAccents | SequenceBagpipes | SequenceNote;
862
+
863
+ export type AudioSequenceVoice = Array<AudioSequenceElement>;
864
+
865
+ export type AudioSequence = Array<AudioSequenceVoice>;
866
+
867
+ export type MidiFile = any // This is a standard midi file format
868
+
869
+ export interface MidiBufferPromise {
870
+ cached: [any] // TODO
871
+ error: [any] // TODO
872
+ loaded: [any] // TODO
873
+ }
874
+
875
+ export interface AudioTrack {
876
+ cmd: AudioTrackCommand;
877
+ [param: any]; // TODO - make this a union
878
+ }
879
+
880
+ export interface AudioTracks {
881
+ tempo: number;
882
+ instrument: number;
883
+ tracks: Array<AudioTrack>;
884
+ totalDuration: number;
885
+ }
886
+
887
+ // Analysis
888
+ export interface AnalyzedTune {
889
+ abc: string;
890
+ id: string;
891
+ pure: string;
892
+ startPos: number;
893
+ title: string;
894
+ }
895
+
896
+ export interface MeasureDef {
897
+ abc: string;
898
+ startEnding?: string;
899
+ endEnding?: true;
900
+ }
901
+
902
+ export interface MeasureList {
903
+ header: string;
904
+ measures: Array<MeasureDef>;
905
+ hasPickup: boolean
906
+ }
907
+
908
+
909
+ //
910
+ // Callbacks
911
+ //
912
+
913
+ // renderAbc
914
+ export type ClickListener = (abcElem: AbcElem, tuneNumber: number, classes: string, analysis: ClickListenerAnalysis, drag: ClickListenerDrag) => void;
915
+
916
+ export type AfterParsing = (tune: TuneObject, tuneNumber: number, abcString: string) => TuneObject;
917
+
918
+ // TimingCallbacks
919
+ export type BeatCallback = (beatNumber: number, totalBeats: number, totalTime: number, position: TimingCallbacksPosition, debugInfo: TimingCallbacksDebug) => void;
920
+
921
+ export type EventCallback = (event: TimingEvent) => void;
922
+
923
+ export type LineEndCallback = (info : LineEndInfo, event: TimingEvent, details: LineEndDetails) => void;
924
+
925
+ // Editor
926
+ export type OnChange = (editor: Editor) => void;
927
+
928
+ export type SelectionChangeCallback = (startChar: number, endChar: number) => void;
929
+
930
+ // Audio
23
931
  export interface CursorControl {
24
932
  beatSubDivision?: number
25
933
 
934
+ onReady?(): void
26
935
  onStart?(): void
27
936
  onFinished?(): void
28
- onBeat?(beatNumber: number, totalBeats?: number, totalTime?: number): void
29
- onEvent?(event: any): void
937
+ onBeat?(beatNumber: number, totalBeats: number, totalTime: number): void
938
+ onEvent?(event: NoteTimingEvent): void
30
939
  }
31
940
 
32
- export interface MidiBuffer {
33
- init?(params: AudioContext): Promise<AudioContextPromise>
34
- prime?(): Promise<void>
35
- start?(): void
36
- pause?(): void
37
- resume?(): void
38
- download?(): any // returns audio buffer in wav format
941
+ //
942
+ // Visual
943
+ //
944
+ let signature: string;
945
+
946
+ export function renderAbc(target: Selector, code: string, params?: AbcVisualParams): TuneObjectArray
947
+
948
+ export function parseOnly(abc: string, params?: AbcVisualParams) : TuneObjectArray
949
+
950
+ //
951
+ // Animation
952
+ //
953
+ export class TimingCallbacks {
954
+ constructor(visualObj: TuneObject, options?: AnimationOptions) ;
955
+ replaceTarget(visualObj: TuneObject): void;
956
+ start(position?: number, units?: ProgressUnit) : void;
957
+ pause() : void;
958
+ reset() : void;
959
+ stop() : void;
960
+ setProgress(position: number, units?: ProgressUnit ) : void;
961
+ currentMillisecond(): number;
962
+
963
+ noteTimings: Array<NoteTimingEvent>;
964
+ }
965
+
966
+ //
967
+ // Editor
968
+ //
969
+ export class Editor {
970
+ constructor(target: Selector, options: EditorOptions);
971
+ paramChanged(options: AbcVisualParams): void;
972
+ synthParamChanged(options: SynthOptions): void;
973
+ setNotDirty(): void;
974
+ isDirty(): boolean;
975
+ pause(shouldPause: boolean): void;
976
+ millisecondsPerMeasure(): number;
977
+ pauseMidi(shouldPause: boolean): void;
39
978
  }
40
979
 
41
980
  //
42
- // Synth widget controller
981
+ // Audio
43
982
  //
983
+ export type AudioControl = any // TODO
984
+
985
+ export interface MidiBuffer {
986
+ init(params?: MidiBufferOptions): Promise<MidiBufferPromise>
987
+ prime(): Promise<void>
988
+ start(): void
989
+ pause(): number
990
+ resume(): void
991
+ seek(position: number, units?: ProgressUnit): void
992
+ stop(): number
993
+ download(): any // returns audio buffer in wav format
994
+ }
995
+
44
996
  export interface SynthObjectController {
45
997
  disable(isDisabled: boolean): void
46
- setTune(visualObj: TuneObject, userAction: Boolean, audioParams?: AbcParams): Promise<any>
47
- load(selector: string, cursorControl?: any, visualOptions?: AbcParams): void
998
+ setTune(visualObj: TuneObject, userAction: Boolean, audioParams?: AbcVisualParams): Promise<any> // TODO
999
+ load(selector: string, cursorControl?: any, visualOptions?: SynthVisualOptions): void
48
1000
  play(): void
49
1001
  pause(): void
50
1002
  toggleLoop(): void
@@ -54,27 +1006,43 @@ declare module 'abcjs' {
54
1006
  download(fName: string): void
55
1007
  }
56
1008
 
57
- //
58
- // Basic Visual stuff
59
- //
60
- let signature: string
61
-
62
- export function renderAbc(target: Selector, code: string, params?: AbcParams): TuneObjectArray
1009
+ export interface SynthSequenceClass {
1010
+ // TODO
1011
+ }
63
1012
 
64
- //
65
- // Basic Audio Stuff
66
- //
67
1013
  export namespace synth {
68
1014
  let instrumentIndexToName: [string]
69
1015
  let pitchToNoteName: [string]
70
1016
  let SynthController: { new (): SynthObjectController }
71
1017
  let CreateSynth: { new (): MidiBuffer }
1018
+ let SynthSequence: { new (): SynthSequenceClass }
72
1019
 
73
1020
  export function supportsAudio(): boolean
74
- export function CreateSynthControl(element: Selector, options: AbcParams): AudioControl
75
- export function getMidiFile(source: String | TuneObject, options?: AbcParams): MidiFile
76
- export function synthSequence(): AudioSequence
77
- export function playEvent(pitches: Pitches, graceNotes: Pitches, milliSecondsPerMeasure: number): Promise<any>
1021
+ export function registerAudioContext(ac?: AudioContext): boolean
78
1022
  export function activeAudioContext(): AudioContext
1023
+ export function CreateSynthControl(element: Selector, options: AbcVisualParams): AudioControl // TODO
1024
+ export function getMidiFile(source: String | TuneObject, options?: MidiFileOptions): MidiFile;
1025
+ export function playEvent(pitches: MidiPitches, graceNotes: MidiGracePitches, milliSecondsPerMeasure: number): Promise<void>;
1026
+ export function sequence(visualObj: TuneObject, options: AbcVisualParams): AudioSequence
1027
+ }
1028
+
1029
+ //
1030
+ // Analysis
1031
+ //
1032
+ export class TuneBook {
1033
+ constructor(tunebookString: string) ;
1034
+ getTuneById(id: string | number): AnalyzedTune;
1035
+ getTuneByTitle(id: string): AnalyzedTune;
1036
+
1037
+ header: string;
1038
+ tunes: Array<AnalyzedTune>;
79
1039
  }
1040
+
1041
+ export function numberOfTunes(abc: string) : number;
1042
+ export function extractMeasures(abc: string) : Array<MeasureList>;
1043
+
1044
+ //
1045
+ // Glyph
1046
+ //
1047
+ export function setGlyph(glyphName: string, glyph: GlyphDef) : void;
80
1048
  }