abcjs 6.3.0 → 6.4.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.
Files changed (46) hide show
  1. package/README.md +4 -0
  2. package/RELEASE.md +44 -0
  3. package/dist/abcjs-basic-min.js +2 -2
  4. package/dist/abcjs-basic.js +1028 -622
  5. package/dist/abcjs-basic.js.map +1 -1
  6. package/dist/abcjs-plugin-min.js +2 -2
  7. package/index.js +1 -0
  8. package/package.json +1 -1
  9. package/src/api/tune-metrics.js +18 -0
  10. package/src/data/abc_tune.js +13 -2
  11. package/src/edit/abc_editarea.js +4 -1
  12. package/src/parse/abc_parse.js +2 -0
  13. package/src/parse/abc_parse_directive.js +6 -0
  14. package/src/synth/abc_midi_flattener.js +40 -462
  15. package/src/synth/abc_midi_sequencer.js +25 -10
  16. package/src/synth/chord-track.js +562 -0
  17. package/src/synth/create-note-map.js +2 -1
  18. package/src/synth/create-synth.js +91 -42
  19. package/src/test/abc_parser_lint.js +1 -0
  20. package/src/write/creation/abstract-engraver.js +4 -1
  21. package/src/write/creation/decoration.js +3 -2
  22. package/src/write/creation/elements/tie-element.js +23 -0
  23. package/src/write/draw/draw.js +1 -1
  24. package/src/write/engraver-controller.js +9 -5
  25. package/src/write/interactive/create-analysis.js +50 -0
  26. package/src/write/interactive/find-selectable-element.js +24 -0
  27. package/src/write/interactive/selection.js +5 -45
  28. package/src/write/layout/layout-in-grid.js +83 -0
  29. package/src/write/layout/layout.js +29 -24
  30. package/src/write/layout/set-upper-and-lower-elements.js +2 -0
  31. package/src/write/layout/staff-group.js +2 -2
  32. package/src/write/layout/voice-elements.js +1 -1
  33. package/src/write/layout/voice.js +1 -1
  34. package/src/write/renderer.js +3 -0
  35. package/temp.txt +1 -48
  36. package/types/index.d.ts +96 -32
  37. package/version.js +1 -1
  38. package/abc2xml_239/abc2xml.html +0 -769
  39. package/abc2xml_239/abc2xml.py +0 -2248
  40. package/abc2xml_239/abc2xml_changelog.html +0 -124
  41. package/abc2xml_239/lazy-river.abc +0 -26
  42. package/abc2xml_239/lazy-river.xml +0 -3698
  43. package/abc2xml_239/mean-to-me.abc +0 -22
  44. package/abc2xml_239/mean-to-me.xml +0 -2954
  45. package/abc2xml_239/pyparsing.py +0 -3672
  46. package/abc2xml_239/pyparsing.pyc +0 -0
@@ -87,6 +87,8 @@ var setUpperAndLowerElements = function (renderer, staffGroup) {
87
87
  if (addedSpace > 0)
88
88
  staff.top += addedSpace;
89
89
  }
90
+ staff.top += renderer.spacing.staffTopMargin / spacing.STEP
91
+
90
92
  lastStaffBottom = 2 - staff.bottom; // the staff starts at position 2 and the bottom variable is negative. Therefore to find out how large the bottom is, we reverse the sign of the bottom, and add the 2 in.
91
93
 
92
94
  // Now we need a little margin on the top, so we'll just throw that in.
@@ -19,7 +19,7 @@ function checkLastBarX(voices) {
19
19
  }
20
20
  }
21
21
 
22
- var layoutStaffGroup = function (spacing, renderer, debug, staffGroup, leftEdge) {
22
+ var layoutStaffGroup = function (spacing, minPadding, debug, staffGroup, leftEdge) {
23
23
  var epsilon = 0.0000001; // Fudging for inexactness of floating point math.
24
24
  var spacingunits = 0; // number of times we will have ended up using the spacing distance (as opposed to fixed width distances)
25
25
  var minspace = 1000; // a big number to start off with - used to find out what the smallest space between two notes is -- GD 2014.1.7
@@ -82,7 +82,7 @@ var layoutStaffGroup = function (spacing, renderer, debug, staffGroup, leftEdge)
82
82
  var topVoice = (lastTopVoice !== undefined && currentvoices[lastTopVoice].voicenumber !== v.voicenumber) ? currentvoices[lastTopVoice] : undefined;
83
83
  if (!isSameStaff(v, topVoice))
84
84
  topVoice = undefined;
85
- var voicechildx = layoutVoiceElements.layoutOneItem(x, spacing, v, renderer.minPadding, topVoice);
85
+ var voicechildx = layoutVoiceElements.layoutOneItem(x, spacing, v, minPadding, topVoice);
86
86
  var dx = voicechildx - x;
87
87
  if (dx > 0) {
88
88
  x = voicechildx; //update x
@@ -96,7 +96,7 @@ VoiceElement.shiftRight = function (dx, voice) {
96
96
 
97
97
  // call when spacingduration has been updated
98
98
  VoiceElement.updateNextX = function (x, spacing, voice) {
99
- voice.nextx = x + (spacing * Math.sqrt(voice.spacingduration * 8));
99
+ voice.nextx = x + (spacing * this.getSpacingUnits(voice));
100
100
  };
101
101
 
102
102
  VoiceElement.updateIndices = function (voice) {
@@ -36,7 +36,7 @@ function moveDecorations(beam) {
36
36
  var top = yAtNote(child, beam);
37
37
  for (var i = 0; i < child.children.length; i++) {
38
38
  var el = child.children[i];
39
- if (el.klass === 'ornament') {
39
+ if (el.klass === 'ornament' && el.position !== 'below') {
40
40
  if (el.bottom - padding < top) {
41
41
  var distance = top - el.bottom + padding; // Find the distance that it needs to move and add a little margin so the element doesn't touch the beam.
42
42
  el.bottom += distance;
@@ -103,6 +103,7 @@ Renderer.prototype.initVerticalSpace = function () {
103
103
  parts: 11.33, // Set the vertical space above a new part.
104
104
  slurHeight: 1.0, // Set the slur height factor.
105
105
  staffSeparation: 61.33, // Do not put a staff system closer than <unit> from the previous system.
106
+ staffTopMargin: 0,
106
107
  stemHeight: 26.67 + 10, // Set the stem height.
107
108
  subtitle: 3.78, // Set the vertical space above the subtitle.
108
109
  systemStaffSeparation: 48, // Do not place the staves closer than <unit> inside a system. * This values applies to all staves when in the tune header. Otherwise, it applies to the next staff
@@ -157,6 +158,8 @@ Renderer.prototype.setVerticalSpace = function (formatting) {
157
158
  this.spacing.title = formatting.titlespace * 4 / 3;
158
159
  if (formatting.sysstaffsep !== undefined)
159
160
  this.spacing.systemStaffSeparation = formatting.sysstaffsep * 4 / 3;
161
+ if (formatting.stafftopmargin !== undefined)
162
+ this.spacing.staffTopMargin = formatting.stafftopmargin * 4 / 3;
160
163
  if (formatting.subtitlespace !== undefined)
161
164
  this.spacing.subtitle = formatting.subtitlespace * 4 / 3;
162
165
  if (formatting.topspace !== undefined)
package/temp.txt CHANGED
@@ -1,50 +1,3 @@
1
- ## Features
2
1
 
3
- ### Tablature
4
- * Add tab feature `hideTabSymbol`
5
- * Add 5-string tab named "fiveString"
6
- * Make "mandolin" and "fiddle" synonyms for "violin" in tablature.
2
+
7
3
 
8
- ### Synth
9
- * change the default synth control options for "play" and "progress" to be true
10
- * expose the MIDI creator function
11
- * Add a `getIsRunning()` function to enable play/pause
12
- * allow passing in soundfont and debug callback when playing an event directly.
13
-
14
- ### Rich Text
15
- * allow up to 9 custom fonts in `%%setfont`
16
- * for rich text fields, escape two dollar signs
17
- * allow rich text in all non-music fields
18
- * give all non-music fields a unique class
19
-
20
- ### Miscellaneous
21
- * add abcjs-notehead class to note heads;
22
- * add `accentAbove` parameter
23
- * handle numbered tune names in the reverser
24
- * support reversing tune names with ", a" and ", an", with a variable amount of whitespace and case-insensitive
25
- * Add Glissando Synonyms
26
- * Put start and end char on slurs so they can be selected.
27
- * Add `expandToWidest` option
28
-
29
- ## Bugs
30
- * fix placement of tab staff when there is no label
31
- * fix font placement bugs
32
- * remove spurious quotes in font name in svg attribute
33
- * Fix the name of the `abcjs-tab-number` class
34
- * fix crash when skipping a staff when creating tablature
35
- * Fix tab staff height when there is a label
36
- * Fix for crash when rendering multiple tab staves
37
- * Offset breath mark to the right
38
- * Center text when using `expandToWidest` set true
39
- * fix placement of triangle notehead
40
- * `afterParsing` now works with line wrapping.
41
- * Add paddingleft to the size of the SVG - it was cut off if the padding was larger than the default.
42
- * Guard against crash when the synth note wasn't loaded.
43
- * protect against spurious mouse click in selection
44
- * Fix bug in Firefox that cuts off the last line of the SVG
45
-
46
- ## Documentation
47
- * add missing typescript types
48
- * fix synth control types
49
- * fixed some typescript types in the TimingCallbacks
50
- * TimingEvent is now NoteTimingEvent
package/types/index.d.ts CHANGED
@@ -48,14 +48,14 @@ declare module 'abcjs' {
48
48
 
49
49
  export type FormatAttributes = "titlefont" | "gchordfont" | "composerfont" | "footerfont" | "headerfont" | "historyfont" | "infofont" |
50
50
  "measurefont" | "partsfont" | "repeatfont" | "subtitlefont" | "tempofont" | "textfont" | "voicefont" | "tripletfont" | "vocalfont" |
51
- "wordsfont" | "annotationfont" | "scale" | "partsbox" | "freegchord" | "fontboxpadding" | "stretchlast" | "tablabelfont" | "tabnumberfont" | "tabgracefont";
51
+ "wordsfont" | "annotationfont" | "scale" | "partsbox" | "freegchord" | "fontboxpadding" | "stretchlast" | "tablabelfont" | "tabnumberfont" | "tabgracefont" | 'stafftopmargin';
52
52
 
53
53
  export type MidiCommands = "nobarlines" | "barlines" | "beataccents" | "nobeataccents" | "droneon" | "droneoff" | "noportamento" | "channel" | "c" |
54
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" |
58
- "drone" | "bassprog" | "chordprog" | "drummap" | "portamento" | "expand" | "grace" | "trim" | "drum" | "chordname";
58
+ "drone" | "drummap" | "portamento" | "expand" | "grace" | "trim" | "drum" | "chordname";
59
59
 
60
60
  export type StemDirection = 'up' | 'down' | 'auto' | 'none';
61
61
 
@@ -292,10 +292,12 @@ declare module 'abcjs' {
292
292
  selectTypes?: boolean | Array<DragTypes>;
293
293
  showDebug?: Array<"grid" | "box">;
294
294
  staffwidth?: number;
295
+ stafftopmargin?: number;
295
296
  startingTune?: number;
296
297
  stop_on_warning?: boolean;
297
298
  tablature?: Array<Tablature>;
298
299
  textboxpadding?: number;
300
+ timeBasedLayout?: { minPadding?:number, minWidth?:number, align?: 'left'|'center'};
299
301
  viewportHorizontal?: boolean;
300
302
  viewportVertical?: boolean;
301
303
  visualTranspose?: number;
@@ -361,6 +363,7 @@ declare module 'abcjs' {
361
363
  drum?: string;
362
364
  drumBars?: number;
363
365
  drumIntro?: number;
366
+ drumOff?: boolean;
364
367
  program?: number;
365
368
  midiTranspose?: number;
366
369
  visualTranspose?: number;
@@ -369,6 +372,13 @@ declare module 'abcjs' {
369
372
  defaultQpm?: number;
370
373
  chordsOff?: boolean;
371
374
  detuneOctave?: boolean;
375
+
376
+ swing?: number;
377
+ bassprog?: number;
378
+ bassvol?: number;
379
+ chordprog?: number;
380
+ chordvol?: number;
381
+ gchord?: string;
372
382
  }
373
383
 
374
384
  export interface SynthVisualOptions {
@@ -554,6 +564,7 @@ declare module 'abcjs' {
554
564
  subtitlespace?: number;
555
565
  sysstaffsep?: number;
556
566
  systemsep?: number;
567
+ stafftopmargin?: number;
557
568
  textspace?: number;
558
569
  titleformat?: string;
559
570
  titleleft?: boolean;
@@ -777,8 +788,10 @@ declare module 'abcjs' {
777
788
  el_type: "note";
778
789
  startChar: number;
779
790
  endChar: number;
791
+ duration: number;
792
+ pitches?: Array<any>; // TODO-PER
793
+ rest?: { type: 'rest' | 'spacer' | 'invisible' | 'invisible-multimeasure' | 'multimeasure', text? : number};
780
794
  }
781
-
782
795
  export type VoiceItem = VoiceItemClef | VoiceItemBar | VoiceItemGap | VoiceItemKey | VoiceItemMeter | VoiceItemMidi | VoiceItemOverlay | VoiceItemPart | VoiceItemScale | VoiceItemStem | VoiceItemStyle | VoiceItemTempo | VoiceItemTranspose | VoiceItemNote;
783
796
 
784
797
  export interface TuneLine {
@@ -805,26 +818,59 @@ declare module 'abcjs' {
805
818
  text: TextFieldProperties;
806
819
  };
807
820
  staff?: Array<{
808
- barNumber?: number;
809
- brace: BracePosition;
810
- bracket: BracePosition;
811
- clef?: ClefProperties;
812
- connectBarLines: BracePosition;
813
- gchordfont: Font;
814
- tripletfont: Font;
815
- vocalfont: Font;
816
- key?: KeySignature;
817
- meter?: Meter;
818
- spacingAbove?: number;
819
- spacingBelow?: number;
820
- stafflines?: number;
821
- staffscale?: number;
822
- title?: Array<string>;
823
- voices?: Array<Array<VoiceItem>>;
824
- }>
821
+ clef?: ClefProperties;
822
+ key?: KeySignature;
823
+ meter?: Meter;
824
+ voices?: Array<Array<VoiceItem>>;
825
+ }>;
826
+ staffGroup?: {
827
+ barNumber?: number;
828
+ brace?: BracePosition;
829
+ bracket?: BracePosition;
830
+ connectBarLines?: BracePosition;
831
+ gchordfont?: Font;
832
+ tripletfont?: Font;
833
+ vocalfont?: Font;
834
+ spacingAbove?: number;
835
+ spacingBelow?: number;
836
+ stafflines?: number;
837
+ staffscale?: number;
838
+ title?: Array<string>;
839
+ height?:number;
840
+ line?: number;
841
+ startx?:number;
842
+ w?:number;
843
+ gridStart?:number;
844
+ gridEnd?:number;
845
+ };
825
846
  vskip?: number;
826
847
  }
827
848
 
849
+ export interface Selectable {
850
+ absEl: AbsoluteElement;
851
+ isDraggable: boolean;
852
+ staffPos: {
853
+ height: number;
854
+ top: number;
855
+ zero: number;
856
+ }
857
+ svgEl: SVGElement;
858
+ }
859
+
860
+ export interface SelectableReturn {
861
+ index: number;
862
+ classes: Array<string>;
863
+ element: Selectable;
864
+ analysis: {
865
+ staffPos: number;
866
+ name: string;
867
+ voice: number;
868
+ line: number;
869
+ measure: number;
870
+ selectableElement: HTMLElement;
871
+ }
872
+ }
873
+
828
874
  export interface TuneObject {
829
875
  formatting: Formatting;
830
876
  engraver?: EngraverController;
@@ -833,6 +879,7 @@ declare module 'abcjs' {
833
879
  metaText: MetaText;
834
880
  metaTextInfo: MetaTextInfo;
835
881
  version: string;
882
+ warnings?: Array<string>;
836
883
 
837
884
  getTotalTime: NumberFunction;
838
885
  getTotalBeats: NumberFunction;
@@ -851,22 +898,14 @@ declare module 'abcjs' {
851
898
  setUpAudio: (options: SynthOptions) => AudioTracks;
852
899
  makeVoicesArray: () => Array<Selectable[]>
853
900
  deline: () => Array<TuneLine>;
901
+ findSelectableElement: (target: HTMLElement) => SelectableReturn | null;
902
+ getSelectableArray: () => Array<Selectable>
854
903
  lineBreaks?: Array<number>;
855
904
  visualTranspose?: number;
856
905
  }
857
906
 
858
907
  export type TuneObjectArray = [TuneObject]
859
908
 
860
- export interface Selectable {
861
- absEl: AbsoluteElement;
862
- isDraggable: boolean;
863
- staffPos: {
864
- height: number;
865
- top: number;
866
- zero: number;
867
- }
868
- }
869
-
870
909
  export interface AbcElem {
871
910
  el_type: string; //TODO enumerate these
872
911
  abselem: AbsoluteElement;
@@ -1123,6 +1162,8 @@ declare module 'abcjs' {
1123
1162
 
1124
1163
  export function renderAbc(target: Selector, code: string, params?: AbcVisualParams): TuneObjectArray
1125
1164
 
1165
+ export function tuneMetrics(code: string, params?: AbcVisualParams): Array<{sections: Array<{left: number, measureWidths:Array<number>, total: number}>}>
1166
+
1126
1167
  export function parseOnly(abc: string, params?: AbcVisualParams) : TuneObjectArray
1127
1168
 
1128
1169
  //
@@ -1227,6 +1268,29 @@ declare module 'abcjs' {
1227
1268
  embed(parent:Element, noplayer:boolean):void
1228
1269
  }
1229
1270
 
1271
+ export interface SynthControlOptions {
1272
+ ac?: AudioContext;
1273
+ afterResume?: () => void;
1274
+ loopHandler?: (ev: any) => Promise<void>;
1275
+ restartHandler?: (ev: any) => Promise<void>;
1276
+ playHandler?: (ev: any) => Promise<void>;
1277
+ playPromiseHandler?: (ev: any) => Promise<void>;
1278
+ progressHandler?: (ev: any) => Promise<void>;
1279
+ warpHandler?: (ev: any) => Promise<void>;
1280
+ hasClock?: boolean;
1281
+ repeatTitle?: string;
1282
+ repeatAria?: string;
1283
+ restartTitle?: string;
1284
+ restartAria?: string;
1285
+ playTitle?: string;
1286
+ playAria?: string;
1287
+ randomTitle?: string;
1288
+ randomAria?: string;
1289
+ warpTitle?: string;
1290
+ warpAria?: string;
1291
+ bpm?: string;
1292
+ }
1293
+
1230
1294
  export namespace synth {
1231
1295
  let instrumentIndexToName: [string]
1232
1296
  let pitchToNoteName: [string]
@@ -1237,7 +1301,7 @@ declare module 'abcjs' {
1237
1301
  export function supportsAudio(): boolean
1238
1302
  export function registerAudioContext(ac?: AudioContext): boolean
1239
1303
  export function activeAudioContext(): AudioContext
1240
- export function CreateSynthControl(element: Selector, options: AbcVisualParams): AudioControl
1304
+ export function CreateSynthControl(element: Selector, options?: SynthControlOptions): AudioControl
1241
1305
  export function getMidiFile(source: string | TuneObject, options?: MidiFileOptions): MidiFile;
1242
1306
  export function playEvent(pitches: MidiPitches, graceNotes: MidiGracePitches | undefined, milliSecondsPerMeasure: number, soundFontUrl? : string, debugCallback?: (message: string) => void): Promise<void>;
1243
1307
  export function sequence(visualObj: TuneObject, options: AbcVisualParams): AudioSequence
@@ -1259,7 +1323,7 @@ declare module 'abcjs' {
1259
1323
  export function numberOfTunes(abc: string) : number;
1260
1324
  export function extractMeasures(abc: string) : Array<MeasureList>;
1261
1325
 
1262
- export function strTranspose(originalAbc: string, visualObj: TuneObject, steps: number): string;
1326
+ export function strTranspose(originalAbc: string, visualObj: TuneObjectArray, steps: number): string;
1263
1327
 
1264
1328
  //
1265
1329
  // Glyph
package/version.js CHANGED
@@ -1,3 +1,3 @@
1
- var version = '6.3.0';
1
+ var version = '6.4.0';
2
2
 
3
3
  module.exports = version;