notations 0.0.45 → 0.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/beats.js +5 -1
- package/lib/cjs/beats.js.map +1 -1
- package/lib/cjs/carnatic/LineView.js +5 -1
- package/lib/cjs/carnatic/LineView.js.map +1 -1
- package/lib/cjs/carnatic/NotationView.js +5 -1
- package/lib/cjs/carnatic/NotationView.js.map +1 -1
- package/lib/cjs/carnatic/atomviews.js +5 -1
- package/lib/cjs/carnatic/atomviews.js.map +1 -1
- package/lib/cjs/carnatic/beatviews.js +5 -1
- package/lib/cjs/carnatic/beatviews.js.map +1 -1
- package/lib/cjs/carnatic/embelishments.js +5 -1
- package/lib/cjs/carnatic/embelishments.js.map +1 -1
- package/lib/cjs/carnatic/index.js +5 -1
- package/lib/cjs/carnatic/index.js.map +1 -1
- package/lib/cjs/commands.js +5 -1
- package/lib/cjs/commands.js.map +1 -1
- package/lib/cjs/core.js +5 -1
- package/lib/cjs/core.js.map +1 -1
- package/lib/cjs/cycle.js +5 -1
- package/lib/cjs/cycle.js.map +1 -1
- package/lib/cjs/index.js +5 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/iterators.js +5 -1
- package/lib/cjs/iterators.js.map +1 -1
- package/lib/cjs/layouts.js +5 -1
- package/lib/cjs/layouts.js.map +1 -1
- package/lib/cjs/loader.js +5 -1
- package/lib/cjs/loader.js.map +1 -1
- package/lib/cjs/parser.js +5 -1
- package/lib/cjs/parser.js.map +1 -1
- package/lib/cjs/shapes.js +5 -1
- package/lib/cjs/shapes.js.map +1 -1
- package/lib/cjs/utils.js +5 -1
- package/lib/cjs/utils.js.map +1 -1
- package/package.json +17 -17
package/lib/cjs/commands.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/commands.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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A8C,CAAC,CAAC;SACjE;IACH,CAAC;IAED,sBAAI,yCAAY;aAAhB;YACE,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAC9B,CAAC;;;OAAA;IAED,yCAAe,GAAf,UAAgB,QAAkB;QAChC,QAAQ,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC;QACxC,QAAQ,CAAC,iBAAiB,EAAE,CAAC;IAC/B,CAAC;IACH,sBAAC;AAAD,CAAC,AAfD,CAAqC,kBAAkB,GAetD;AAfY,0CAAe","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Atom } from \"./core\";\nimport { parseCycle } from \"./utils\";\nimport { Command, RawBlock, Notation, MetaData as Meta } from \"./notation\";\n\nexport class RawEmbedding extends Command {\n get rawContents(): string {\n return this.getParamAt(0);\n }\n\n applyToNotation(notation: Notation): void {\n const raw = new RawBlock(this.rawContents);\n notation.addRawBlock(raw);\n }\n}\n\nexport class MetaData extends Command {\n // Called when running in execution mode\n applyToNotation(notation: Notation): void {\n // Create the role - ensure that we have a role\n notation.addMetaData(this.meta);\n }\n\n get meta(): Meta {\n const out = new Meta(this.key, this.value);\n return out;\n }\n\n get key(): string {\n return this.getParamAt(0);\n }\n\n get value(): string {\n return this.getParamAt(1);\n }\n}\n\nexport class ActivateRole extends Command {\n // Called when running in execution mode\n applyToNotation(notation: Notation): void {\n // Create the role - ensure that we have a role\n notation.setCurrRole(this.roleName);\n // const line = notation.ensureLine();\n }\n\n get roleName(): string {\n return this.getParamAt(0);\n }\n}\n\nexport class AddAtoms extends Command {\n index: number;\n atoms: Atom[];\n\n constructor(...atoms: Atom[]) {\n super();\n this.atoms = atoms;\n this.index = 0;\n }\n\n debugValue(): any {\n return {\n name: this.name,\n index: this.index,\n atoms: this.atoms.map((a) => a.debugValue()),\n };\n }\n\n applyToNotation(notation: Notation): void {\n let roleDef = notation.currRoleDef;\n if (roleDef == null) {\n // By default create a role for swaras\n roleDef = notation.newRoleDef(\"Sw\", true);\n // throw new Error(\"Current role is invalid\");\n }\n // Ensure a line exists\n const lpForLine = notation.layoutParamsForLine(notation.currentLine);\n if (lpForLine == null) {\n notation.setLayoutParamsForLine(notation.currentLine, notation.layoutParams);\n } else {\n TSU.assert(\n lpForLine == notation.layoutParams,\n \"Layout parameters have changed so a new line should have been started\",\n );\n }\n const finalised = this.atoms;\n notation.currentLine.addAtoms(roleDef.name, roleDef.notesOnly, ...finalised);\n }\n}\n\nexport class CreateLine extends Command {\n applyToNotation(notation: Notation): void {\n // We are not calling a newLine here just to avoid\n // a series of \\line commands creating wasteful empty lines\n // TODO - how do we consider offsets in line create\n const line = notation.newLine();\n line.offset = this.offset;\n line.marginText = this.marginText;\n }\n\n get offset(): TSU.Num.Fraction {\n let offset = this.getParam(\"offset\") || TSU.Num.Fraction.ZERO;\n if (typeof offset === \"number\") offset = new TSU.Num.Fraction(offset);\n return offset;\n }\n\n get marginText(): string {\n if (this.params.length > 0) {\n if (this.params[0].key == null && typeof this.params[0].value === \"string\") {\n return this.params[0].value.trim();\n }\n }\n return this.getParam(\"marginText\") || \"\";\n }\n}\n\nexport class CreateRole extends Command {\n applyToNotation(notation: Notation): void {\n // Create the role\n const name = this.getParamAt(0);\n notation.newRoleDef(name, this.notesOnly);\n }\n\n get notesOnly(): boolean {\n const notesOnly = this.getParam(\"notes\");\n return notesOnly == \"true\" || notesOnly == \"yes\" || notesOnly == true;\n }\n}\n\nexport abstract class LayoutParamCommand extends Command {}\n\n/**\n * Saves the current layout with the given name.\n * Typically users can change layout params (currently cycle, APB and line layout)\n * with the \\cycle, \\layout and \\beatDuration commands. Each time these are\n * changed, the current layout params is set to null. So the next time layout\n * params are needed we look at saved layout params and search by by the unique\n * combination of cycle, apb and line layout. This prevetns users from creating\n * too many layouts with the same config. Each layout is associated with an\n * AtomLayout instance.\n *\n * For example consider this:\n *\n * \\apb(4)\n * \\breaks(4)\n * \\cycle(\"|4|2|2|\")\n * \\apb(5)\n * \\breaks(3)\n *\n * In all these cases LayoutParams are *not* created. Instead they are reset to null.\n *\n *\n * When we do an AddAtoms command, this is where a LineView is created and along with this\n * a layoutParams is created taking the latest state of the layout params resulting an\n * LP (instance id = 1) of (layout = 3, cycle = \"4|2|2\", apb = 5)\n *\n * Now after this say we had the following commands:\n *\n * \\cycle(x)\n * \\cycle(|4|2|2)\n * \\apb(10)\n * \\apb(5)\n *\n * Sw: a b c\n *\n * Here again since the LP was set to null, \"creating\" layout params results in returning\n * the LP created previously (at the end of these commands the cycle, apb and layout params\n * are the same).\n *\n * eg doing\n *\n * \\layout(\"layout1\")\n *\n * This ensures that a *new* LP instance is created (even if another one exists with the same\n * apb, cycle, layout combo). This allows us to group different sectiosn that are identical\n * in layout but to be processed by different atom layouts.\n *\n * To use a saved layout simply do:\n *\n * \\layout(\"layout\")\n *\n * Note the use and saving commands are same - as we cannot override existing\n * layouts so referring to it the first time creates and saves it too\n */\nexport class ApplyLayout extends Command {\n validateParams(): void {\n if (this.params.length != 1 || typeof this.params[0].value !== \"string\") {\n throw new Error(\"layout command must contain one string argument\");\n }\n }\n\n applyToNotation(notation: Notation): void {\n const value = this.params[0].value;\n notation.ensureNamedLayoutParams(value);\n }\n}\n\n/**\n * Allows use (and creation) of layouts.\n */\nexport class SetBreaks extends LayoutParamCommand {\n get pattern(): number[] {\n return this.params.map((cmd) => cmd.value as number);\n }\n\n /**\n * called to validate parameters.\n */\n validateParams(): void {\n for (const param of this.params) {\n if (param.key != null) {\n throw new Error(\"Breaks command cannot have keyword params\");\n }\n if (typeof param.value !== \"number\") {\n throw new Error(\"Breaks command must be a list of integers\");\n }\n }\n }\n\n applyToNotation(notation: Notation): void {\n notation.currentBreaks = this.pattern;\n notation.resetLayoutParams();\n }\n}\n\nexport class SetCycle extends LayoutParamCommand {\n applyToNotation(notation: Notation): void {\n const value = this.params[0].value;\n // TODO - move the parsing to validation\n const cycle = parseCycle(value);\n notation.currentCycle = cycle;\n notation.resetLayoutParams();\n }\n}\n\nexport class SetBeatDuration extends LayoutParamCommand {\n validateParams(): void {\n if (this.params.length != 1 || typeof this.params[0].value !== \"number\") {\n throw new Error(\"beatDuration command must contain one number\");\n }\n }\n\n get beatDuration(): number {\n return this.params[0].value;\n }\n\n applyToNotation(notation: Notation): void {\n notation.currentAPB = this.beatDuration;\n notation.resetLayoutParams();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/commands.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAuC;AAEvC,iCAAqC;AACrC,uCAA2E;AAE3E;IAAkC,gCAAO;IAAzC;;IASA,CAAC;IARC,sBAAI,qCAAW;aAAf;YACE,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC5B,CAAC;;;OAAA;IAED,sCAAe,GAAf,UAAgB,QAAkB;QAChC,IAAM,GAAG,GAAG,IAAI,mBAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC3C,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IACH,mBAAC;AAAD,CAAC,AATD,CAAkC,kBAAO,GASxC;AATY,oCAAY;AAWzB;IAA8B,4BAAO;IAArC;;IAmBA,CAAC;IAjBC,kCAAe,GAAf,UAAgB,QAAkB;QAEhC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,sBAAI,0BAAI;aAAR;YACE,IAAM,GAAG,GAAG,IAAI,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;YAC3C,OAAO,GAAG,CAAC;QACb,CAAC;;;OAAA;IAED,sBAAI,yBAAG;aAAP;YACE,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC5B,CAAC;;;OAAA;IAED,sBAAI,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AAQ,CAAC,iBAAiB,EAAE,CAAC;IAC/B,CAAC;IACH,eAAC;AAAD,CAAC,AARD,CAA8B,kBAAkB,GAQ/C;AARY,4BAAQ;AAUrB;IAAqC,mCAAkB;IAAvD;;IAeA,CAAC;IAdC,wCAAc,GAAd;QACE,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,QAAQ,EAAE;YACvE,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;SACjE;IACH,CAAC;IAED,sBAAI,yCAAY;aAAhB;YACE,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAC9B,CAAC;;;OAAA;IAED,yCAAe,GAAf,UAAgB,QAAkB;QAChC,QAAQ,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC;QACxC,QAAQ,CAAC,iBAAiB,EAAE,CAAC;IAC/B,CAAC;IACH,sBAAC;AAAD,CAAC,AAfD,CAAqC,kBAAkB,GAetD;AAfY,0CAAe","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Atom } from \"./core\";\nimport { parseCycle } from \"./utils\";\nimport { Command, RawBlock, Notation, MetaData as Meta } from \"./notation\";\n\nexport class RawEmbedding extends Command {\n get rawContents(): string {\n return this.getParamAt(0);\n }\n\n applyToNotation(notation: Notation): void {\n const raw = new RawBlock(this.rawContents);\n notation.addRawBlock(raw);\n }\n}\n\nexport class MetaData extends Command {\n // Called when running in execution mode\n applyToNotation(notation: Notation): void {\n // Create the role - ensure that we have a role\n notation.addMetaData(this.meta);\n }\n\n get meta(): Meta {\n const out = new Meta(this.key, this.value);\n return out;\n }\n\n get key(): string {\n return this.getParamAt(0);\n }\n\n get value(): string {\n return this.getParamAt(1);\n }\n}\n\nexport class ActivateRole extends Command {\n // Called when running in execution mode\n applyToNotation(notation: Notation): void {\n // Create the role - ensure that we have a role\n notation.setCurrRole(this.roleName);\n // const line = notation.ensureLine();\n }\n\n get roleName(): string {\n return this.getParamAt(0);\n }\n}\n\nexport class AddAtoms extends Command {\n index: number;\n atoms: Atom[];\n\n constructor(...atoms: Atom[]) {\n super();\n this.atoms = atoms;\n this.index = 0;\n }\n\n debugValue(): any {\n return {\n name: this.name,\n index: this.index,\n atoms: this.atoms.map((a) => a.debugValue()),\n };\n }\n\n applyToNotation(notation: Notation): void {\n let roleDef = notation.currRoleDef;\n if (roleDef == null) {\n // By default create a role for swaras\n roleDef = notation.newRoleDef(\"Sw\", true);\n // throw new Error(\"Current role is invalid\");\n }\n // Ensure a line exists\n const lpForLine = notation.layoutParamsForLine(notation.currentLine);\n if (lpForLine == null) {\n notation.setLayoutParamsForLine(notation.currentLine, notation.layoutParams);\n } else {\n TSU.assert(\n lpForLine == notation.layoutParams,\n \"Layout parameters have changed so a new line should have been started\",\n );\n }\n const finalised = this.atoms;\n notation.currentLine.addAtoms(roleDef.name, roleDef.notesOnly, ...finalised);\n }\n}\n\nexport class CreateLine extends Command {\n applyToNotation(notation: Notation): void {\n // We are not calling a newLine here just to avoid\n // a series of \\line commands creating wasteful empty lines\n // TODO - how do we consider offsets in line create\n const line = notation.newLine();\n line.offset = this.offset;\n line.marginText = this.marginText;\n }\n\n get offset(): TSU.Num.Fraction {\n let offset = this.getParam(\"offset\") || TSU.Num.Fraction.ZERO;\n if (typeof offset === \"number\") offset = new TSU.Num.Fraction(offset);\n return offset;\n }\n\n get marginText(): string {\n if (this.params.length > 0) {\n if (this.params[0].key == null && typeof this.params[0].value === \"string\") {\n return this.params[0].value.trim();\n }\n }\n return this.getParam(\"marginText\") || \"\";\n }\n}\n\nexport class CreateRole extends Command {\n applyToNotation(notation: Notation): void {\n // Create the role\n const name = this.getParamAt(0);\n notation.newRoleDef(name, this.notesOnly);\n }\n\n get notesOnly(): boolean {\n const notesOnly = this.getParam(\"notes\");\n return notesOnly == \"true\" || notesOnly == \"yes\" || notesOnly == true;\n }\n}\n\nexport abstract class LayoutParamCommand extends Command {}\n\n/**\n * Saves the current layout with the given name.\n * Typically users can change layout params (currently cycle, APB and line layout)\n * with the \\cycle, \\layout and \\beatDuration commands. Each time these are\n * changed, the current layout params is set to null. So the next time layout\n * params are needed we look at saved layout params and search by by the unique\n * combination of cycle, apb and line layout. This prevetns users from creating\n * too many layouts with the same config. Each layout is associated with an\n * AtomLayout instance.\n *\n * For example consider this:\n *\n * \\apb(4)\n * \\breaks(4)\n * \\cycle(\"|4|2|2|\")\n * \\apb(5)\n * \\breaks(3)\n *\n * In all these cases LayoutParams are *not* created. Instead they are reset to null.\n *\n *\n * When we do an AddAtoms command, this is where a LineView is created and along with this\n * a layoutParams is created taking the latest state of the layout params resulting an\n * LP (instance id = 1) of (layout = 3, cycle = \"4|2|2\", apb = 5)\n *\n * Now after this say we had the following commands:\n *\n * \\cycle(x)\n * \\cycle(|4|2|2)\n * \\apb(10)\n * \\apb(5)\n *\n * Sw: a b c\n *\n * Here again since the LP was set to null, \"creating\" layout params results in returning\n * the LP created previously (at the end of these commands the cycle, apb and layout params\n * are the same).\n *\n * eg doing\n *\n * \\layout(\"layout1\")\n *\n * This ensures that a *new* LP instance is created (even if another one exists with the same\n * apb, cycle, layout combo). This allows us to group different sectiosn that are identical\n * in layout but to be processed by different atom layouts.\n *\n * To use a saved layout simply do:\n *\n * \\layout(\"layout\")\n *\n * Note the use and saving commands are same - as we cannot override existing\n * layouts so referring to it the first time creates and saves it too\n */\nexport class ApplyLayout extends Command {\n validateParams(): void {\n if (this.params.length != 1 || typeof this.params[0].value !== \"string\") {\n throw new Error(\"layout command must contain one string argument\");\n }\n }\n\n applyToNotation(notation: Notation): void {\n const value = this.params[0].value;\n notation.ensureNamedLayoutParams(value);\n }\n}\n\n/**\n * Allows use (and creation) of layouts.\n */\nexport class SetBreaks extends LayoutParamCommand {\n get pattern(): number[] {\n return this.params.map((cmd) => cmd.value as number);\n }\n\n /**\n * called to validate parameters.\n */\n validateParams(): void {\n for (const param of this.params) {\n if (param.key != null) {\n throw new Error(\"Breaks command cannot have keyword params\");\n }\n if (typeof param.value !== \"number\") {\n throw new Error(\"Breaks command must be a list of integers\");\n }\n }\n }\n\n applyToNotation(notation: Notation): void {\n notation.currentBreaks = this.pattern;\n notation.resetLayoutParams();\n }\n}\n\nexport class SetCycle extends LayoutParamCommand {\n applyToNotation(notation: Notation): void {\n const value = this.params[0].value;\n // TODO - move the parsing to validation\n const cycle = parseCycle(value);\n notation.currentCycle = cycle;\n notation.resetLayoutParams();\n }\n}\n\nexport class SetBeatDuration extends LayoutParamCommand {\n validateParams(): void {\n if (this.params.length != 1 || typeof this.params[0].value !== \"number\") {\n throw new Error(\"beatDuration command must contain one number\");\n }\n }\n\n get beatDuration(): number {\n return this.params[0].value;\n }\n\n applyToNotation(notation: Notation): void {\n notation.currentAPB = this.beatDuration;\n notation.resetLayoutParams();\n }\n}\n"]}
|
package/lib/cjs/core.js
CHANGED
|
@@ -27,7 +27,11 @@ var __assign = (this && this.__assign) || function () {
|
|
|
27
27
|
};
|
|
28
28
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
29
29
|
if (k2 === undefined) k2 = k;
|
|
30
|
-
Object.
|
|
30
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
31
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
32
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
33
|
+
}
|
|
34
|
+
Object.defineProperty(o, k2, desc);
|
|
31
35
|
}) : (function(o, m, k, k2) {
|
|
32
36
|
if (k2 === undefined) k2 = k;
|
|
33
37
|
o[k2] = m[k];
|
package/lib/cjs/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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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,eAAM,GAwC/B;AAxCY,oBAAI","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Entity, TimedEntity } from \"./entity\";\n\n/**\n * Alias to TSU.Num.Fraction in tsutils.\n */\ntype Fraction = TSU.Num.Fraction;\nconst ZERO = TSU.Num.Fraction.ZERO;\nconst ONE = TSU.Num.Fraction.ONE;\n\n/**\n * AtomType enums are used to denote specific Atoms\n * @enum\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\n/**\n * Atoms are the base class of timed entities that can appear in a Notation.\n */\nexport abstract class Atom extends TimedEntity {\n protected _duration: Fraction;\n nextSibling: TSU.Nullable<Atom> = null;\n prevSibling: TSU.Nullable<Atom> = null;\n // Which group does this Atom belong to\n parentGroup: TSU.Nullable<Group> = null;\n\n // Tells if this Atom is a \"continuation\" from a previous atom\n isContinuation = false;\n\n constructor(duration = ONE) {\n super();\n this._duration = duration || ONE;\n }\n\n abstract splitAt(requiredDuration: Fraction): TSU.Nullable<Atom>;\n\n debugValue(): any {\n const out = super.debugValue();\n if (!this.duration.isOne) {\n out.duration = this.duration.factorized.toString();\n }\n if (this.isContinuation) {\n out.isContinuation = true;\n }\n return out;\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 /**\n * Splits this atom at a certain duration. If this atom's duration is\n * longer than the given duration then it is truncated to the given duration\n * and a continuation space is returned.\n */\n splitAt(duration: Fraction): TSU.Nullable<Atom> {\n if (this.duration.cmp(duration) > 0) {\n const spillOver = this.createSpilloverSpace(this.duration.minus(duration));\n spillOver.isContinuation = true;\n this.duration = duration;\n return spillOver;\n }\n return null;\n }\n\n protected createSpilloverSpace(duration: Fraction): Space {\n return new Space(duration);\n }\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 protected createSpilloverSpace(duration: Fraction): Space {\n const out = super.createSpilloverSpace(duration);\n out.isSilent = this.isSilent;\n return out;\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 out.beforeRest = lit.beforeRest;\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 out.beforeRest = lit.beforeRest;\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 = new TSU.Lists.ValueList<Atom>();\n\n constructor(...atoms: Atom[]) {\n super(atoms.length == 0 ? ZERO : ONE);\n this.addAtoms(false, ...atoms);\n }\n\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 another.durationIsMultiplier = this.durationIsMultiplier;\n this.atoms.forEach((atom) => another.atoms.add(atom.clone()));\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 setDurationAsMultiplier(asMultiplier = true): this {\n this.durationIsMultiplier = asMultiplier;\n return this;\n }\n\n setDuration(d: Fraction, asMultiplier = false): this {\n this._duration = d;\n this.durationIsMultiplier = asMultiplier;\n return this;\n }\n // set duration(d: Fraction) { this._duration = d; }\n\n debugValue(): any {\n const out = { ...super.debugValue(), atoms: Array.from(this.atoms.values(), (a) => a.debugValue()) };\n // out.duration = this._duration.factorized.toString();\n // out.realDuration = this.duration.factorized.toString();\n if (this.durationIsMultiplier) out.durationIsMultiplier = true;\n return out;\n }\n\n /**\n * Splits this group into two parts such that first part (this group)\n * fits within the given duration and everything else longer than the\n * given duration then it is truncated to the given duration and a\n * continuation space is returned.\n */\n splitAt(requiredDuration: Fraction): TSU.Nullable<Group> {\n if (this.duration.isLTE(requiredDuration) || requiredDuration.isLTE(ZERO)) {\n return null;\n }\n const targetGroup = new Group();\n if (this.durationIsMultiplier) {\n targetGroup.durationIsMultiplier = true;\n targetGroup._duration = this._duration;\n }\n\n let remainingDur = this.duration;\n const totalChildDuration = this.totalChildDuration;\n const durationFactor = this.durationIsMultiplier\n ? ONE.divby(this._duration)\n : this._duration.divby(totalChildDuration, true);\n while (remainingDur.isGT(requiredDuration) && this.atoms.last) {\n const lastChild = this.atoms.last;\n // Child's duration is absolute in its own \"system\"\n // Its duration within the parent (this) group's frame of reference depends\n // on whether the parent's duration is absolute or as a multiplier\n //\n // realChildDuration = case (group.durationIsMultiper) {\n // | true => child.duration / this._duration\n // | false => child.duration * this._duration / total child duration\n // }\n const childDuration = lastChild.duration.times(durationFactor);\n const newDuration = remainingDur.minus(childDuration);\n if (newDuration.isGTE(requiredDuration)) {\n // remove ourselves and add to target\n // in both cases duration will be adjusted if need be\n this.removeAtoms(true, lastChild);\n targetGroup.insertAtomsAt(targetGroup.atoms.first, true, lastChild);\n if (newDuration.equals(requiredDuration)) {\n // we have reached the end so return\n return targetGroup;\n }\n } else {\n // our scenario is now this:\n //\n // totalParentDuration = 10\n // required = 8\n // lastChildDuration (relative to parent) is 5\n //\n // durWithoutLast = 10 - 5\n // newRequired = requiredDur - durWithoutLast = 3\n //\n // However 3 is a duration in the parent's frame of reference\n // this has to be converted back to the child's FoR\n const newRequiredDur = requiredDuration.minus(newDuration, true).divby(durationFactor, true);\n // console.log( \"newRequiredDur: \", newRequiredDur, \"requiedDur: \", requiredDuration, \"remainingDur: \", remainingDur,);\n // then the last item needs to be split, and by how much?\n const spillOver = lastChild.splitAt(newRequiredDur);\n if (spillOver == null) {\n throw new Error(\"Spill over cannot be null here\");\n }\n if (!this.durationIsMultiplier) {\n // Our own duration has also now changed\n this._duration = requiredDuration;\n } else {\n if (this._duration.isZero) throw new Error(\"How can this be?\");\n }\n spillOver.isContinuation = true;\n // Add spill over to the target\n targetGroup.insertAtomsAt(targetGroup.atoms.first, true, spillOver);\n return targetGroup;\n }\n remainingDur = newDuration;\n }\n return targetGroup;\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 /**\n * Inserts atom before a given cursor atom. If the cursor atom is null\n * then the atoms are appended at the end.\n */\n insertAtomsAt(beforeAtom: TSU.Nullable<Atom>, adjustDuration = false, ...atoms: Atom[]): this {\n adjustDuration = adjustDuration && !this.durationIsMultiplier;\n const oldChildDuration = adjustDuration ? this.totalChildDuration : ONE;\n // First form a chain of the given atoms\n for (const atom of atoms) {\n if (atom.parentGroup != null) {\n if (atom.parentGroup != this) {\n throw new Error(\"Atom belongs to another parent. Remove it first\");\n }\n atom.parentGroup.removeAtoms(false, atom);\n }\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.parentGroup = this;\n this.atoms.add(atom, beforeAtom);\n }\n }\n if (adjustDuration) {\n if (this._duration.isZero) {\n if (this.durationIsMultiplier) throw new Error(\"How can this be?\");\n this._duration = this.totalChildDuration;\n } else {\n const scaleFactor = this.totalChildDuration.divby(oldChildDuration);\n this._duration = this._duration.times(scaleFactor, true);\n }\n }\n return this;\n }\n\n /**\n * Adds atoms to the end of our atom list.\n */\n addAtoms(adjustDuration = false, ...atoms: Atom[]): this {\n return this.insertAtomsAt(null, adjustDuration, ...atoms);\n }\n\n /**\n * Removes atoms from our child list.\n *\n * @param adjustDuration If the duration is not a multiplier then it might\n * sometimes be useful to automatically adjust the duration\n * to accomodate the removal of the given atom.\n * @param atoms List of atoms to remove from this list.\n */\n removeAtoms(adjustDuration = false, ...atoms: Atom[]): this {\n adjustDuration = adjustDuration && !this.durationIsMultiplier;\n const oldChildDuration = adjustDuration ? this.totalChildDuration : ONE;\n for (const atom of atoms) {\n if (atom.parentGroup == this) {\n this.atoms.remove(atom);\n atom.parentGroup = null;\n } else if (atom.parentGroup != null) {\n throw new Error(\"Atom cannot be removed as it does not belong to this group\");\n }\n }\n if (adjustDuration) {\n if (this._duration.isZero) {\n if (this.durationIsMultiplier) throw new Error(\"How can this be?\");\n this._duration = this.totalChildDuration;\n } else {\n const scaleFactor = this.totalChildDuration.divby(oldChildDuration);\n this._duration = this._duration.times(scaleFactor, true);\n }\n }\n return this;\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\n // wasteful\n // A better solution is inter-beat annotation but it is very complex 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":";;;;;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G,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,eAAM,GAwC/B;AAxCY,oBAAI","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Entity, TimedEntity } from \"./entity\";\n\n/**\n * Alias to TSU.Num.Fraction in tsutils.\n */\ntype Fraction = TSU.Num.Fraction;\nconst ZERO = TSU.Num.Fraction.ZERO;\nconst ONE = TSU.Num.Fraction.ONE;\n\n/**\n * AtomType enums are used to denote specific Atoms\n * @enum\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\n/**\n * Atoms are the base class of timed entities that can appear in a Notation.\n */\nexport abstract class Atom extends TimedEntity {\n protected _duration: Fraction;\n nextSibling: TSU.Nullable<Atom> = null;\n prevSibling: TSU.Nullable<Atom> = null;\n // Which group does this Atom belong to\n parentGroup: TSU.Nullable<Group> = null;\n\n // Tells if this Atom is a \"continuation\" from a previous atom\n isContinuation = false;\n\n constructor(duration = ONE) {\n super();\n this._duration = duration || ONE;\n }\n\n abstract splitAt(requiredDuration: Fraction): TSU.Nullable<Atom>;\n\n debugValue(): any {\n const out = super.debugValue();\n if (!this.duration.isOne) {\n out.duration = this.duration.factorized.toString();\n }\n if (this.isContinuation) {\n out.isContinuation = true;\n }\n return out;\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 /**\n * Splits this atom at a certain duration. If this atom's duration is\n * longer than the given duration then it is truncated to the given duration\n * and a continuation space is returned.\n */\n splitAt(duration: Fraction): TSU.Nullable<Atom> {\n if (this.duration.cmp(duration) > 0) {\n const spillOver = this.createSpilloverSpace(this.duration.minus(duration));\n spillOver.isContinuation = true;\n this.duration = duration;\n return spillOver;\n }\n return null;\n }\n\n protected createSpilloverSpace(duration: Fraction): Space {\n return new Space(duration);\n }\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 protected createSpilloverSpace(duration: Fraction): Space {\n const out = super.createSpilloverSpace(duration);\n out.isSilent = this.isSilent;\n return out;\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 out.beforeRest = lit.beforeRest;\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 out.beforeRest = lit.beforeRest;\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 = new TSU.Lists.ValueList<Atom>();\n\n constructor(...atoms: Atom[]) {\n super(atoms.length == 0 ? ZERO : ONE);\n this.addAtoms(false, ...atoms);\n }\n\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 another.durationIsMultiplier = this.durationIsMultiplier;\n this.atoms.forEach((atom) => another.atoms.add(atom.clone()));\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 setDurationAsMultiplier(asMultiplier = true): this {\n this.durationIsMultiplier = asMultiplier;\n return this;\n }\n\n setDuration(d: Fraction, asMultiplier = false): this {\n this._duration = d;\n this.durationIsMultiplier = asMultiplier;\n return this;\n }\n // set duration(d: Fraction) { this._duration = d; }\n\n debugValue(): any {\n const out = { ...super.debugValue(), atoms: Array.from(this.atoms.values(), (a) => a.debugValue()) };\n // out.duration = this._duration.factorized.toString();\n // out.realDuration = this.duration.factorized.toString();\n if (this.durationIsMultiplier) out.durationIsMultiplier = true;\n return out;\n }\n\n /**\n * Splits this group into two parts such that first part (this group)\n * fits within the given duration and everything else longer than the\n * given duration then it is truncated to the given duration and a\n * continuation space is returned.\n */\n splitAt(requiredDuration: Fraction): TSU.Nullable<Group> {\n if (this.duration.isLTE(requiredDuration) || requiredDuration.isLTE(ZERO)) {\n return null;\n }\n const targetGroup = new Group();\n if (this.durationIsMultiplier) {\n targetGroup.durationIsMultiplier = true;\n targetGroup._duration = this._duration;\n }\n\n let remainingDur = this.duration;\n const totalChildDuration = this.totalChildDuration;\n const durationFactor = this.durationIsMultiplier\n ? ONE.divby(this._duration)\n : this._duration.divby(totalChildDuration, true);\n while (remainingDur.isGT(requiredDuration) && this.atoms.last) {\n const lastChild = this.atoms.last;\n // Child's duration is absolute in its own \"system\"\n // Its duration within the parent (this) group's frame of reference depends\n // on whether the parent's duration is absolute or as a multiplier\n //\n // realChildDuration = case (group.durationIsMultiper) {\n // | true => child.duration / this._duration\n // | false => child.duration * this._duration / total child duration\n // }\n const childDuration = lastChild.duration.times(durationFactor);\n const newDuration = remainingDur.minus(childDuration);\n if (newDuration.isGTE(requiredDuration)) {\n // remove ourselves and add to target\n // in both cases duration will be adjusted if need be\n this.removeAtoms(true, lastChild);\n targetGroup.insertAtomsAt(targetGroup.atoms.first, true, lastChild);\n if (newDuration.equals(requiredDuration)) {\n // we have reached the end so return\n return targetGroup;\n }\n } else {\n // our scenario is now this:\n //\n // totalParentDuration = 10\n // required = 8\n // lastChildDuration (relative to parent) is 5\n //\n // durWithoutLast = 10 - 5\n // newRequired = requiredDur - durWithoutLast = 3\n //\n // However 3 is a duration in the parent's frame of reference\n // this has to be converted back to the child's FoR\n const newRequiredDur = requiredDuration.minus(newDuration, true).divby(durationFactor, true);\n // console.log( \"newRequiredDur: \", newRequiredDur, \"requiedDur: \", requiredDuration, \"remainingDur: \", remainingDur,);\n // then the last item needs to be split, and by how much?\n const spillOver = lastChild.splitAt(newRequiredDur);\n if (spillOver == null) {\n throw new Error(\"Spill over cannot be null here\");\n }\n if (!this.durationIsMultiplier) {\n // Our own duration has also now changed\n this._duration = requiredDuration;\n } else {\n if (this._duration.isZero) throw new Error(\"How can this be?\");\n }\n spillOver.isContinuation = true;\n // Add spill over to the target\n targetGroup.insertAtomsAt(targetGroup.atoms.first, true, spillOver);\n return targetGroup;\n }\n remainingDur = newDuration;\n }\n return targetGroup;\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 /**\n * Inserts atom before a given cursor atom. If the cursor atom is null\n * then the atoms are appended at the end.\n */\n insertAtomsAt(beforeAtom: TSU.Nullable<Atom>, adjustDuration = false, ...atoms: Atom[]): this {\n adjustDuration = adjustDuration && !this.durationIsMultiplier;\n const oldChildDuration = adjustDuration ? this.totalChildDuration : ONE;\n // First form a chain of the given atoms\n for (const atom of atoms) {\n if (atom.parentGroup != null) {\n if (atom.parentGroup != this) {\n throw new Error(\"Atom belongs to another parent. Remove it first\");\n }\n atom.parentGroup.removeAtoms(false, atom);\n }\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.parentGroup = this;\n this.atoms.add(atom, beforeAtom);\n }\n }\n if (adjustDuration) {\n if (this._duration.isZero) {\n if (this.durationIsMultiplier) throw new Error(\"How can this be?\");\n this._duration = this.totalChildDuration;\n } else {\n const scaleFactor = this.totalChildDuration.divby(oldChildDuration);\n this._duration = this._duration.times(scaleFactor, true);\n }\n }\n return this;\n }\n\n /**\n * Adds atoms to the end of our atom list.\n */\n addAtoms(adjustDuration = false, ...atoms: Atom[]): this {\n return this.insertAtomsAt(null, adjustDuration, ...atoms);\n }\n\n /**\n * Removes atoms from our child list.\n *\n * @param adjustDuration If the duration is not a multiplier then it might\n * sometimes be useful to automatically adjust the duration\n * to accomodate the removal of the given atom.\n * @param atoms List of atoms to remove from this list.\n */\n removeAtoms(adjustDuration = false, ...atoms: Atom[]): this {\n adjustDuration = adjustDuration && !this.durationIsMultiplier;\n const oldChildDuration = adjustDuration ? this.totalChildDuration : ONE;\n for (const atom of atoms) {\n if (atom.parentGroup == this) {\n this.atoms.remove(atom);\n atom.parentGroup = null;\n } else if (atom.parentGroup != null) {\n throw new Error(\"Atom cannot be removed as it does not belong to this group\");\n }\n }\n if (adjustDuration) {\n if (this._duration.isZero) {\n if (this.durationIsMultiplier) throw new Error(\"How can this be?\");\n this._duration = this.totalChildDuration;\n } else {\n const scaleFactor = this.totalChildDuration.divby(oldChildDuration);\n this._duration = this._duration.times(scaleFactor, true);\n }\n }\n return this;\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\n // wasteful\n // A better solution is inter-beat annotation but it is very complex 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"]}
|
package/lib/cjs/cycle.js
CHANGED
|
@@ -27,7 +27,11 @@ var __assign = (this && this.__assign) || function () {
|
|
|
27
27
|
};
|
|
28
28
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
29
29
|
if (k2 === undefined) k2 = k;
|
|
30
|
-
Object.
|
|
30
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
31
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
32
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
33
|
+
}
|
|
34
|
+
Object.defineProperty(o, k2, desc);
|
|
31
35
|
}) : (function(o, m, k, k2) {
|
|
32
36
|
if (k2 === undefined) k2 = k;
|
|
33
37
|
o[k2] = m[k];
|
package/lib/cjs/cycle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cycle.js","sourceRoot":"","sources":["../../src/cycle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAuC;AACvC,mCAA+C;AAS/C,IAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;AACnC,IAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;AAEjC;IACE,qBAA4B,KAAY,EAAS,QAAY,EAAS,SAAa,EAAS,QAAY;QAAvD,yBAAA,EAAA,YAAY;QAAS,0BAAA,EAAA,aAAa;QAAS,yBAAA,EAAA,YAAY;QAA5E,UAAK,GAAL,KAAK,CAAO;QAAS,aAAQ,GAAR,QAAQ,CAAI;QAAS,cAAS,GAAT,SAAS,CAAI;QAAS,aAAQ,GAAR,QAAQ,CAAI;IAAG,CAAC;IAE5G,sBAAI,6BAAI;aAAR;YACE,IAAM,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AC,IAAI,CAAA,gBAAA;oBAAtB,IAAM,GAAG,WAAA;oBAAe,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC;iBAAA;;;;;;;;;YACvD,OAAO,GAAG,CAAC;QACb,CAAC;;;OAAA;IAKD,sBAAI,2BAAQ;aAAZ;YACE,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAlB,CAAkB,EAAE,IAAI,CAAC,CAAC;QAC9D,CAAC;;;OAAA;IAvLe,aAAO,GAAG,IAAI,KAAK,CAAC;QAClC,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,IAAI,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;YACrD,IAAI,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;YACjD,IAAI,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;SAClD;KACF,CAAC,CAAC;IAiLL,YAAC;CAAA,AA5LD,CAA2B,oBAAW,GA4LrC;AA5LY,sBAAK","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Entity, TimedEntity } from \"./entity\";\n\n/**\n * Alias to TSU.Num.Fraction in tsutils.\n */\ntype Fraction = TSU.Num.Fraction;\nexport type CyclePosition = [number, number, number];\nexport type CycleIterator = Generator<[CyclePosition, Fraction]>;\n\nconst ZERO = TSU.Num.Fraction.ZERO;\nconst ONE = TSU.Num.Fraction.ONE;\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 instanceCount(beatIndex: number): number {\n if (beatIndex > this.beatCounts.length) {\n // by default each beat has 1 instance?\n return 1;\n } else {\n return this.beatCounts[beatIndex];\n }\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"]}
|
|
1
|
+
{"version":3,"file":"cycle.js","sourceRoot":"","sources":["../../src/cycle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAuC;AACvC,mCAA+C;AAS/C,IAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;AACnC,IAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;AAEjC;IACE,qBAA4B,KAAY,EAAS,QAAY,EAAS,SAAa,EAAS,QAAY;QAAvD,yBAAA,EAAA,YAAY;QAAS,0BAAA,EAAA,aAAa;QAAS,yBAAA,EAAA,YAAY;QAA5E,UAAK,GAAL,KAAK,CAAO;QAAS,aAAQ,GAAR,QAAQ,CAAI;QAAS,cAAS,GAAT,SAAS,CAAI;QAAS,aAAQ,GAAR,QAAQ,CAAI;IAAG,CAAC;IAE5G,sBAAI,6BAAI;aAAR;YACE,IAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC/C,IAAM,MAAM,GAA8B;gBACxC,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC;gBAC9C,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,S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,EAAE,CAAC,IAAK,OAAA,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAlB,CAAkB,EAAE,IAAI,CAAC,CAAC;QAC9D,CAAC;;;OAAA;IAvLe,aAAO,GAAG,IAAI,KAAK,CAAC;QAClC,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,IAAI,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;YACrD,IAAI,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;YACjD,IAAI,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;SAClD;KACF,CAAC,CAAC;IAiLL,YAAC;CAAA,AA5LD,CAA2B,oBAAW,GA4LrC;AA5LY,sBAAK","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Entity, TimedEntity } from \"./entity\";\n\n/**\n * Alias to TSU.Num.Fraction in tsutils.\n */\ntype Fraction = TSU.Num.Fraction;\nexport type CyclePosition = [number, number, number];\nexport type CycleIterator = Generator<[CyclePosition, Fraction]>;\n\nconst ZERO = TSU.Num.Fraction.ZERO;\nconst ONE = TSU.Num.Fraction.ONE;\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 instanceCount(beatIndex: number): number {\n if (beatIndex > this.beatCounts.length) {\n // by default each beat has 1 instance?\n return 1;\n } else {\n return this.beatCounts[beatIndex];\n }\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"]}
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,0CAAwB;AACxB,yCAAuB;AACvB,8CAA4B;AAC5B,4CAA0B;AAC1B,0CAAwB;AACxB,6CAA2B;AAC3B,2CAAyB;AACzB,2CAAyB;AACzB,2CAAyB;AACzB,iDAAiC;AACjC,uDAAuC","sourcesContent":["export * from \"./entity\";\nexport * from \"./cycle\";\nexport * from \"./core\";\nexport * from \"./iterators\";\nexport * from \"./layouts\";\nexport * from \"./beats\";\nexport * from \"./notation\";\nexport * from \"./parser\";\nexport * from \"./shapes\";\nexport * from \"./loader\";\nexport * as Utils from \"./utils\";\nexport * as Carnatic from \"./carnatic\";\n"]}
|
package/lib/cjs/iterators.js
CHANGED
|
@@ -27,7 +27,11 @@ var __assign = (this && this.__assign) || function () {
|
|
|
27
27
|
};
|
|
28
28
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
29
29
|
if (k2 === undefined) k2 = k;
|
|
30
|
-
Object.
|
|
30
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
31
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
32
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
33
|
+
}
|
|
34
|
+
Object.defineProperty(o, k2, desc);
|
|
31
35
|
}) : (function(o, m, k, k2) {
|
|
32
36
|
if (k2 === undefined) k2 = k;
|
|
33
37
|
o[k2] = m[k];
|
package/lib/cjs/iterators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iterators.js","sourceRoot":"","sources":["../../src/iterators.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAuC;AACvC,mCAAuC;AACvC,+BAAgE;AAMhE;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,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC;QAC/B,KAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC;QACjD,KAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;QACrD,KAAI,CAAC,cAAc,GAAG,gBAAgB,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC;;IACnF,CAAC;IAKD,sBAAI,0BA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AAI,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,YAAK,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 } from \"./entity\";\nimport { Atom, LeafAtom, Space, Group, AtomType } from \"./core\";\n\ntype Fraction = TSU.Num.Fraction;\n\ntype FlatAtom2 = [atom: Atom, duration: TSU.Num.Fraction, offset: TSU.Num.Fraction];\n\nexport class FlatAtom extends TimedEntity {\n depth: number;\n duration: TSU.Num.Fraction;\n offset: TSU.Num.Fraction;\n private 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\n/**\n * A nested atom iterator that returns one atom at a time at the leaf-most level.\n * If we have a Group (or nested Groups) only the leaf atoms are returned as if\n * in an in order traversal thus ensuring time order of atoms.\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 WindowIterator {\n private atomQueue = new TSU.Lists.List<Atom>();\n private currOffset = TSU.Num.Fraction.ZERO;\n private peeked: TSU.Nullable<Atom> = 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);\n }\n return this;\n }\n\n next(): TSU.Nullable<Atom> {\n const out = this.peek();\n this.peeked = null;\n if (out != null) {\n this.currOffset = this.currOffset.plus(out.duration, true);\n }\n return out;\n }\n\n peek(): TSU.Nullable<Atom> {\n if (this.peeked == null && this.hasMore) {\n this.peeked = this.atomQueue.popFront();\n }\n return this.peeked;\n }\n\n get hasMore(): boolean {\n return !this.atomQueue.isEmpty;\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): [Atom[], boolean] {\n const out: Atom[] = [];\n let remaining = duration;\n while (remaining.isGTNum(0) && this.hasMore) {\n const next = this.next();\n TSU.assert(next != null, \"Next cannot be null here\");\n out.push(next);\n const spillOver = next.splitAt(remaining);\n remaining = remaining.minus(next.duration);\n if (spillOver != null) {\n // push the spill over to the front of the queue to be\n // picked up on the next \"get\" call\n this.atomQueue.pushFront(spillOver);\n }\n }\n return [out, remaining.isZero];\n }\n}\n\n/**\n * Duration Iterators take a tree of Atoms and return atoms in given windowed\n * durations. This also ensures that a leaf atom can be further split if it is\n * larger than the required duration.\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,mCAAuC;AACvC,+BAAgE;AAMhE;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,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI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Fraction = TSU.Num.Fraction;\n\ntype FlatAtom2 = [atom: Atom, duration: TSU.Num.Fraction, offset: TSU.Num.Fraction];\n\nexport class FlatAtom extends TimedEntity {\n depth: number;\n duration: TSU.Num.Fraction;\n offset: TSU.Num.Fraction;\n private 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\n/**\n * A nested atom iterator that returns one atom at a time at the leaf-most level.\n * If we have a Group (or nested Groups) only the leaf atoms are returned as if\n * in an in order traversal thus ensuring time order of atoms.\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 WindowIterator {\n private atomQueue = new TSU.Lists.List<Atom>();\n private currOffset = TSU.Num.Fraction.ZERO;\n private peeked: TSU.Nullable<Atom> = 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);\n }\n return this;\n }\n\n next(): TSU.Nullable<Atom> {\n const out = this.peek();\n this.peeked = null;\n if (out != null) {\n this.currOffset = this.currOffset.plus(out.duration, true);\n }\n return out;\n }\n\n peek(): TSU.Nullable<Atom> {\n if (this.peeked == null && this.hasMore) {\n this.peeked = this.atomQueue.popFront();\n }\n return this.peeked;\n }\n\n get hasMore(): boolean {\n return !this.atomQueue.isEmpty;\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): [Atom[], boolean] {\n const out: Atom[] = [];\n let remaining = duration;\n while (remaining.isGTNum(0) && this.hasMore) {\n const next = this.next();\n TSU.assert(next != null, \"Next cannot be null here\");\n out.push(next);\n const spillOver = next.splitAt(remaining);\n remaining = remaining.minus(next.duration);\n if (spillOver != null) {\n // push the spill over to the front of the queue to be\n // picked up on the next \"get\" call\n this.atomQueue.pushFront(spillOver);\n }\n }\n return [out, remaining.isZero];\n }\n}\n\n/**\n * Duration Iterators take a tree of Atoms and return atoms in given windowed\n * durations. This also ensures that a leaf atom can be further split if it is\n * larger than the required duration.\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"]}
|
package/lib/cjs/layouts.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/lib/cjs/layouts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layouts.js","sourceRoot":"","sources":["../../src/layouts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAuC;AACvC,iCAA4D;AAG5D,IAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;AAEnC;IAaE,sBAAY,MAAY;QAXf,SAAI,GAAG,YAAY,CAAC,OAAO,EAAE,CAAC;QAYrC,MAAM,GAAG,MAAM,IAAI,EAAE,CAAC;QACtB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,IAAI,CAAC,CAAC;QAC7C,IAAI,OAAO,IAAI,MAAM;YAAE,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QACjD,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE;YAC7C,IAAI,CAAC,KAAK,GAAG,aAAK,CAAC,OAAO,CAAC;SAC5B;QAED,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAC3B,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;QACxB,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;QACjC,IAAI,CAAC,W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CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAI,CAAC,gBAAgB,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/F,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,UAAC,EAAE,EAAE,KAAK;YACrD,OAAO,KAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAT,CAAS,EAAE,IAAI,CAAC,CAAC;IACnF,CAAC;IAMD,sBAAI,qCAAW;aAAf;YACE,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;gBAC3E,IAAI,CAAC,aAAa,EAAE,CAAC;aACtB;YACD,OAAO,IAAI,CAAC,YAAY,CAAC;QAC3B,CAAC;;;OAAA;IAKD,sBAAI,oCAAU;aAAd;YACE,IAAI,CAAC,WAAW,CAAC;YACjB,OAAO,IAAI,CAAC,WAAW,CAAC;QAC1B,CAAC;;;OAAA;IAKD,sBAAI,6CAAmB;aAAvB;YACE,IAAI,CAAC,WAAW,CAAC;YACjB,OAAO,IAAI,CAAC,oBAAoB,CAAC;QACnC,CAAC;;;OAAA;IAjLc,oBAAO,GAAG,CAAC,CAAC;IA+M7B,mBAAC;CAAA,AAhND,IAgNC;AAhNY,oCAAY","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Cycle, CyclePosition, CycleCursor } from \"./cycle\";\n\ntype Fraction = TSU.Num.Fraction;\nconst ZERO = TSU.Num.Fraction.ZERO;\n\nexport class LayoutParams {\n private static counter = 0;\n readonly uuid = LayoutParams.counter++;\n beatDuration: number;\n cycle: Cycle;\n protected _lineBreaks: number[];\n private _rowStartOffsets: Fraction[];\n private _rowEndOffsets: Fraction[];\n private _rowDurations: Fraction[];\n private _totalLayoutDuration;\n private _beatLayouts: [CyclePosition, Fraction][][];\n private _totalBeats: number;\n\n constructor(config?: any) {\n config = config || {};\n this.beatDuration = config.beatDuration || 1;\n if (\"cycle\" in config) this.cycle = config.cycle;\n if (!this.cycle || this.cycle.duration.isZero) {\n this.cycle = Cycle.DEFAULT;\n }\n\n this._rowStartOffsets = [];\n this._rowEndOffsets = [];\n this._rowDurations = [];\n this._totalLayoutDuration = ZERO;\n this._totalBeats = 0;\n this._beatLayouts = [];\n this.lineBreaks = config.lineBreaks || config.layout || [];\n }\n\n equals(another: this): boolean {\n return (\n // super.equals(another) &&\n this.beatDuration == another.beatDuration &&\n this.cycle.equals(another.cycle) &&\n this.lineBreaksEqual(another._lineBreaks)\n );\n }\n\n lineBreaksEqual(another: number[]): boolean {\n return this._lineBreaks.length == another.length && this._lineBreaks.every((x, i) => x == another[i]);\n }\n\n debugValue(): any {\n return {\n // ...super.debugValue(),\n cycle: this.cycle?.debugValue(),\n beatDuration: this.beatDuration,\n lineBreaks: this._lineBreaks,\n };\n }\n\n /**\n * Returns the \"location\" of a beat within a layout.\n *\n * Lines are broken into beats of notes (which can be changed) and those beats\n * are aligned as per the specs in the LayoutParams (breaks).\n *\n * This methods returns the triple: [layoutLine, layoutColumn, rowOffset]\n * where\n *\n * layoutLine: The particular line in the layout break spec this index falls in. Note\n * that since lines can start with negative offsets, we can even return a\n * layoutLine that is towards the end and then go back to 0, eg 4, 0, 1, 2, 3, 4 ...\n * layoutColumn: The column within the layoutLine line where this beat falls.\n * rowOffset: The note offset of the beat from the start of the row/line\n * (not from the start of the cycle).\n *\n * Note the beatIndex can also be negative so we can return a beat starting from before\n * the cycle starting point.\n *\n * To calculate the \"real\" line globally simply do:\n *\n * realLine = [Math.floor(beatIndex / this.totalBeats) + layoutLine;\n */\n getBeatLocation(beat: {\n index: number;\n barIndex: number;\n beatIndex: number;\n instance: number;\n }): [number, number, Fraction] {\n const modIndex = beat.index % this.totalBeats;\n let total = 0;\n for (let i = 0; i < this._lineBreaks.length; i++) {\n if (modIndex < total + this._lineBreaks[i]) {\n // TODO: What is the right offset here?\n let offset = ZERO;\n const startBeat = beat;\n if (modIndex > total) {\n const cursor = new CycleCursor(this.cycle, beat.barIndex, beat.beatIndex, beat.instance);\n let [pos, duration] = cursor.prev;\n for (let i = total; i < modIndex; i++) {\n [pos, duration] = cursor.prev;\n offset = offset.plus(duration.timesNum(this.beatDuration));\n }\n }\n return [i, modIndex - total, offset];\n }\n total += this._lineBreaks[i];\n }\n throw new Error(\"Invalid beat index: \" + beat.index);\n return [-1, -1, ZERO];\n }\n\n /**\n * Return the line layout - ie number of beats in each line - as a\n * repeating pattern.\n *\n * For example 4,2,4 indicates that the notes in our song should be\n * laid out 4 beats in line 1, 2 beats in line 2, 4 beats in line 3 and\n * 4 beats in line 4 and so on as long as there are more notes available\n * in this line.\n */\n get lineBreaks(): number[] {\n if (!this._lineBreaks || this._lineBreaks.length == 0) {\n // trigger a refresh\n this.lineBreaks = [this.cycle.beatCount];\n }\n return this._lineBreaks;\n }\n\n /**\n * Sets the line layout pattern.\n */\n set lineBreaks(val: number[]) {\n this._lineBreaks = val;\n this.refreshLayout();\n }\n\n refreshLayout(): void {\n const cycleIter = this.cycle.iterateBeats();\n const akb = this.beatDuration;\n this._beatLayouts = this.lineBreaks.map((numBeats, index) => {\n const beats: [CyclePosition, Fraction][] = [];\n // see what the beat lengths are here\n for (let i = 0; i < numBeats; i++) {\n const nextCP = cycleIter.next().value;\n nextCP[1] = nextCP[1].timesNum(akb);\n beats.push(nextCP);\n }\n return beats;\n });\n this._totalBeats = this.lineBreaks.reduce((a, b) => a + b, 0);\n this._rowDurations = this._beatLayouts.map((beats) => beats.reduce((x, y) => x.plus(y[1]), ZERO));\n this._rowDurations.forEach((rd, index) => {\n this._rowStartOffsets[index] = index == 0 ? ZERO : this._rowStartOffsets[index - 1].plus(rd);\n });\n this._rowEndOffsets = this._rowDurations.map((rd, index) => {\n return this._rowStartOffsets[index].plus(rd);\n });\n this._totalLayoutDuration = this._rowDurations.reduce((x, y) => x.plus(y), ZERO);\n }\n\n /**\n * Returns the number of beats in each line based on the line layout\n * after taking beatDuration into account.\n */\n get beatLayouts(): ReadonlyArray<ReadonlyArray<[CyclePosition, Fraction]>> {\n if (!this._beatLayouts || this._beatLayouts.length < this.lineBreaks.length) {\n this.refreshLayout();\n }\n return this._beatLayouts;\n }\n\n /**\n * Total duration of all beats across all lines in our line layout.\n */\n get totalBeats(): number {\n this.beatLayouts;\n return this._totalBeats;\n }\n\n /**\n * Total duration of all beats across all lines in our line layout.\n */\n get totalLayoutDuration(): Fraction {\n this.beatLayouts;\n return this._totalLayoutDuration;\n }\n\n /*\n layoutOffsetsFor(offset: Fraction, layoutLine = -1): [number, Fraction] {\n const m1 = offset.mod(this.totalLayoutDuration);\n\n // layoutLine = L such that layout[L].startOffset <= atom.offset % totalLayoutDuration < layout[L].endOffset\n // calculate layoutLine if not provided\n if (layoutLine < 0) {\n // this.beatLayouts should kick off eval of all row offsets, durations etc\n for (let i = 0; i < this.beatLayouts.length; i++) {\n let cmp = this._rowStartOffsets[i].cmp(m1);\n if (cmp >= 0) {\n cmp = m1.cmp(this._rowEndOffsets[i]);\n if (cmp < 0) {\n layoutLine = i;\n break;\n }\n }\n }\n }\n if (layoutLine < 0) {\n throw new Error(\"Atom offset falls outside beat layout range: \" + offset.toString());\n }\n\n // offset = atom.offset % totalLayoutDuration - rowOffset[layoutLine]\n const layoutOffset = m1.minus(this._rowStartOffsets[layoutLine]);\n return [layoutLine, layoutOffset];\n }\n */\n}\n"]}
|
|
1
|
+
{"version":3,"file":"layouts.js","sourceRoot":"","sources":["../../src/layouts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;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CAAS,EAAE,IAAI,CAAC,CAAC;IACnF,CAAC;IAMD,sBAAI,qCAAW;aAAf;YACE,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;gBAC3E,IAAI,CAAC,aAAa,EAAE,CAAC;aACtB;YACD,OAAO,IAAI,CAAC,YAAY,CAAC;QAC3B,CAAC;;;OAAA;IAKD,sBAAI,oCAAU;aAAd;YACE,IAAI,CAAC,WAAW,CAAC;YACjB,OAAO,IAAI,CAAC,WAAW,CAAC;QAC1B,CAAC;;;OAAA;IAKD,sBAAI,6CAAmB;aAAvB;YACE,IAAI,CAAC,WAAW,CAAC;YACjB,OAAO,IAAI,CAAC,oBAAoB,CAAC;QACnC,CAAC;;;OAAA;IAjLc,oBAAO,GAAG,CAAC,CAAC;IA+M7B,mBAAC;CAAA,AAhND,IAgNC;AAhNY,oCAAY","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Cycle, CyclePosition, CycleCursor } from \"./cycle\";\n\ntype Fraction = TSU.Num.Fraction;\nconst ZERO = TSU.Num.Fraction.ZERO;\n\nexport class LayoutParams {\n private static counter = 0;\n readonly uuid = LayoutParams.counter++;\n beatDuration: number;\n cycle: Cycle;\n protected _lineBreaks: number[];\n private _rowStartOffsets: Fraction[];\n private _rowEndOffsets: Fraction[];\n private _rowDurations: Fraction[];\n private _totalLayoutDuration;\n private _beatLayouts: [CyclePosition, Fraction][][];\n private _totalBeats: number;\n\n constructor(config?: any) {\n config = config || {};\n this.beatDuration = config.beatDuration || 1;\n if (\"cycle\" in config) this.cycle = config.cycle;\n if (!this.cycle || this.cycle.duration.isZero) {\n this.cycle = Cycle.DEFAULT;\n }\n\n this._rowStartOffsets = [];\n this._rowEndOffsets = [];\n this._rowDurations = [];\n this._totalLayoutDuration = ZERO;\n this._totalBeats = 0;\n this._beatLayouts = [];\n this.lineBreaks = config.lineBreaks || config.layout || [];\n }\n\n equals(another: this): boolean {\n return (\n // super.equals(another) &&\n this.beatDuration == another.beatDuration &&\n this.cycle.equals(another.cycle) &&\n this.lineBreaksEqual(another._lineBreaks)\n );\n }\n\n lineBreaksEqual(another: number[]): boolean {\n return this._lineBreaks.length == another.length && this._lineBreaks.every((x, i) => x == another[i]);\n }\n\n debugValue(): any {\n return {\n // ...super.debugValue(),\n cycle: this.cycle?.debugValue(),\n beatDuration: this.beatDuration,\n lineBreaks: this._lineBreaks,\n };\n }\n\n /**\n * Returns the \"location\" of a beat within a layout.\n *\n * Lines are broken into beats of notes (which can be changed) and those beats\n * are aligned as per the specs in the LayoutParams (breaks).\n *\n * This methods returns the triple: [layoutLine, layoutColumn, rowOffset]\n * where\n *\n * layoutLine: The particular line in the layout break spec this index falls in. Note\n * that since lines can start with negative offsets, we can even return a\n * layoutLine that is towards the end and then go back to 0, eg 4, 0, 1, 2, 3, 4 ...\n * layoutColumn: The column within the layoutLine line where this beat falls.\n * rowOffset: The note offset of the beat from the start of the row/line\n * (not from the start of the cycle).\n *\n * Note the beatIndex can also be negative so we can return a beat starting from before\n * the cycle starting point.\n *\n * To calculate the \"real\" line globally simply do:\n *\n * realLine = [Math.floor(beatIndex / this.totalBeats) + layoutLine;\n */\n getBeatLocation(beat: {\n index: number;\n barIndex: number;\n beatIndex: number;\n instance: number;\n }): [number, number, Fraction] {\n const modIndex = beat.index % this.totalBeats;\n let total = 0;\n for (let i = 0; i < this._lineBreaks.length; i++) {\n if (modIndex < total + this._lineBreaks[i]) {\n // TODO: What is the right offset here?\n let offset = ZERO;\n const startBeat = beat;\n if (modIndex > total) {\n const cursor = new CycleCursor(this.cycle, beat.barIndex, beat.beatIndex, beat.instance);\n let [pos, duration] = cursor.prev;\n for (let i = total; i < modIndex; i++) {\n [pos, duration] = cursor.prev;\n offset = offset.plus(duration.timesNum(this.beatDuration));\n }\n }\n return [i, modIndex - total, offset];\n }\n total += this._lineBreaks[i];\n }\n throw new Error(\"Invalid beat index: \" + beat.index);\n return [-1, -1, ZERO];\n }\n\n /**\n * Return the line layout - ie number of beats in each line - as a\n * repeating pattern.\n *\n * For example 4,2,4 indicates that the notes in our song should be\n * laid out 4 beats in line 1, 2 beats in line 2, 4 beats in line 3 and\n * 4 beats in line 4 and so on as long as there are more notes available\n * in this line.\n */\n get lineBreaks(): number[] {\n if (!this._lineBreaks || this._lineBreaks.length == 0) {\n // trigger a refresh\n this.lineBreaks = [this.cycle.beatCount];\n }\n return this._lineBreaks;\n }\n\n /**\n * Sets the line layout pattern.\n */\n set lineBreaks(val: number[]) {\n this._lineBreaks = val;\n this.refreshLayout();\n }\n\n refreshLayout(): void {\n const cycleIter = this.cycle.iterateBeats();\n const akb = this.beatDuration;\n this._beatLayouts = this.lineBreaks.map((numBeats, index) => {\n const beats: [CyclePosition, Fraction][] = [];\n // see what the beat lengths are here\n for (let i = 0; i < numBeats; i++) {\n const nextCP = cycleIter.next().value;\n nextCP[1] = nextCP[1].timesNum(akb);\n beats.push(nextCP);\n }\n return beats;\n });\n this._totalBeats = this.lineBreaks.reduce((a, b) => a + b, 0);\n this._rowDurations = this._beatLayouts.map((beats) => beats.reduce((x, y) => x.plus(y[1]), ZERO));\n this._rowDurations.forEach((rd, index) => {\n this._rowStartOffsets[index] = index == 0 ? ZERO : this._rowStartOffsets[index - 1].plus(rd);\n });\n this._rowEndOffsets = this._rowDurations.map((rd, index) => {\n return this._rowStartOffsets[index].plus(rd);\n });\n this._totalLayoutDuration = this._rowDurations.reduce((x, y) => x.plus(y), ZERO);\n }\n\n /**\n * Returns the number of beats in each line based on the line layout\n * after taking beatDuration into account.\n */\n get beatLayouts(): ReadonlyArray<ReadonlyArray<[CyclePosition, Fraction]>> {\n if (!this._beatLayouts || this._beatLayouts.length < this.lineBreaks.length) {\n this.refreshLayout();\n }\n return this._beatLayouts;\n }\n\n /**\n * Total duration of all beats across all lines in our line layout.\n */\n get totalBeats(): number {\n this.beatLayouts;\n return this._totalBeats;\n }\n\n /**\n * Total duration of all beats across all lines in our line layout.\n */\n get totalLayoutDuration(): Fraction {\n this.beatLayouts;\n return this._totalLayoutDuration;\n }\n\n /*\n layoutOffsetsFor(offset: Fraction, layoutLine = -1): [number, Fraction] {\n const m1 = offset.mod(this.totalLayoutDuration);\n\n // layoutLine = L such that layout[L].startOffset <= atom.offset % totalLayoutDuration < layout[L].endOffset\n // calculate layoutLine if not provided\n if (layoutLine < 0) {\n // this.beatLayouts should kick off eval of all row offsets, durations etc\n for (let i = 0; i < this.beatLayouts.length; i++) {\n let cmp = this._rowStartOffsets[i].cmp(m1);\n if (cmp >= 0) {\n cmp = m1.cmp(this._rowEndOffsets[i]);\n if (cmp < 0) {\n layoutLine = i;\n break;\n }\n }\n }\n }\n if (layoutLine < 0) {\n throw new Error(\"Atom offset falls outside beat layout range: \" + offset.toString());\n }\n\n // offset = atom.offset % totalLayoutDuration - rowOffset[layoutLine]\n const layoutOffset = m1.minus(this._rowStartOffsets[layoutLine]);\n return [layoutLine, layoutOffset];\n }\n */\n}\n"]}
|
package/lib/cjs/loader.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/lib/cjs/loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":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;;;iBACF;aACF;SACF;;;;;;;;;IACD,IAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IACpC,IAAI,MAAM,CAAC,GAAG,EAAE;QACd,OAAO,CAAC,GAAG,CAAC,mCAA4B,SAAS,GAAG,SAAS,6BAAmB,SAAS,GAAG,SAAS,OAAI,CAAC,CAAC;KAC5G;IACD,OAAO;QACL,QAAQ;QACR,eAAe;QACf,WAAW;QACX,MAAM;QACN;YACE,SAAS,EAAE,SAAS,GAAG,SAAS;YAChC,SAAS,EAAE,SAAS,GAAG,SAAS;SACjC;KACF,CAAC;AACJ,CAAC;AAxDD,oBAwDC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport * as G from \"galore\";\nimport { Line } from \"./core\";\nimport { BeatLayout, Beat, BeatsBuilder } from \"./beats\";\nimport { Parser } from \"./parser\";\nimport { Notation } from \"./notation\";\n\nexport function parse(input: string): [Notation, G.ParseError[]] {\n const notation = new Notation();\n const parser = new Parser();\n const errors: G.ParseError[] = [];\n parser.parse(input);\n errors.push(...parser.errors);\n for (const cmd of parser.commands) cmd.applyToNotation(notation);\n return [notation, errors];\n}\n\nexport function load(\n codeText: string,\n config: any = {},\n): [Notation, Map<number, Beat[][]>, Map<number, BeatLayout>, G.ParseError[], TSU.StringMap<number>] {\n const beatsByLineRole = new Map<number, Beat[][]>();\n const beatLayouts = new Map<number, BeatLayout>();\n const startTime = performance.now();\n const [notation, errors] = parse(codeText);\n const parseTime = performance.now();\n\n // Create Line Beats\n for (const block of notation.blocks) {\n if (block.type == \"Line\") {\n const line = block as Line;\n // LP should exist by now\n const layoutParams = notation.layoutParamsForLine(line) || null;\n if (!line.isEmpty) {\n // Probably because this is an empty line and AddAtoms was not called\n TSU.assert(layoutParams != null, \"Layout params for a non empty line *should* exist\");\n let beatLayout = beatLayouts.get(layoutParams.uuid) || null;\n if (beatLayout == null) {\n beatLayout = new BeatLayout(layoutParams);\n beatLayouts.set(layoutParams.uuid, beatLayout);\n }\n const roleBeats = [] as Beat[][];\n beatsByLineRole.set(line.uuid, roleBeats);\n\n const lineOffset = line.offset.divbyNum(layoutParams.beatDuration);\n for (const role of line.roles) {\n const bb = new BeatsBuilder(role, layoutParams, lineOffset);\n bb.addAtoms(...role.atoms);\n roleBeats.push(bb.beats);\n\n // Add these to the beat layout too\n for (const beat of bb.beats) {\n // beat.ensureUniformSpaces(layoutParams.beatDuration);\n beatLayout.addBeat(beat);\n }\n }\n }\n }\n }\n const buildTime = performance.now();\n if (config.log) {\n console.log(`V4 Document, Parse Time: ${parseTime - startTime}ms, Build Time: ${buildTime - parseTime}ms`);\n }\n return [\n notation,\n beatsByLineRole,\n beatLayouts,\n errors,\n {\n parseTime: parseTime - startTime,\n buildTime: buildTime - parseTime,\n },\n ];\n}\n"]}
|
package/lib/cjs/parser.js
CHANGED
|
@@ -5,7 +5,11 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
5
5
|
};
|
|
6
6
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
7
|
if (k2 === undefined) k2 = k;
|
|
8
|
-
Object.
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
9
13
|
}) : (function(o, m, k, k2) {
|
|
10
14
|
if (k2 === undefined) k2 = k;
|
|
11
15
|
o[k2] = m[k];
|