UNPKG

brand-music

Version:

Strongly typed music theory library

121 lines (114 loc) 3.71 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all2) => { for (var name in all2) __defProp(target, name, { get: all2[name], enumerable: true }); }; var __copyProps = (to, from3, except, desc) => { if (from3 && typeof from3 === "object" || typeof from3 === "function") { for (let key of __getOwnPropNames(from3)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc(from3, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2); // src/PitchClass.ts var PitchClass_exports2 = {}; __export(PitchClass_exports2, { ALL: () => ALL, MAX: () => MAX, MIN: () => MIN, from: () => from, fromIntClamp: () => fromIntClamp, fromIntMod: () => fromIntMod, fromMnn: () => pcFromMnn, fromNum: () => fromNum, fromUnknown: () => fromUnknown, hasShape: () => hasShape, ic: () => icBetweenPc, invert: () => invert, mark: () => mark, markNum: () => markNum, markUnknown: () => markUnknown, pic: () => picBetweenPc, transpose: () => pcTranspose }); module.exports = __toCommonJS(PitchClass_exports2); // src/internal/utils.ts var mod = (a, n) => (a % n + n) % n; // src/internal/refined/Literal.ts var is = (start, end) => (v) => Number.isSafeInteger(v) && start <= v && v <= end; var clamp = (start, end) => (v) => v < start ? start : v > end ? end : v; var modded = (start, end) => (v) => { const size = end - start + 1; const zero = v - start; const m = mod(zero, size); return m + start; }; var all = (start, end) => ( // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment [...Array(end - start + 1)].map((_, i) => start + i) ); var asInt = (v) => v; // src/internal/refined/Int.ts var add = (a, b) => a + b; var sub = (a, b) => a - b; // src/internal/PitchClass.ts var min = 0; var max = 11; var hasShape = is(min, max); var mark = (_v) => true; var markNum = (v) => hasShape(v); var markUnknown = (v) => hasShape(v); var from = (v) => v; var fromNum = (v) => markNum(v) ? v : void 0; var fromIntClamp = (v) => from(clamp(min, max)(v)); var fromIntMod = (v) => from(modded(min, max)(v)); var fromUnknown = (v) => is(min, max)(v) ? from(v) : void 0; var const_ = (value) => value; var MIN = const_(min); var MAX = const_(max); var ALL = all(min, max).map(const_); var invert = (v, index = 0) => fromIntMod(sub(asInt(index), asInt(v))); // src/internal/PitchIntervalClass.ts var min2 = 0; var max2 = 11; var hasShape2 = is(min2, max2); var from2 = (v) => v; var fromIntMod2 = (v) => from2(modded(min2, max2)(v)); var const_2 = (value) => value; var MIN2 = const_2(min2); var MAX2 = const_2(max2); var ALL2 = all(min2, max2).map(const_2); var invert2 = (v, index = 0) => fromIntMod2(sub(asInt(index), asInt(v))); // src/internal/conversion.ts var icFromPic = (pic) => Math.min(pic, invert2(pic)); var icBetweenPc = (a, b) => icFromPic(picBetweenPc(a, b)); var pcTranspose = (value, interval) => fromIntMod(add(asInt(value), asInt(interval))); var pcFromMnn = (mnn) => fromIntMod(asInt(mnn)); var picBetweenPc = (from3, to) => fromIntMod2(sub(asInt(to), asInt(from3))); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { ALL, MAX, MIN, from, fromIntClamp, fromIntMod, fromMnn, fromNum, fromUnknown, hasShape, ic, invert, mark, markNum, markUnknown, pic, transpose }); //# sourceMappingURL=PitchClass.cjs.map