@libraz/libcantus 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +63 -0
- package/README.md +7 -1
- package/README_ja.md +17 -11
- package/dist/analyze/index.cjs +31 -7
- package/dist/analyze/index.cjs.map +1 -1
- package/dist/analyze/index.d.cts +161 -13
- package/dist/analyze/index.d.ts +161 -13
- package/dist/analyze/index.js +37 -13
- package/dist/{chunk-NB25P3EH.js → chunk-2G5MCGYU.js} +33 -11
- package/dist/chunk-2G5MCGYU.js.map +1 -0
- package/dist/{chunk-NM7UAMC3.cjs → chunk-3FDBMIPR.cjs} +64 -64
- package/dist/chunk-3FDBMIPR.cjs.map +1 -0
- package/dist/{chunk-HPVSH7SF.cjs → chunk-3MDOEFIQ.cjs} +618 -954
- package/dist/chunk-3MDOEFIQ.cjs.map +1 -0
- package/dist/{chunk-FBH75DAY.js → chunk-5MWRBYAT.js} +560 -159
- package/dist/chunk-5MWRBYAT.js.map +1 -0
- package/dist/{chunk-J7FHVZII.cjs → chunk-6TTBEON3.cjs} +3074 -740
- package/dist/chunk-6TTBEON3.cjs.map +1 -0
- package/dist/{chunk-UMWZ4ZET.js → chunk-7NQ6AL3H.js} +4 -4
- package/dist/chunk-7NQ6AL3H.js.map +1 -0
- package/dist/{chunk-HWHGOVO6.cjs → chunk-E3QO3UET.cjs} +31 -23
- package/dist/chunk-E3QO3UET.cjs.map +1 -0
- package/dist/{chunk-H2KJHBW4.js → chunk-FJFULJZE.js} +2375 -191
- package/dist/chunk-FJFULJZE.js.map +1 -0
- package/dist/{chunk-Q6LFSAKV.js → chunk-FK3DGAIZ.js} +2657 -323
- package/dist/chunk-FK3DGAIZ.js.map +1 -0
- package/dist/chunk-GEDTJHAC.cjs.map +1 -1
- package/dist/{chunk-RFIBF2RR.js → chunk-H7FVMBUC.js} +138 -65
- package/dist/chunk-H7FVMBUC.js.map +1 -0
- package/dist/{chunk-DSMJRXCZ.cjs → chunk-HYSVSFNI.cjs} +931 -530
- package/dist/chunk-HYSVSFNI.cjs.map +1 -0
- package/dist/{chunk-35NBV2FT.cjs → chunk-KMYGRFZ6.cjs} +47 -24
- package/dist/chunk-KMYGRFZ6.cjs.map +1 -0
- package/dist/chunk-LQZQDBCD.cjs +5513 -0
- package/dist/chunk-LQZQDBCD.cjs.map +1 -0
- package/dist/{chunk-PM4XJE2Y.cjs → chunk-P3CPXAJ5.cjs} +76 -54
- package/dist/chunk-P3CPXAJ5.cjs.map +1 -0
- package/dist/{chunk-S5BKZZGM.cjs → chunk-S3QELJUE.cjs} +72 -56
- package/dist/chunk-S3QELJUE.cjs.map +1 -0
- package/dist/{chunk-PUKJP2Z5.js → chunk-TXFWSU5D.js} +31 -8
- package/dist/chunk-TXFWSU5D.js.map +1 -0
- package/dist/{chunk-76ZBTRG2.cjs → chunk-U4EQTDGN.cjs} +258 -218
- package/dist/chunk-U4EQTDGN.cjs.map +1 -0
- package/dist/chunk-UGLFDG7L.cjs.map +1 -1
- package/dist/{chunk-HYJJ2V2I.js → chunk-UTE5A36R.js} +483 -819
- package/dist/chunk-UTE5A36R.js.map +1 -0
- package/dist/{chunk-NFJ4P6ZZ.js → chunk-UZKQISRF.js} +17 -9
- package/dist/chunk-UZKQISRF.js.map +1 -0
- package/dist/{chunk-7KG3RTYS.js → chunk-VL5NXVCN.js} +281 -155
- package/dist/chunk-VL5NXVCN.js.map +1 -0
- package/dist/{chunk-CGBADIO5.cjs → chunk-WOMCXN2W.cjs} +328 -202
- package/dist/chunk-WOMCXN2W.cjs.map +1 -0
- package/dist/{chunk-3R3QVKY5.cjs → chunk-YDGMWH43.cjs} +397 -324
- package/dist/chunk-YDGMWH43.cjs.map +1 -0
- package/dist/{chunk-AGOVW7U6.js → chunk-YYVXRV3V.js} +72 -56
- package/dist/chunk-YYVXRV3V.js.map +1 -0
- package/dist/{chunk-M5RYMAFI.js → chunk-ZLNSH4UL.js} +71 -31
- package/dist/chunk-ZLNSH4UL.js.map +1 -0
- package/dist/{coerce-DRERzdve.d.cts → coerce-CUhHc3Tu.d.ts} +16 -8
- package/dist/{coerce-DP0vYu-x.d.ts → coerce-Ytt2Eiq9.d.cts} +16 -8
- package/dist/core/index.cjs +5 -5
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +9 -8
- package/dist/core/index.d.ts +9 -8
- package/dist/core/index.js +4 -4
- package/dist/generate/index.cjs +20 -8
- package/dist/generate/index.cjs.map +1 -1
- package/dist/generate/index.d.cts +105 -17
- package/dist/generate/index.d.ts +105 -17
- package/dist/generate/index.js +19 -7
- package/dist/{index-CL4b4gUQ.d.ts → index-5VJgKz_Q.d.cts} +6 -2
- package/dist/{index-B9QLziDe.d.cts → index-BLuDesVG.d.ts} +20 -13
- package/dist/{index-BHIUyjhZ.d.ts → index-BV6APVa6.d.cts} +20 -13
- package/dist/{index-BMweUlm5.d.cts → index-Bf0Sv8a9.d.ts} +6 -2
- package/dist/{index-Dw2DP7vm.d.ts → index-BkT21EMv.d.cts} +3 -2
- package/dist/{index-BL5N2Oyz.d.cts → index-C7KCaTRz.d.ts} +3 -2
- package/dist/{index-Cy15oTvh.d.ts → index-C9MYbuKS.d.cts} +7 -3
- package/dist/{index-Cy15oTvh.d.cts → index-C9MYbuKS.d.ts} +7 -3
- package/dist/{index-BNSM-DSk.d.cts → index-DVInzCDS.d.cts} +533 -28
- package/dist/{index-9eoQs2C1.d.ts → index-Dg-SAfhz.d.ts} +6 -4
- package/dist/{index-BJgP97N1.d.ts → index-jgeug9EA.d.ts} +533 -28
- package/dist/{index-cHvbYgJI.d.cts → index-pQihL4z7.d.cts} +6 -4
- package/dist/index.cjs +49 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.js +55 -19
- package/dist/{masks-Cc7-MzzY.d.ts → masks-BnzXnBj0.d.cts} +3 -2
- package/dist/{masks-pADfTOiD.d.cts → masks-tycmkrgs.d.ts} +3 -2
- package/dist/model/index.cjs +12 -12
- package/dist/model/index.cjs.map +1 -1
- package/dist/model/index.d.cts +259 -48
- package/dist/model/index.d.ts +259 -48
- package/dist/model/index.js +11 -11
- package/dist/{positional-DJgs6ltD.d.ts → positional-CscpxtlE.d.cts} +3 -2
- package/dist/{positional-DMZer-FM.d.cts → positional-DLnfUgqG.d.ts} +3 -2
- package/dist/{index-BRMbPkHE.d.ts → profile-B4WqcM4H.d.ts} +85 -610
- package/dist/{index-DGCNKAUr.d.cts → profile-BJd1XkPB.d.cts} +85 -610
- package/dist/theory/index.cjs +5 -5
- package/dist/theory/index.cjs.map +1 -1
- package/dist/theory/index.d.cts +18 -14
- package/dist/theory/index.d.ts +18 -14
- package/dist/theory/index.js +4 -4
- package/dist/{index-CJBBiAmU.d.ts → types-7mGFwvMm.d.ts} +1210 -31
- package/dist/{index-BBWNZS0f.d.cts → types-_ofpb2be.d.cts} +1210 -31
- package/package.json +13 -13
- package/dist/chunk-35NBV2FT.cjs.map +0 -1
- package/dist/chunk-3R3QVKY5.cjs.map +0 -1
- package/dist/chunk-76ZBTRG2.cjs.map +0 -1
- package/dist/chunk-7KG3RTYS.js.map +0 -1
- package/dist/chunk-AGOVW7U6.js.map +0 -1
- package/dist/chunk-CGBADIO5.cjs.map +0 -1
- package/dist/chunk-DSMJRXCZ.cjs.map +0 -1
- package/dist/chunk-FBH75DAY.js.map +0 -1
- package/dist/chunk-H2KJHBW4.js.map +0 -1
- package/dist/chunk-HPVSH7SF.cjs.map +0 -1
- package/dist/chunk-HWHGOVO6.cjs.map +0 -1
- package/dist/chunk-HYJJ2V2I.js.map +0 -1
- package/dist/chunk-J7FHVZII.cjs.map +0 -1
- package/dist/chunk-M5RYMAFI.js.map +0 -1
- package/dist/chunk-NB25P3EH.js.map +0 -1
- package/dist/chunk-NFJ4P6ZZ.js.map +0 -1
- package/dist/chunk-NM7UAMC3.cjs.map +0 -1
- package/dist/chunk-PM4XJE2Y.cjs.map +0 -1
- package/dist/chunk-PUKJP2Z5.js.map +0 -1
- package/dist/chunk-Q6LFSAKV.js.map +0 -1
- package/dist/chunk-RFIBF2RR.js.map +0 -1
- package/dist/chunk-S5BKZZGM.cjs.map +0 -1
- package/dist/chunk-SGLEQVJH.cjs +0 -3329
- package/dist/chunk-SGLEQVJH.cjs.map +0 -1
- package/dist/chunk-UMWZ4ZET.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/duration/index.ts","../src/core/tempo/internal.ts","../src/core/tempo/index.ts","../src/core/tuning/index.ts"],"sourcesContent":["/**\n * Note values: the written durations a score shows — a base value, its\n * augmentation dots, and an optional tuplet ratio — and the conversion between\n * them and the quarter-note beats the rest of the library measures in.\n *\n * The base values are named the American way (whole, half, quarter, eighth),\n * matching the library's \"quarter-note beat\" convention and the vocabulary of\n * the MIDI and DAW world this engine reads events from.\n */\n\nimport { InvalidInputError, NoSolutionError } from '../errors/index.js';\nimport {\n assertFiniteNumber,\n assertGenerationBudget,\n assertInteger,\n assertOneOf,\n assertOptions,\n assertPositiveInt,\n describeRejected,\n} from '../validation/index.js';\n\n/**\n * A written base note value, from the whole note down to the sixty-fourth.\n *\n * Longer values (the breve and beyond) are written as tied notes; see\n * {@link beatsToTiedDurations}.\n *\n * @category Rhythm & Meter\n */\nexport type NoteValue =\n | 'whole'\n | 'half'\n | 'quarter'\n | 'eighth'\n | 'sixteenth'\n | 'thirtySecond'\n | 'sixtyFourth';\n\n/**\n * Every base note value, longest first.\n *\n * @category Rhythm & Meter\n */\nexport const NOTE_VALUES: readonly NoteValue[] = Object.freeze([\n 'whole',\n 'half',\n 'quarter',\n 'eighth',\n 'sixteenth',\n 'thirtySecond',\n 'sixtyFourth',\n] as const);\n\n/**\n * A tuplet ratio: `actual` written notes played in the time of `normal` ones —\n * `{ actual: 3, normal: 2 }` for a triplet, `{ actual: 5, normal: 4 }` for a\n * quintuplet.\n *\n * @category Rhythm & Meter\n */\nexport type Tuplet = {\n /** How many notes are written. */\n actual: number;\n /** How many of the same base value they occupy. */\n normal: number;\n};\n\n/**\n * A written duration: a base value, optional augmentation dots, and an optional\n * tuplet ratio. Its length is `base * (2 - 2^-dots) * normal / actual`.\n *\n * @category Rhythm & Meter\n */\nexport type DurationData = {\n base: NoteValue;\n /** Augmentation dots, 0 when absent; up to four are accepted. */\n dots?: number;\n tuplet?: Tuplet;\n};\n\n/**\n * A duration as {@link beatsToDuration} spells it, with the dot count always\n * stated.\n *\n * @category Rhythm & Meter\n */\nexport type SpelledDuration = {\n base: NoteValue;\n dots: number;\n tuplet?: Tuplet;\n};\n\n/** Length of each base value in quarter notes. */\nconst NOTE_VALUE_QUARTERS: Readonly<Record<NoteValue, number>> = Object.freeze({\n whole: 4,\n half: 2,\n quarter: 1,\n eighth: 0.5,\n sixteenth: 0.25,\n thirtySecond: 0.125,\n sixtyFourth: 0.0625,\n});\n\n/**\n * Match tolerance in quarter-note beats. Wide enough to read a seven-digit\n * decimal such as 0.3333333 as a triplet, and still far below one tick at\n * PPQ 960 (≈ 0.00104 beats), so no two spellings a sequencer can distinguish\n * collapse into one.\n */\nconst EPS = 1e-6;\n\n/** Most dots {@link beatsToDuration} will spell; more is never the reading. */\nconst MAX_SPELLED_DOTS = 2;\n\n/** Most dots {@link durationToBeats} will read; triple dots occur, four is the ceiling. */\nconst MAX_DOTS = 4;\n\n/** Upper bound on either side of a tuplet ratio. */\nconst MAX_TUPLET = 64;\n\n/**\n * The tuplet families {@link beatsToDuration} spells, in preference order, with\n * the plain (non-tuplet) reading first. Quintuplets and septuplets are taken in\n * the time of four, the reading that fills one beat of their base value.\n */\nconst SPELLED_TUPLETS: readonly (Tuplet | undefined)[] = Object.freeze([\n undefined,\n { actual: 3, normal: 2 },\n { actual: 5, normal: 4 },\n { actual: 7, normal: 4 },\n]);\n\n/** Length in quarter notes of a base value with dots and an optional tuplet. */\nfunction quartersOfParts(base: NoteValue, dots: number, tuplet: Tuplet | undefined): number {\n const dotted = NOTE_VALUE_QUARTERS[base] * (2 - 2 ** -dots);\n return tuplet === undefined ? dotted : (dotted * tuplet.normal) / tuplet.actual;\n}\n\n/** Validate a duration, accepting the bare base value as shorthand. */\nfunction assertDuration(value: NoteValue | DurationData, name: string): DurationData {\n if (typeof value === 'string') {\n return { base: assertOneOf(value, NOTE_VALUES, name), dots: 0 };\n }\n if (typeof value !== 'object' || value === null) {\n throw new InvalidInputError(\n `${name} must be a note value or a duration; received ${describeRejected(value)}`,\n );\n }\n const base = assertOneOf(value.base, NOTE_VALUES, `${name}.base`);\n const dots =\n value.dots === undefined ? 0 : assertInteger(value.dots, `${name}.dots`, 0, MAX_DOTS);\n if (value.tuplet === undefined) {\n return { base, dots };\n }\n // A duration restored from a file can carry a null where the tuplet is, and\n // reading a field off it would report the library's own TypeError rather than\n // the malformed input it is.\n if (typeof value.tuplet !== 'object' || value.tuplet === null) {\n throw new InvalidInputError(\n `${name}.tuplet must be a tuplet; received ${describeRejected(value.tuplet)}`,\n );\n }\n const tuplet = {\n actual: assertPositiveInt(value.tuplet.actual, `${name}.tuplet.actual`, MAX_TUPLET),\n normal: assertPositiveInt(value.tuplet.normal, `${name}.tuplet.normal`, MAX_TUPLET),\n };\n return { base, dots, tuplet };\n}\n\n/** Length of a validated duration in quarter notes. */\nfunction quartersOf(duration: DurationData): number {\n return quartersOfParts(duration.base, duration.dots ?? 0, duration.tuplet);\n}\n\n/** Length of the beat unit in quarter notes; a quarter note unless overridden. */\nfunction beatQuarters(options: { beatUnit?: NoteValue | DurationData }): number {\n if (options.beatUnit === undefined) {\n return NOTE_VALUE_QUARTERS.quarter;\n }\n return quartersOf(assertDuration(options.beatUnit, 'beatUnit'));\n}\n\n/** The conventional spelling of a length in quarter notes, if it has one. */\nfunction spellQuarters(quarters: number): SpelledDuration | undefined {\n for (const tuplet of SPELLED_TUPLETS) {\n for (let dots = 0; dots <= MAX_SPELLED_DOTS; dots += 1) {\n for (const base of NOTE_VALUES) {\n if (Math.abs(quartersOfParts(base, dots, tuplet) - quarters) <= EPS) {\n return tuplet === undefined\n ? { base, dots }\n : { base, dots, tuplet: { actual: tuplet.actual, normal: tuplet.normal } };\n }\n }\n }\n }\n return undefined;\n}\n\n/** The undotted values a tie chain is built from, longest first. */\nconst PLAIN_VALUES: readonly { base: NoteValue; quarters: number }[] = Object.freeze(\n NOTE_VALUES.map((base) => ({ base, quarters: NOTE_VALUE_QUARTERS[base] })),\n);\n\n/** Require a positive, finite beat count. */\nfunction assertPositiveBeats(beats: number, name: string): number {\n assertFiniteNumber(beats, name);\n if (beats <= 0) {\n throw new InvalidInputError(`${name} must be positive; received ${beats}`);\n }\n return beats;\n}\n\n/**\n * Length of a written duration in beats.\n *\n * @param duration The duration, or a bare base value as shorthand for an\n * undotted one.\n * @param options `beatUnit` sets what one beat is; a quarter note by default,\n * so a dotted quarter reads as 1.5. Pass `{ base: 'quarter', dots: 1 }` to\n * count in the felt beats of a compound meter.\n * @returns The length in beats.\n * @throws If the base value is unknown, the dot count is not an integer in\n * 0..4, or a tuplet side is not a positive integer.\n * @example\n * ```ts\n * import { durationToBeats } from '@libraz/libcantus';\n * durationToBeats('quarter'); // 1\n * durationToBeats({ base: 'quarter', dots: 1 }); // 1.5\n * durationToBeats({ base: 'eighth', tuplet: { actual: 3, normal: 2 } }) * 3; // 1 — three\n * // eighth-note triplets fill the beat two eighths would\n * ```\n * @category Rhythm & Meter\n */\nexport function durationToBeats(\n duration: NoteValue | DurationData,\n options: { beatUnit?: NoteValue | DurationData } = {},\n): number {\n const quarters = quartersOf(assertDuration(duration, 'duration'));\n return quarters / beatQuarters(assertOptions(options, 'options'));\n}\n\n/**\n * Spell a length in beats as the note value a score would show.\n *\n * The spelling is the conventional one, not merely an arithmetically valid one:\n * 1.5 beats is a dotted quarter rather than a quarter tied to an eighth, and a\n * third of a beat is an eighth triplet rather than a twenty-fourth note. Plain\n * values are preferred to dotted ones and both to tuplets, and within the\n * tuplets triplets come before quintuplets and septuplets.\n *\n * Lengths are matched within 1e-6 quarter notes, so a rounded decimal such as\n * 0.3333333 still reads as a triplet. The tolerance is measured in quarter\n * notes whatever `beatUnit` names, so a longer beat unit narrows it in\n * proportion: under `{ beatUnit: 'whole' }` it is 2.5e-7 of a beat.\n *\n * @param beats The length in beats.\n * @param options `beatUnit` sets what one beat is; a quarter note by default.\n * @returns The base value, its dot count, and its tuplet when it has one.\n * @throws If `beats` is not positive, or — as a `NoSolutionError` — if no single\n * note value spells it, as for 5 beats in 4/4. Use\n * {@link beatsToTiedDurations} for those.\n * @example\n * ```ts\n * import { beatsToDuration } from '@libraz/libcantus';\n * beatsToDuration(1.5); // { base: 'quarter', dots: 1 }\n * beatsToDuration(1 / 3); // { base: 'eighth', dots: 0, tuplet: { actual: 3, normal: 2 } }\n * ```\n * @category Rhythm & Meter\n */\nexport function beatsToDuration(\n beats: number,\n options: { beatUnit?: NoteValue | DurationData } = {},\n): SpelledDuration {\n assertPositiveBeats(beats, 'beats');\n const spelled = spellQuarters(beats * beatQuarters(assertOptions(options, 'options')));\n if (spelled === undefined) {\n throw new NoSolutionError(`no single note value spells ${beats} beats`);\n }\n return spelled;\n}\n\n/**\n * Spell a length in beats as a chain of tied note values.\n *\n * A length with a single spelling comes back as a one-element chain. Anything\n * else is broken into undotted values, longest first, and a value immediately\n * followed by its own half is then written as a dot instead: 5 beats reads as a\n * whole note tied to a quarter, and 1.9375 beats as a double-dotted quarter tied\n * to a dotted thirty-second. The dot is only written where it leaves the chain\n * in longest-first order, so 10 beats reads as two whole notes tied to a half\n * rather than as a whole note tied to a longer dotted whole. The chain knows\n * nothing of barlines or beat grouping — an engraver splits further at those —\n * and it uses no tuplets, so a length off the plain grid and with no single\n * spelling has no chain either.\n *\n * @param beats The length in beats.\n * @param options `beatUnit` sets what one beat is; a quarter note by default.\n * @returns The tied durations, longest first, summing to `beats`.\n * @throws If `beats` is not positive, if the chain would exceed the generation\n * budget, or — as a `NoSolutionError` — if no chain of plain and dotted values\n * sums to it.\n * @example\n * ```ts\n * import { beatsToTiedDurations } from '@libraz/libcantus';\n * beatsToTiedDurations(5); // [{ base: 'whole', dots: 0 }, { base: 'quarter', dots: 0 }]\n * ```\n * @category Rhythm & Meter\n */\nexport function beatsToTiedDurations(\n beats: number,\n options: { beatUnit?: NoteValue | DurationData } = {},\n): SpelledDuration[] {\n assertPositiveBeats(beats, 'beats');\n const quarters = beats * beatQuarters(assertOptions(options, 'options'));\n const single = spellQuarters(quarters);\n if (single !== undefined) {\n return [single];\n }\n assertGenerationBudget(\n Math.ceil(quarters / NOTE_VALUE_QUARTERS.whole) + PLAIN_VALUES.length,\n 'tie chain length',\n );\n const chain: SpelledDuration[] = [];\n let remaining = quarters;\n let previousQuarters = 0;\n while (remaining > EPS) {\n const next = PLAIN_VALUES.find((candidate) => candidate.quarters <= remaining + EPS);\n if (next === undefined) {\n throw new NoSolutionError(`no chain of tied note values sums to ${beats} beats`);\n }\n const last = chain[chain.length - 1];\n const before = chain[chain.length - 2];\n // A value followed by exactly its own half is one dotted note, not a tie —\n // but the dot lengthens a value already written, so it is only taken where\n // the result still fits under the value it is tied after. Dotting the\n // second whole note of 10 beats would make it outlast the first.\n const dotted =\n last === undefined || last.dots >= MAX_SPELLED_DOTS\n ? undefined\n : quartersOfParts(last.base, last.dots + 1, undefined);\n const staysInOrder =\n dotted !== undefined && (before === undefined || dotted <= quartersOf(before) + EPS);\n if (\n last !== undefined &&\n staysInOrder &&\n Math.abs(next.quarters * 2 - previousQuarters) <= EPS\n ) {\n last.dots += 1;\n } else {\n chain.push({ base: next.base, dots: 0 });\n }\n previousQuarters = next.quarters;\n remaining -= next.quarters;\n }\n return chain;\n}\n","/**\n * The index a tempo map is read through, and the mark that says it is valid.\n *\n * A map is handed to a conversion once per note, so a pass over a piece asks\n * the same array the same questions tens of thousands of times: is it valid,\n * and which segment holds this beat. Answered from the array each time, both\n * cost the whole map per note — an imported accelerando marks a tempo every\n * tick, and the two counts multiply. They are answered from a snapshot instead,\n * which is the shape the meter map already reads through.\n */\n\nimport type { TempoMap } from './index.js';\n\n/** One tempo map as it read when the index was built. */\nexport type TempoIndex = {\n /** Onsets in map order. */\n startBeats: number[];\n /** Tempo of each entry. */\n bpms: number[];\n /**\n * Seconds elapsed from the map's origin to each entry's own onset — the\n * prefix sum of the segments before it, summed in map order.\n *\n * The same additions the origin-to-beat integral makes, made once for the\n * map rather than once per note: asking when the last note of an imported\n * accelerando sounds otherwise re-adds every tempo change in the piece.\n */\n secondsBefore: number[];\n /** Whether the map had passed validation when the index was built. */\n validated: boolean;\n};\n\nconst SECONDS_PER_MINUTE = 60;\n\n/**\n * Indexes held against the identity of the map they describe.\n *\n * A caller keeps its own array and may write to it after the library has read\n * it, so an index is only trusted while every entry still reads as it did when\n * the index was built. Anything else rebuilds, and a map that had passed\n * validation is validated again.\n */\nconst INDEX_CACHE = new WeakMap<TempoMap, TempoIndex>();\n\n/** Whether the index still describes the map it was built from. */\nfunction describesMap(index: TempoIndex, map: TempoMap): boolean {\n if (index.startBeats.length !== map.length) {\n return false;\n }\n for (let i = 0; i < map.length; i += 1) {\n const event = map[i];\n if (\n event === undefined ||\n event === null ||\n event.startBeat !== index.startBeats[i] ||\n event.bpm !== index.bpms[i]\n ) {\n return false;\n }\n }\n return true;\n}\n\n/** Build and cache the index of a map, recording whether it is validated. */\nfunction buildTempoIndex(map: TempoMap, validated: boolean): TempoIndex {\n const startBeats: number[] = [];\n const bpms: number[] = [];\n const secondsBefore: number[] = [];\n let elapsed = 0;\n for (let i = 0; i < map.length; i += 1) {\n const event = map[i];\n if (event === undefined) {\n continue;\n }\n const previousBeat = startBeats[i - 1];\n const previousBpm = bpms[i - 1];\n if (previousBeat !== undefined && previousBpm !== undefined) {\n elapsed += ((event.startBeat - previousBeat) * SECONDS_PER_MINUTE) / previousBpm;\n }\n startBeats.push(event.startBeat);\n bpms.push(event.bpm);\n secondsBefore.push(elapsed);\n }\n const index: TempoIndex = { startBeats, bpms, secondsBefore, validated };\n INDEX_CACHE.set(map, index);\n return index;\n}\n\n/** The index of `map`, rebuilt when the caller has written to the array since. */\nexport function tempoIndexOf(map: TempoMap): TempoIndex {\n const cached = INDEX_CACHE.get(map);\n return cached !== undefined && describesMap(cached, map) ? cached : buildTempoIndex(map, false);\n}\n\n/**\n * Whether the map has already passed validation and is unchanged since.\n *\n * What this still pays on every call is a comparison per entry: an array the\n * caller keeps says nothing about whether it has been written to since, so the\n * only way to know a validated map is still the one that was validated is to\n * read it. What it saves is the validation itself — the range checks, the\n * ordering, and the error messages built to describe them.\n */\nexport function isValidatedTempoMap(map: TempoMap): boolean {\n const cached = INDEX_CACHE.get(map);\n return cached?.validated === true && describesMap(cached, map);\n}\n\n/** Record that a map passed validation, and snapshot it. */\nexport function rememberValidatedTempoMap(map: TempoMap): void {\n buildTempoIndex(map, true);\n}\n\n/**\n * Index of the segment in force at `beat`, by binary search.\n *\n * The opening tempo reaches back before the beat it is marked on, so a beat\n * before the first entry answers with entry 0: a pickup is played at the tempo\n * of the piece it leads into, and the map names no other one to play it at.\n *\n * @param map A validated tempo map.\n * @param beat The beat to place.\n * @returns The index of the entry whose tempo holds at `beat`.\n */\nexport function tempoSegmentAt(map: TempoMap, beat: number): number {\n return segmentBy(tempoIndexOf(map).startBeats, beat);\n}\n\n/**\n * Seconds from the map's origin to `beat`, read off the prefix sums.\n *\n * The same additions the segment-by-segment integral makes, in the same order:\n * every whole segment before `beat` was summed into the index in map order, and\n * the part of the segment holding `beat` is added last. A beat before the origin\n * comes back negative, at the opening tempo.\n *\n * @param map A validated tempo map.\n * @param beat The beat to place in time.\n * @returns Elapsed seconds, 0 at the map's first event.\n */\nexport function elapsedSecondsAt(map: TempoMap, beat: number): number {\n return elapsedSecondsIn(tempoIndexOf(map), beat);\n}\n\n/** Seconds from the origin to `beat`, against an index already in hand. */\nexport function elapsedSecondsIn(index: TempoIndex, beat: number): number {\n const at = segmentBy(index.startBeats, beat);\n const start = index.startBeats[at] ?? 0;\n const bpm = index.bpms[at] ?? 1;\n return (index.secondsBefore[at] ?? 0) + ((beat - start) * SECONDS_PER_MINUTE) / bpm;\n}\n\n/**\n * Beat reached after `seconds` from the map's origin — the inverse of\n * {@link elapsedSecondsAt}, read off the same prefix sums.\n *\n * @param map A validated tempo map.\n * @param seconds Elapsed seconds; negative for a position before the origin.\n * @returns The position in quarter-note beats.\n */\nexport function beatAtElapsedSeconds(map: TempoMap, seconds: number): number {\n return beatAtElapsedIn(tempoIndexOf(map), seconds);\n}\n\n/** The beat reached after `seconds`, against an index already in hand. */\nexport function beatAtElapsedIn(index: TempoIndex, seconds: number): number {\n const at = segmentBy(index.secondsBefore, seconds);\n const start = index.startBeats[at] ?? 0;\n const bpm = index.bpms[at] ?? 1;\n return start + ((seconds - (index.secondsBefore[at] ?? 0)) * bpm) / SECONDS_PER_MINUTE;\n}\n\n/**\n * The last index of an ascending run whose value is at or below `value`, and 0\n * for a value below the run's first: the opening segment governs what precedes\n * it, so there is no index before it to answer with.\n */\nfunction segmentBy(ascending: readonly number[], value: number): number {\n let low = 0;\n let high = ascending.length - 1;\n while (low < high) {\n const mid = (low + high + 1) >> 1;\n const at = ascending[mid];\n if (at !== undefined && at <= value) {\n low = mid;\n } else {\n high = mid - 1;\n }\n }\n return Math.max(0, low);\n}\n","/**\n * Tempo and time conversion: beats to wall-clock seconds across tempo changes,\n * and beats to MIDI ticks.\n *\n * Positions are measured in quarter-note beats, matching the rest of the\n * library's beat convention. A {@link TempoMap} is piecewise constant: each\n * entry sets the tempo from its beat onwards, so the elapsed time over a span is\n * the sum of the segments it crosses rather than the tempo at either end.\n */\n\nimport { InvalidInputError } from '../errors/index.js';\nimport {\n assertFiniteNumber,\n assertGenerationBudget,\n assertInteger,\n assertPositiveInt,\n assertRange,\n describeRejected,\n} from '../validation/index.js';\nimport {\n beatAtElapsedIn,\n beatAtElapsedSeconds,\n elapsedSecondsAt,\n elapsedSecondsIn,\n isValidatedTempoMap,\n rememberValidatedTempoMap,\n tempoIndexOf,\n tempoSegmentAt,\n} from './internal.js';\n\n/**\n * A tempo change: the beat it takes effect on, and the tempo it sets.\n *\n * The tempo holds until the next entry, so a map of one entry is a constant\n * tempo for the whole timeline.\n *\n * @category Rhythm & Meter\n */\nexport type TempoEvent = {\n /** Onset in quarter-note beats, absolute from the start of the timeline. */\n readonly startBeat: number;\n /** Quarter-note beats per minute from `startBeat` onwards. */\n readonly bpm: number;\n};\n\n/**\n * A tempo track: {@link TempoEvent}s sorted by `startBeat`, strictly ascending.\n *\n * The first entry is the time origin — {@link beatsToSeconds} returns 0 for its\n * `startBeat` — and its tempo also governs the beats before it, which is where\n * a pickup sounds. A map cannot say anything else about that stretch, and a\n * piece is played into its first downbeat at the tempo it starts in, so elapsed\n * time there is negative rather than an error.\n *\n * @category Rhythm & Meter\n */\nexport type TempoMap = readonly TempoEvent[];\n\nconst SECONDS_PER_MINUTE = 60;\n\n/**\n * Upper bound on a tempo, matching the bound the generators accept. A faster\n * marking is a notation of a slower pulse, not a distinct tempo.\n */\nconst MAX_BPM = 1000;\n\n/**\n * Lower bound on a tempo. One beat lasts ten minutes here; anything slower is a\n * corrupt or mis-scaled value rather than a marking, and letting it through\n * would make the conversions overflow to infinity while still reporting a\n * validated tempo.\n */\nconst MIN_BPM = 0.1;\n\n/**\n * Upper bound on the number of changes one tempo map may declare.\n *\n * A map is read on every conversion asked of it, so an unbounded map is an\n * unbounded per-note cost the way an unbounded event array is an unbounded\n * pass. The bound is the one the meter map takes, and for the same reason: far\n * above any notated piece — a change on every bar of a hundred thousand bars —\n * and it rejects the map rather than the work built on it. A recorded\n * accelerando reaches it, which is exactly the import the bound is for.\n */\nconst MAX_TEMPO_CHANGES = 100_000;\n\n/**\n * Validate a tempo map: non-empty, strictly ascending, finite onsets, and\n * tempos inside the range the conversions stay finite over.\n *\n * An onset is not bounded below, for the reason the note events are not: beat 0\n * is the first downbeat, so a piece that opens with a pickup marks its tempo\n * before it.\n *\n * An unsorted map is rejected rather than sorted: reordering it would silently\n * accept a data error, and two entries on the same beat name no segment at all.\n */\nfunction assertTempoMap(map: TempoMap, name = 'tempo map'): TempoMap {\n if (!Array.isArray(map) || map.length === 0) {\n throw new InvalidInputError(`${name} must hold at least one tempo event`);\n }\n assertGenerationBudget(map.length, `${name} count`, MAX_TEMPO_CHANGES);\n // A map is re-validated on every conversion asked of it, so a pass over a\n // piece pays for the whole map per note unless a map it has already read is\n // recognized as one. The meter map is read the same way.\n if (isValidatedTempoMap(map)) {\n return map;\n }\n for (let index = 0; index < map.length; index += 1) {\n const event = map[index];\n // A hole in a sparse array, an explicit null, and a number are all rejected\n // here rather than at the first field read, which would surface as the\n // library's own TypeError instead of as the malformed input it is. The\n // meter map is read the same way.\n if (typeof event !== 'object' || event === null) {\n throw new InvalidInputError(\n `${name}[${index}] must be a tempo event; received ${describeRejected(event)}`,\n );\n }\n assertFiniteNumber(event.startBeat, `${name}[${index}].startBeat`);\n assertRange(event.bpm, MIN_BPM, MAX_BPM, `${name}[${index}].bpm`);\n const previous = map[index - 1];\n if (previous !== undefined && event.startBeat <= previous.startBeat) {\n throw new InvalidInputError(\n `${name} must be sorted by startBeat with no repeats; ` +\n `[${index}].startBeat ${event.startBeat} does not follow ${previous.startBeat}`,\n );\n }\n }\n rememberValidatedTempoMap(map);\n return map;\n}\n\n/** The map's first event, which is its time origin. */\nfunction firstEvent(map: TempoMap): TempoEvent {\n const first = map[0];\n if (first === undefined) {\n throw new InvalidInputError('tempo map must hold at least one tempo event');\n }\n return first;\n}\n\n/**\n * Elapsed seconds over `[fromBeat, toBeat]`, summed segment by segment. Both\n * bounds are assumed validated; a span running backwards reports negative time,\n * which is what keeps the integral additive across the origin.\n *\n * The sum starts at the segment the span starts in rather than at the map's\n * first, so a note late in a piece is not charged for every tempo change before\n * it. What it costs is the segments the span actually crosses, which is what\n * the span is made of.\n */\nfunction integrateSeconds(map: TempoMap, fromBeat: number, toBeat: number): number {\n if (toBeat < fromBeat) {\n return -integrateSeconds(map, toBeat, fromBeat);\n }\n let seconds = 0;\n for (let index = tempoSegmentAt(map, fromBeat); index < map.length; index += 1) {\n const event = map[index];\n if (event === undefined) {\n continue;\n }\n // The opening tempo reaches back before the beat it is marked on: a pickup\n // is played at the tempo of the piece it leads into, and the map names no\n // other one to play it at.\n const segmentStart = index === 0 ? Number.NEGATIVE_INFINITY : event.startBeat;\n const segmentEnd = map[index + 1]?.startBeat ?? Number.POSITIVE_INFINITY;\n const low = Math.max(fromBeat, segmentStart);\n const high = Math.min(toBeat, segmentEnd);\n if (high > low) {\n seconds += ((high - low) * SECONDS_PER_MINUTE) / event.bpm;\n }\n if (toBeat <= segmentEnd) {\n break;\n }\n }\n return seconds;\n}\n\n/**\n * Wall-clock seconds from the start of a tempo map to a beat.\n *\n * The result integrates every tempo segment the span crosses; it is not the\n * tempo in effect at `beat` applied to the whole span.\n *\n * A beat before the map's first event reports negative elapsed time, at the\n * opening tempo: a pickup sounds before the downbeat, and asking when it sounds\n * is a fair question.\n *\n * @param beat Position in quarter-note beats.\n * @param map The tempo map; its first event is the time origin.\n * @returns Elapsed seconds, 0 at the map's first event and negative before it.\n * @throws If the map is empty, unsorted, or carries a tempo outside 0.1..1000\n * quarter-note beats per minute.\n * @example\n * ```ts\n * import { beatsToSeconds } from '@libraz/libcantus';\n * const map = [{ startBeat: 0, bpm: 120 }, { startBeat: 4, bpm: 60 }];\n * beatsToSeconds(8, map); // 6 = 4 beats at 120 + 4 beats at 60\n * ```\n * @category Rhythm & Meter\n */\nexport function beatsToSeconds(beat: number, map: TempoMap): number {\n assertFiniteNumber(beat, 'beat');\n assertTempoMap(map);\n // The origin-to-beat integral crosses every segment before `beat`, so a pass\n // that asks it of every note re-adds the whole map per note. The sum of the\n // whole segments is the map's own, made once and read here.\n return elapsedSecondsAt(map, beat);\n}\n\n/**\n * The beat reached after a number of seconds — the inverse of\n * {@link beatsToSeconds}.\n *\n * @param seconds Elapsed seconds from the map's first event; negative for a\n * position before it, such as a pickup.\n * @param map The tempo map.\n * @returns The position in quarter-note beats.\n * @throws If the map is malformed or `seconds` is not finite.\n * @example\n * ```ts\n * import { secondsToBeats } from '@libraz/libcantus';\n * const map = [{ startBeat: 0, bpm: 120 }, { startBeat: 4, bpm: 60 }];\n * secondsToBeats(6, map); // 8\n * ```\n * @category Rhythm & Meter\n */\nexport function secondsToBeats(seconds: number, map: TempoMap): number {\n assertFiniteNumber(seconds, 'seconds');\n assertTempoMap(map);\n // Before the origin only the opening tempo is in force, which is the segment\n // {@link beatsToSeconds} integrates backwards over; the prefix sums place a\n // negative elapsed time there without a case of its own.\n return beatAtElapsedSeconds(map, seconds);\n}\n\n/**\n * Duration in seconds of a span of beats.\n *\n * Equal to the difference of two {@link beatsToSeconds} calls — the integral is\n * additive, so that reading is exact — but integrated over the span directly, so\n * a short note late in a long piece does not lose precision to the subtraction\n * of two large elapsed times.\n *\n * @param startBeat Where the span begins, in quarter-note beats; a pickup\n * starts before the map's first event and is measured like any other span.\n * @param lengthBeats How long the span lasts, in quarter-note beats.\n * @param map The tempo map.\n * @returns The span's duration in seconds, never negative.\n * @throws If the map is malformed or the length is negative.\n * @example\n * ```ts\n * import { durationToSeconds } from '@libraz/libcantus';\n * const map = [{ startBeat: 0, bpm: 120 }, { startBeat: 4, bpm: 60 }];\n * durationToSeconds(2, 4, map); // 3 = 2 beats at 120 + 2 beats at 60\n * ```\n * @category Rhythm & Meter\n */\nexport function durationToSeconds(startBeat: number, lengthBeats: number, map: TempoMap): number {\n assertFiniteNumber(startBeat, 'startBeat');\n assertRange(lengthBeats, 0, Number.MAX_SAFE_INTEGER, 'lengthBeats');\n assertTempoMap(map);\n return integrateSeconds(map, startBeat, startBeat + lengthBeats);\n}\n\n/**\n * The tempo in effect at a beat.\n *\n * A beat before the first event reads the opening tempo, which is the tempo a\n * pickup is played at.\n *\n * @param beat Position in quarter-note beats.\n * @param map The tempo map.\n * @returns Quarter-note beats per minute.\n * @throws If the map is malformed.\n * @example\n * ```ts\n * import { tempoAt } from '@libraz/libcantus';\n * tempoAt(5, [{ startBeat: 0, bpm: 120 }, { startBeat: 4, bpm: 60 }]); // 60\n * ```\n * @category Rhythm & Meter\n */\nexport function tempoAt(beat: number, map: TempoMap): number {\n assertFiniteNumber(beat, 'beat');\n assertTempoMap(map);\n return map[tempoSegmentAt(map, beat)]?.bpm ?? firstEvent(map).bpm;\n}\n\n/** A reader that converts many positions against one tempo map. */\nexport type TempoReader = {\n /** Elapsed seconds from the map's origin to a beat. */\n secondsAt(beat: number): number;\n /** The beat reached after a number of seconds from the origin. */\n beatAt(seconds: number): number;\n};\n\n/**\n * Hold a tempo map for the length of one pass, and convert against it.\n *\n * A conversion validates the map it is handed and re-reads it to know the\n * caller has not written to it since, so a pass that converts every note of a\n * piece pays for the whole map per note — and an imported accelerando marks a\n * tempo every tick. A pass that reads the map once instead pays for it once.\n *\n * The map is read when the reader is made, so the reader answers for the map as\n * it was then: a pass hands out no reader it does not own the map of.\n *\n * Not part of the public surface: it hands out a view of a validated map, which\n * only the pass that validated it can say is still current.\n *\n * @param map The tempo map, validated here.\n * @returns The conversions, reading one snapshot of the map.\n */\nexport function tempoReader(map: TempoMap): TempoReader {\n assertTempoMap(map);\n const index = tempoIndexOf(map);\n return {\n secondsAt: (beat) => elapsedSecondsIn(index, assertFiniteNumber(beat, 'beat')),\n beatAt: (seconds) => beatAtElapsedIn(index, assertFiniteNumber(seconds, 'seconds')),\n };\n}\n\n/**\n * Convert quarter-note beats to MIDI ticks.\n *\n * Ticks are whole units of a sequencer's grid, so the result is rounded to the\n * nearest tick; a beat that is not on the grid is not representable and comes\n * back quantized.\n *\n * A position before the first downbeat is a negative tick count, which is how a\n * pickup crosses the MIDI boundary and comes back. A position that rounds to\n * the downbeat from below comes back as positive zero: `-0` and `0` are the\n * same tick, and only one of them keys as it under `Object.is`.\n *\n * @param beat Position or length in quarter-note beats.\n * @param ppq Pulses (ticks) per quarter note, e.g. 96, 480, or 960.\n * @returns The whole tick count.\n * @throws If `beat` is not finite or `ppq` is not a positive integer.\n * @example\n * ```ts\n * import { beatsToTicks } from '@libraz/libcantus';\n * beatsToTicks(1.5, 480); // 720\n * ```\n * @category Rhythm & Meter\n */\nexport function beatsToTicks(beat: number, ppq: number): number {\n assertFiniteNumber(beat, 'beat');\n assertPositiveInt(ppq, 'ppq');\n const ticks = Math.round(beat * ppq);\n return ticks === 0 ? 0 : ticks;\n}\n\n/**\n * Convert MIDI ticks to quarter-note beats.\n *\n * @param ticks Whole tick count, negative before the first downbeat.\n * @param ppq Pulses (ticks) per quarter note, e.g. 96, 480, or 960.\n * @returns The position or length in quarter-note beats.\n * @throws If `ticks` is not an integer or `ppq` is not a positive integer.\n * @example\n * ```ts\n * import { ticksToBeats } from '@libraz/libcantus';\n * ticksToBeats(720, 480); // 1.5\n * ```\n * @category Rhythm & Meter\n */\nexport function ticksToBeats(ticks: number, ppq: number): number {\n assertInteger(ticks, 'ticks');\n assertPositiveInt(ppq, 'ppq');\n return ticks / ppq;\n}\n","/**\n * Tuning and microtonality: frequency conversion, cents, arbitrary equal\n * temperaments (EDO), and just-intonation ratios.\n *\n * The rest of the library reasons in twelve-tone pitch classes, which is a\n * deliberate scope choice for tonal theory. This module is the escape hatch for\n * anyone who needs actual frequencies, cents, non-12 equal temperaments, or the\n * acoustic (just) tuning behind the tempered intervals.\n */\n\nimport { InvalidInputError } from '../errors/index.js';\nimport {\n assertFiniteNumber,\n assertInteger,\n assertPositiveInt,\n assertRange,\n describeRejected,\n} from '../validation/index.js';\n\n/**\n * An equal-tempered tuning: a reference pitch and a number of equal divisions of\n * the octave. With `divisions === 12` a step index is an ordinary MIDI number.\n *\n * @category Pitch & Intervals\n */\nexport type TuningTable = {\n /** Step index (MIDI number when `divisions` is 12) whose frequency is `refFreq`. */\n readonly refStep: number;\n /** Frequency in Hz of `refStep`. */\n readonly refFreq: number;\n /** Equal divisions of the octave (12 standard; e.g. 19 or 31 for microtonal). */\n readonly divisions: number;\n};\n\n/**\n * Standard twelve-tone equal temperament, A4 (MIDI 69) = 440 Hz.\n *\n * @category Pitch & Intervals\n */\nexport const TWELVE_TET: TuningTable = Object.freeze({ refStep: 69, refFreq: 440, divisions: 12 });\n\nfunction assertTuning(tuning: TuningTable): TuningTable {\n // The shape is checked before any field is read: a value from JSON or a\n // plugin host may be null or a number, and reading a reference step off it\n // would report the library's own TypeError instead of the caller's bad input.\n if (typeof tuning !== 'object' || tuning === null) {\n throw new InvalidInputError(\n `tuning must be a tuning table; received ${describeRejected(tuning)}`,\n );\n }\n assertFiniteNumber(tuning.refStep, 'tuning.refStep');\n assertRange(tuning.refFreq, Number.MIN_VALUE, Number.MAX_VALUE, 'tuning.refFreq');\n assertPositiveInt(tuning.divisions, 'tuning.divisions');\n return tuning;\n}\n\n/**\n * Build an equal temperament with `n` divisions of the octave.\n *\n * @param n Divisions of the octave (e.g. 19, 24, 31).\n * @param refFreq Reference frequency in Hz (default 440).\n * @param refStep Step index of the reference (default 69).\n * @returns The tuning.\n * @example\n * ```ts\n * import { edo, frequencyOf } from '@libraz/libcantus';\n * const et19 = edo(19); // { refStep: 69, refFreq: 440, divisions: 19 }\n * frequencyOf(70, et19); // one 19-EDO step above A4\n * ```\n * @category Pitch & Intervals\n */\nexport function edo(n: number, refFreq = 440, refStep = 69): TuningTable {\n assertPositiveInt(n, 'EDO divisions');\n assertRange(refFreq, Number.MIN_VALUE, Number.MAX_VALUE, 'reference frequency');\n assertFiniteNumber(refStep, 'reference step');\n return { refStep, refFreq, divisions: n };\n}\n\n/**\n * Frequency in Hz of a step index under a tuning.\n *\n * @param step Step index (a MIDI number under 12-EDO).\n * @param tuning The tuning (default 12-TET).\n * @returns The frequency in Hz.\n * @example\n * ```ts\n * import { frequencyOf } from '@libraz/libcantus';\n * frequencyOf(69); // 440 (A4 in 12-TET)\n * frequencyOf(60); // middle C in Hz\n * ```\n * @category Pitch & Intervals\n */\nexport function frequencyOf(step: number, tuning: TuningTable = TWELVE_TET): number {\n assertFiniteNumber(step, 'step');\n assertTuning(tuning);\n const result = tuning.refFreq * 2 ** ((step - tuning.refStep) / tuning.divisions);\n return assertRange(result, Number.MIN_VALUE, Number.MAX_VALUE, 'frequency result');\n}\n\n/**\n * Nearest step index to a frequency under a tuning (the inverse of\n * {@link frequencyOf}, rounded).\n *\n * @param freq Frequency in Hz.\n * @param tuning The tuning (default 12-TET).\n * @returns The nearest step index.\n * @category Pitch & Intervals\n */\nexport function nearestStep(freq: number, tuning: TuningTable = TWELVE_TET): number {\n assertRange(freq, Number.MIN_VALUE, Number.MAX_VALUE, 'frequency');\n assertTuning(tuning);\n return Math.round(tuning.refStep + tuning.divisions * Math.log2(freq / tuning.refFreq));\n}\n\n/**\n * Step index of a frequency under a tuning, unrounded.\n *\n * The exact inverse of {@link frequencyOf}. {@link nearestStep} rounds it,\n * which discards how far off the pitch actually is — the figure a tuner\n * display, a pitch-bend amount, or an intonation check is built on.\n *\n * @param freq Frequency in Hz.\n * @param tuning The tuning (default 12-TET).\n * @returns The fractional step index.\n * @example\n * ```ts\n * import { stepOf } from '@libraz/libcantus';\n * stepOf(442); // slightly above 69, the step for A440\n * ```\n * @category Pitch & Intervals\n */\nexport function stepOf(freq: number, tuning: TuningTable = TWELVE_TET): number {\n assertRange(freq, Number.MIN_VALUE, Number.MAX_VALUE, 'frequency');\n assertTuning(tuning);\n return tuning.refStep + tuning.divisions * Math.log2(freq / tuning.refFreq);\n}\n\n/**\n * How far a frequency sits from its nearest step, in cents.\n *\n * Positive means sharp of the step, negative flat.\n *\n * @param freq Frequency in Hz.\n * @param tuning The tuning (default 12-TET).\n * @returns The signed deviation in cents.\n * @example\n * ```ts\n * import { centsFromNearestStep } from '@libraz/libcantus';\n * Math.round(centsFromNearestStep(442)); // 8\n * ```\n * @category Pitch & Intervals\n */\nexport function centsFromNearestStep(freq: number, tuning: TuningTable = TWELVE_TET): number {\n const exact = stepOf(freq, tuning);\n return centsOfSteps(exact - Math.round(exact), tuning);\n}\n\n/**\n * Steps spanned by an interval in cents, unrounded — the inverse of\n * {@link centsOfSteps}.\n *\n * @param cents The interval in cents.\n * @param tuning The tuning (default 12-TET).\n * @returns The fractional step count.\n * @category Pitch & Intervals\n */\nexport function stepsOfCents(cents: number, tuning: TuningTable = TWELVE_TET): number {\n assertFiniteNumber(cents, 'cents');\n assertTuning(tuning);\n return assertFiniteNumber((cents * tuning.divisions) / 1200, 'steps result');\n}\n\n/**\n * The frequency ratio an interval in cents spans — the inverse of\n * {@link ratioToCents}.\n *\n * Multiply a frequency by this to move it by that many cents, which is how a\n * cents offset (a pitch-bend spec, a tuning table entry) is applied.\n *\n * @param cents The interval in cents.\n * @returns The frequency ratio.\n * @example\n * ```ts\n * import { centsToRatio } from '@libraz/libcantus';\n * 440 * centsToRatio(14); // A440 raised by 14 cents\n * ```\n * @category Pitch & Intervals\n */\nexport function centsToRatio(cents: number): number {\n assertFiniteNumber(cents, 'cents');\n const result = 2 ** (cents / 1200);\n return assertRange(result, Number.MIN_VALUE, Number.MAX_VALUE, 'ratio result');\n}\n\n/**\n * Interval in cents between two frequencies.\n *\n * @param a Lower/first frequency in Hz.\n * @param b Upper/second frequency in Hz.\n * @returns Cents from `a` to `b` (negative if `b` is lower).\n * @category Pitch & Intervals\n */\nexport function centsBetweenFreq(a: number, b: number): number {\n assertRange(a, Number.MIN_VALUE, Number.MAX_VALUE, 'first frequency');\n assertRange(b, Number.MIN_VALUE, Number.MAX_VALUE, 'second frequency');\n return 1200 * (Math.log2(b) - Math.log2(a));\n}\n\n/**\n * Cents spanned by a number of equal-temperament steps.\n *\n * @param steps Number of steps.\n * @param tuning The tuning (default 12-TET).\n * @returns The cents.\n * @category Pitch & Intervals\n */\nexport function centsOfSteps(steps: number, tuning: TuningTable = TWELVE_TET): number {\n assertFiniteNumber(steps, 'steps');\n assertTuning(tuning);\n return assertFiniteNumber((steps * 1200) / tuning.divisions, 'cents result');\n}\n\n/**\n * Cents of a frequency ratio, e.g. `ratioToCents(3, 2)` ≈ 701.955 for the just\n * perfect fifth.\n *\n * @param numerator Ratio numerator.\n * @param denominator Ratio denominator.\n * @returns The interval in cents.\n * @category Pitch & Intervals\n */\nexport function ratioToCents(numerator: number, denominator: number): number {\n assertRange(numerator, Number.MIN_VALUE, Number.MAX_VALUE, 'ratio numerator');\n assertRange(denominator, Number.MIN_VALUE, Number.MAX_VALUE, 'ratio denominator');\n return 1200 * (Math.log2(numerator) - Math.log2(denominator));\n}\n\n/** One entry of {@link JUST_RATIOS}: a numerator and a denominator, frozen. */\nfunction justRatio(numerator: number, denominator: number): readonly [number, number] {\n return Object.freeze([numerator, denominator] as [number, number]);\n}\n\n/**\n * Five-limit just-intonation ratios for the twelve interval classes above a\n * unison, indexed by semitone class (0..12).\n *\n * @category Pitch & Intervals\n */\nexport const JUST_RATIOS: Readonly<\n Record<0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12, readonly [number, number]>\n> = Object.freeze({\n 0: justRatio(1, 1),\n 1: justRatio(16, 15),\n 2: justRatio(9, 8),\n 3: justRatio(6, 5),\n 4: justRatio(5, 4),\n 5: justRatio(4, 3),\n 6: justRatio(45, 32),\n 7: justRatio(3, 2),\n 8: justRatio(8, 5),\n 9: justRatio(5, 3),\n 10: justRatio(9, 5),\n 11: justRatio(15, 8),\n 12: justRatio(2, 1),\n});\n\n/** Whether a semitone class is one of the classes {@link JUST_RATIOS} lists. */\nfunction isJustSemitoneClass(value: number): value is keyof typeof JUST_RATIOS {\n return value in JUST_RATIOS;\n}\n\n/**\n * Cents by which a five-limit just interval departs from its 12-TET tempering\n * (positive means the just interval is wider).\n *\n * @param semitoneClass Semitone class in [0, 12].\n * @returns The deviation in cents.\n * @throws If `semitoneClass` is not an integer in [0, 12].\n * @category Pitch & Intervals\n */\nexport function justDeviationCents(semitoneClass: number): number {\n assertInteger(semitoneClass, 'semitone class', 0, 12);\n if (!isJustSemitoneClass(semitoneClass)) {\n throw new InvalidInputError(`semitone class has no just ratio: ${semitoneClass}`);\n }\n const ratio = JUST_RATIOS[semitoneClass];\n return ratioToCents(ratio[0], ratio[1]) - semitoneClass * 100;\n}\n"],"mappings":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