notations 0.0.63 → 0.0.65
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.map +1 -1
- package/lib/cjs/beatutils.js.map +1 -1
- package/lib/cjs/beatview.js.map +1 -1
- package/lib/cjs/commands.js.map +1 -1
- package/lib/cjs/core.d.ts +2 -0
- package/lib/cjs/core.js +19 -19
- package/lib/cjs/core.js.map +1 -1
- package/lib/cjs/cycle.js.map +1 -1
- package/lib/cjs/entity.js.map +1 -1
- package/lib/cjs/grids.d.ts +2 -0
- package/lib/cjs/grids.js +7 -2
- package/lib/cjs/grids.js.map +1 -1
- package/lib/cjs/iterators.js.map +1 -1
- package/lib/cjs/layouts.js.map +1 -1
- package/lib/cjs/loader.js.map +1 -1
- package/lib/cjs/notation.js.map +1 -1
- package/lib/cjs/shapes.d.ts +3 -0
- package/lib/cjs/shapes.js +26 -4
- package/lib/cjs/shapes.js.map +1 -1
- package/lib/cjs/utils.js.map +1 -1
- package/lib/esm/beats.js.map +1 -1
- package/lib/esm/beatutils.js.map +1 -1
- package/lib/esm/beatview.js.map +1 -1
- package/lib/esm/commands.js.map +1 -1
- package/lib/esm/core.d.ts +2 -0
- package/lib/esm/core.js +3 -3
- package/lib/esm/core.js.map +1 -1
- package/lib/esm/cycle.js.map +1 -1
- package/lib/esm/entity.js.map +1 -1
- package/lib/esm/grids.d.ts +2 -0
- package/lib/esm/grids.js +7 -2
- package/lib/esm/grids.js.map +1 -1
- package/lib/esm/iterators.js.map +1 -1
- package/lib/esm/layouts.js.map +1 -1
- package/lib/esm/loader.js.map +1 -1
- package/lib/esm/notation.js.map +1 -1
- package/lib/esm/shapes.d.ts +3 -0
- package/lib/esm/shapes.js +26 -4
- package/lib/esm/shapes.js.map +1 -1
- package/lib/esm/utils.js.map +1 -1
- package/package.json +1 -1
package/lib/cjs/beats.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beats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4CAoHC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { AtomType, Marker, Group, Line, Atom, Space, Role } from \"./\";\nimport { CycleIterator, CyclePosition } from \"./cycle\";\nimport { WindowIterator } from \"./iterators\";\nimport { LayoutParams } from \"./layouts\";\nimport { GridModel, GridRow, GridCell, ColAlign, GridLayoutGroup } from \"./grids\";\n\ntype Fraction = TSU.Num.Fraction;\nconst ZERO = TSU.Num.Fraction.ZERO;\nconst ONE = TSU.Num.Fraction.ONE;\n\nexport class Beat {\n private static idCounter = 0;\n readonly uuid = Beat.idCounter++;\n // Should this be as flat Atoms or should we keep it as atoms and breakdown\n // later?\n atom: Atom;\n protected atomIsPlaceholder = false;\n constructor(\n public readonly index: number,\n public readonly role: Role,\n public readonly offset: Fraction,\n public readonly duration: Fraction,\n public readonly barIndex: number,\n public readonly beatIndex: number,\n public readonly instance: number,\n public readonly prevBeat: null | Beat,\n public nextBeat: null | Beat,\n ) {}\n\n debugValue(): any {\n return {\n index: this.index,\n role: this.role.name,\n offset: this.offset.toString(),\n duration: this.duration.toString(),\n barIndex: this.barIndex,\n beatIndex: this.beatIndex,\n instance: this.instance,\n atom: this.atom.debugValue(),\n };\n }\n\n get endOffset(): Fraction {\n return this.offset.plus(this.duration);\n }\n get filled(): boolean {\n return this.remaining.isZero;\n }\n\n get remaining(): Fraction {\n return this.atom ? this.duration.minus(this.atom.duration, true) : this.duration;\n }\n\n add(atom: Atom): boolean {\n if (this.remaining.cmp(atom.duration) < 0) {\n return false;\n }\n if (!this.atom) {\n this.atom = atom;\n } else {\n if (!this.atomIsPlaceholder) {\n this.atomIsPlaceholder = true;\n this.atom = new Group(this.atom).setDuration(ONE, true);\n }\n (this.atom as Group).addAtoms(true, atom);\n }\n return true;\n }\n\n get preMarkers(): Marker[] {\n const out = [] as Marker[];\n let curr: Atom | null = this.atom;\n while (curr != null) {\n for (const marker of curr.markersBefore || []) {\n out.push(marker);\n }\n if (curr.TYPE == AtomType.GROUP) {\n curr = (curr as Group).atoms.first;\n } else {\n curr = null;\n }\n }\n return out;\n }\n\n get postMarkers(): Marker[] {\n const out = [] as Marker[];\n let curr: Atom | null = this.atom;\n while (curr != null) {\n out.splice(0, 0, ...(curr.markersAfter || []));\n if (curr.TYPE == AtomType.GROUP) {\n curr = (curr as Group).atoms.last;\n } else {\n curr = null;\n }\n }\n return out;\n }\n}\n\nexport class BeatsBuilder {\n // All atoms divided into beats\n readonly beats: Beat[] = [];\n readonly startIndex: number;\n readonly beatOffset: Fraction;\n cycleIter: CycleIterator;\n windowIter: WindowIterator;\n\n // Callback for when an atom is added to this role.\n onAtomAdded: (atom: Atom, beat: Beat) => void;\n\n // Callback for when a new beat is added\n onBeatAdded: (beat: Beat) => void;\n // Callback for when a beat has been filled\n onBeatFilled: (beat: Beat) => void;\n\n constructor(\n public readonly role: Role,\n public readonly layoutParams: LayoutParams,\n public readonly startOffset: Fraction = ZERO,\n ...atoms: Atom[]\n ) {\n const [, [bar, beat, instance], beatOffset, index] = layoutParams.cycle.getPosition(startOffset);\n this.cycleIter = layoutParams.cycle.iterateBeats(bar, beat, instance);\n this.windowIter = new WindowIterator();\n this.beatOffset = beatOffset;\n\n // evaluate the start beatindex - typically it would be 0 if things start\n // at beginning of a cycle. But if the start offset is < 0 then the\n // startIndex should also shift accordingly\n this.startIndex = index;\n this.addAtoms(...atoms);\n }\n\n addAtoms(...atoms: Atom[]): void {\n // First add all atoms to the atom Iterator so we can\n // fetch them as FlatAtoms. This is needed because atoms\n // passed here could be unflatted (via groups) or much larger\n // than what can fit in the given role/bar etc. So this\n // flattening and windowing is needed before we add them\n // to the views - and this is done by the durationIterators.\n this.windowIter.push(...atoms);\n while (this.windowIter.hasMore) {\n // get the last/current row and add a new one if it is full\n let currBeat = this.beats[this.beats.length - 1];\n\n // First add a row if last row is filled\n if (this.beats.length == 0 || currBeat.filled) {\n // what should be the beatlengths be here?\n currBeat = this.addBeat();\n }\n\n // For this beat get symbols in all roles\n const [remAtoms, filled] = this.windowIter.get(currBeat.remaining);\n TSU.assert(remAtoms.length > 0, \"Atleast one element should have been available here\");\n // render the atoms now\n for (const atom of remAtoms) {\n // console.log(\"Adding FA: \", flatAtom.debugValue(), flatAtom.atom);\n TSU.assert(currBeat.add(atom), \"Should return true as we are already using a duration iterator here\");\n if (this.onAtomAdded) this.onAtomAdded(atom, currBeat);\n }\n if (currBeat.filled) {\n if (this.onBeatFilled) this.onBeatFilled(currBeat);\n }\n }\n }\n\n protected addBeat(): Beat {\n const numBeats = this.beats.length;\n const lastBeat = numBeats == 0 ? null : this.beats[numBeats - 1];\n const nextCP: [CyclePosition, Fraction] = this.cycleIter.next().value;\n const apb = this.layoutParams.beatDuration;\n const newBeat = new Beat(\n lastBeat == null ? this.startIndex : lastBeat.index + 1,\n this.role,\n lastBeat == null ? this.startOffset.minus(this.beatOffset).timesNum(apb, true) : lastBeat.endOffset,\n nextCP[1].timesNum(apb),\n nextCP[0][0],\n nextCP[0][1],\n nextCP[0][2],\n lastBeat,\n null,\n );\n if (lastBeat == null && this.beatOffset.isGT(ZERO)) {\n // Add spaces to fill up empty beats\n newBeat.add(new Space(this.beatOffset.timesNum(apb)));\n }\n if (lastBeat) lastBeat.nextBeat = newBeat;\n this.beats.push(newBeat);\n if (this.onBeatAdded) this.onBeatAdded(newBeat);\n return newBeat;\n }\n}\n\nexport class BeatColumn extends ColAlign {\n atomSpacing = 5;\n readonly key: string;\n constructor(\n public readonly offset: Fraction,\n public readonly endOffset: Fraction,\n public readonly markerType: number,\n ) {\n super();\n offset = offset.factorized;\n endOffset = endOffset.factorized;\n this.key = BeatColumn.keyFor(offset, endOffset, markerType);\n }\n\n static keyFor(offset: Fraction, endOffset: Fraction, markerType = 0): string {\n offset = offset.factorized;\n endOffset = endOffset.factorized;\n if (markerType < 0) {\n // return the column for the marker \"before\" this col\n // int his case only the \"start offset\" is needed and length doesnt matter\n return \":\" + offset.toString();\n } else if (markerType > 0) {\n // return the column for the marker \"after\" this col\n // in this case only thd end offset matters\n return endOffset.toString() + \":\";\n } else {\n return offset.toString() + \":\" + endOffset.toString();\n }\n }\n}\n\n/**\n * Grouping of beats by their column based on the layout params.\n * The confusion is we have beats broken up and saved in columns\n * but we are loosing how a line is supposed to access it in its own way\n * we have beatsByRole for getting all beats for a role (in a line)\n * sequentially we have beatColumns for getting all beats in a particular\n * column across all lines and roles globally.\n *\n * What we want here is for a given line get all roles, their beats\n * in zipped way. eg for a Line with 3 roles and say 10 beats each\n * (with the breaks of 4, 1) we need:\n *\n * R1 B1 R1 B2 R1 B3 R1 B4\n * R2 B1 R2 B2 R2 B3 R2 B4\n * R3 B1 R3 B2 R3 B3 R3 B4\n *\n * R1 B5\n * R2 B5\n * R3 B5\n *\n * R1 B6 R1 B7 R1 B8 R1 B9\n * R2 B6 R2 B7 R2 B8 R2 B9\n * R3 B6 R3 B7 R3 B8 R3 B9\n *\n * R1 B10\n * R2 B10\n * R3 B10\n *\n *\n * Here we have 5 distinct beat columns:\n *\n * 1: R1B1, R2B1, R3B1, R1B6, R2B6, R3B6,\n * 2: R1B2, R2B2, R3B2, R1B7, R2B7, R3B7,\n * 3: R1B3, R2B3, R3B3, R1B8, R2B8, R3B8,\n * 4: R1B4, R2B4, R3B4, R1B9, R2B9, R3B9,\n * 5: R1B5, R2B5, R3B5, R1B10, R2B10, R3B10,\n *\n */\nexport class BeatColDAG {\n beatColumns = new Map<string, BeatColumn>();\n\n constructor(public readonly layoutGroup: GridLayoutGroup) {\n //\n }\n\n /**\n * Gets the beat column of a given duration at the given offset.\n */\n getBeatColumn(offset: Fraction, endOffset: Fraction, markerType = 0): BeatColumn {\n const [bcol, newcreated] = this.ensureBeatColumn(offset, endOffset, markerType);\n if (newcreated) {\n if (markerType == 0) {\n const [prevcol] = this.ensureBeatColumn(offset, endOffset, -1);\n const [nextcol] = this.ensureBeatColumn(offset, endOffset, 1);\n prevcol.addSuccessor(bcol);\n bcol.addSuccessor(nextcol);\n for (const other of this.beatColumns.values()) {\n // only join the \"marker\" columns\n if (other.markerType == -1 && endOffset.equals(other.offset)) {\n // our next col is a preecessor of other\n nextcol.addSuccessor(other);\n } else if (other.markerType == 1 && other.endOffset.equals(offset)) {\n // our prev col is a predecessor of other\n other.addSuccessor(prevcol);\n }\n }\n }\n }\n return bcol;\n }\n\n protected ensureBeatColumn(offset: Fraction, endOffset: Fraction, markerType = 0): [BeatColumn, boolean] {\n const key = BeatColumn.keyFor(offset, endOffset, markerType);\n let bcol = this.beatColumns.get(key) || null;\n const newcreated = bcol == null;\n if (!bcol) {\n bcol = new BeatColumn(offset, endOffset, markerType);\n this.beatColumns.set(key, bcol);\n }\n return [bcol, newcreated];\n }\n}\n\n/**\n * Manages the beat layouts for *all* lines in a notation.\n */\ntype LineId = number;\ntype LPID = number;\nexport class GlobalBeatLayout {\n gridModelsForLine = new Map<LineId, GridModel>();\n roleBeatsForLine = new Map<LineId, Beat[][]>();\n beatColDAGsByLP = new Map<LPID, BeatColDAG>();\n readonly gridLayoutGroup = new GridLayoutGroup();\n\n /**\n * Get the GridView associated with a particular line.\n */\n getGridModelForLine(lineid: LineId): GridModel {\n let out = this.gridModelsForLine.get(lineid) || null;\n if (!out) {\n out = new GridModel();\n this.gridLayoutGroup.addGridModel(out);\n this.gridModelsForLine.set(lineid, out);\n }\n return out;\n }\n\n protected beatColDAGForLP(lpid: LPID): BeatColDAG {\n let out = this.beatColDAGsByLP.get(lpid) || null;\n if (!out) {\n out = new BeatColDAG(this.gridLayoutGroup);\n this.beatColDAGsByLP.set(lpid, out);\n }\n return out;\n }\n\n /**\n * First lines are added to the BeatLayout object.\n * This ensures that a line is broken down into beats and added\n * into a dedicated GridModel per line.\n *\n * A line must also be given the layout params by which the beat\n * break down will happen. This LayoutParams object does not have\n * to be unique per line (this non-constraint allows to align\n * beats across lines!).\n */\n addLine(line: Line): void {\n const gridModel = this.getGridModelForLine(line.uuid) as GridModel;\n gridModel.eventHub?.startBatchMode();\n this.lineToRoleBeats(line, gridModel);\n gridModel.eventHub?.commitBatch();\n }\n\n protected lineToRoleBeats(line: Line, gridModel: GridModel): Beat[][] {\n const lp = line.layoutParams;\n const roleBeats = [] as Beat[][];\n this.roleBeatsForLine.set(line.uuid, roleBeats);\n const lineOffset = line.offset.divbyNum(lp.beatDuration);\n for (const role of line.roles) {\n const bb = new BeatsBuilder(role, lp, lineOffset, ...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 this.addBeat(beat, gridModel);\n }\n }\n return roleBeats;\n }\n\n /**\n * Adds the beat to this layout and returns the BeatColumn to which\n * this beat was added.\n */\n protected addBeat(beat: Beat, gridModel: GridModel): GridCell {\n // Get the beat column at this index (and line) and add to it.\n const line = beat.role.line;\n const lp = line.layoutParams;\n const beatColDAG = this.beatColDAGForLP(lp.uuid);\n const [layoutLine, layoutColumn, rowOffset] = lp.getBeatLocation(beat);\n const colEnd = rowOffset.plus(beat.duration, true);\n const bcol = beatColDAG.getBeatColumn(rowOffset, colEnd, 0);\n\n // Since a beat's column has a \"pre\" and \"post\" col to, each\n // beat has 3 columns for it\n const roleIndex = beat.role.line.indexOfRole(beat.role.name);\n const nthLine = Math.floor(beat.index / lp.totalBeats);\n const realLine = lp.lineBreaks.length * nthLine + layoutLine;\n const realRow = line.roles.length * realLine + roleIndex;\n // pre marker goes on realCol - 1, post marker goes on realCol + 1\n const realCol = 1 + layoutColumn * 3;\n const preMarkers = beat.preMarkers;\n if (preMarkers.length > 0) {\n const val = {\n beat: beat,\n markers: preMarkers,\n };\n const precol = beatColDAG.getBeatColumn(rowOffset, colEnd, -1);\n gridModel.setValue(realRow, realCol - 1, val, (gridRow: GridRow, col: number) => {\n const cell = new GridCell(gridRow, col);\n cell.colAlign = precol;\n return cell;\n });\n }\n const postMarkers = beat.postMarkers;\n if (postMarkers.length > 0) {\n const val = {\n beat: beat,\n markers: postMarkers,\n };\n const postcol = beatColDAG.getBeatColumn(rowOffset, colEnd, 1);\n gridModel.setValue(realRow, realCol + 1, val, (gridRow: GridRow, col: number) => {\n const cell = new GridCell(gridRow, col);\n cell.colAlign = postcol;\n return cell;\n });\n }\n return gridModel.setValue(realRow, realCol, beat, (gridRow: GridRow, col: number) => {\n const cell = new GridCell(gridRow, col);\n cell.colAlign = bcol;\n return cell;\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"beats.js","sourceRoot":"","sources":["../../src/beats.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,yBAAsE;AAEtE,2CAA6C;AAE7C,mCAAkF;AAGlF,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;AACnC,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;AAMjC,MAAa,IAAI;IAqBf,YACkB,KAAa,EACb,IAAU,EACV,MAAgB,EAChB,QAAkB,EAClB,QAAgB,EAChB,SAAiB,EACjB,QAAgB,EAChB,QAAqB,EAC9B,QAAqB;QARZ,UAAK,GAAL,KAAK,CAAQ;QACb,SAAI,GAAJ,IAAI,CAAM;QACV,WAAM,GAAN,MAAM,CAAU;QAChB,aAAQ,GAAR,QAAQ,CAAU;QAClB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,cAAS,GAAT,SAAS,CAAQ;QACjB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,aAAQ,GAAR,QAAQ,CAAa;QAC9B,aAAQ,GAAR,QAAQ,CAAa;QA5BrB,SAAI,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAKvB,sBAAiB,GAAG,KAAK,CAAC;IAwBjC,CAAC;IAMJ,UAAU;QACR,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI;YACpB,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;YAC9B,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OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,OAAgB,EAAE,GAAW,EAAE,EAAE;YAClF,MAAM,IAAI,GAAG,IAAI,gBAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;YACxC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAvID,4CAuIC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { AtomType, Marker, Group, Line, Atom, Space, Role } from \"./\";\nimport { CycleIterator, CyclePosition } from \"./cycle\";\nimport { WindowIterator } from \"./iterators\";\nimport { LayoutParams } from \"./layouts\";\nimport { GridModel, GridRow, GridCell, ColAlign, GridLayoutGroup } from \"./grids\";\n\ntype Fraction = TSU.Num.Fraction;\nconst ZERO = TSU.Num.Fraction.ZERO;\nconst ONE = TSU.Num.Fraction.ONE;\n\n/**\n * Represents a single beat in the notation.\n * A beat contains one or more atoms and has a specific position in a bar.\n */\nexport class Beat {\n private static idCounter = 0;\n readonly uuid = Beat.idCounter++;\n // Should this be as flat Atoms or should we keep it as atoms and breakdown later?\n\n /** The atom contained in this beat */\n atom: Atom;\n protected atomIsPlaceholder = false;\n \n /**\n * Creates a new Beat.\n * @param index The index of this beat in the sequence\n * @param role The role this beat belongs to\n * @param offset The time offset of this beat from the start\n * @param duration The duration of this beat\n * @param barIndex The index of the bar containing this beat\n * @param beatIndex The index of this beat within its bar\n * @param instance The instance number of this beat\n * @param prevBeat The previous beat in the sequence, if any\n * @param nextBeat The next beat in the sequence, if any\n */\n constructor(\n public readonly index: number,\n public readonly role: Role,\n public readonly offset: Fraction,\n public readonly duration: Fraction,\n public readonly barIndex: number,\n public readonly beatIndex: number,\n public readonly instance: number,\n public readonly prevBeat: null | Beat,\n public nextBeat: null | Beat,\n ) {}\n\n /**\n * Returns a debug-friendly representation of this Beat.\n * @returns An object containing debug information\n */\n debugValue(): any {\n return {\n index: this.index,\n role: this.role.name,\n offset: this.offset.toString(),\n duration: this.duration.toString(),\n barIndex: this.barIndex,\n beatIndex: this.beatIndex,\n instance: this.instance,\n atom: this.atom.debugValue(),\n };\n }\n\n /**\n * Gets the end offset of this beat (offset + duration).\n */\n get endOffset(): Fraction {\n return this.offset.plus(this.duration);\n }\n \n /**\n * Checks if this beat is filled completely (no remaining space).\n */\n get filled(): boolean {\n return this.remaining.isZero;\n }\n\n /**\n * Gets the remaining duration available in this beat.\n */\n get remaining(): Fraction {\n return this.atom ? this.duration.minus(this.atom.duration, true) : this.duration;\n }\n\n /**\n * Adds an atom to this beat.\n * @param atom The atom to add\n * @returns True if the atom was added successfully, false if there's not enough space\n */\n add(atom: Atom): boolean {\n if (this.remaining.cmp(atom.duration) < 0) {\n return false;\n }\n if (!this.atom) {\n this.atom = atom;\n } else {\n if (!this.atomIsPlaceholder) {\n this.atomIsPlaceholder = true;\n this.atom = new Group(this.atom).setDuration(ONE, true);\n }\n (this.atom as Group).addAtoms(true, atom);\n }\n return true;\n }\n\n /**\n * Gets all markers that should be displayed before this beat.\n * @returns An array of Marker objects\n */\n get preMarkers(): Marker[] {\n const out = [] as Marker[];\n let curr: Atom | null = this.atom;\n while (curr != null) {\n for (const marker of curr.markersBefore || []) {\n out.push(marker);\n }\n if (curr.TYPE == AtomType.GROUP) {\n curr = (curr as Group).atoms.first;\n } else {\n curr = null;\n }\n }\n return out;\n }\n\n /**\n * Gets all markers that should be displayed after this beat.\n * @returns An array of Marker objects\n */\n get postMarkers(): Marker[] {\n const out = [] as Marker[];\n let curr: Atom | null = this.atom;\n while (curr != null) {\n out.splice(0, 0, ...(curr.markersAfter || []));\n if (curr.TYPE == AtomType.GROUP) {\n curr = (curr as Group).atoms.last;\n } else {\n curr = null;\n }\n }\n return out;\n }\n}\n\n/**\n * Builds a sequence of beats from atoms according to layout parameters.\n * Used to convert a flat sequence of atoms into structured beats for display.\n */\nexport class BeatsBuilder {\n /** All atoms divided into beats */\n readonly beats: Beat[] = [];\n readonly startIndex: number;\n readonly beatOffset: Fraction;\n cycleIter: CycleIterator;\n windowIter: WindowIterator;\n\n /** Callback for when an atom is added to this role */\n onAtomAdded: (atom: Atom, beat: Beat) => void;\n\n /** Callback for when a new beat is added */\n onBeatAdded: (beat: Beat) => void;\n \n /** Callback for when a beat has been filled */\n onBeatFilled: (beat: Beat) => void;\n\n /**\n * Creates a new BeatsBuilder.\n * @param role The role containing the atoms\n * @param layoutParams Layout parameters for structuring beats\n * @param startOffset The starting offset for the first beat, defaults to ZERO\n * @param atoms Initial atoms to add to the beats\n */\n constructor(\n public readonly role: Role,\n public readonly layoutParams: LayoutParams,\n public readonly startOffset: Fraction = ZERO,\n ...atoms: Atom[]\n ) {\n const [, [bar, beat, instance], beatOffset, index] = layoutParams.cycle.getPosition(startOffset);\n this.cycleIter = layoutParams.cycle.iterateBeats(bar, beat, instance);\n this.windowIter = new WindowIterator();\n this.beatOffset = beatOffset;\n\n // evaluate the start beatindex - typically it would be 0 if things start\n // at beginning of a cycle. But if the start offset is < 0 then the\n // startIndex should also shift accordingly\n this.startIndex = index;\n this.addAtoms(...atoms);\n }\n\n /**\n * Adds atoms to be processed into beats.\n * @param atoms The atoms to add\n */\n addAtoms(...atoms: Atom[]): void {\n // First add all atoms to the atom Iterator so we can\n // fetch them as FlatAtoms. This is needed because atoms\n // passed here could be unflatted (via groups) or much larger\n // than what can fit in the given role/bar etc. So this\n // flattening and windowing is needed before we add them\n // to the views - and this is done by the durationIterators.\n this.windowIter.push(...atoms);\n while (this.windowIter.hasMore) {\n // get the last/current row and add a new one if it is full\n let currBeat = this.beats[this.beats.length - 1];\n\n // First add a row if last row is filled\n if (this.beats.length == 0 || currBeat.filled) {\n // what should be the beatlengths be here?\n currBeat = this.addBeat();\n }\n\n // For this beat get symbols in all roles\n const [remAtoms, filled] = this.windowIter.get(currBeat.remaining);\n TSU.assert(remAtoms.length > 0, \"Atleast one element should have been available here\");\n // render the atoms now\n for (const atom of remAtoms) {\n // console.log(\"Adding FA: \", flatAtom.debugValue(), flatAtom.atom);\n TSU.assert(currBeat.add(atom), \"Should return true as we are already using a duration iterator here\");\n if (this.onAtomAdded) this.onAtomAdded(atom, currBeat);\n }\n if (currBeat.filled) {\n if (this.onBeatFilled) this.onBeatFilled(currBeat);\n }\n }\n }\n\n /**\n * Adds a new beat to the sequence.\n * @returns The newly created beat\n */\n protected addBeat(): Beat {\n const numBeats = this.beats.length;\n const lastBeat = numBeats == 0 ? null : this.beats[numBeats - 1];\n const nextCP: [CyclePosition, Fraction] = this.cycleIter.next().value;\n const apb = this.layoutParams.beatDuration;\n const newBeat = new Beat(\n lastBeat == null ? this.startIndex : lastBeat.index + 1,\n this.role,\n lastBeat == null ? this.startOffset.minus(this.beatOffset).timesNum(apb, true) : lastBeat.endOffset,\n nextCP[1].timesNum(apb),\n nextCP[0][0],\n nextCP[0][1],\n nextCP[0][2],\n lastBeat,\n null,\n );\n if (lastBeat == null && this.beatOffset.isGT(ZERO)) {\n // Add spaces to fill up empty beats\n newBeat.add(new Space(this.beatOffset.timesNum(apb)));\n }\n if (lastBeat) lastBeat.nextBeat = newBeat;\n this.beats.push(newBeat);\n if (this.onBeatAdded) this.onBeatAdded(newBeat);\n return newBeat;\n }\n}\n\n/**\n * Represents a column of beats in a layout grid.\n * Used for aligning beats vertically in the notation.\n */\nexport class BeatColumn extends ColAlign {\n /** Spacing between atoms in this column */\n atomSpacing = 5;\n /** Unique key for this column */\n readonly key: string;\n\n /**\n * Creates a new BeatColumn.\n * @param offset The starting offset of this column\n * @param endOffset The ending offset of this column\n * @param markerType The type of marker for this column (negative: before, positive: after, zero: normal)\n */\n constructor(\n public readonly offset: Fraction,\n public readonly endOffset: Fraction,\n public readonly markerType: number,\n ) {\n super();\n offset = offset.factorized;\n endOffset = endOffset.factorized;\n this.key = BeatColumn.keyFor(offset, endOffset, markerType);\n }\n\n /**\n * Generates a key for identifying columns with the same offsets and marker type.\n * @param offset The starting offset\n * @param endOffset The ending offset\n * @param markerType The type of marker (negative: before, positive: after, zero: normal)\n * @returns A string key\n */\n static keyFor(offset: Fraction, endOffset: Fraction, markerType = 0): string {\n offset = offset.factorized;\n endOffset = endOffset.factorized;\n if (markerType < 0) {\n // return the column for the marker \"before\" this col\n // int his case only the \"start offset\" is needed and length doesnt matter\n return \":\" + offset.toString();\n } else if (markerType > 0) {\n // return the column for the marker \"after\" this col\n // in this case only thd end offset matters\n return endOffset.toString() + \":\";\n } else {\n return offset.toString() + \":\" + endOffset.toString();\n }\n }\n}\n\n/**\n * Manages the organization of beats into columns based on their offsets.\n * Used to create a directed acyclic graph (DAG) of beat columns for layout purposes.\n *\n * Grouping of beats by their column based on the layout params.\n * The confusion is we have beats broken up and saved in columns\n * but we are loosing how a line is supposed to access it in its own way\n * we have beatsByRole for getting all beats for a role (in a line)\n * sequentially we have beatColumns for getting all beats in a particular\n * column across all lines and roles globally.\n *\n * What we want here is for a given line get all roles, their beats\n * in zipped way. eg for a Line with 3 roles and say 10 beats each\n * (with the breaks of 4, 1) we need:\n *\n * R1 B1 R1 B2 R1 B3 R1 B4\n * R2 B1 R2 B2 R2 B3 R2 B4\n * R3 B1 R3 B2 R3 B3 R3 B4\n *\n * R1 B5\n * R2 B5\n * R3 B5\n *\n * R1 B6 R1 B7 R1 B8 R1 B9\n * R2 B6 R2 B7 R2 B8 R2 B9\n * R3 B6 R3 B7 R3 B8 R3 B9\n *\n * R1 B10\n * R2 B10\n * R3 B10\n *\n *\n * Here we have 5 distinct beat columns:\n *\n * 1: R1B1, R2B1, R3B1, R1B6, R2B6, R3B6,\n * 2: R1B2, R2B2, R3B2, R1B7, R2B7, R3B7,\n * 3: R1B3, R2B3, R3B3, R1B8, R2B8, R3B8,\n * 4: R1B4, R2B4, R3B4, R1B9, R2B9, R3B9,\n * 5: R1B5, R2B5, R3B5, R1B10, R2B10, R3B10,\n *\n */\nexport class BeatColDAG {\n /** Map of column keys to BeatColumn objects */\n beatColumns = new Map<string, BeatColumn>();\n\n /**\n * Creates a new BeatColDAG.\n * @param layoutGroup The layout group to associate with this DAG\n */\n constructor(public readonly layoutGroup: GridLayoutGroup) {\n //\n }\n\n /**\n * Gets the beat column for a given duration at the specified offset.\n * Creates a new column if none exists.\n * @param offset The starting offset\n * @param endOffset The ending offset\n * @param markerType The type of marker\n * @returns The BeatColumn for the specified parameters\n */\n getBeatColumn(offset: Fraction, endOffset: Fraction, markerType = 0): BeatColumn {\n const [bcol, newcreated] = this.ensureBeatColumn(offset, endOffset, markerType);\n if (newcreated) {\n if (markerType == 0) {\n const [prevcol] = this.ensureBeatColumn(offset, endOffset, -1);\n const [nextcol] = this.ensureBeatColumn(offset, endOffset, 1);\n prevcol.addSuccessor(bcol);\n bcol.addSuccessor(nextcol);\n for (const other of this.beatColumns.values()) {\n // only join the \"marker\" columns\n if (other.markerType == -1 && endOffset.equals(other.offset)) {\n // our next col is a preecessor of other\n nextcol.addSuccessor(other);\n } else if (other.markerType == 1 && other.endOffset.equals(offset)) {\n // our prev col is a predecessor of other\n other.addSuccessor(prevcol);\n }\n }\n }\n }\n return bcol;\n }\n\n /**\n * Ensures a beat column exists for the given parameters.\n * @param offset The starting offset\n * @param endOffset The ending offset\n * @param markerType The type of marker\n * @returns A tuple containing the column and whether it was newly created\n */\n protected ensureBeatColumn(offset: Fraction, endOffset: Fraction, markerType = 0): [BeatColumn, boolean] {\n const key = BeatColumn.keyFor(offset, endOffset, markerType);\n let bcol = this.beatColumns.get(key) || null;\n const newcreated = bcol == null;\n if (!bcol) {\n bcol = new BeatColumn(offset, endOffset, markerType);\n this.beatColumns.set(key, bcol);\n }\n return [bcol, newcreated];\n }\n}\n\n/** Type alias for line IDs */\ntype LineId = number;\n/** Type alias for layout parameter IDs */\ntype LPID = number;\n\n/**\n * Manages the beat layouts for all lines in a notation.\n * Handles the creation of grid models, positioning of beats, and alignment of beats across lines.\n */\nexport class GlobalBeatLayout {\n /** Map of line IDs to grid models */\n gridModelsForLine = new Map<LineId, GridModel>();\n /** Map of line IDs to arrays of beats for each role */\n roleBeatsForLine = new Map<LineId, Beat[][]>();\n /** Map of layout parameter IDs to beat column DAGs */\n beatColDAGsByLP = new Map<LPID, BeatColDAG>();\n /** The global layout group for all grid models */\n readonly gridLayoutGroup = new GridLayoutGroup();\n\n /**\n * Gets the GridModel associated with a particular line, creating one if it doesn't exist.\n * @param lineid The ID of the line\n * @returns The GridModel for the line\n */\n getGridModelForLine(lineid: LineId): GridModel {\n let out = this.gridModelsForLine.get(lineid) || null;\n if (!out) {\n out = new GridModel();\n this.gridLayoutGroup.addGridModel(out);\n this.gridModelsForLine.set(lineid, out);\n }\n return out;\n }\n\n /**\n * Gets the BeatColDAG for a specific layout parameter ID, creating one if it doesn't exist.\n * @param lpid The layout parameter ID\n * @returns The BeatColDAG for the layout parameters\n */\n protected beatColDAGForLP(lpid: LPID): BeatColDAG {\n let out = this.beatColDAGsByLP.get(lpid) || null;\n if (!out) {\n out = new BeatColDAG(this.gridLayoutGroup);\n this.beatColDAGsByLP.set(lpid, out);\n }\n return out;\n }\n\n /**\n * Adds a line to the beat layout.\n * This ensures that a line is broken down into beats and added into a dedicated GridModel.\n * \n * A line must also be given the layout params by which the beat breakdown will happen.\n * This LayoutParams object does not have to be unique per line (this non-constraint allows\n * beats to be aligned across lines).\n * \n * @param line The line to add\n */\n addLine(line: Line): void {\n const gridModel = this.getGridModelForLine(line.uuid) as GridModel;\n gridModel.eventHub?.startBatchMode();\n this.lineToRoleBeats(line, gridModel);\n gridModel.eventHub?.commitBatch();\n }\n\n /**\n * Converts a line into a series of beats for each role.\n * @param line The line to convert\n * @param gridModel The grid model to use\n * @returns Arrays of beats for each role\n */\n protected lineToRoleBeats(line: Line, gridModel: GridModel): Beat[][] {\n const lp = line.layoutParams;\n const roleBeats = [] as Beat[][];\n this.roleBeatsForLine.set(line.uuid, roleBeats);\n const lineOffset = line.offset.divbyNum(lp.beatDuration);\n for (const role of line.roles) {\n const bb = new BeatsBuilder(role, lp, lineOffset, ...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 this.addBeat(beat, gridModel);\n }\n }\n return roleBeats;\n }\n\n /**\n * Adds a beat to the layout.\n * @param beat The beat to add\n * @param gridModel The grid model to add the beat to\n * @returns The grid cell containing the beat\n */\n protected addBeat(beat: Beat, gridModel: GridModel): GridCell {\n // Get the beat column at this index (and line) and add to it.\n const line = beat.role.line;\n const lp = line.layoutParams;\n const beatColDAG = this.beatColDAGForLP(lp.uuid);\n const [layoutLine, layoutColumn, rowOffset] = lp.getBeatLocation(beat);\n const colEnd = rowOffset.plus(beat.duration, true);\n const bcol = beatColDAG.getBeatColumn(rowOffset, colEnd, 0);\n\n // Since a beat's column has a \"pre\" and \"post\" col to, each\n // beat has 3 columns for it\n const roleIndex = beat.role.line.indexOfRole(beat.role.name);\n const nthLine = Math.floor(beat.index / lp.totalBeats);\n const realLine = lp.lineBreaks.length * nthLine + layoutLine;\n const realRow = line.roles.length * realLine + roleIndex;\n // pre marker goes on realCol - 1, post marker goes on realCol + 1\n const realCol = 1 + layoutColumn * 3;\n const preMarkers = beat.preMarkers;\n if (preMarkers.length > 0) {\n const val = {\n beat: beat,\n markers: preMarkers,\n };\n const precol = beatColDAG.getBeatColumn(rowOffset, colEnd, -1);\n gridModel.setValue(realRow, realCol - 1, val, (gridRow: GridRow, col: number) => {\n const cell = new GridCell(gridRow, col);\n cell.colAlign = precol;\n return cell;\n });\n }\n const postMarkers = beat.postMarkers;\n if (postMarkers.length > 0) {\n const val = {\n beat: beat,\n markers: postMarkers,\n };\n const postcol = beatColDAG.getBeatColumn(rowOffset, colEnd, 1);\n gridModel.setValue(realRow, realCol + 1, val, (gridRow: GridRow, col: number) => {\n const cell = new GridCell(gridRow, col);\n cell.colAlign = postcol;\n return cell;\n });\n }\n return gridModel.setValue(realRow, realCol, beat, (gridRow: GridRow, col: number) => {\n const cell = new GridCell(gridRow, col);\n cell.colAlign = bcol;\n return cell;\n });\n }\n}\n"]}
|
package/lib/cjs/beatutils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beatutils.js","sourceRoot":"","sources":["../../src/beatutils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"beatutils.js","sourceRoot":"","sources":["../../src/beatutils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,kDA8CC;AA5DD,qDAAuC;AACvC,yBAA2B;AAC3B,2CAAuC;AAYvC,SAAgB,mBAAmB,CAAC,UAA4B,EAAE,KAAiB,EAAE,YAAY,GAAG,CAAC;IACnG,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;QACzB,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC;QACnC,MAAM,OAAO,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC;QAC/B,IAAI,OAAO,IAAI,CAAC,EAAE,CAAC;YACjB,GAAG,IAAI,OAAO,CAAC;YACf,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC;gBACb,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC;YACvB,CAAC;iBAAM,CAAC;gBACN,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;gBAClC,GAAG,IAAI,GAAG,CAAC;YACb,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IAeH,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,GAAI,CAAC;QACnC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACpB,MAAM,SAAS,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,CAAC;QAE7E,EAAE,CAAC,QAAQ,GAAG,OAAO,CAAC;QACtB,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC,EAAE,CAAC;QACJ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;YACxC,MAAM,KAAK,GAAG,IAAI,QAAK,CAAC,OAAO,CAAC,CAAC;YACjC,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC;YAC5B,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,oBAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;YACxC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,oBAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;YACxC,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Space } from \"./\";\nimport { FlatAtom } from \"./iterators\";\n\n/**\n * Ensures uniform spacing between atoms in a beat.\n * This utility function adjusts the spacing between atoms to create a consistent,\n * evenly spaced visualization based on the least common multiple (LCM) of their \n * duration denominators.\n * \n * @param currOffset Current time offset at which to start\n * @param atoms Array of flat atoms to process\n * @param slotsPerBeat Number of slots per beat, defaults to 1\n */\nexport function ensureUniformSpaces(currOffset: TSU.Num.Fraction, atoms: FlatAtom[], slotsPerBeat = 1): void {\n let lcm = 1;\n let gcd = 0;\n atoms.forEach((a, index) => {\n a.duration = a.duration.factorized;\n const currDen = a.duration.den;\n if (currDen != 1) {\n lcm *= currDen;\n if (gcd == 0) {\n gcd = a.duration.den;\n } else {\n gcd = TSU.Num.gcdof(gcd, currDen);\n lcm /= gcd;\n }\n }\n });\n\n // Easiest option is (without worrying about depths)\n // just adding this N number 1 / LCM sized spaces for\n // each note where N = (LCM / note.frac.den) - 1\n\n // eg in the case of something like (a beat with) the notes\n // A: 1/2, B: 1/4, C: 1/6\n // LCM (of dens) = 24\n // 12 (1/24) spaces, 6 (1/24)\n // A = (24 / 2) - 1 = 11 spaces after A\n // B = (24 / 4) - 1 = 5 spaces after B\n // C = (24 / 6) - 1 = 3 spaces after C\n // Total = 11 + 5 + 3 + 3 (for A + B + C) = 22 notes in the beat\n\n const baseDur = new TSU.Num.Fraction(1, lcm);\n for (let i = 0; i < atoms.length; ) {\n const fa = atoms[i];\n const numSpaces = lcm == 1 ? fa.duration.num - 1 : lcm / fa.duration.den - 1;\n // reset its duration to 1 / LCM so we can add numSpaces after it\n fa.duration = baseDur;\n currOffset = currOffset.plus(baseDur);\n i++;\n for (let j = 0; j < numSpaces; j++, i++) {\n const space = new Space(baseDur);\n space.isContinuation = true;\n atoms.splice(i, 0, new FlatAtom(space));\n atoms.splice(i, 0, new FlatAtom(space));\n currOffset = currOffset.plus(baseDur);\n }\n }\n}\n"]}
|
package/lib/cjs/beatview.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beatview.js","sourceRoot":"","sources":["../../src/beatview.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,qCAAgE;
|
|
1
|
+
{"version":3,"file":"beatview.js","sourceRoot":"","sources":["../../src/beatview.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,qCAAgE;AAUhE,MAAsB,QAAS,SAAQ,qBAAyB;IAkB9D,YACkB,IAAc,EACd,IAAU,EACV,WAA+B,EAC/B,KAAY,EAC5B,MAAY;QAEZ,KAAK,CACH,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE;YACzB,MAAM,EAAE,WAAW;YACnB,KAAK,EAAE;gBACL,KAAK,EAAE,iBAAiB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;gBACxC,MAAM,EAAE,EAAE,GAAG,IAAI,CAAC,IAAI;gBACtB,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,IAAI;gBAClB,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI;gBACxB,SAAS,EAAE,EAAE,GAAG,IAAI,CAAC,KAAK;gBAC1B,OAAO,EAAE,IAAI,CAAC,QAAQ;gBACtB,OAAO,EAAE,IAAI,CAAC,QAAQ;aACvB;SACF,CAAC,CACH,CAAC;QAnBc,SAAI,GAAJ,IAAI,CAAU;QACd,SAAI,GAAJ,IAAI,CAAM;QACV,gBAAW,GAAX,WAAW,CAAoB;QAC/B,UAAK,GAAL,KAAK,CAAO;QAd9B,gBAAW,GAAG,IAAI,CAAC;QA+BjB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QACtC,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC;IAChC,CAAC;IAKD,IAAI,aAAa;QACf,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;YACzB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACnD,CAAC;QACD,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAMD,SAAS,CAAC,MAAW;QACnB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;CAaF;AAxED,4BAwEC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { AtomView, Embelishment, ElementShape } from \"./shapes\";\nimport { GridCell, GridCellView } from \"./grids\";\nimport { Cycle } from \"./cycle\";\nimport { Beat } from \"./beats\";\n\n/**\n * Abstract base class for views that represent beats in the notation.\n * BeatView provides the visual representation of a beat and implements the GridCellView\n * interface to support placement in a grid.\n */\nexport abstract class BeatView extends ElementShape<SVGGElement> implements GridCellView {\n /** Embellishments applied to this beat view */\n private _embelishments: Embelishment[];\n \n /** View for the atom contained in this beat */\n atomView: AtomView;\n \n /** Whether this view needs layout */\n needsLayout = true;\n \n /**\n * Creates a new BeatView.\n * @param cell The grid cell this beat view belongs to\n * @param beat The beat this view represents\n * @param rootElement The root SVG element to attach to\n * @param cycle The cycle this beat belongs to\n * @param config Optional configuration object\n */\n constructor(\n public readonly cell: GridCell,\n public readonly beat: Beat,\n public readonly rootElement: SVGGraphicsElement,\n public readonly cycle: Cycle,\n config?: any,\n ) {\n super(\n TSU.DOM.createSVGNode(\"g\", {\n parent: rootElement,\n attrs: {\n class: `beatView role_${beat.role.name}`,\n beatId: \"\" + beat.uuid,\n id: \"\" + beat.uuid,\n roleName: beat.role.name,\n beatIndex: \"\" + beat.index,\n gridRow: cell.rowIndex,\n gridCol: cell.colIndex,\n },\n }),\n );\n this.atomView = this.createAtomView();\n this.atomView.refreshLayout();\n }\n\n /**\n * Gets the embellishments for this beat view.\n */\n get embelishments(): Embelishment[] {\n if (!this._embelishments) {\n this._embelishments = this.createEmbelishments();\n }\n return this._embelishments;\n }\n\n /**\n * Sets the styles for this beat view.\n * @param config Style configuration object\n */\n setStyles(config: any): void {\n this.needsLayout = true;\n }\n\n /**\n * Creates the embellishments for this beat view.\n * @returns An array of embellishments\n */\n protected abstract createEmbelishments(): Embelishment[];\n \n /**\n * Creates the atom view for this beat view.\n * @returns The created atom view\n */\n protected abstract createAtomView(): AtomView;\n}\n"]}
|
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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Y,GAAG,KAAK,CAAC;QAC9B,QAAQ,CAAC,iBAAiB,EAAE,CAAC;IAC/B,CAAC;CACF;AARD,4BAQC;AAED,MAAa,eAAgB,SAAQ,kBAAkB;IACrD,cAAc;QACZ,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YACxE,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC9B,CAAC;IAED,eAAe,CAAC,QAAkB;QAChC,QAAQ,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC;QACxC,QAAQ,CAAC,iBAAiB,EAAE,CAAC;IAC/B,CAAC;CACF;AAfD,0CAeC","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.currentLine.layoutParams;\n if (lpForLine == null) {\n notation.currentLine.layoutParams = 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,qDAAuC;AAEvC,mCAAqC;AACrC,yCAA2E;AAM3E,MAAa,YAAa,SAAQ,kBAAO;IAIvC,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAMD,eAAe,CAAC,QAAkB;QAChC,MAAM,GAAG,GAAG,IAAI,mBAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC3C,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;CACF;AAhBD,oCAgBC;AAKD,MAAa,QAAS,SAAQ,kBAAO;IAKnC,eAAe,CAAC,QAAkB;QAEhC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAKD,IAAI,IAAI;QACN,MAAM,GAAG,GAAG,IAAI,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3C,OAAO,GAAG,CAAC;IACb,CAAC;IAKD,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,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atom } from \"./core\";\nimport { parseCycle } from \"./utils\";\nimport { Command, RawBlock, Notation, MetaData as Meta } from \"./notation\";\n\n/**\n * Command for embedding raw content in the notation.\n * This allows including arbitrary raw text blocks (like markdown or HTML) within the notation.\n */\nexport class RawEmbedding extends Command {\n /**\n * Gets the raw content of this embedding.\n */\n get rawContents(): string {\n return this.getParamAt(0);\n }\n\n /**\n * Applies this command to a notation.\n * @param notation The notation to apply this command to\n */\n applyToNotation(notation: Notation): void {\n const raw = new RawBlock(this.rawContents);\n notation.addRawBlock(raw);\n }\n}\n\n/**\n * Command for adding metadata to the notation.\n */\nexport class MetaData extends Command {\n /**\n * Applies this command to a notation.\n * @param notation The notation to apply this command to\n */\n applyToNotation(notation: Notation): void {\n // Create the role - ensure that we have a role\n notation.addMetaData(this.meta);\n }\n\n /**\n * Gets the metadata object for this command.\n */\n get meta(): Meta {\n const out = new Meta(this.key, this.value);\n return out;\n }\n\n /**\n * Gets the key for this metadata.\n */\n get key(): string {\n return this.getParamAt(0);\n }\n\n /**\n * Gets the value for this metadata.\n */\n get value(): string {\n return this.getParamAt(1);\n }\n}\n\n/**\n * Command for activating (selecting) a specific role.\n */\nexport class ActivateRole extends Command {\n /**\n * Applies this command to a notation.\n * @param notation The notation to apply this command to\n */\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 /**\n * Gets the name of the role to activate.\n */\n get roleName(): string {\n return this.getParamAt(0);\n }\n}\n\n/**\n * Command for adding atoms to the current role.\n */\nexport class AddAtoms extends Command {\n /** Index of this command in the sequence */\n index: number;\n /** Atoms to add */\n atoms: Atom[];\n\n /**\n * Creates a new AddAtoms command.\n * @param atoms Atoms to add\n */\n constructor(...atoms: Atom[]) {\n super();\n this.atoms = atoms;\n this.index = 0;\n }\n\n /**\n * Returns a debug-friendly representation of this command.\n * @returns An object containing debug information\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 /**\n * Applies this command to a notation.\n * @param notation The notation to apply this command to\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.currentLine.layoutParams;\n if (lpForLine == null) {\n notation.currentLine.layoutParams = 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\n/**\n * Command for creating a new line in the notation.\n */\nexport class CreateLine extends Command {\n /**\n * Applies this command to a notation.\n * @param notation The notation to apply this command to\n */\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 /**\n * Gets the offset for the new line.\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 /**\n * Gets the margin text for the new line.\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\n/**\n * Command for creating a new role in the notation.\n */\nexport class CreateRole extends Command {\n /**\n * Applies this command to a notation.\n * @param notation The notation to apply this command to\n */\n applyToNotation(notation: Notation): void {\n // Create the role\n const name = this.getParamAt(0);\n notation.newRoleDef(name, this.notesOnly);\n }\n\n /**\n * Gets whether this role should contain only notes (true) or also syllables/text (false).\n */\n get notesOnly(): boolean {\n const notesOnly = this.getParam(\"notes\");\n return notesOnly == \"true\" || notesOnly == \"yes\" || notesOnly == true;\n }\n}\n\n/**\n * Base class for commands that modify layout parameters.\n */\nexport abstract class LayoutParamCommand extends Command {}\n\n/**\n * Command for applying a named layout to the notation.\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 the unique\n * combination of cycle, apb and line layout. This prevents 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 /**\n * Validates the parameters for this command.\n * @throws Error if parameters are invalid\n */\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 /**\n * Applies this command to a notation.\n * @param notation The notation to apply this command to\n */\n applyToNotation(notation: Notation): void {\n const value = this.params[0].value;\n notation.ensureNamedLayoutParams(value);\n }\n}\n\n/**\n * Command for setting line breaks in the layout.\n */\nexport class SetBreaks extends LayoutParamCommand {\n /**\n * Gets the line breaks pattern.\n */\n get pattern(): number[] {\n return this.params.map((cmd) => cmd.value as number);\n }\n\n /**\n * Validates the parameters for this command.\n * @throws Error if parameters are invalid\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 /**\n * Applies this command to a notation.\n * @param notation The notation to apply this command to\n */\n applyToNotation(notation: Notation): void {\n notation.currentBreaks = this.pattern;\n notation.resetLayoutParams();\n }\n}\n\n/**\n * Command for setting the cycle pattern in the layout.\n */\nexport class SetCycle extends LayoutParamCommand {\n /**\n * Applies this command to a notation.\n * @param notation The notation to apply this command to\n */\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\n/**\n * Command for setting the beat duration in the layout.\n */\nexport class SetBeatDuration extends LayoutParamCommand {\n /**\n * Validates the parameters for this command.\n * @throws Error if parameters are invalid\n */\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 /**\n * Gets the beat duration value.\n */\n get beatDuration(): number {\n return this.params[0].value;\n }\n\n /**\n * Applies this command to a notation.\n * @param notation The notation to apply this command to\n */\n applyToNotation(notation: Notation): void {\n notation.currentAPB = this.beatDuration;\n notation.resetLayoutParams();\n }\n}\n"]}
|
package/lib/cjs/core.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import * as TSU from "@panyam/tsutils";
|
|
|
2
2
|
import { Entity, TimedEntity } from "./entity";
|
|
3
3
|
import { LayoutParams } from "./layouts";
|
|
4
4
|
type Fraction = TSU.Num.Fraction;
|
|
5
|
+
export declare const ZERO: TSU.Num.Fraction;
|
|
6
|
+
export declare const ONE: TSU.Num.Fraction;
|
|
5
7
|
export declare enum AtomType {
|
|
6
8
|
NOTE = "Note",
|
|
7
9
|
LITERAL = "Literal",
|
package/lib/cjs/core.js
CHANGED
|
@@ -33,11 +33,11 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.Role = exports.Line = exports.Group = exports.Note = exports.Syllable = exports.Literal = exports.Space = exports.Rest = exports.Marker = exports.LeafAtom = exports.Atom = exports.AtomType = void 0;
|
|
36
|
+
exports.Role = exports.Line = exports.Group = exports.Note = exports.Syllable = exports.Literal = exports.Space = exports.Rest = exports.Marker = exports.LeafAtom = exports.Atom = exports.AtomType = exports.ONE = exports.ZERO = void 0;
|
|
37
37
|
const TSU = __importStar(require("@panyam/tsutils"));
|
|
38
38
|
const entity_1 = require("./entity");
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
exports.ZERO = TSU.Num.Fraction.ZERO;
|
|
40
|
+
exports.ONE = TSU.Num.Fraction.ONE;
|
|
41
41
|
var AtomType;
|
|
42
42
|
(function (AtomType) {
|
|
43
43
|
AtomType["NOTE"] = "Note";
|
|
@@ -50,14 +50,14 @@ var AtomType;
|
|
|
50
50
|
AtomType["MARKER"] = "Marker";
|
|
51
51
|
})(AtomType || (exports.AtomType = AtomType = {}));
|
|
52
52
|
class Atom extends entity_1.TimedEntity {
|
|
53
|
-
constructor(duration = ONE) {
|
|
53
|
+
constructor(duration = exports.ONE) {
|
|
54
54
|
super();
|
|
55
55
|
this.TYPE = "Atom";
|
|
56
56
|
this.nextSibling = null;
|
|
57
57
|
this.prevSibling = null;
|
|
58
58
|
this.parentGroup = null;
|
|
59
59
|
this.isContinuation = false;
|
|
60
|
-
this._duration = duration || ONE;
|
|
60
|
+
this._duration = duration || exports.ONE;
|
|
61
61
|
}
|
|
62
62
|
debugValue() {
|
|
63
63
|
const out = super.debugValue();
|
|
@@ -127,13 +127,13 @@ class Marker extends entity_1.Entity {
|
|
|
127
127
|
exports.Marker = Marker;
|
|
128
128
|
class Rest extends LeafAtom {
|
|
129
129
|
constructor() {
|
|
130
|
-
super(ZERO);
|
|
130
|
+
super(exports.ZERO);
|
|
131
131
|
this.TYPE = "Rest";
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
exports.Rest = Rest;
|
|
135
135
|
class Space extends LeafAtom {
|
|
136
|
-
constructor(duration = ONE, isSilent = false) {
|
|
136
|
+
constructor(duration = exports.ONE, isSilent = false) {
|
|
137
137
|
super(duration);
|
|
138
138
|
this.TYPE = "Space";
|
|
139
139
|
this.isSilent = false;
|
|
@@ -160,7 +160,7 @@ class Space extends LeafAtom {
|
|
|
160
160
|
}
|
|
161
161
|
exports.Space = Space;
|
|
162
162
|
class Literal extends LeafAtom {
|
|
163
|
-
constructor(value, duration = ONE) {
|
|
163
|
+
constructor(value, duration = exports.ONE) {
|
|
164
164
|
super(duration);
|
|
165
165
|
this.value = value;
|
|
166
166
|
this.TYPE = "Literal";
|
|
@@ -204,7 +204,7 @@ class Syllable extends Literal {
|
|
|
204
204
|
}
|
|
205
205
|
exports.Syllable = Syllable;
|
|
206
206
|
class Note extends Literal {
|
|
207
|
-
constructor(value, duration = ONE, octave = 0, shift = 0) {
|
|
207
|
+
constructor(value, duration = exports.ONE, octave = 0, shift = 0) {
|
|
208
208
|
super(value, duration);
|
|
209
209
|
this.TYPE = "Note";
|
|
210
210
|
this.octave = 0;
|
|
@@ -243,7 +243,7 @@ class Note extends Literal {
|
|
|
243
243
|
exports.Note = Note;
|
|
244
244
|
class Group extends Atom {
|
|
245
245
|
constructor(...atoms) {
|
|
246
|
-
super(atoms.length == 0 ? ZERO : ONE);
|
|
246
|
+
super(atoms.length == 0 ? exports.ZERO : exports.ONE);
|
|
247
247
|
this.TYPE = "Group";
|
|
248
248
|
this.durationIsMultiplier = false;
|
|
249
249
|
this.atoms = new TSU.Lists.ValueList();
|
|
@@ -283,7 +283,7 @@ class Group extends Atom {
|
|
|
283
283
|
return out;
|
|
284
284
|
}
|
|
285
285
|
splitAt(requiredDuration) {
|
|
286
|
-
if (this.duration.isLTE(requiredDuration) || requiredDuration.isLTE(ZERO)) {
|
|
286
|
+
if (this.duration.isLTE(requiredDuration) || requiredDuration.isLTE(exports.ZERO)) {
|
|
287
287
|
return null;
|
|
288
288
|
}
|
|
289
289
|
const targetGroup = new Group();
|
|
@@ -294,7 +294,7 @@ class Group extends Atom {
|
|
|
294
294
|
let remainingDur = this.duration;
|
|
295
295
|
const totalChildDuration = this.totalChildDuration;
|
|
296
296
|
const durationFactor = this.durationIsMultiplier
|
|
297
|
-
? ONE.divby(this._duration)
|
|
297
|
+
? exports.ONE.divby(this._duration)
|
|
298
298
|
: this._duration.divby(totalChildDuration, true);
|
|
299
299
|
while (remainingDur.isGT(requiredDuration) && this.atoms.last) {
|
|
300
300
|
const lastChild = this.atoms.last;
|
|
@@ -329,17 +329,17 @@ class Group extends Atom {
|
|
|
329
329
|
return targetGroup;
|
|
330
330
|
}
|
|
331
331
|
get totalChildDuration() {
|
|
332
|
-
let out = ZERO;
|
|
332
|
+
let out = exports.ZERO;
|
|
333
333
|
this.atoms.forEach((atom) => (out = out.plus(atom.duration)));
|
|
334
334
|
return out;
|
|
335
335
|
}
|
|
336
336
|
insertAtomsAt(beforeAtom, adjustDuration = false, ...atoms) {
|
|
337
337
|
adjustDuration = adjustDuration && !this.durationIsMultiplier;
|
|
338
|
-
const oldChildDuration = adjustDuration ? this.totalChildDuration : ONE;
|
|
338
|
+
const oldChildDuration = adjustDuration ? this.totalChildDuration : exports.ONE;
|
|
339
339
|
for (const atom of atoms) {
|
|
340
340
|
if (atom.parentGroup != null) {
|
|
341
341
|
if (atom.parentGroup != this) {
|
|
342
|
-
throw new Error("Atom belongs to another parent.
|
|
342
|
+
throw new Error("Atom belongs to another parent. Remove it first");
|
|
343
343
|
}
|
|
344
344
|
atom.parentGroup.removeAtoms(false, atom);
|
|
345
345
|
}
|
|
@@ -372,7 +372,7 @@ class Group extends Atom {
|
|
|
372
372
|
}
|
|
373
373
|
removeAtoms(adjustDuration = false, ...atoms) {
|
|
374
374
|
adjustDuration = adjustDuration && !this.durationIsMultiplier;
|
|
375
|
-
const oldChildDuration = adjustDuration ? this.totalChildDuration : ONE;
|
|
375
|
+
const oldChildDuration = adjustDuration ? this.totalChildDuration : exports.ONE;
|
|
376
376
|
for (const atom of atoms) {
|
|
377
377
|
if (atom.parentGroup == this) {
|
|
378
378
|
this.atoms.remove(atom);
|
|
@@ -401,7 +401,7 @@ class Line extends entity_1.Entity {
|
|
|
401
401
|
constructor() {
|
|
402
402
|
super(...arguments);
|
|
403
403
|
this.TYPE = "Line";
|
|
404
|
-
this.offset = ZERO;
|
|
404
|
+
this.offset = exports.ZERO;
|
|
405
405
|
this.roles = [];
|
|
406
406
|
this.marginText = "";
|
|
407
407
|
}
|
|
@@ -445,7 +445,7 @@ class Line extends entity_1.Entity {
|
|
|
445
445
|
return this.roles[ri];
|
|
446
446
|
}
|
|
447
447
|
get duration() {
|
|
448
|
-
let max = ZERO;
|
|
448
|
+
let max = exports.ZERO;
|
|
449
449
|
for (const role of this.roles) {
|
|
450
450
|
max = TSU.Num.Fraction.max(role.duration, max);
|
|
451
451
|
}
|
|
@@ -486,7 +486,7 @@ class Role extends entity_1.Entity {
|
|
|
486
486
|
another.addAtoms(...this.atoms);
|
|
487
487
|
}
|
|
488
488
|
get duration() {
|
|
489
|
-
return this.atoms.reduce((a, b) => a.plus(b.duration), ZERO);
|
|
489
|
+
return this.atoms.reduce((a, b) => a.plus(b.duration), exports.ZERO);
|
|
490
490
|
}
|
|
491
491
|
}
|
|
492
492
|
exports.Role = Role;
|
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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;QAC7B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,IAAI,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;gBAC/B,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,QAAQ,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;oBACtE,IAAiB,CAAC,UAAU,GAAG,IAAI,CAAC;gBACvC,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACxB,CAAC;YACD,IAAI,GAAG,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,MAAM,CAAC,OAAa;QAClB,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAKD,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC;IAC/D,CAAC;CACF;AA1CD,oBA0CC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Entity, TimedEntity } from \"./entity\";\nimport { LayoutParams } from \"./layouts\";\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 MARKER = \"Marker\",\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 readonly TYPE: string = \"Atom\";\n\n protected _duration: Fraction;\n markersBefore: Marker[];\n markersAfter: Marker[];\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 if ((this.markersBefore || []).length > 0) {\n out.mbef = this.markersBefore.map((m) => m.debugValue());\n }\n if ((this.markersAfter || []).length > 0) {\n out.maft = this.markersAfter.map((m) => m.debugValue());\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 readonly TYPE: string = \"LeafAtom\";\n\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 // TODO - Here we need to move the markersAfter to the spill-over as it doesnt belong to this any more\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 Marker extends Entity {\n readonly TYPE = \"Marker\";\n\n constructor(public text: string, public isBefore = true) {\n super();\n }\n\n debugValue(): any {\n return { ...super.debugValue(), text: this.text, before: this.isBefore };\n }\n\n toString(): string {\n return `Marker(${this.text}-${this.isBefore})`;\n }\n}\n\nexport class Rest extends LeafAtom {\n readonly TYPE = \"Rest\";\n\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 readonly TYPE = \"Space\";\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 readonly TYPE: string = \"Literal\";\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 readonly TYPE = \"Syllable\";\n\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 readonly TYPE = \"Note\";\n\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 readonly TYPE = \"Group\";\n\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 readonly TYPE: string = \"Line\";\n\n // Line can have atoms starting \"before\" the cycle. The offset tells how\n // many notes 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\n // found in notations - eg line X of a pallavi has this. This makes vertical\n // space less wasteful\n // A better solution is inter-beat annotation but it is very complex for now\n marginText = \"\";\n\n // The LayoutParams associated with this line.\n layoutParams: LayoutParams;\n\n indexOfRole(name: string): number {\n for (let i = 0; i < this.roles.length; i++) {\n if (this.roles[i].name == name) return i;\n }\n return -1;\n }\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 };\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 readonly TYPE = \"Role\";\n\n defaultToNotes = true;\n atoms: Atom[] = [];\n\n constructor(public readonly line: Line, public readonly name: string) {\n super();\n }\n\n get isEmpty(): boolean {\n return this.atoms.length == 0;\n }\n\n debugValue(): any {\n return { name: this.name, atoms: this.atoms.map((a) => a.debugValue()) };\n }\n\n addAtoms(...atoms: Atom[]): void {\n let last: null | Atom = null;\n for (const atom of atoms) {\n if (atom.TYPE == AtomType.REST) {\n if (last && last.TYPE != AtomType.GROUP && last.TYPE != AtomType.LABEL) {\n (last as LeafAtom).beforeRest = true;\n }\n } else {\n this.atoms.push(atom);\n }\n last = atom;\n }\n }\n\n copyTo(another: Role): void {\n another.addAtoms(...this.atoms);\n }\n\n /**\n * Duration for this role.\n */\n get duration(): Fraction {\n return this.atoms.reduce((a, b) => a.plus(b.duration), ZERO);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAA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AI,GAAgB,IAAI,CAAC;QAC7B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,IAAI,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;gBAC/B,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,QAAQ,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;oBACtE,IAAiB,CAAC,UAAU,GAAG,IAAI,CAAC;gBACvC,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACxB,CAAC;YACD,IAAI,GAAG,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAMD,MAAM,CAAC,OAAa;QAClB,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAKD,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,YAAI,CAAC,CAAC;IAC/D,CAAC;CACF;AArED,oBAqEC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Entity, TimedEntity } from \"./entity\";\nimport { LayoutParams } from \"./layouts\";\n\n/**\n * Alias to TSU.Num.Fraction in tsutils.\n */\ntype Fraction = TSU.Num.Fraction;\nexport const ZERO = TSU.Num.Fraction.ZERO;\nexport const ONE = TSU.Num.Fraction.ONE;\n\n/**\n * AtomType enums are used to denote specific Atoms\n * Each type represents a specific musical or notational element.\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 MARKER = \"Marker\",\n}\n\n/**\n * Atoms are the base class for all timed entities that can appear in a Notation.\n * An Atom represents the fundamental building block of the notation system.\n */\nexport abstract class Atom extends TimedEntity {\n readonly TYPE: string = \"Atom\";\n\n protected _duration: Fraction;\n /** Markers to be displayed before this atom */\n markersBefore: Marker[];\n /** Markers to be displayed after this atom */\n markersAfter: Marker[];\n /** Next atom in the sequence */\n nextSibling: TSU.Nullable<Atom> = null;\n /** Previous atom in the sequence */\n prevSibling: TSU.Nullable<Atom> = null;\n /** The Group this Atom belongs to, if any */\n parentGroup: TSU.Nullable<Group> = null;\n\n /** Indicates if this Atom is a continuation from a previous atom */\n isContinuation = false;\n\n /**\n * Creates a new Atom with the specified duration.\n * @param duration The duration of the atom, defaults to ONE (1/1)\n */\n constructor(duration = ONE) {\n super();\n this._duration = duration || ONE;\n }\n\n /**\n * Splits this atom at the specified duration.\n * @param requiredDuration The duration at which to split the atom\n * @returns A new atom representing the portion beyond the split point, or null if no split is needed\n */\n abstract splitAt(requiredDuration: Fraction): TSU.Nullable<Atom>;\n\n /**\n * Returns a debug-friendly representation of this Atom.\n * @returns An object containing debug information\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 if ((this.markersBefore || []).length > 0) {\n out.mbef = this.markersBefore.map((m) => m.debugValue());\n }\n if ((this.markersAfter || []).length > 0) {\n out.maft = this.markersAfter.map((m) => m.debugValue());\n }\n return out;\n }\n\n /**\n * Copies the properties of this atom to another atom.\n * @param another The target atom to copy properties to\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 /**\n * Gets the duration of this atom.\n */\n get duration(): Fraction {\n return this._duration;\n }\n\n /**\n * Sets the duration of this atom.\n */\n set duration(d: Fraction) {\n this._duration = d;\n }\n}\n\n/**\n * Base class for atoms that cannot contain other atoms.\n * LeafAtom represents atomic elements that can't be further subdivided.\n */\nexport abstract class LeafAtom extends Atom {\n readonly TYPE: string = \"LeafAtom\";\n\n /** Indicates if this atom is followed by a rest */\n beforeRest = false;\n\n /**\n * Splits this atom at a certain duration.\n * If this atom's duration is longer than the given duration, it's truncated\n * to the given duration and a continuation space is returned.\n * \n * @param duration The duration at which to split the atom\n * @returns A new Space atom representing the spillover if needed, otherwise null\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 // TODO - Here we need to move the markersAfter to the spill-over as it doesnt belong to this any more\n return spillOver;\n }\n return null;\n }\n\n /**\n * Creates a Space atom to represent spillover duration when splitting.\n * @param duration The duration of the spillover\n * @returns A new Space atom\n */\n protected createSpilloverSpace(duration: Fraction): Space {\n return new Space(duration);\n }\n\n /**\n * Returns a debug-friendly representation of this LeafAtom.\n * @returns An object containing debug information\n */\n debugValue(): any {\n return this.beforeRest ? { ...super.debugValue(), beforeRest: true } : super.debugValue();\n }\n}\n\n/**\n * Represents a marker or annotation in the notation.\n * Markers can be placed before or after atoms to provide additional context.\n */\nexport class Marker extends Entity {\n readonly TYPE = \"Marker\";\n\n /**\n * Creates a new Marker with the specified text.\n * @param text The text content of the marker\n * @param isBefore Whether the marker should appear before (true) or after (false) its associated atom\n */\n constructor(public text: string, public isBefore = true) {\n super();\n }\n\n /**\n * Returns a debug-friendly representation of this Marker.\n * @returns An object containing debug information\n */\n debugValue(): any {\n return { ...super.debugValue(), text: this.text, before: this.isBefore };\n }\n\n /**\n * Returns a string representation of this Marker.\n * @returns A string representation\n */\n toString(): string {\n return `Marker(${this.text}-${this.isBefore})`;\n }\n}\n\n/**\n * Represents a rest (silence) in the notation.\n * Rests are zero-length atoms that indicate a pause.\n */\nexport class Rest extends LeafAtom {\n readonly TYPE = \"Rest\";\n\n /**\n * Creates a new Rest.\n * Rests are zero length by default.\n */\n constructor() {\n super(ZERO);\n }\n}\n\n/**\n * Represents a space or silence in the notation.\n * Spaces can be used to denote either silence or continuations of previous notes.\n */\nexport class Space extends LeafAtom {\n readonly TYPE = \"Space\";\n \n /**\n * Indicates whether this is a silent space or a continuation of the previous note.\n */\n isSilent = false;\n\n /**\n * Creates a new Space with the specified duration and silence property.\n * @param duration The duration of the space, defaults to ONE (1/1)\n * @param isSilent Whether the space represents silence (true) or a continuation (false)\n */\n constructor(duration = ONE, isSilent = false) {\n super(duration);\n this.isSilent = isSilent;\n }\n\n /**\n * Returns a debug-friendly representation of this Space.\n * @returns An object containing debug information\n */\n debugValue(): any {\n return { ...super.debugValue(), isSilent: this.isSilent };\n }\n\n /**\n * Returns a string representation of this Space.\n * @returns A string representation\n */\n toString(): string {\n return `Space(${this.duration}-${this.isSilent})`;\n }\n\n /**\n * Copies the properties of this Space to another Space.\n * @param another The target Space to copy properties to\n */\n copyTo(another: this): void {\n super.copyTo(another);\n another.isSilent = this.isSilent;\n }\n\n /**\n * Checks if this Space is equal to another Space.\n * @param another The Space to compare with\n * @returns True if the Spaces are equal, false otherwise\n */\n equals(another: this): boolean {\n return super.equals(another) && this.isSilent == another.isSilent;\n }\n\n /**\n * Creates a Space atom to represent spillover duration when splitting.\n * @param duration The duration of the spillover\n * @returns A new Space atom with the same silence property as this Space\n */\n protected createSpilloverSpace(duration: Fraction): Space {\n const out = super.createSpilloverSpace(duration);\n out.isSilent = this.isSilent;\n return out;\n }\n}\n\n/**\n * Represents a literal value in the notation.\n * Literals are the basic building blocks for notes and syllables.\n */\nexport class Literal extends LeafAtom {\n readonly TYPE: string = \"Literal\";\n \n /**\n * The embellishments applied to this Literal.\n */\n embelishments: any[] = [];\n\n /**\n * Creates a new Literal with the specified value and duration.\n * @param value The string value of the literal\n * @param duration The duration of the literal, defaults to ONE (1/1)\n */\n constructor(public value: string, duration = ONE) {\n super(duration);\n }\n\n /**\n * Returns a debug-friendly representation of this Literal.\n * @returns An object containing debug information\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 /**\n * Returns a string representation of this Literal.\n * @returns A string representation\n */\n toString(): string {\n return `Lit(${this.duration}-${this.value})`;\n }\n\n /**\n * Checks if this Literal is equal to another Literal.\n * @param another The Literal to compare with\n * @returns True if the Literals are equal, false otherwise\n */\n equals(another: this): boolean {\n return super.equals(another) && this.value == another.value;\n }\n\n /**\n * Copies the properties of this Literal to another Literal.\n * @param another The target Literal to copy properties to\n */\n copyTo(another: this): void {\n super.copyTo(another);\n another.value = this.value;\n }\n}\n\n/**\n * Represents a syllable in lyrics or text to be sung.\n * Extends Literal to provide specialized handling for sung text.\n */\nexport class Syllable extends Literal {\n readonly TYPE = \"Syllable\";\n\n /**\n * Creates a Syllable from a Literal.\n * @param lit The Literal to convert to a Syllable\n * @returns A new Syllable with the properties of the Literal\n */\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 /**\n * Returns a string representation of this Syllable.\n * @returns A string representation\n */\n toString(): string {\n return `Syll(${this.duration}-${this.value})`;\n }\n}\n\n/**\n * Represents a musical note in the notation.\n * Extends Literal to add properties specific to musical notes.\n */\nexport class Note extends Literal {\n readonly TYPE = \"Note\";\n\n /**\n * Which octave the note is in. Can be positive or negative to indicate higher or lower octaves.\n */\n octave = 0;\n\n /**\n * How the note is shifted - i.e., shifted towards major or minor by # of semi-tones.\n */\n shift: number | boolean = 0;\n\n /**\n * Creates a new Note with the specified properties.\n * @param value The string value of the note\n * @param duration The duration of the note, defaults to ONE (1/1)\n * @param octave The octave of the note, defaults to 0\n * @param shift The shift of the note, defaults to 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 /**\n * Creates a Note from a Literal.\n * @param lit The Literal to convert to a Note\n * @returns A new Note with the properties of the Literal\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 /**\n * Returns a debug-friendly representation of this Note.\n * @returns An object containing debug information\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 /**\n * Returns a string representation of this Note.\n * @returns A string representation\n */\n toString(): string {\n return `Note(${this.duration}-${this.value}-${this.octave})`;\n }\n\n /**\n * Checks if this Note is equal to another Note.\n * @param another The Note to compare with\n * @returns True if the Notes are equal, false otherwise\n */\n equals(another: this): boolean {\n return super.equals(another) && this.octave == another.octave && this.shift == another.shift;\n }\n\n /**\n * Copies the properties of this Note to another Note.\n * @param another The target Note to copy properties to\n */\n copyTo(another: this): void {\n super.copyTo(another);\n another.octave = this.octave;\n another.shift = this.shift;\n }\n}\n\n/**\n * Represents a group of atoms that are treated as a single unit.\n * Groups can contain any number of atoms, including other groups.\n */\nexport class Group extends Atom {\n readonly TYPE = \"Group\";\n\n /**\n * Indicates whether the duration is static or linear to the number of atoms in this group.\n * When true, the duration is used as a multiplier for the total child duration.\n * When false, the duration is absolute.\n */\n durationIsMultiplier = false;\n \n /**\n * The list of atoms in this group.\n */\n readonly atoms = new TSU.Lists.ValueList<Atom>();\n\n /**\n * Creates a new Group containing the specified atoms.\n * @param atoms The atoms to include in this group\n */\n constructor(...atoms: Atom[]) {\n super(atoms.length == 0 ? ZERO : ONE);\n this.addAtoms(false, ...atoms);\n }\n\n /**\n * Checks if this Group is equal to another Group.\n * @param another The Group to compare with\n * @param expect Optional parameter\n * @returns True if the Groups are equal, false otherwise\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 /**\n * Copies the properties of this Group to another Group.\n * @param another The target Group to copy properties to\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 /**\n * Gets the duration of this group.\n * If durationIsMultiplier is true, returns the total child duration divided by the multiplier.\n * Otherwise, returns the absolute duration.\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 /**\n * Sets this group to use a multiplier for duration calculations.\n * @param asMultiplier Whether to use the duration as a multiplier\n * @returns This Group instance for method chaining\n */\n setDurationAsMultiplier(asMultiplier = true): this {\n this.durationIsMultiplier = asMultiplier;\n return this;\n }\n\n /**\n * Sets the duration of this group.\n * @param d The new duration\n * @param asMultiplier Whether to use the duration as a multiplier\n * @returns This Group instance for method chaining\n */\n setDuration(d: Fraction, asMultiplier = false): this {\n this._duration = d;\n this.durationIsMultiplier = asMultiplier;\n return this;\n }\n\n /**\n * Returns a debug-friendly representation of this Group.\n * @returns An object containing debug information\n */\n debugValue(): any {\n const out = { ...super.debugValue(), atoms: Array.from(this.atoms.values(), (a) => a.debugValue()) };\n if (this.durationIsMultiplier) out.durationIsMultiplier = true;\n return out;\n }\n\n /**\n * Splits this group into two parts.\n * The first part (this group) fits within the given duration and everything else\n * longer than the given duration is returned as a new Group.\n * \n * @param requiredDuration The duration at which to split the group\n * @returns A new Group containing the atoms beyond the split point, or null if no split is needed\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 /**\n * Gets the total duration of all child atoms.\n * @returns The sum of durations of all atoms in this group\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 atoms before a given cursor atom.\n * If the cursor atom is null, the atoms are appended at the end.\n * \n * @param beforeAtom The atom before which to insert the new atoms, or null to append\n * @param adjustDuration Whether to adjust this group's duration based on the new atoms\n * @param atoms The atoms to insert\n * @returns This Group instance for method chaining\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 this group's atom list.\n * \n * @param adjustDuration Whether to adjust this group's duration based on the new atoms\n * @param atoms The atoms to add\n * @returns This Group instance for method chaining\n */\n addAtoms(adjustDuration = false, ...atoms: Atom[]): this {\n return this.insertAtomsAt(null, adjustDuration, ...atoms);\n }\n\n /**\n * Removes atoms from this group's child list.\n * \n * @param adjustDuration Whether to adjust this group's duration after removing atoms\n * @param atoms The atoms to remove\n * @returns This Group instance for method chaining\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\n/**\n * Represents a line of notation containing multiple roles.\n * A line can have atoms starting before or after the cycle.\n */\nexport class Line extends Entity {\n readonly TYPE: string = \"Line\";\n\n /**\n * Offset tells how many notes before or after the cycle this line's atoms start at.\n */\n offset: Fraction = ZERO;\n \n /**\n * The roles contained in this line.\n */\n roles: Role[] = [];\n\n /**\n * Text to be displayed in the margin of the line.\n * This is a hacky solution to doing left side pre-margin text typically\n * found in notations - e.g., line X of a pallavi has this. This makes vertical\n * space less wasteful.\n *\n * A better solution is inter-beat annotation but it is very complex for now.\n */\n marginText = \"\";\n\n /**\n * The LayoutParams associated with this line.\n */\n layoutParams: LayoutParams;\n\n /**\n * Finds the index of a role with the given name.\n * @param name The name of the role to find\n * @returns The index of the role, or -1 if not found\n */\n indexOfRole(name: string): number {\n for (let i = 0; i < this.roles.length; i++) {\n if (this.roles[i].name == name) return i;\n }\n return -1;\n }\n\n /**\n * Checks if this line is empty (has no content in any role).\n */\n get isEmpty(): boolean {\n for (const r of this.roles) if (!r.isEmpty) return false;\n return true;\n }\n\n /**\n * Returns a debug-friendly representation of this Line.\n * @returns An object containing debug information\n */\n debugValue(): any {\n const out = {\n ...super.debugValue(),\n roles: this.roles.map((r) => r.debugValue()),\n };\n if (!this.offset.isZero) {\n out.offset = this.offset.toString();\n }\n return out;\n }\n\n /**\n * Copies the properties of this Line to another Line.\n * @param another The target Line to copy properties to\n */\n copyTo(another: this): void {\n super.copyTo(another);\n another.roles = this.roles.map((r) => r.clone());\n }\n\n /**\n * Adds atoms to a role in this line.\n * @param roleName The name of the role to add atoms to\n * @param defaultToNotes Whether to default to notes for this role\n * @param atoms The atoms to add\n * @returns This Line instance for method chaining\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 /**\n * Ensures a role with the given name exists in this line, creating it if needed.\n * @param roleName The name of the role to ensure\n * @param defaultToNotes Whether to default to notes for this role\n * @returns The role with the specified name\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 * Gets the maximum duration across 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\n/**\n * Represents a specific role or voice in a line of notation.\n * Each role contains a sequence of atoms.\n */\nexport class Role extends Entity {\n readonly TYPE = \"Role\";\n\n /**\n * Whether this role represents notes by default.\n */\n defaultToNotes = true;\n \n /**\n * The atoms in this role.\n */\n atoms: Atom[] = [];\n\n /**\n * Creates a new Role with the specified line and name.\n * @param line The line this role belongs to\n * @param name The name of the role\n */\n constructor(public readonly line: Line, public readonly name: string) {\n super();\n }\n\n /**\n * Checks if this role is empty (has no atoms).\n */\n get isEmpty(): boolean {\n return this.atoms.length == 0;\n }\n\n /**\n * Returns a debug-friendly representation of this Role.\n * @returns An object containing debug information\n */\n debugValue(): any {\n return { name: this.name, atoms: this.atoms.map((a) => a.debugValue()) };\n }\n\n /**\n * Adds atoms to this role.\n * @param atoms The atoms to add\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 /**\n * Copies the properties of this Role to another Role.\n * @param another The target Role to copy properties to\n */\n copyTo(another: Role): void {\n another.addAtoms(...this.atoms);\n }\n\n /**\n * Gets the total duration of all atoms in this role.\n */\n get duration(): Fraction {\n return this.atoms.reduce((a, b) => a.plus(b.duration), ZERO);\n }\n}\n"]}
|