notations 0.0.38 → 0.0.43

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.
@@ -378,7 +378,7 @@ var Jaaru = (function (_super) {
378
378
  y -= h2;
379
379
  y2 = y + h2;
380
380
  }
381
- return ["M " + x + " " + y, "Q " + x2 + " " + y + " " + x2 + " " + y2].join(" ");
381
+ return ["M ".concat(x, " ").concat(y), "Q ".concat(x2, " ").concat(y, " ").concat(x2, " ").concat(y2)].join(" ");
382
382
  };
383
383
  Jaaru.prototype.refreshMinSize = function () {
384
384
  return TSU.DOM.svgBBox(this.pathElem);
@@ -1 +1 @@
1
- {"version":3,"file":"embelishments.js","sourceRoot":"","sources":["../../../src/carnatic/embelishments.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAuC;AAGvC,oCAAmD;AAMnD;IAAmD,wCAAY;IAC7D,8BAA4B,QAAkB;QAA9C,YACE,iBAAO,SACR;QAF2B,cAAQ,GAAR,QAAQ,CAAU;;IAE9C,CAAC;IACH,2BAAC;AAAD,CAAC,AAJD,CAAmD,qBAAY,GAI9D;AAJqB,oDAAoB;AAM1C;IAAqC,mCAAoB;IAKvD,yBAA4B,QAAkB,EAAkB,IAAU;QAA1E,YACE,kBAAM,QAAQ,CAAC,SA2BhB;QA5B2B,cAAQ,GAAR,QAAQ,CAAU;QAAkB,UAAI,GAAJ,IAAI,CAAM;QAJ1E,eAAS,GAAG,CAAC,CAAC;QACd,gBAAU,GAAG,GAAG,CAAC;QAKf,IAAM,QAAQ,GAAG,KAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACzC,IAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtC,KAAI,CAAC,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE;YACzC,GAAG,EAAE,Q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tsutils\";\nimport { Note } from \"../core\";\nimport { BeatView } from \"../layouts\";\nimport { AtomView, Embelishment } from \"../shapes\";\nimport { JaaruGamaka } from \"./gamakas\";\n\n/**\n * Embelishments specifically \"around\" a single atom view.\n */\nexport abstract class AtomViewEmbelishment extends Embelishment {\n constructor(public readonly atomView: AtomView) {\n super();\n }\n}\n\nexport class OctaveIndicator extends AtomViewEmbelishment {\n dotRadius = 1;\n dotSpacing = 2.5;\n dotsElem: SVGGElement;\n\n constructor(public readonly noteView: AtomView, public readonly note: Note) {\n super(noteView);\n const rootElem = this.noteView.embRoot();\n const numDots = Math.abs(note.octave);\n this.dotsElem = TSU.DOM.createSVGNode(\"g\", {\n doc: document,\n parent: rootElem,\n attrs: {\n width: this.dotRadius * 2 * numDots + (numDots - 1) * this.dotSpacing,\n height: this.dotRadius * 2,\n source: \"atom\" + this.noteView.flatAtom.atom.uuid,\n },\n });\n let cx = 0;\n for (let i = 0; i < numDots; i++) {\n TSU.DOM.createSVGNode(\"circle\", {\n doc: document,\n parent: this.dotsElem,\n attrs: {\n cx: cx,\n cy: 0,\n r: this.dotRadius,\n stroke: \"black\",\n \"stroke-width\": \"1\",\n },\n });\n cx += this.dotRadius + this.dotRadius + this.dotSpacing;\n }\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n const numDots = Math.abs(this.note.octave);\n return {\n width: this.dotRadius * 2 * numDots + (numDots - 1) * this.dotSpacing,\n height: this.dotRadius * 2,\n };\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n if (x == null) x = this.x;\n if (y == null) y = this.y;\n // cannot set w/h\n // this.bbox.x = x;\n // this.bbox.y = y;\n return [x, y, null, null];\n }\n\n refreshLayout(): void {\n this.dotsElem.setAttribute(\"transform\", \"translate(\" + this.x + \",\" + this.y + \")\");\n }\n}\n\n////////// Carnatic embelishments\nexport class LabelEmbelishment extends AtomViewEmbelishment {\n labelElem: SVGTextElement;\n constructor(public readonly label: string, public readonly atomView: AtomView) {\n super(atomView);\n const rootElem = this.atomView.embRoot();\n this.labelElem = TSU.DOM.createSVGNode(\"text\", {\n doc: document,\n parent: rootElem,\n text: label,\n attrs: {\n source: \"atom\" + this.atomView.flatAtom.atom.uuid,\n \"dominant-baseline\": \"hanging\",\n },\n });\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return TSU.DOM.svgBBox(this.labelElem);\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, w, h];\n }\n\n refreshLayout(): void {\n this.labelElem.setAttribute(\"x\", \"\" + this.x);\n this.labelElem.setAttribute(\"y\", \"\" + this.y);\n }\n}\n\nexport class BeatStartLines extends Embelishment {\n barSpacing = 10;\n protected line: SVGLineElement;\n\n constructor(public readonly source: BeatView, public readonly rootElement: SVGGraphicsElement) {\n super();\n this.line = TSU.DOM.createSVGNode(\"line\", {\n doc: document,\n parent: this.rootElement,\n attrs: {\n stroke: \"black\",\n \"stroke-width\": \"1\",\n class: \"bar-start-line\",\n },\n });\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n refreshLayout(): void {\n const line = this.line;\n const x = -this.barSpacing;\n line.setAttribute(\"x1\", \"\" + x);\n line.setAttribute(\"x2\", \"\" + x);\n const y = 0;\n const h = this.source.height;\n line.setAttribute(\"y1\", \"\" + y);\n line.setAttribute(\"y2\", \"\" + (y + h));\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, null, h];\n }\n}\n\nexport class BeatEndLines extends Embelishment {\n lineSpacing = 2;\n protected lines: SVGLineElement[];\n\n constructor(public readonly source: BeatView, public readonly rootElement: SVGGraphicsElement, nLines = 1) {\n super();\n this.lines = [];\n for (let i = 0; i < nLines; i++) {\n this.lines.push(\n TSU.DOM.createSVGNode(\"line\", {\n doc: document,\n // parent: l2g,\n parent: this.rootElement,\n attrs: {\n stroke: \"black\",\n \"stroke-width\": \"1\",\n class: \"bar-end-line\",\n },\n }),\n );\n }\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n protected updatePosition(x: null | number, y: null | number): [number | null, number | null] {\n return [x, y];\n }\n\n barSpacing = 15;\n\n refreshLayout(): void {\n const x = this.source.width + this.barSpacing;\n const y = 0;\n const h = this.source.height;\n let currX = x;\n for (const line of this.lines) {\n const lx = \"\" + currX;\n line.setAttribute(\"x1\", lx);\n line.setAttribute(\"x2\", lx);\n currX += 4;\n }\n for (const line of this.lines) {\n line.setAttribute(\"y1\", \"\" + y);\n line.setAttribute(\"y2\", \"\" + (y + h));\n }\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [null, null, null, null];\n }\n}\n\n/// Carnatic Embelishments\nexport class Kampitham extends LabelEmbelishment {\n constructor(public readonly atomView: AtomView) {\n super(\"~\", atomView);\n }\n}\n\nexport class Nokku extends LabelEmbelishment {\n constructor(public readonly atomView: AtomView) {\n super(\"w\", atomView);\n }\n}\n\nexport class Prathyagatham extends LabelEmbelishment {\n constructor(public readonly atomView: AtomView) {\n super(\"∵\", atomView);\n }\n}\nexport class Spuritham extends LabelEmbelishment {\n constructor(public readonly atomView: AtomView) {\n super(\"∴\", atomView);\n }\n}\nexport class Raavi extends LabelEmbelishment {\n constructor(public readonly atomView: AtomView) {\n super(\"^\", atomView);\n }\n}\nexport class Kandippu extends LabelEmbelishment {\n constructor(public readonly atomView: AtomView) {\n super(\"✓\", atomView);\n }\n}\n\nexport class Vaali extends LabelEmbelishment {\n constructor(public readonly atomView: AtomView) {\n super(\"⌒\", atomView);\n }\n}\nexport class Odukkal extends LabelEmbelishment {\n constructor(public readonly atomView: AtomView) {\n super(\"x\", atomView);\n }\n}\nexport class Orikkai extends LabelEmbelishment {\n constructor(public readonly atomView: AtomView) {\n super(\"γ\", atomView);\n }\n}\n\nexport class Jaaru extends AtomViewEmbelishment {\n pathElem: SVGPathElement;\n constructor(public readonly jaaru: JaaruGamaka, public readonly atomView: AtomView) {\n super(atomView);\n // TODO - Create the \"fancier\" view\n // for now represent this with just a slant line (like a slash)\n const rootElem = this.atomView.embRoot();\n this.pathElem = TSU.DOM.createSVGNode(\"path\", {\n doc: document,\n parent: rootElem,\n attrs: {\n source: \"atom\" + this.atomView.flatAtom.atom.uuid,\n stroke: \"black\",\n fill: \"transparent\",\n d: this.pathAttribute(),\n },\n });\n }\n\n pathAttribute(x = 0): string {\n const avbbox = this.atomView.minSize;\n let y2 = 0;\n const h2 = avbbox.height / 2;\n const x2 = x + h2;\n let y = this.atomView.y;\n if (this.jaaru.ascending) {\n y += avbbox.height;\n y2 = y - h2;\n } else {\n y -= h2;\n y2 = y + h2;\n }\n return [`M ${x} ${y}`, `Q ${x2} ${y} ${x2} ${y2}`].join(\" \");\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return TSU.DOM.svgBBox(this.pathElem);\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, null, null, null];\n }\n\n refreshLayout(): void {\n this.pathElem.setAttribute(\"d\", this.pathAttribute(this.x));\n }\n}\n"]}
1
+ {"version":3,"file":"embelishments.js","sourceRoot":"","sources":["../../../src/carnatic/embelishments.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAuC;AAGvC,oCAAmD;AAMnD;IAAmD,wCAAY;IAC7D,8BAA4B,QAAkB;QAA9C,YACE,iBAAO,SACR;QAF2B,cAAQ,GAAR,QAAQ,CAAU;;IAE9C,CAAC;IACH,2BAAC;AAAD,CAAC,AAJD,CAAmD,qBAAY,GAI9D;AAJqB,oDAAoB;AAM1C;IA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GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IAES,4BAAY,GAAtB,UACE,CAAgB,EAChB,CAAgB,EAChB,CAAgB,EAChB,CAAgB;QAEhB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,6BAAa,GAAb;QACE,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9D,CAAC;IACH,YAAC;AAAD,CAAC,AAnDD,CAA2B,oBAAoB,GAmD9C;AAnDY,sBAAK","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Note } from \"../core\";\nimport { BeatView } from \"../layouts\";\nimport { AtomView, Embelishment } from \"../shapes\";\nimport { JaaruGamaka } from \"./gamakas\";\n\n/**\n * Embelishments specifically \"around\" a single atom view.\n */\nexport abstract class AtomViewEmbelishment extends Embelishment {\n constructor(public readonly atomView: AtomView) {\n super();\n }\n}\n\nexport class OctaveIndicator extends AtomViewEmbelishment {\n dotRadius = 1;\n dotSpacing = 2.5;\n dotsElem: SVGGElement;\n\n constructor(public readonly noteView: AtomView, public readonly note: Note) {\n super(noteView);\n const rootElem = this.noteView.embRoot();\n const numDots = Math.abs(note.octave);\n this.dotsElem = TSU.DOM.createSVGNode(\"g\", {\n doc: document,\n parent: rootElem,\n attrs: {\n width: this.dotRadius * 2 * numDots + (numDots - 1) * this.dotSpacing,\n height: this.dotRadius * 2,\n source: \"atom\" + this.noteView.flatAtom.atom.uuid,\n },\n });\n let cx = 0;\n for (let i = 0; i < numDots; i++) {\n TSU.DOM.createSVGNode(\"circle\", {\n doc: document,\n parent: this.dotsElem,\n attrs: {\n cx: cx,\n cy: 0,\n r: this.dotRadius,\n stroke: \"black\",\n \"stroke-width\": \"1\",\n },\n });\n cx += this.dotRadius + this.dotRadius + this.dotSpacing;\n }\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n const numDots = Math.abs(this.note.octave);\n return {\n width: this.dotRadius * 2 * numDots + (numDots - 1) * this.dotSpacing,\n height: this.dotRadius * 2,\n };\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n if (x == null) x = this.x;\n if (y == null) y = this.y;\n // cannot set w/h\n // this.bbox.x = x;\n // this.bbox.y = y;\n return [x, y, null, null];\n }\n\n refreshLayout(): void {\n this.dotsElem.setAttribute(\"transform\", \"translate(\" + this.x + \",\" + this.y + \")\");\n }\n}\n\n////////// Carnatic embelishments\nexport class LabelEmbelishment extends AtomViewEmbelishment {\n labelElem: SVGTextElement;\n constructor(public readonly label: string, public readonly atomView: AtomView) {\n super(atomView);\n const rootElem = this.atomView.embRoot();\n this.labelElem = TSU.DOM.createSVGNode(\"text\", {\n doc: document,\n parent: rootElem,\n text: label,\n attrs: {\n source: \"atom\" + this.atomView.flatAtom.atom.uuid,\n \"dominant-baseline\": \"hanging\",\n },\n });\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return TSU.DOM.svgBBox(this.labelElem);\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, w, h];\n }\n\n refreshLayout(): void {\n this.labelElem.setAttribute(\"x\", \"\" + this.x);\n this.labelElem.setAttribute(\"y\", \"\" + this.y);\n }\n}\n\nexport class BeatStartLines extends Embelishment {\n barSpacing = 10;\n protected line: SVGLineElement;\n\n constructor(public readonly source: BeatView, public readonly rootElement: SVGGraphicsElement) {\n super();\n this.line = TSU.DOM.createSVGNode(\"line\", {\n doc: document,\n parent: this.rootElement,\n attrs: {\n stroke: \"black\",\n \"stroke-width\": \"1\",\n class: \"bar-start-line\",\n },\n });\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n refreshLayout(): void {\n const line = this.line;\n const x = -this.barSpacing;\n line.setAttribute(\"x1\", \"\" + x);\n line.setAttribute(\"x2\", \"\" + x);\n const y = 0;\n const h = this.source.height;\n line.setAttribute(\"y1\", \"\" + y);\n line.setAttribute(\"y2\", \"\" + (y + h));\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, null, h];\n }\n}\n\nexport class BeatEndLines extends Embelishment {\n lineSpacing = 2;\n protected lines: SVGLineElement[];\n\n constructor(public readonly source: BeatView, public readonly rootElement: SVGGraphicsElement, nLines = 1) {\n super();\n this.lines = [];\n for (let i = 0; i < nLines; i++) {\n this.lines.push(\n TSU.DOM.createSVGNode(\"line\", {\n doc: document,\n // parent: l2g,\n parent: this.rootElement,\n attrs: {\n stroke: \"black\",\n \"stroke-width\": \"1\",\n class: \"bar-end-line\",\n },\n }),\n );\n }\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n protected updatePosition(x: null | number, y: null | number): [number | null, number | null] {\n return [x, y];\n }\n\n barSpacing = 15;\n\n refreshLayout(): void {\n const x = this.source.width + this.barSpacing;\n const y = 0;\n const h = this.source.height;\n let currX = x;\n for (const line of this.lines) {\n const lx = \"\" + currX;\n line.setAttribute(\"x1\", lx);\n line.setAttribute(\"x2\", lx);\n currX += 4;\n }\n for (const line of this.lines) {\n line.setAttribute(\"y1\", \"\" + y);\n line.setAttribute(\"y2\", \"\" + (y + h));\n }\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [null, null, null, null];\n }\n}\n\n/// Carnatic Embelishments\nexport class Kampitham extends LabelEmbelishment {\n constructor(public readonly atomView: AtomView) {\n super(\"~\", atomView);\n }\n}\n\nexport class Nokku extends LabelEmbelishment {\n constructor(public readonly atomView: AtomView) {\n super(\"w\", atomView);\n }\n}\n\nexport class Prathyagatham extends LabelEmbelishment {\n constructor(public readonly atomView: AtomView) {\n super(\"∵\", atomView);\n }\n}\nexport class Spuritham extends LabelEmbelishment {\n constructor(public readonly atomView: AtomView) {\n super(\"∴\", atomView);\n }\n}\nexport class Raavi extends LabelEmbelishment {\n constructor(public readonly atomView: AtomView) {\n super(\"^\", atomView);\n }\n}\nexport class Kandippu extends LabelEmbelishment {\n constructor(public readonly atomView: AtomView) {\n super(\"✓\", atomView);\n }\n}\n\nexport class Vaali extends LabelEmbelishment {\n constructor(public readonly atomView: AtomView) {\n super(\"⌒\", atomView);\n }\n}\nexport class Odukkal extends LabelEmbelishment {\n constructor(public readonly atomView: AtomView) {\n super(\"x\", atomView);\n }\n}\nexport class Orikkai extends LabelEmbelishment {\n constructor(public readonly atomView: AtomView) {\n super(\"γ\", atomView);\n }\n}\n\nexport class Jaaru extends AtomViewEmbelishment {\n pathElem: SVGPathElement;\n constructor(public readonly jaaru: JaaruGamaka, public readonly atomView: AtomView) {\n super(atomView);\n // TODO - Create the \"fancier\" view\n // for now represent this with just a slant line (like a slash)\n const rootElem = this.atomView.embRoot();\n this.pathElem = TSU.DOM.createSVGNode(\"path\", {\n doc: document,\n parent: rootElem,\n attrs: {\n source: \"atom\" + this.atomView.flatAtom.atom.uuid,\n stroke: \"black\",\n fill: \"transparent\",\n d: this.pathAttribute(),\n },\n });\n }\n\n pathAttribute(x = 0): string {\n const avbbox = this.atomView.minSize;\n let y2 = 0;\n const h2 = avbbox.height / 2;\n const x2 = x + h2;\n let y = this.atomView.y;\n if (this.jaaru.ascending) {\n y += avbbox.height;\n y2 = y - h2;\n } else {\n y -= h2;\n y2 = y + h2;\n }\n return [`M ${x} ${y}`, `Q ${x2} ${y} ${x2} ${y2}`].join(\" \");\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return TSU.DOM.svgBBox(this.pathElem);\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, null, null, null];\n }\n\n refreshLayout(): void {\n this.pathElem.setAttribute(\"d\", this.pathAttribute(this.x));\n }\n}\n"]}
@@ -108,7 +108,7 @@ function parseEmbelishment(value) {
108
108
  else if (value == "γ" || value == "Y") {
109
109
  return [new Gamaka(GamakaType.Orikkai), true];
110
110
  }
111
- throw new Error("Invalid carnatic embelishment: " + value);
111
+ return [null, false];
112
112
  }
113
113
  exports.parseEmbelishment = parseEmbelishment;
114
114
  //# sourceMappingURL=gamakas.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"gamakas.js","sourceRoot":"","sources":["../../../src/carnatic/gamakas.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gCAA+B;AAE/B,IAAY,UAwCX;AAxCD,WAAY,UAAU;IAGpB,qCAAuB,CAAA;IAGvB,6BAAe,CAAA;IAGf,qCAAuB,CAAA;IAGvB,6CAA+B,CAAA;IAG/B,sCAAwB,CAAA;IAIxB,4CAA8B,CAAA;IAG9B,6BAAe,CAAA;IAOf,iCAAmB,CAAA;IAGnB,wCAA0B,CAAA;IAG1B,0CAA4B,CAAA;IAI5B,iCAAmB,CAAA;AACrB,CAAC,EAxCW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAwCrB;AAED;IACE,gBAA4B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAChD,2BAAU,GAAV;QACE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;IAC7B,CAAC;IACH,aAAC;AAAD,CAAC,AALD,IAKC;AALY,wBAAM;AAOnB;IAAiC,+BAAM;IACrC,qBAA4B,SAAgB,EAAkB,YAAgC;QAAlE,0BAAA,EAAA,gBAAgB;QAAkB,6BAAA,EAAA,mBAAgC;QAA9F,YACE,kBAAM,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,YA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AC,EAAE,IAAI,CAAC,CAAC;KAC/C;IACD,MAAM,IAAI,KAAK,CAAC,iCAAiC,GAAG,KAAK,CAAC,CAAC;AAE7D,CAAC;AA7BD,8CA6BC","sourcesContent":["import { Note } from \"../core\";\n\nexport enum GamakaType {\n // Kampitam (~)\n // The oscilation between 2 notes - eg p , S..n S..n S..n\n Kampitham = \"Kampitham\",\n\n // Nokku (w)\n Nokku = \"Nokku\",\n\n // Spuritham (∴ / u+2234) - Stress on the second note of a jantai\n Spuritham = \"Spuritham\",\n\n // Prathyagatham (∵ / u+2235) - Similar to reverse of Spuritham (in descending order)\n Prathyagatham = \"Prathyagatham\",\n\n // Raavi (^)\n Aahaatam_Raavi = \"Raavi\",\n\n // Kandippu (✓)\n // eg - Shankarabharanam's S. ,,, n , P ,,, - where the n is subtle\n Aahaatam_Kandippu = \"Kandippu\",\n\n // Vali (⌒ - U+2312)\n Vaali = \"Vaali\",\n\n // Odukkal (x):\n // A veena gamakam where the note itself is stretched more to get the next\n // note effect (instead of plucking the next note itself).\n // Not possible where plucking of strings is not possible.\n // On voice etc it just will sound like an Eetra Jaaru.\n Odukkal = \"Odukkal\",\n\n // (/) Ascension from one note to another - eg S / P\n Jaaru_Eetra = \"EetraJaaru\",\n\n // (\\) Descending from one note to another - eg P \\ S\n Jaaru_Irakka = \"IrakkaJaaru\",\n\n // Orikkai (γ)\n // eg S~~ RN N~~S.D D~~~NP\n Orikkai = \"Orikkai\",\n}\n\nexport class Gamaka {\n constructor(public readonly type: GamakaType) {}\n debugValue(): any {\n return { type: this.type };\n }\n}\n\nexport class JaaruGamaka extends Gamaka {\n constructor(public readonly ascending = true, public readonly startingNote: null | Note = null) {\n super(ascending ? GamakaType.Jaaru_Eetra : GamakaType.Jaaru_Irakka);\n }\n\n debugValue(): any {\n const out = { ...super.debugValue(), ascending: this.ascending };\n if (this.startingNote) out[\"startingNote\"] = this.startingNote.debugValue();\n return out;\n }\n}\n\nexport function parseEmbelishment(value: string): [any, boolean] {\n value = value.substring(1);\n if (value == \"\") {\n return [new Gamaka(GamakaType.Kampitham), true];\n } else if (value == \"^\") {\n return [new Gamaka(GamakaType.Aahaatam_Raavi), true];\n } else if (value == \"~\") {\n return [new Gamaka(GamakaType.Vaali), true];\n } else if (value == \"w\" || value == \"W\") {\n return [new Gamaka(GamakaType.Nokku), true];\n } else if (value == \"∴\" || value == \":-\") {\n return [new Gamaka(GamakaType.Spuritham), true];\n } else if (value == \"∵\" || value == \"-:\") {\n return [new Gamaka(GamakaType.Prathyagatham), true];\n } else if (value == \"✓\" || value == \"./\" || value == \".\\\\\") {\n return [new Gamaka(GamakaType.Aahaatam_Kandippu), true];\n } else if (value.endsWith(\"/\")) {\n value = value.substring(0, value.length - 1).trim();\n return [new JaaruGamaka(true, value.length > 0 ? new Note(value) : null), true];\n } else if (value.endsWith(\"\\\\\")) {\n value = value.substring(0, value.length - 1);\n return [new JaaruGamaka(false, value.length > 0 ? new Note(value) : null), true];\n } else if (value == \"x\") {\n return [new Gamaka(GamakaType.Odukkal), true];\n } else if (value == \"γ\" || value == \"Y\") {\n return [new Gamaka(GamakaType.Orikkai), true];\n }\n throw new Error(\"Invalid carnatic embelishment: \" + value);\n // return null;\n}\n"]}
1
+ {"version":3,"file":"gamakas.js","sourceRoot":"","sources":["../../../src/carnatic/gamakas.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gCAA+B;AAE/B,IAAY,UAwCX;AAxCD,WAAY,UAAU;IAGpB,qCAAuB,CAAA;IAGvB,6BAAe,CAAA;IAGf,qCAAuB,CAAA;IAGvB,6CAA+B,CAAA;IAG/B,sCAAwB,CAAA;IAIxB,4CAA8B,CAAA;IAG9B,6BAAe,CAAA;IAOf,iCAAmB,CAAA;IAGnB,wCAA0B,CAAA;IAG1B,0CAA4B,CAAA;IAI5B,iCAAmB,CAAA;AACrB,CAAC,EAxCW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAwCrB;AAED;IACE,gBAA4B,IA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,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,WAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;KAClF;SAAM,IAAI,KAAK,IAAI,GAAG,EAAE;QACvB,OAAO,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC;KAC/C;SAAM,IAAI,KAAK,IAAI,GAAG,IAAI,KAAK,IAAI,GAAG,EAAE;QACvC,OAAO,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC;KAC/C;IAED,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACvB,CAAC;AA7BD,8CA6BC","sourcesContent":["import { Note } from \"../core\";\n\nexport enum GamakaType {\n // Kampitam (~)\n // The oscilation between 2 notes - eg p , S..n S..n S..n\n Kampitham = \"Kampitham\",\n\n // Nokku (w)\n Nokku = \"Nokku\",\n\n // Spuritham (∴ / u+2234) - Stress on the second note of a jantai\n Spuritham = \"Spuritham\",\n\n // Prathyagatham (∵ / u+2235) - Similar to reverse of Spuritham (in descending order)\n Prathyagatham = \"Prathyagatham\",\n\n // Raavi (^)\n Aahaatam_Raavi = \"Raavi\",\n\n // Kandippu (✓)\n // eg - Shankarabharanam's S. ,,, n , P ,,, - where the n is subtle\n Aahaatam_Kandippu = \"Kandippu\",\n\n // Vali (⌒ - U+2312)\n Vaali = \"Vaali\",\n\n // Odukkal (x):\n // A veena gamakam where the note itself is stretched more to get the next\n // note effect (instead of plucking the next note itself).\n // Not possible where plucking of strings is not possible.\n // On voice etc it just will sound like an Eetra Jaaru.\n Odukkal = \"Odukkal\",\n\n // (/) Ascension from one note to another - eg S / P\n Jaaru_Eetra = \"EetraJaaru\",\n\n // (\\) Descending from one note to another - eg P \\ S\n Jaaru_Irakka = \"IrakkaJaaru\",\n\n // Orikkai (γ)\n // eg S~~ RN N~~S.D D~~~NP\n Orikkai = \"Orikkai\",\n}\n\nexport class Gamaka {\n constructor(public readonly type: GamakaType) {}\n debugValue(): any {\n return { type: this.type };\n }\n}\n\nexport class JaaruGamaka extends Gamaka {\n constructor(public readonly ascending = true, public readonly startingNote: null | Note = null) {\n super(ascending ? GamakaType.Jaaru_Eetra : GamakaType.Jaaru_Irakka);\n }\n\n debugValue(): any {\n const out = { ...super.debugValue(), ascending: this.ascending };\n if (this.startingNote) out[\"startingNote\"] = this.startingNote.debugValue();\n return out;\n }\n}\n\nexport function parseEmbelishment(value: string): [any, boolean] {\n value = value.substring(1);\n if (value == \"\") {\n return [new Gamaka(GamakaType.Kampitham), true];\n } else if (value == \"^\") {\n return [new Gamaka(GamakaType.Aahaatam_Raavi), true];\n } else if (value == \"~\") {\n return [new Gamaka(GamakaType.Vaali), true];\n } else if (value == \"w\" || value == \"W\") {\n return [new Gamaka(GamakaType.Nokku), true];\n } else if (value == \"∴\" || value == \":-\") {\n return [new Gamaka(GamakaType.Spuritham), true];\n } else if (value == \"∵\" || value == \"-:\") {\n return [new Gamaka(GamakaType.Prathyagatham), true];\n } else if (value == \"✓\" || value == \"./\" || value == \".\\\\\") {\n return [new Gamaka(GamakaType.Aahaatam_Kandippu), true];\n } else if (value.endsWith(\"/\")) {\n value = value.substring(0, value.length - 1).trim();\n return [new JaaruGamaka(true, value.length > 0 ? new Note(value) : null), true];\n } else if (value.endsWith(\"\\\\\")) {\n value = value.substring(0, value.length - 1);\n return [new JaaruGamaka(false, value.length > 0 ? new Note(value) : null), true];\n } else if (value == \"x\") {\n return [new Gamaka(GamakaType.Odukkal), true];\n } else if (value == \"γ\" || value == \"Y\") {\n return [new Gamaka(GamakaType.Orikkai), true];\n }\n // throw new Error(\"Invalid carnatic embelishment: \" + value);\n return [null, false];\n}\n"]}
package/lib/cjs/core.js CHANGED
@@ -201,7 +201,7 @@ var Entity = (function () {
201
201
  configurable: true
202
202
  });
203
203
  Entity.prototype.toString = function () {
204
- return "Entity(id = " + this.uuid + ")";
204
+ return "Entity(id = ".concat(this.uuid, ")");
205
205
  };
206
206
  Entity.prototype.equals = function (another, expect) {
207
207
  if (expect === void 0) { expect = false; }
@@ -312,7 +312,7 @@ var Space = (function (_super) {
312
312
  return __assign(__assign({}, _super.prototype.debugValue.call(this)), { isSilent: this.isSilent });
313
313
  };
314
314
  Space.prototype.toString = function () {
315
- return "Space(" + this.duration + "-" + this.isSilent + ")";
315
+ return "Space(".concat(this.duration, "-").concat(this.isSilent, ")");
316
316
  };
317
317
  Space.prototype.copyTo = function (another) {
318
318
  _super.prototype.copyTo.call(this, another);
@@ -341,7 +341,7 @@ var Literal = (function (_super) {
341
341
  return out;
342
342
  };
343
343
  Literal.prototype.toString = function () {
344
- return "Lit(" + this.duration + "-" + this.value + ")";
344
+ return "Lit(".concat(this.duration, "-").concat(this.value, ")");
345
345
  };
346
346
  Literal.prototype.equals = function (another) {
347
347
  return _super.prototype.equals.call(this, another) && this.value == another.value;
@@ -366,7 +366,7 @@ var Syllable = (function (_super) {
366
366
  return out;
367
367
  };
368
368
  Syllable.prototype.toString = function () {
369
- return "Syll(" + this.duration + "-" + this.value + ")";
369
+ return "Syll(".concat(this.duration, "-").concat(this.value, ")");
370
370
  };
371
371
  return Syllable;
372
372
  }(Literal));
@@ -400,7 +400,7 @@ var Note = (function (_super) {
400
400
  return out;
401
401
  };
402
402
  Note.prototype.toString = function () {
403
- return "Note(" + this.duration + "-" + this.value + "-" + this.octave + ")";
403
+ return "Note(".concat(this.duration, "-").concat(this.value, "-").concat(this.octave, ")");
404
404
  };
405
405
  Note.prototype.equals = function (another) {
406
406
  return _super.prototype.equals.call(this, another) && this.octave == another.octave && this.shift == another.shift;
@@ -1 +1 @@
1
- {"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AC,KAAK,WAAE;IAClC,CAAC;IAKD,sBAAI,0BAAQ;aAAZ;YACE,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAlB,CAAkB,EAAE,IAAI,CAAC,CAAC;QAC/D,CAAC;;;OAAA;IACH,WAAC;AAAD,CAAC,AAxCD,CAA0B,MAAM,GAwC/B;AAxCY,oBAAI","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\n\ntype Fraction = TSU.Num.Fraction;\nconst ZERO = TSU.Num.Fraction.ZERO;\nconst ONE = TSU.Num.Fraction.ONE;\n\nexport class Entity {\n private static counter = 0;\n readonly uuid = Entity.counter++;\n metadata: TSU.StringMap<any>;\n parent: TSU.Nullable<Entity> = null;\n\n constructor(config: any = null) {\n config = config || {};\n this.metadata = config.metadata || {};\n }\n\n debugValue(): any {\n if (Object.keys(this.metadata).length > 0) return { metadata: this.metadata, type: this.type };\n else return { type: this.type };\n }\n\n children(): Entity[] {\n return [];\n }\n\n get childCount(): number {\n return this.children().length;\n }\n\n addChild(child: Entity, index = -1): this {\n if (index < 0) {\n this.children().push(child);\n } else {\n this.children().splice(index, 0, child);\n }\n return this;\n }\n\n childAt(index: number): Entity {\n return this.children()[index];\n }\n\n indexOfChild(entity: Entity): number {\n let i = 0;\n for (const child of this.children()) {\n if (child == entity) return i;\n i++;\n }\n return -1;\n }\n\n removeChildAt(index: number): Entity {\n const children = this.children();\n const out = children[index];\n children.splice(index, 1);\n return out;\n }\n\n setChildAt(index: number, entity: Entity): this {\n this.children()[index] = entity;\n return this;\n }\n\n setMetadata(key: string, value: any): this {\n this.metadata[key] = value;\n return this;\n }\n\n getMetadata(key: string, recurse = true): any {\n if (key in this.metadata) {\n return this.metadata[key];\n }\n if (recurse && this.parent) {\n return this.parent.getMetadata(key);\n }\n return null;\n }\n\n /**\n * Returns the type of this Entity.\n */\n get type(): unknown {\n return this.constructor.name;\n }\n\n toString(): string {\n return `Entity(id = ${this.uuid})`;\n }\n\n equals(another: this, expect = false): boolean {\n if (this.type != another.type) return false;\n // check metadata too\n return true;\n }\n\n clone(): this {\n const out = this.newInstance();\n this.copyTo(out);\n return out;\n }\n\n copyTo(another: this): void {\n another.metadata = { ...this.metadata };\n }\n\n protected newInstance(): this {\n return new (this.constructor as any)();\n }\n}\n\nexport abstract class TimedEntity extends Entity {\n // Duration of this entity in beats.\n // By default entities durations are readonly\n abstract get duration(): Fraction;\n\n equals(another: this): boolean {\n return super.equals(another) && this.duration.equals(another.duration);\n }\n}\n\nexport enum AtomType {\n NOTE = \"Note\",\n LITERAL = \"Literal\",\n SYLLABLE = \"Syllable\",\n SPACE = \"Space\",\n GROUP = \"Group\",\n LABEL = \"Label\",\n REST = \"Rest\",\n}\n\nexport abstract class Atom extends TimedEntity {\n protected _duration: Fraction;\n nextSibling: TSU.Nullable<Atom> = null;\n prevSibling: TSU.Nullable<Atom> = null;\n\n constructor(duration = ONE) {\n super();\n this._duration = duration || ONE;\n }\n\n debugValue(): any {\n return this.duration.isOne\n ? super.debugValue()\n : { ...super.debugValue(), duration: this.duration.factorized.toString() };\n }\n\n copyTo(another: this): void {\n super.copyTo(another);\n another.duration = new TSU.Num.Fraction(this.duration.num, this.duration.den);\n }\n\n get duration(): Fraction {\n return this._duration;\n }\n\n set duration(d: Fraction) {\n this._duration = d;\n }\n}\n\nexport abstract class LeafAtom extends Atom {\n // Tells if this atom is followed by a rest\n beforeRest = false;\n\n debugValue(): any {\n return this.beforeRest ? { ...super.debugValue(), beforeRest: true } : super.debugValue();\n }\n}\n\nexport class Rest extends LeafAtom {\n // rests are zero length - why not just use 0 length silent spaces?\n constructor() {\n super(ZERO);\n }\n}\n\n/**\n * Spaces are used to denote either silence or continuations of previous notes.\n */\nexport class Space extends LeafAtom {\n /**\n * Tells if this is a silent space or a continuation of previous note.\n */\n isSilent = false;\n\n constructor(duration = ONE, isSilent = false) {\n super(duration);\n this.isSilent = isSilent;\n }\n\n debugValue(): any {\n return { ...super.debugValue(), isSilent: this.isSilent };\n }\n\n toString(): string {\n return `Space(${this.duration}-${this.isSilent})`;\n }\n\n copyTo(another: this): void {\n super.copyTo(another);\n another.isSilent = this.isSilent;\n }\n\n equals(another: this): boolean {\n return super.equals(another) && this.isSilent == another.isSilent;\n }\n}\n\nexport class Literal extends LeafAtom {\n /**\n * The value of this Syllable.\n */\n embelishments: any[] = [];\n\n constructor(public value: string, duration = ONE) {\n super(duration);\n }\n\n debugValue(): any {\n const out = { ...super.debugValue(), value: this.value };\n if (this.embelishments.length > 0) {\n out.embs = this.embelishments.map((e) => (\"debugValue\" in e ? e.debugValue() : e));\n }\n return out;\n }\n\n toString(): string {\n return `Lit(${this.duration}-${this.value})`;\n }\n\n equals(another: this): boolean {\n return super.equals(another) && this.value == another.value;\n }\n\n copyTo(another: this): void {\n super.copyTo(another);\n another.value = this.value;\n }\n}\n\nexport class Syllable extends Literal {\n static fromLit(lit: Literal): Syllable {\n if (lit.type == AtomType.SYLLABLE) return lit as Syllable;\n const out = new Syllable(lit.value, lit.duration);\n out.embelishments = lit.embelishments;\n return out;\n }\n\n toString(): string {\n return `Syll(${this.duration}-${this.value})`;\n }\n}\n\nexport class Note extends Literal {\n /**\n * Which octave is the note in. Can be +ve or -ve to indicate higher or lower octaves.\n */\n octave = 0;\n\n /**\n * How is the note shifted - ie by shifted towards major or minore by # of semi-tones.\n */\n shift: number | boolean = 0;\n\n constructor(value: string, duration = ONE, octave = 0, shift = 0) {\n super(value, duration);\n this.octave = octave;\n this.shift = shift;\n }\n\n static fromLit(lit: Literal): Note {\n if (lit.type == AtomType.NOTE) return lit as Note;\n const out = new Note(lit.value, lit.duration);\n out.embelishments = lit.embelishments;\n return out;\n }\n\n debugValue(): any {\n const out = { ...super.debugValue() };\n if (this.octave != 0) out.octave = this.octave;\n if (this.shift != 0) out.shift = this.shift;\n return out;\n }\n\n toString(): string {\n return `Note(${this.duration}-${this.value}-${this.octave})`;\n }\n\n equals(another: this): boolean {\n return super.equals(another) && this.octave == another.octave && this.shift == another.shift;\n }\n\n copyTo(another: this): void {\n super.copyTo(another);\n another.octave = this.octave;\n another.shift = this.shift;\n }\n}\n\nexport class Group extends Atom {\n /**\n * This indicates whether our duration is static or linear to number of\n * atoms in this group.\n */\n durationIsMultiplier = false;\n readonly atoms: TSU.Lists.ValueList<Atom> = new TSU.Lists.ValueList<Atom>();\n\n constructor(duration = ONE, ...atoms: Atom[]) {\n super(duration);\n this.addAtoms(...atoms);\n }\n\n get duration(): Fraction {\n if (this.durationIsMultiplier) {\n return this.totalChildDuration.divby(this._duration);\n } else {\n return this._duration;\n }\n }\n\n set duration(d: Fraction) {\n this._duration = d;\n }\n\n debugValue(): any {\n const out = { ...super.debugValue(), atoms: Array.from(this.atoms.values(), (a) => a.debugValue()) };\n if (this.durationIsMultiplier) out.durationIsMultiplier = true;\n return out;\n }\n\n get totalChildDuration(): Fraction {\n let out = ZERO;\n this.atoms.forEach((atom) => (out = out.plus(atom.duration)));\n return out;\n }\n\n /** Entities can have children and thus siblings and parents. */\n equals(another: this, expect = false): boolean {\n if (!super.equals(another)) return false;\n return this.atoms.equals(another.atoms, (a1, a2) => a1.equals(a2));\n }\n\n copyTo(another: this): void {\n super.copyTo(another);\n this.atoms.forEach((atom) => another.atoms.add(atom.clone()));\n }\n\n addAtoms(...atoms: Atom[]): this {\n for (const atom of atoms) {\n if (atom.type == AtomType.REST) {\n const last = this.atoms.last;\n if (last && last.type != AtomType.GROUP && last.type != AtomType.LABEL) {\n (last as LeafAtom).beforeRest = true;\n }\n } else {\n atom.parent = this;\n this.atoms.add(atom);\n }\n }\n return this;\n }\n}\n\nexport type CyclePosition = [number, number, number];\nexport type CycleIterator = Generator<[CyclePosition, Fraction]>;\n\nexport class CycleCursor {\n constructor(public readonly cycle: Cycle, public barIndex = 0, public beatIndex = 0, public instance = 0) {}\n\n get next(): [CyclePosition, Fraction] {\n const currBar = this.cycle.bars[this.barIndex];\n const result: [CyclePosition, Fraction] = [\n [this.barIndex, this.beatIndex, this.instance],\n currBar.beatLengths[this.beatIndex],\n ];\n this.instance++;\n if (!currBar.beatCounts[this.beatIndex] || this.instance >= currBar.beatCounts[this.beatIndex]) {\n this.instance = 0;\n this.beatIndex++;\n if (this.beatIndex >= currBar.beatLengths.length) {\n this.beatIndex = 0;\n this.barIndex++;\n if (this.barIndex >= this.cycle.bars.length) {\n this.barIndex = 0;\n }\n }\n }\n return result;\n }\n\n get prev(): [CyclePosition, Fraction] {\n const currBar = this.cycle.bars[this.barIndex];\n const result: [CyclePosition, Fraction] = [\n [this.barIndex, this.beatIndex, this.instance],\n currBar.beatLengths[this.beatIndex],\n ];\n // TODO - result should be set *after* decrementing if we had already\n // done a \"next\" before this otherwise user may have to do a prev twice\n this.instance--;\n if (this.instance < 0) {\n this.beatIndex--;\n if (this.beatIndex < 0) {\n this.barIndex--;\n if (this.barIndex < 0) {\n this.barIndex = this.cycle.bars.length - 1;\n }\n this.beatIndex = this.cycle.bars[this.barIndex].beatCount - 1;\n }\n this.instance = (this.cycle.bars[this.barIndex].beatCounts[this.beatIndex] || 1) - 1;\n }\n return result;\n }\n}\n\nexport class Bar extends TimedEntity {\n name: string;\n // Length/Duration of each beat.\n beatLengths: Fraction[] = [];\n\n // How many times should a beat be repeated - the Kalai!\n beatCounts: number[] = [];\n\n constructor(config: any = null) {\n super((config = config || {}));\n this.name = config.name || \"\";\n for (const bl of config.beatLengths || []) {\n if (typeof bl === \"number\") {\n this.beatLengths.push(TSU.Num.Frac(bl));\n } else {\n this.beatLengths.push(bl);\n }\n }\n for (const bc of config.beatCounts || []) {\n this.beatCounts.push(bc);\n }\n while (this.beatCounts.length < this.beatLengths.length) {\n this.beatCounts.push(1);\n }\n }\n\n debugValue(): any {\n return { ...super.debugValue(), name: name, beatLengths: this.beatLengths };\n }\n\n equals(another: this): boolean {\n if (!super.equals(another)) return false;\n if (this.beatLengths.length != another.beatLengths.length) return false;\n if (this.beatCounts.length != another.beatCounts.length) return false;\n for (let i = 0; i < this.beatLengths.length; i++) {\n if (!this.beatLengths[i].equals(another.beatLengths[i])) return false;\n }\n for (let i = 0; i < this.beatCounts.length; i++) {\n if (this.beatCounts[i] != another.beatCounts[i]) return false;\n }\n return true;\n }\n\n copyTo(another: this): void {\n super.copyTo(another);\n another.name = this.name;\n another.beatLengths = [...this.beatLengths];\n another.beatCounts = [...this.beatCounts];\n }\n\n get beatCount(): number {\n return this.beatLengths.length;\n }\n\n get totalBeatCount(): number {\n let out = 0;\n for (let i = 0; i < this.beatLengths.length; i++) {\n out += this.beatCounts[i] || 1;\n }\n return out;\n }\n\n /**\n * Total duration (of time) across all beats in this bar.\n */\n get duration(): Fraction {\n let total = ZERO;\n for (let i = 0; i < this.beatLengths.length; i++) {\n total = total.plus(this.beatLengths[i].timesNum(this.beatCounts[i] || 1));\n }\n return total;\n }\n}\n\n// Describes the cycle pattern\nexport class Cycle extends TimedEntity {\n name: string;\n bars: Bar[];\n\n static readonly DEFAULT = new Cycle({\n name: \"Adi Thalam\",\n bars: [\n new Bar({ name: \"Laghu\", beatLengths: [1, 1, 1, 1] }),\n new Bar({ name: \"Dhrutam\", beatLengths: [1, 1] }),\n new Bar({ name: \"Dhrutam\", beatLengths: [1, 1] }),\n ],\n });\n\n constructor(config: null | { name?: string; bars?: Bar[] } = null) {\n super((config = config || {}));\n this.name = config.name || \"\";\n this.bars = config.bars || [];\n }\n\n debugValue(): any {\n return { ...super.debugValue(), name: name, bars: this.bars.map((p) => p.debugValue()) };\n }\n\n children(): Entity[] {\n return this.bars;\n }\n\n equals(another: this): boolean {\n if (!super.equals(another)) {\n return false;\n }\n if (this.bars.length != another.bars.length) return false;\n for (let i = 0; i < this.bars.length; i++) {\n if (!this.bars[i].equals(another.bars[i])) return false;\n }\n return true;\n }\n\n /**\n * Given a global beat index returns four values [cycle,bar,beat,instance] where:\n *\n * cycle - The nth cycle in which the beat lies. Since the global beat\n * index can be greater the number of beats in this cycle this\n * allows us to wrap around. Similarly if beatindex is less than\n * 0 then we can also go behind a cycle.\n * bar - The mth bar in the nth cycle which the offset exists\n * beat - The beat within the mth bar in the nth cycle where the\n * offset lies\n * instance - The beat instance where the offset lies.\n * startOffset - Offset of the beat at this global index.\n */\n getAtIndex(globalIndex: number): [number, CyclePosition, Fraction] {\n let cycle = 0;\n while (globalIndex < 0) {\n globalIndex += this.totalBeatCount;\n cycle--;\n }\n if (globalIndex >= this.totalBeatCount) {\n cycle = Math.floor(globalIndex / this.totalBeatCount);\n }\n globalIndex = globalIndex % this.totalBeatCount;\n let offset = ZERO;\n for (let barIndex = 0; barIndex < this.bars.length; barIndex++) {\n const bar = this.bars[barIndex];\n if (globalIndex >= bar.totalBeatCount) {\n globalIndex -= bar.totalBeatCount;\n offset = offset.plus(bar.duration);\n } else {\n // this is the bar!\n for (let beatIndex = 0; beatIndex < bar.beatCount; beatIndex++) {\n const beatLength = bar.beatLengths[beatIndex];\n const beatCount = bar.beatCounts[beatIndex] || 1;\n if (globalIndex >= beatCount) {\n globalIndex -= beatCount;\n offset = offset.plus(beatLength.timesNum(beatCount));\n } else {\n // this is it\n const instance = globalIndex;\n return [cycle, [barIndex, beatIndex, instance], offset.plus(beatLength.timesNum(instance))];\n }\n }\n }\n }\n throw new Error(\"Should not be here!\");\n }\n\n /**\n * Given a global offset returns five values [cycle, bar,beat,instance,offset] where:\n *\n * cycle - The nth cycle in which the beat lies. Since the global offset can be\n * greater the duration of the cycle this allows us to wrap around.\n * Similarly if globalOffset is less than 0 then we can also go behind a cycle.\n * bar - The mth bar in the nth cycle which the offset exists\n * beat - The beat within the mth bar in the nth cycle where the offset lies\n * instance - The beat instance where the offset lies.\n * startOffset - The note offset within the beat where the global offset lies.\n * globalIndex - The beat index within the entire cycle and not just within the bar.\n */\n getPosition(globalOffset: Fraction): [number, CyclePosition, Fraction, number] {\n const duration = this.duration;\n let cycleNum = 0;\n if (globalOffset.isLT(ZERO)) {\n while (globalOffset.isLT(ZERO)) {\n cycleNum--;\n globalOffset = globalOffset.plus(duration);\n }\n } else if (globalOffset.isGTE(duration)) {\n const realOffset = globalOffset.mod(duration);\n globalOffset = globalOffset.minus(realOffset).divby(duration);\n TSU.assert(globalOffset.isWhole);\n cycleNum = globalOffset.floor;\n globalOffset = realOffset;\n }\n\n // here globalOffset is positive and >= 0 and < this.duration\n let globalIndex = 0;\n for (let barIndex = 0; barIndex < this.bars.length; barIndex++) {\n const bar = this.bars[barIndex];\n const barDuration = bar.duration;\n if (globalOffset.isGTE(barDuration)) {\n globalOffset = globalOffset.minus(barDuration);\n } else {\n // this is the bar!\n for (let beatIndex = 0; beatIndex < bar.beatCount; beatIndex++) {\n const beatLength = bar.beatLengths[beatIndex];\n const beatCount = bar.beatCounts[beatIndex] || 1;\n for (let instance = 0; instance < beatCount; instance++, globalIndex++) {\n if (globalOffset.isGTE(beatLength)) {\n globalOffset = globalOffset.minus(beatLength);\n } else {\n // this is it\n return [cycleNum, [barIndex, beatIndex, instance], globalOffset, globalIndex];\n }\n }\n }\n }\n globalIndex += bar.totalBeatCount;\n }\n\n throw new Error(\"Should not be here!\");\n }\n\n *iterateBeats(startBar = 0, startBeat = 0, startInstance = 0): CycleIterator {\n let barIndex = startBar;\n let beatIndex = startBeat;\n let instanceIndex = startInstance;\n while (true) {\n const currBar = this.bars[barIndex];\n yield [[barIndex, beatIndex, instanceIndex], currBar.beatLengths[beatIndex]];\n instanceIndex++;\n if (!currBar.beatCounts[beatIndex] || instanceIndex >= currBar.beatCounts[beatIndex]) {\n instanceIndex = 0;\n beatIndex++;\n if (beatIndex >= currBar.beatLengths.length) {\n beatIndex = 0;\n barIndex++;\n if (barIndex >= this.bars.length) {\n barIndex = 0;\n }\n }\n }\n }\n }\n\n copyTo(another: this): void {\n super.copyTo(another);\n another.name = this.name;\n another.bars = this.bars.map((x) => x.clone());\n }\n\n get beatCount(): number {\n let out = 0;\n for (const bar of this.bars) out += bar.beatCount;\n return out;\n }\n\n get totalBeatCount(): number {\n let out = 0;\n for (const bar of this.bars) out += bar.totalBeatCount;\n return out;\n }\n\n /**\n * Total duration (of time) across all bars in this cycle.\n */\n get duration(): Fraction {\n return this.bars.reduce((x, y) => x.plus(y.duration), ZERO);\n }\n}\n\nexport class Line extends Entity {\n // Line can have atoms starting \"before\" the cycle. The offset tells how many notes\n // before or after the cycle this line's atoms start at.\n offset: Fraction = ZERO;\n roles: Role[] = [];\n\n // This is a very hacky solution to doing left side pre-margin text typically found\n // in notations - eg line X of a pallavi has this. This makes vertical space less wasteful\n // A better solution is inter-beat annotation but it is very complex and ambiguous for now\n marginText = \"\";\n\n get isEmpty(): boolean {\n for (const r of this.roles) if (!r.isEmpty) return false;\n return true;\n }\n\n debugValue(): any {\n const out = {\n ...super.debugValue(),\n roles: this.roles.map((r) => r.debugValue()),\n // layoutParams: this.layoutParams?.uuid,\n };\n if (!this.offset.isZero) {\n out.offset = this.offset.toString();\n }\n return out;\n }\n\n copyTo(another: this): void {\n super.copyTo(another);\n another.roles = this.roles.map((r) => r.clone());\n }\n\n addAtoms(roleName: string, defaultToNotes: boolean, ...atoms: Atom[]): this {\n const role = this.ensureRole(roleName, defaultToNotes);\n role.addAtoms(...atoms);\n return this;\n }\n\n ensureRole(roleName: string, defaultToNotes: boolean): Role {\n // Ensure we have this many roles\n let ri = this.roles.findIndex((r) => r.name == roleName);\n if (ri < 0) {\n ri = this.roles.length;\n const role = new Role(this, roleName);\n role.defaultToNotes = defaultToNotes;\n this.roles.push(role);\n }\n return this.roles[ri];\n }\n\n /**\n * Returns the maximum duration of all roles in this line.\n */\n get duration(): Fraction {\n let max = ZERO;\n for (const role of this.roles) {\n max = TSU.Num.Fraction.max(role.duration, max);\n }\n return max;\n }\n}\n\nexport class Role extends Entity {\n defaultToNotes = true;\n atoms: Atom[] = [];\n\n constructor(public readonly line: Line, public readonly name: string) {\n super();\n }\n\n get isEmpty(): boolean {\n return this.atoms.length == 0;\n }\n\n debugValue(): any {\n return { name: this.name, atoms: this.atoms.map((a) => a.debugValue()) };\n }\n\n addAtoms(...atoms: Atom[]): void {\n let last: null | Atom = null;\n for (const atom of atoms) {\n if (atom.type == AtomType.REST) {\n if (last && last.type != AtomType.GROUP && last.type != AtomType.LABEL) {\n (last as LeafAtom).beforeRest = true;\n }\n } else {\n this.atoms.push(atom);\n }\n last = atom;\n }\n }\n\n copyTo(another: Role): void {\n another.addAtoms(...this.atoms);\n }\n\n /**\n * Duration for this role.\n */\n get duration(): Fraction {\n return this.atoms.reduce((a, b) => a.plus(b.duration), ZERO);\n }\n}\n"]}
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAuC;AAGvC,IAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;AACnC,IAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;AAEjC;IAME,gBAAY,MAAkB;QAAlB,uBAAA,EAAA,aAAkB;QAJrB,SAAI,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;QAEjC,WAAM,GAAyB,IAAI,CAAC;QAGlC,MAAM,GAAG,MAAM,IAAI,EAAE,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC;IACxC,CAAC;IAED,2BAAU,GAAV;QACE,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;;YAC1F,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;IA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A,4BAAA,+CAAE;gBAArB,IAAM,IAAI,kBAAA;gBACb,IAAI,IAAI,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,EAAE;oBAC9B,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,QAAQ,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,IAAI,QAAQ,CAAC,KAAK,EAAE;wBACrE,IAAiB,CAAC,UAAU,GAAG,IAAI,CAAC;qBACtC;iBACF;qBAAM;oBACL,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBACvB;gBACD,IAAI,GAAG,IAAI,CAAC;aACb;;;;;;;;;IACH,CAAC;IAED,qBAAM,GAAN,UAAO,OAAa;QAClB,OAAO,CAAC,QAAQ,OAAhB,OAAO,2BAAa,IAAI,CAAC,KAAK,WAAE;IAClC,CAAC;IAKD,sBAAI,0BAAQ;aAAZ;YACE,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAlB,CAAkB,EAAE,IAAI,CAAC,CAAC;QAC/D,CAAC;;;OAAA;IACH,WAAC;AAAD,CAAC,AAxCD,CAA0B,MAAM,GAwC/B;AAxCY,oBAAI","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\n\ntype Fraction = TSU.Num.Fraction;\nconst ZERO = TSU.Num.Fraction.ZERO;\nconst ONE = TSU.Num.Fraction.ONE;\n\nexport class Entity {\n private static counter = 0;\n readonly uuid = Entity.counter++;\n metadata: TSU.StringMap<any>;\n parent: TSU.Nullable<Entity> = null;\n\n constructor(config: any = null) {\n config = config || {};\n this.metadata = config.metadata || {};\n }\n\n debugValue(): any {\n if (Object.keys(this.metadata).length > 0) return { metadata: this.metadata, type: this.type };\n else return { type: this.type };\n }\n\n children(): Entity[] {\n return [];\n }\n\n get childCount(): number {\n return this.children().length;\n }\n\n addChild(child: Entity, index = -1): this {\n if (index < 0) {\n this.children().push(child);\n } else {\n this.children().splice(index, 0, child);\n }\n return this;\n }\n\n childAt(index: number): Entity {\n return this.children()[index];\n }\n\n indexOfChild(entity: Entity): number {\n let i = 0;\n for (const child of this.children()) {\n if (child == entity) return i;\n i++;\n }\n return -1;\n }\n\n removeChildAt(index: number): Entity {\n const children = this.children();\n const out = children[index];\n children.splice(index, 1);\n return out;\n }\n\n setChildAt(index: number, entity: Entity): this {\n this.children()[index] = entity;\n return this;\n }\n\n setMetadata(key: string, value: any): this {\n this.metadata[key] = value;\n return this;\n }\n\n getMetadata(key: string, recurse = true): any {\n if (key in this.metadata) {\n return this.metadata[key];\n }\n if (recurse && this.parent) {\n return this.parent.getMetadata(key);\n }\n return null;\n }\n\n /**\n * Returns the type of this Entity.\n */\n get type(): unknown {\n return this.constructor.name;\n }\n\n toString(): string {\n return `Entity(id = ${this.uuid})`;\n }\n\n equals(another: this, expect = false): boolean {\n if (this.type != another.type) return false;\n // check metadata too\n return true;\n }\n\n clone(): this {\n const out = this.newInstance();\n this.copyTo(out);\n return out;\n }\n\n copyTo(another: this): void {\n another.metadata = { ...this.metadata };\n }\n\n protected newInstance(): this {\n return new (this.constructor as any)();\n }\n}\n\nexport abstract class TimedEntity extends Entity {\n // Duration of this entity in beats.\n // By default entities durations are readonly\n abstract get duration(): Fraction;\n\n equals(another: this): boolean {\n return super.equals(another) && this.duration.equals(another.duration);\n }\n}\n\nexport enum AtomType {\n NOTE = \"Note\",\n LITERAL = \"Literal\",\n SYLLABLE = \"Syllable\",\n SPACE = \"Space\",\n GROUP = \"Group\",\n LABEL = \"Label\",\n REST = \"Rest\",\n}\n\nexport abstract class Atom extends TimedEntity {\n protected _duration: Fraction;\n nextSibling: TSU.Nullable<Atom> = null;\n prevSibling: TSU.Nullable<Atom> = null;\n\n constructor(duration = ONE) {\n super();\n this._duration = duration || ONE;\n }\n\n debugValue(): any {\n return this.duration.isOne\n ? super.debugValue()\n : { ...super.debugValue(), duration: this.duration.factorized.toString() };\n }\n\n copyTo(another: this): void {\n super.copyTo(another);\n another.duration = new TSU.Num.Fraction(this.duration.num, this.duration.den);\n }\n\n get duration(): Fraction {\n return this._duration;\n }\n\n set duration(d: Fraction) {\n this._duration = d;\n }\n}\n\nexport abstract class LeafAtom extends Atom {\n // Tells if this atom is followed by a rest\n beforeRest = false;\n\n debugValue(): any {\n return this.beforeRest ? { ...super.debugValue(), beforeRest: true } : super.debugValue();\n }\n}\n\nexport class Rest extends LeafAtom {\n // rests are zero length - why not just use 0 length silent spaces?\n constructor() {\n super(ZERO);\n }\n}\n\n/**\n * Spaces are used to denote either silence or continuations of previous notes.\n */\nexport class Space extends LeafAtom {\n /**\n * Tells if this is a silent space or a continuation of previous note.\n */\n isSilent = false;\n\n constructor(duration = ONE, isSilent = false) {\n super(duration);\n this.isSilent = isSilent;\n }\n\n debugValue(): any {\n return { ...super.debugValue(), isSilent: this.isSilent };\n }\n\n toString(): string {\n return `Space(${this.duration}-${this.isSilent})`;\n }\n\n copyTo(another: this): void {\n super.copyTo(another);\n another.isSilent = this.isSilent;\n }\n\n equals(another: this): boolean {\n return super.equals(another) && this.isSilent == another.isSilent;\n }\n}\n\nexport class Literal extends LeafAtom {\n /**\n * The value of this Syllable.\n */\n embelishments: any[] = [];\n\n constructor(public value: string, duration = ONE) {\n super(duration);\n }\n\n debugValue(): any {\n const out = { ...super.debugValue(), value: this.value };\n if (this.embelishments.length > 0) {\n out.embs = this.embelishments.map((e) => (\"debugValue\" in e ? e.debugValue() : e));\n }\n return out;\n }\n\n toString(): string {\n return `Lit(${this.duration}-${this.value})`;\n }\n\n equals(another: this): boolean {\n return super.equals(another) && this.value == another.value;\n }\n\n copyTo(another: this): void {\n super.copyTo(another);\n another.value = this.value;\n }\n}\n\nexport class Syllable extends Literal {\n static fromLit(lit: Literal): Syllable {\n if (lit.type == AtomType.SYLLABLE) return lit as Syllable;\n const out = new Syllable(lit.value, lit.duration);\n out.embelishments = lit.embelishments;\n return out;\n }\n\n toString(): string {\n return `Syll(${this.duration}-${this.value})`;\n }\n}\n\nexport class Note extends Literal {\n /**\n * Which octave is the note in. Can be +ve or -ve to indicate higher or lower octaves.\n */\n octave = 0;\n\n /**\n * How is the note shifted - ie by shifted towards major or minore by # of semi-tones.\n */\n shift: number | boolean = 0;\n\n constructor(value: string, duration = ONE, octave = 0, shift = 0) {\n super(value, duration);\n this.octave = octave;\n this.shift = shift;\n }\n\n static fromLit(lit: Literal): Note {\n if (lit.type == AtomType.NOTE) return lit as Note;\n const out = new Note(lit.value, lit.duration);\n out.embelishments = lit.embelishments;\n return out;\n }\n\n debugValue(): any {\n const out = { ...super.debugValue() };\n if (this.octave != 0) out.octave = this.octave;\n if (this.shift != 0) out.shift = this.shift;\n return out;\n }\n\n toString(): string {\n return `Note(${this.duration}-${this.value}-${this.octave})`;\n }\n\n equals(another: this): boolean {\n return super.equals(another) && this.octave == another.octave && this.shift == another.shift;\n }\n\n copyTo(another: this): void {\n super.copyTo(another);\n another.octave = this.octave;\n another.shift = this.shift;\n }\n}\n\nexport class Group extends Atom {\n /**\n * This indicates whether our duration is static or linear to number of\n * atoms in this group.\n */\n durationIsMultiplier = false;\n readonly atoms: TSU.Lists.ValueList<Atom> = new TSU.Lists.ValueList<Atom>();\n\n constructor(duration = ONE, ...atoms: Atom[]) {\n super(duration);\n this.addAtoms(...atoms);\n }\n\n get duration(): Fraction {\n if (this.durationIsMultiplier) {\n return this.totalChildDuration.divby(this._duration);\n } else {\n return this._duration;\n }\n }\n\n set duration(d: Fraction) {\n this._duration = d;\n }\n\n debugValue(): any {\n const out = { ...super.debugValue(), atoms: Array.from(this.atoms.values(), (a) => a.debugValue()) };\n if (this.durationIsMultiplier) out.durationIsMultiplier = true;\n return out;\n }\n\n get totalChildDuration(): Fraction {\n let out = ZERO;\n this.atoms.forEach((atom) => (out = out.plus(atom.duration)));\n return out;\n }\n\n /** Entities can have children and thus siblings and parents. */\n equals(another: this, expect = false): boolean {\n if (!super.equals(another)) return false;\n return this.atoms.equals(another.atoms, (a1, a2) => a1.equals(a2));\n }\n\n copyTo(another: this): void {\n super.copyTo(another);\n this.atoms.forEach((atom) => another.atoms.add(atom.clone()));\n }\n\n addAtoms(...atoms: Atom[]): this {\n for (const atom of atoms) {\n if (atom.type == AtomType.REST) {\n const last = this.atoms.last;\n if (last && last.type != AtomType.GROUP && last.type != AtomType.LABEL) {\n (last as LeafAtom).beforeRest = true;\n }\n } else {\n atom.parent = this;\n this.atoms.add(atom);\n }\n }\n return this;\n }\n}\n\nexport type CyclePosition = [number, number, number];\nexport type CycleIterator = Generator<[CyclePosition, Fraction]>;\n\nexport class CycleCursor {\n constructor(public readonly cycle: Cycle, public barIndex = 0, public beatIndex = 0, public instance = 0) {}\n\n get next(): [CyclePosition, Fraction] {\n const currBar = this.cycle.bars[this.barIndex];\n const result: [CyclePosition, Fraction] = [\n [this.barIndex, this.beatIndex, this.instance],\n currBar.beatLengths[this.beatIndex],\n ];\n this.instance++;\n if (!currBar.beatCounts[this.beatIndex] || this.instance >= currBar.beatCounts[this.beatIndex]) {\n this.instance = 0;\n this.beatIndex++;\n if (this.beatIndex >= currBar.beatLengths.length) {\n this.beatIndex = 0;\n this.barIndex++;\n if (this.barIndex >= this.cycle.bars.length) {\n this.barIndex = 0;\n }\n }\n }\n return result;\n }\n\n get prev(): [CyclePosition, Fraction] {\n const currBar = this.cycle.bars[this.barIndex];\n const result: [CyclePosition, Fraction] = [\n [this.barIndex, this.beatIndex, this.instance],\n currBar.beatLengths[this.beatIndex],\n ];\n // TODO - result should be set *after* decrementing if we had already\n // done a \"next\" before this otherwise user may have to do a prev twice\n this.instance--;\n if (this.instance < 0) {\n this.beatIndex--;\n if (this.beatIndex < 0) {\n this.barIndex--;\n if (this.barIndex < 0) {\n this.barIndex = this.cycle.bars.length - 1;\n }\n this.beatIndex = this.cycle.bars[this.barIndex].beatCount - 1;\n }\n this.instance = (this.cycle.bars[this.barIndex].beatCounts[this.beatIndex] || 1) - 1;\n }\n return result;\n }\n}\n\nexport class Bar extends TimedEntity {\n name: string;\n // Length/Duration of each beat.\n beatLengths: Fraction[] = [];\n\n // How many times should a beat be repeated - the Kalai!\n beatCounts: number[] = [];\n\n constructor(config: any = null) {\n super((config = config || {}));\n this.name = config.name || \"\";\n for (const bl of config.beatLengths || []) {\n if (typeof bl === \"number\") {\n this.beatLengths.push(TSU.Num.Frac(bl));\n } else {\n this.beatLengths.push(bl);\n }\n }\n for (const bc of config.beatCounts || []) {\n this.beatCounts.push(bc);\n }\n while (this.beatCounts.length < this.beatLengths.length) {\n this.beatCounts.push(1);\n }\n }\n\n debugValue(): any {\n return { ...super.debugValue(), name: name, beatLengths: this.beatLengths };\n }\n\n equals(another: this): boolean {\n if (!super.equals(another)) return false;\n if (this.beatLengths.length != another.beatLengths.length) return false;\n if (this.beatCounts.length != another.beatCounts.length) return false;\n for (let i = 0; i < this.beatLengths.length; i++) {\n if (!this.beatLengths[i].equals(another.beatLengths[i])) return false;\n }\n for (let i = 0; i < this.beatCounts.length; i++) {\n if (this.beatCounts[i] != another.beatCounts[i]) return false;\n }\n return true;\n }\n\n copyTo(another: this): void {\n super.copyTo(another);\n another.name = this.name;\n another.beatLengths = [...this.beatLengths];\n another.beatCounts = [...this.beatCounts];\n }\n\n get beatCount(): number {\n return this.beatLengths.length;\n }\n\n get totalBeatCount(): number {\n let out = 0;\n for (let i = 0; i < this.beatLengths.length; i++) {\n out += this.beatCounts[i] || 1;\n }\n return out;\n }\n\n /**\n * Total duration (of time) across all beats in this bar.\n */\n get duration(): Fraction {\n let total = ZERO;\n for (let i = 0; i < this.beatLengths.length; i++) {\n total = total.plus(this.beatLengths[i].timesNum(this.beatCounts[i] || 1));\n }\n return total;\n }\n}\n\n// Describes the cycle pattern\nexport class Cycle extends TimedEntity {\n name: string;\n bars: Bar[];\n\n static readonly DEFAULT = new Cycle({\n name: \"Adi Thalam\",\n bars: [\n new Bar({ name: \"Laghu\", beatLengths: [1, 1, 1, 1] }),\n new Bar({ name: \"Dhrutam\", beatLengths: [1, 1] }),\n new Bar({ name: \"Dhrutam\", beatLengths: [1, 1] }),\n ],\n });\n\n constructor(config: null | { name?: string; bars?: Bar[] } = null) {\n super((config = config || {}));\n this.name = config.name || \"\";\n this.bars = config.bars || [];\n }\n\n debugValue(): any {\n return { ...super.debugValue(), name: name, bars: this.bars.map((p) => p.debugValue()) };\n }\n\n children(): Entity[] {\n return this.bars;\n }\n\n equals(another: this): boolean {\n if (!super.equals(another)) {\n return false;\n }\n if (this.bars.length != another.bars.length) return false;\n for (let i = 0; i < this.bars.length; i++) {\n if (!this.bars[i].equals(another.bars[i])) return false;\n }\n return true;\n }\n\n /**\n * Given a global beat index returns four values [cycle,bar,beat,instance] where:\n *\n * cycle - The nth cycle in which the beat lies. Since the global beat\n * index can be greater the number of beats in this cycle this\n * allows us to wrap around. Similarly if beatindex is less than\n * 0 then we can also go behind a cycle.\n * bar - The mth bar in the nth cycle which the offset exists\n * beat - The beat within the mth bar in the nth cycle where the\n * offset lies\n * instance - The beat instance where the offset lies.\n * startOffset - Offset of the beat at this global index.\n */\n getAtIndex(globalIndex: number): [number, CyclePosition, Fraction] {\n let cycle = 0;\n while (globalIndex < 0) {\n globalIndex += this.totalBeatCount;\n cycle--;\n }\n if (globalIndex >= this.totalBeatCount) {\n cycle = Math.floor(globalIndex / this.totalBeatCount);\n }\n globalIndex = globalIndex % this.totalBeatCount;\n let offset = ZERO;\n for (let barIndex = 0; barIndex < this.bars.length; barIndex++) {\n const bar = this.bars[barIndex];\n if (globalIndex >= bar.totalBeatCount) {\n globalIndex -= bar.totalBeatCount;\n offset = offset.plus(bar.duration);\n } else {\n // this is the bar!\n for (let beatIndex = 0; beatIndex < bar.beatCount; beatIndex++) {\n const beatLength = bar.beatLengths[beatIndex];\n const beatCount = bar.beatCounts[beatIndex] || 1;\n if (globalIndex >= beatCount) {\n globalIndex -= beatCount;\n offset = offset.plus(beatLength.timesNum(beatCount));\n } else {\n // this is it\n const instance = globalIndex;\n return [cycle, [barIndex, beatIndex, instance], offset.plus(beatLength.timesNum(instance))];\n }\n }\n }\n }\n throw new Error(\"Should not be here!\");\n }\n\n /**\n * Given a global offset returns five values [cycle, bar,beat,instance,offset] where:\n *\n * cycle - The nth cycle in which the beat lies. Since the global offset can be\n * greater the duration of the cycle this allows us to wrap around.\n * Similarly if globalOffset is less than 0 then we can also go behind a cycle.\n * bar - The mth bar in the nth cycle which the offset exists\n * beat - The beat within the mth bar in the nth cycle where the offset lies\n * instance - The beat instance where the offset lies.\n * startOffset - The note offset within the beat where the global offset lies.\n * globalIndex - The beat index within the entire cycle and not just within the bar.\n */\n getPosition(globalOffset: Fraction): [number, CyclePosition, Fraction, number] {\n const duration = this.duration;\n let cycleNum = 0;\n if (globalOffset.isLT(ZERO)) {\n while (globalOffset.isLT(ZERO)) {\n cycleNum--;\n globalOffset = globalOffset.plus(duration);\n }\n } else if (globalOffset.isGTE(duration)) {\n const realOffset = globalOffset.mod(duration);\n globalOffset = globalOffset.minus(realOffset).divby(duration);\n TSU.assert(globalOffset.isWhole);\n cycleNum = globalOffset.floor;\n globalOffset = realOffset;\n }\n\n // here globalOffset is positive and >= 0 and < this.duration\n let globalIndex = 0;\n for (let barIndex = 0; barIndex < this.bars.length; barIndex++) {\n const bar = this.bars[barIndex];\n const barDuration = bar.duration;\n if (globalOffset.isGTE(barDuration)) {\n globalOffset = globalOffset.minus(barDuration);\n } else {\n // this is the bar!\n for (let beatIndex = 0; beatIndex < bar.beatCount; beatIndex++) {\n const beatLength = bar.beatLengths[beatIndex];\n const beatCount = bar.beatCounts[beatIndex] || 1;\n for (let instance = 0; instance < beatCount; instance++, globalIndex++) {\n if (globalOffset.isGTE(beatLength)) {\n globalOffset = globalOffset.minus(beatLength);\n } else {\n // this is it\n return [cycleNum, [barIndex, beatIndex, instance], globalOffset, globalIndex];\n }\n }\n }\n }\n globalIndex += bar.totalBeatCount;\n }\n\n throw new Error(\"Should not be here!\");\n }\n\n *iterateBeats(startBar = 0, startBeat = 0, startInstance = 0): CycleIterator {\n let barIndex = startBar;\n let beatIndex = startBeat;\n let instanceIndex = startInstance;\n while (true) {\n const currBar = this.bars[barIndex];\n yield [[barIndex, beatIndex, instanceIndex], currBar.beatLengths[beatIndex]];\n instanceIndex++;\n if (!currBar.beatCounts[beatIndex] || instanceIndex >= currBar.beatCounts[beatIndex]) {\n instanceIndex = 0;\n beatIndex++;\n if (beatIndex >= currBar.beatLengths.length) {\n beatIndex = 0;\n barIndex++;\n if (barIndex >= this.bars.length) {\n barIndex = 0;\n }\n }\n }\n }\n }\n\n copyTo(another: this): void {\n super.copyTo(another);\n another.name = this.name;\n another.bars = this.bars.map((x) => x.clone());\n }\n\n get beatCount(): number {\n let out = 0;\n for (const bar of this.bars) out += bar.beatCount;\n return out;\n }\n\n get totalBeatCount(): number {\n let out = 0;\n for (const bar of this.bars) out += bar.totalBeatCount;\n return out;\n }\n\n /**\n * Total duration (of time) across all bars in this cycle.\n */\n get duration(): Fraction {\n return this.bars.reduce((x, y) => x.plus(y.duration), ZERO);\n }\n}\n\nexport class Line extends Entity {\n // Line can have atoms starting \"before\" the cycle. The offset tells how many notes\n // before or after the cycle this line's atoms start at.\n offset: Fraction = ZERO;\n roles: Role[] = [];\n\n // This is a very hacky solution to doing left side pre-margin text typically found\n // in notations - eg line X of a pallavi has this. This makes vertical space less wasteful\n // A better solution is inter-beat annotation but it is very complex and ambiguous for now\n marginText = \"\";\n\n get isEmpty(): boolean {\n for (const r of this.roles) if (!r.isEmpty) return false;\n return true;\n }\n\n debugValue(): any {\n const out = {\n ...super.debugValue(),\n roles: this.roles.map((r) => r.debugValue()),\n // layoutParams: this.layoutParams?.uuid,\n };\n if (!this.offset.isZero) {\n out.offset = this.offset.toString();\n }\n return out;\n }\n\n copyTo(another: this): void {\n super.copyTo(another);\n another.roles = this.roles.map((r) => r.clone());\n }\n\n addAtoms(roleName: string, defaultToNotes: boolean, ...atoms: Atom[]): this {\n const role = this.ensureRole(roleName, defaultToNotes);\n role.addAtoms(...atoms);\n return this;\n }\n\n ensureRole(roleName: string, defaultToNotes: boolean): Role {\n // Ensure we have this many roles\n let ri = this.roles.findIndex((r) => r.name == roleName);\n if (ri < 0) {\n ri = this.roles.length;\n const role = new Role(this, roleName);\n role.defaultToNotes = defaultToNotes;\n this.roles.push(role);\n }\n return this.roles[ri];\n }\n\n /**\n * Returns the maximum duration of all roles in this line.\n */\n get duration(): Fraction {\n let max = ZERO;\n for (const role of this.roles) {\n max = TSU.Num.Fraction.max(role.duration, max);\n }\n return max;\n }\n}\n\nexport class Role extends Entity {\n defaultToNotes = true;\n atoms: Atom[] = [];\n\n constructor(public readonly line: Line, public readonly name: string) {\n super();\n }\n\n get isEmpty(): boolean {\n return this.atoms.length == 0;\n }\n\n debugValue(): any {\n return { name: this.name, atoms: this.atoms.map((a) => a.debugValue()) };\n }\n\n addAtoms(...atoms: Atom[]): void {\n let last: null | Atom = null;\n for (const atom of atoms) {\n if (atom.type == AtomType.REST) {\n if (last && last.type != AtomType.GROUP && last.type != AtomType.LABEL) {\n (last as LeafAtom).beforeRest = true;\n }\n } else {\n this.atoms.push(atom);\n }\n last = atom;\n }\n }\n\n copyTo(another: Role): void {\n another.addAtoms(...this.atoms);\n }\n\n /**\n * Duration for this role.\n */\n get duration(): Fraction {\n return this.atoms.reduce((a, b) => a.plus(b.duration), ZERO);\n }\n}\n"]}
@@ -155,7 +155,7 @@ var AtomIterator = (function () {
155
155
  var out = this.peek();
156
156
  this.peeked = null;
157
157
  if (out != null) {
158
- this.currOffset = this.currOffset.plus(out.duration);
158
+ this.currOffset = this.currOffset.plus(out.duration).factorized;
159
159
  }
160
160
  return out;
161
161
  };
@@ -189,7 +189,7 @@ var AtomIterator = (function () {
189
189
  this.atomQueue.pushFront([
190
190
  child,
191
191
  nextDepth + 1,
192
- nextDuration.times(child.duration).divby(group.totalChildDuration),
192
+ nextDuration.times(child.duration).divby(group.totalChildDuration).factorized,
193
193
  ]);
194
194
  }
195
195
  }
@@ -1 +1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,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;YACnE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,IAAI,IAAI,IAAI,IAAI,EAAE;gBAEhB,MAAM;aACP;iBAAM;gBACL,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACf,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;oBACrC,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;iBAC5C;qBAAM;oBAGL,IAAI,CAAC,SAAS,GAAG,IAAI,QAAQ,CAAC,IAAI,QAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;oBACzE,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;oBAC1B,SAAS,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;iBACnC;aACF;SACF;QACD,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IACH,uBAAC;AAAD,CAAC,AA/CD,IA+CC;AA/CY,4CAAgB","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { TimedEntity, Atom, LeafAtom, Space, Group, AtomType } from \"./\";\n\ntype Fraction = TSU.Num.Fraction;\n\nexport class FlatAtom extends TimedEntity {\n depth: number;\n duration: TSU.Num.Fraction;\n offset: TSU.Num.Fraction;\n isContinuation: boolean;\n\n constructor(public atom: LeafAtom, config: any = null) {\n super((config = config || {}));\n this.depth = config.depth || 0;\n this.duration = config.duration || atom.duration;\n this.offset = config.offset || TSU.Num.Fraction.ZERO;\n this.isContinuation = \"isContinuation\" in config ? config.isContinuation : false;\n }\n\n /**\n * Returns the type of this Entity.\n */\n get type(): unknown {\n return \"FlatAtom\";\n }\n\n get endOffset(): TSU.Num.Fraction {\n return this.offset.plus(this.duration);\n }\n\n debugValue(): any {\n const out = {\n ...super.debugValue(),\n atom: this.atom.debugValue(),\n duration: this.duration.toString(),\n offset: this.offset.toString(),\n depth: this.depth,\n };\n if (this.isContinuation) out.isContinuation = true;\n return out;\n }\n}\n\nexport class AtomIterator {\n private atomQueue = new TSU.Lists.List<[Atom, number, Fraction]>();\n private currOffset = TSU.Num.Fraction.ZERO;\n private peeked: TSU.Nullable<FlatAtom> = null;\n\n constructor(...atoms: Atom[]) {\n this.push(...atoms);\n }\n\n /**\n * Push atoms to be flattened and served by this iterator.\n */\n push(...atoms: Atom[]): this {\n for (const atom of atoms) {\n this.atomQueue.add([atom, 0, atom.duration]);\n }\n return this;\n }\n\n next(): TSU.Nullable<FlatAtom> {\n const out = this.peek();\n this.peeked = null;\n if (out != null) {\n this.currOffset = this.currOffset.plus(out.duration);\n }\n return out;\n }\n\n peek(): TSU.Nullable<FlatAtom> {\n if (this.peeked == null) {\n if (this.hasNext) {\n const [nextAtom, nextDepth, nextDuration] = this.atomQueue.popFront();\n this.peeked = new FlatAtom(nextAtom as LeafAtom, {\n depth: nextDepth,\n offset: this.currOffset,\n duration: nextDuration,\n });\n }\n }\n return this.peeked;\n }\n\n get hasNext(): boolean {\n while (this.atomQueue.first != null) {\n // Get from front of queue\n const [nextAtom, nextDepth, nextDuration] = this.atomQueue.first.value;\n if (nextAtom.type != AtomType.GROUP) {\n return true;\n } else {\n this.atomQueue.popFront();\n const group = nextAtom as Group;\n for (const child of group.atoms.reversedValues()) {\n this.atomQueue.pushFront([\n child,\n nextDepth + 1,\n nextDuration.times(child.duration).divby(group.totalChildDuration),\n ]);\n }\n }\n }\n return false;\n }\n\n static getMin(iterators: AtomIterator[]): [number, FlatAtom] {\n let currRole = -1;\n let currAtom: TSU.Nullable<FlatAtom> = null;\n for (let ri = 0; ri < iterators.length; ri++) {\n const flatAtom = iterators[ri].peek();\n if (flatAtom != null) {\n if (currAtom == null || flatAtom.offset.cmp(currAtom.offset) < 0) {\n currRole = ri;\n currAtom = flatAtom;\n }\n }\n }\n if (currRole >= 0) {\n iterators[currRole].next();\n }\n return [currRole, currAtom!];\n }\n}\n\nexport class DurationIterator {\n private atomIterator: AtomIterator;\n private spillOver: TSU.Nullable<FlatAtom> = null;\n\n constructor(atomIterator: AtomIterator) {\n this.atomIterator = atomIterator;\n }\n\n get hasMore(): boolean {\n if (this.spillOver != null) {\n return true;\n }\n return this.atomIterator.hasNext;\n }\n\n /**\n * Gets the atoms to cover the given duration.\n *\n * If the number of atoms left in the iterator is 0 then an empty list\n * is returned. Otherwise the duration of atoms returned will cover\n * the given duration even if padding with Space atoms is necessary.\n */\n get(duration: TSU.Num.Fraction): [FlatAtom[], boolean] {\n const iter = this.atomIterator;\n const out: FlatAtom[] = [];\n let remaining = duration;\n while (remaining.isGTNum(0)) {\n const next = this.spillOver == null ? iter.next() : this.spillOver;\n this.spillOver = null;\n if (next == null) {\n // stop here\n break;\n } else {\n out.push(next);\n if (next.duration.cmp(remaining) <= 0) {\n remaining = remaining.minus(next.duration);\n } else {\n // Next leaf atm is > duration\n // so split it into two\n this.spillOver = new FlatAtom(new Space(next.duration.minus(remaining)));\n next.duration = remaining;\n remaining = TSU.Num.Fraction.ZERO;\n }\n }\n }\n return [out, remaining.isZero];\n }\n}\n"]}
1
+ {"version":3,"file":"iterators.js","sourceRoot":"","sources":["../../src/iterators.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAuC;AACvC,uBAAyE;AAIzE;IAA8B,4BAAW;IAMvC,kBAAmB,IAAc,EAAE,MAAkB;QAAlB,uBAAA,EAAA,aAAkB;QAArD,YACE,kBAAM,CAAC,MAAM,GAAG,MAAM,IAAI,EAAE,CAAC,CAAC,SAK/B;QANkB,UAAI,GAAJ,IAAI,CAAU;QAE/B,KAAI,CA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QAAQ,CAAC,CAAC;iBAC5C;qBAAM;oBAGL,IAAI,CAAC,SAAS,GAAG,IAAI,QAAQ,CAAC,IAAI,QAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;oBACzE,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;oBAC1B,SAAS,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;iBACnC;aACF;SACF;QACD,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IACH,uBAAC;AAAD,CAAC,AA/CD,IA+CC;AA/CY,4CAAgB","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { TimedEntity, Atom, LeafAtom, Space, Group, AtomType } from \"./\";\n\ntype Fraction = TSU.Num.Fraction;\n\nexport class FlatAtom extends TimedEntity {\n depth: number;\n duration: TSU.Num.Fraction;\n offset: TSU.Num.Fraction;\n isContinuation: boolean;\n\n constructor(public atom: LeafAtom, config: any = null) {\n super((config = config || {}));\n this.depth = config.depth || 0;\n this.duration = config.duration || atom.duration;\n this.offset = config.offset || TSU.Num.Fraction.ZERO;\n this.isContinuation = \"isContinuation\" in config ? config.isContinuation : false;\n }\n\n /**\n * Returns the type of this Entity.\n */\n get type(): unknown {\n return \"FlatAtom\";\n }\n\n get endOffset(): TSU.Num.Fraction {\n return this.offset.plus(this.duration);\n }\n\n debugValue(): any {\n const out = {\n ...super.debugValue(),\n atom: this.atom.debugValue(),\n duration: this.duration.toString(),\n offset: this.offset.toString(),\n depth: this.depth,\n };\n if (this.isContinuation) out.isContinuation = true;\n return out;\n }\n}\n\nexport class AtomIterator {\n private atomQueue = new TSU.Lists.List<[Atom, number, Fraction]>();\n private currOffset = TSU.Num.Fraction.ZERO;\n private peeked: TSU.Nullable<FlatAtom> = null;\n\n constructor(...atoms: Atom[]) {\n this.push(...atoms);\n }\n\n /**\n * Push atoms to be flattened and served by this iterator.\n */\n push(...atoms: Atom[]): this {\n for (const atom of atoms) {\n this.atomQueue.add([atom, 0, atom.duration]);\n }\n return this;\n }\n\n next(): TSU.Nullable<FlatAtom> {\n const out = this.peek();\n this.peeked = null;\n if (out != null) {\n this.currOffset = this.currOffset.plus(out.duration).factorized;\n }\n return out;\n }\n\n peek(): TSU.Nullable<FlatAtom> {\n if (this.peeked == null) {\n if (this.hasNext) {\n const [nextAtom, nextDepth, nextDuration] = this.atomQueue.popFront();\n this.peeked = new FlatAtom(nextAtom as LeafAtom, {\n depth: nextDepth,\n offset: this.currOffset,\n duration: nextDuration,\n });\n }\n }\n return this.peeked;\n }\n\n get hasNext(): boolean {\n while (this.atomQueue.first != null) {\n // Get from front of queue\n const [nextAtom, nextDepth, nextDuration] = this.atomQueue.first.value;\n if (nextAtom.type != AtomType.GROUP) {\n return true;\n } else {\n this.atomQueue.popFront();\n const group = nextAtom as Group;\n for (const child of group.atoms.reversedValues()) {\n this.atomQueue.pushFront([\n child,\n nextDepth + 1,\n nextDuration.times(child.duration).divby(group.totalChildDuration).factorized,\n ]);\n }\n }\n }\n return false;\n }\n\n static getMin(iterators: AtomIterator[]): [number, FlatAtom] {\n let currRole = -1;\n let currAtom: TSU.Nullable<FlatAtom> = null;\n for (let ri = 0; ri < iterators.length; ri++) {\n const flatAtom = iterators[ri].peek();\n if (flatAtom != null) {\n if (currAtom == null || flatAtom.offset.cmp(currAtom.offset) < 0) {\n currRole = ri;\n currAtom = flatAtom;\n }\n }\n }\n if (currRole >= 0) {\n iterators[currRole].next();\n }\n return [currRole, currAtom!];\n }\n}\n\nexport class DurationIterator {\n private atomIterator: AtomIterator;\n private spillOver: TSU.Nullable<FlatAtom> = null;\n\n constructor(atomIterator: AtomIterator) {\n this.atomIterator = atomIterator;\n }\n\n get hasMore(): boolean {\n if (this.spillOver != null) {\n return true;\n }\n return this.atomIterator.hasNext;\n }\n\n /**\n * Gets the atoms to cover the given duration.\n *\n * If the number of atoms left in the iterator is 0 then an empty list\n * is returned. Otherwise the duration of atoms returned will cover\n * the given duration even if padding with Space atoms is necessary.\n */\n get(duration: TSU.Num.Fraction): [FlatAtom[], boolean] {\n const iter = this.atomIterator;\n const out: FlatAtom[] = [];\n let remaining = duration;\n while (remaining.isGTNum(0)) {\n const next = this.spillOver == null ? iter.next() : this.spillOver;\n this.spillOver = null;\n if (next == null) {\n // stop here\n break;\n } else {\n out.push(next);\n if (next.duration.cmp(remaining) <= 0) {\n remaining = remaining.minus(next.duration);\n } else {\n // Next leaf atm is > duration\n // so split it into two\n this.spillOver = new FlatAtom(new Space(next.duration.minus(remaining)));\n next.duration = remaining;\n remaining = TSU.Num.Fraction.ZERO;\n }\n }\n }\n return [out, remaining.isZero];\n }\n}\n"]}