brand-music
Version:
Strongly typed music theory library
107 lines (101 loc) • 3.26 kB
JavaScript
;
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, from2, except, desc) => {
if (from2 && typeof from2 === "object" || typeof from2 === "function") {
for (let key of __getOwnPropNames(from2))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
// src/PitchIntervalClass.ts
var PitchIntervalClass_exports2 = {};
__export(PitchIntervalClass_exports2, {
ALL: () => ALL,
MAX: () => MAX,
MIN: () => MIN,
between: () => picBetweenPc,
from: () => from,
fromIntClamp: () => fromIntClamp,
fromIntMod: () => fromIntMod,
fromNum: () => fromNum,
fromPi: () => picFromPi,
fromSemitones: () => picFromSemitones,
fromUnknown: () => fromUnknown,
hasShape: () => hasShape,
ic: () => icFromPic,
invert: () => invert,
mark: () => mark,
markNum: () => markNum,
markUnknown: () => markUnknown
});
module.exports = __toCommonJS(PitchIntervalClass_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 sub = (a, b) => a - b;
// src/internal/PitchIntervalClass.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) => markUnknown(v) ? 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/conversion.ts
var icFromPic = (pic) => Math.min(pic, invert(pic));
var picBetweenPc = (from2, to) => fromIntMod(sub(asInt(to), asInt(from2)));
var picFromPi = (pi) => fromIntMod(pi);
var picFromSemitones = (semitones) => fromIntMod(semitones);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ALL,
MAX,
MIN,
between,
from,
fromIntClamp,
fromIntMod,
fromNum,
fromPi,
fromSemitones,
fromUnknown,
hasShape,
ic,
invert,
mark,
markNum,
markUnknown
});
//# sourceMappingURL=PitchIntervalClass.cjs.map