brand-music
Version:
Strongly typed music theory library
139 lines (132 loc) • 9.04 kB
TypeScript
import { R as RangedNat, I as Int, a as IntBrand, N as NonNegativeInt, b as Negate, c as NonNegativeBrand } from './NonNegativeInt-vzHTayKS.js';
import { P as PitchClass } from './PitchClass-RMqPx-Q2.js';
import { P as PitchIntervalClass } from './PitchIntervalClass-AHwI_N3-.js';
declare const min$1 = 0;
declare const max$1 = 6;
type Shape$3 = RangedNat<typeof min$1, typeof max$1>;
declare const hasShape$3: <T>(v: T) => v is T & (0 | 1 | 2 | 3 | 4 | 5 | 6);
interface IntervalClassBrand {
readonly IntervalClass: unique symbol;
}
/**
* Unordered pitch-class interval
*
* Number of ascending semitones from one pitch-class to the next, ordered from lowest to highest
* @see {@link https://en.wikipedia.org/wiki/Pitch_interval#Unordered_pitch-class_intervals_('interval_class;_IC')}
*/
type IntervalClass = Shape$3 & IntervalClassBrand;
declare const mark$3: (_v: Shape$3) => _v is IntervalClass;
declare const markNum$3: (v: number) => v is IntervalClass;
declare const markUnknown$3: (v: unknown) => v is IntervalClass;
declare const from$3: (v: Shape$3) => IntervalClass;
declare const fromNum$3: (v: number) => IntervalClass | undefined;
declare const fromIntClamp$1: (v: Int) => IntervalClass;
declare const fromIntMod$1: (v: Int) => IntervalClass;
declare const fromUnknown$3: (v: unknown) => IntervalClass | undefined;
declare const MIN$2: 0 & IntervalClassBrand;
declare const MAX$1: 6 & IntervalClassBrand;
declare const ALL$1: readonly IntervalClass[];
declare const min = 0;
declare const max = 127;
type Shape$2 = RangedNat<typeof min, typeof max>;
declare const hasShape$2: <T>(v: T) => v is T & (0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 127 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126);
interface MidiNoteNumberBrand {
readonly MidiNoteNumber: unique symbol;
}
type MidiNoteNumber = Shape$2 & MidiNoteNumberBrand;
declare const mark$2: (_v: Shape$2) => _v is MidiNoteNumber;
declare const markNum$2: (v: number) => v is MidiNoteNumber;
declare const markUnknown$2: (v: unknown) => v is MidiNoteNumber;
declare const from$2: (v: Shape$2) => MidiNoteNumber;
declare const fromNum$2: (v: number) => MidiNoteNumber | undefined;
declare const fromIntClamp: (v: Int) => MidiNoteNumber;
declare const fromIntMod: (v: Int) => MidiNoteNumber;
declare const fromUnknown$2: (v: unknown) => MidiNoteNumber | undefined;
declare const MIN$1: 0 & MidiNoteNumberBrand;
declare const MAX: 127 & MidiNoteNumberBrand;
declare const ALL: readonly MidiNoteNumber[];
declare const C_1: 0 & MidiNoteNumberBrand;
declare const C4: 60 & MidiNoteNumberBrand;
declare const G9: 127 & MidiNoteNumberBrand;
type Shape$1 = Int;
declare const hasShape$1: <T>(v: T) => v is T & number & IntBrand;
interface PitchIntervalBrand {
readonly PitchInterval: unique symbol;
}
/**
* Ordered pitch interval
*
* Number of semitones that separates one pitch from another, upward or downward.
* @see {@link https://en.wikipedia.org/wiki/Pitch_interval#Ordered_Pitch_Interval}
*/
type PitchInterval = Shape$1 & PitchIntervalBrand;
declare const mark$1: (_v: Int) => _v is PitchInterval;
declare const markNum$1: (v: number) => v is PitchInterval;
declare const markUnknown$1: (v: unknown) => v is PitchInterval;
type PartialPositivePitchInterval = RangedNat<1, 999>;
type PartialPitchInterval = PartialPositivePitchInterval | 0 | Negate<PartialPositivePitchInterval>;
declare const from$1: (v: Shape$1 | PartialPitchInterval) => PitchInterval;
declare const fromNum$1: (v: number) => PitchInterval | undefined;
declare const fromNumRound: (v: number) => PitchInterval;
declare const fromNumTrunc: (v: number) => PitchInterval;
declare const fromUnknown$1: (v: unknown) => PitchInterval | undefined;
declare const add: (a: PitchInterval, b: PitchInterval) => PitchInterval;
declare const addChecked: (a: PitchInterval, b: PitchInterval) => PitchInterval | undefined;
declare const sub: (a: PitchInterval, b: PitchInterval) => PitchInterval;
declare const subChecked: (a: PitchInterval, b: PitchInterval) => PitchInterval | undefined;
declare const mul: (a: PitchInterval, b: Int) => PitchInterval;
declare const mulChecked: (a: PitchInterval, b: PitchInterval) => PitchInterval | undefined;
declare const mulRound: (a: PitchInterval, b: number) => PitchInterval;
declare const mulTrunc: (a: PitchInterval, b: number) => PitchInterval;
declare const divChecked: (a: PitchInterval, b: PitchInterval) => PitchInterval | undefined;
declare const divRound: (a: PitchInterval, b: number) => PitchInterval;
declare const divTrunc: (a: PitchInterval, b: number) => PitchInterval;
declare const octaves$1: (pi: PitchInterval) => NonNegativeInt;
declare const direction: (pi: PitchInterval) => 1 | 0 | -1;
type Shape = NonNegativeInt;
declare const hasShape: (v: unknown) => v is NonNegativeInt;
interface SemitonesBrand {
readonly Semitones: unique symbol;
}
/**
* Unordered pitch interval
*
* Number of semitones that separates one pitch from another.
* @see {@link https://en.wikipedia.org/wiki/Pitch_interval#Unordered_Pitch_Interval}
*/
type Semitones = NonNegativeInt & SemitonesBrand;
declare const mark: (_v: Shape) => _v is Semitones;
declare const markNum: (v: number) => v is Semitones;
declare const markUnknown: (v: unknown) => v is Semitones;
declare const from: (v: Shape | RangedNat<0, 999>) => Semitones;
declare const fromNum: (v: number) => Semitones | undefined;
declare const fromIntAbs: (v: Int) => Semitones;
declare const fromUnknown: (v: unknown) => Semitones | undefined;
declare const MIN: 0 & IntBrand & NonNegativeBrand & SemitonesBrand;
declare const octaves: (st: Semitones) => NonNegativeInt;
declare const icFromPic: (pic: PitchIntervalClass) => IntervalClass;
declare const icBetweenPc: (a: PitchClass, b: PitchClass) => IntervalClass;
declare const mnnTransposeChecked: (value: MidiNoteNumber, interval: PitchInterval) => MidiNoteNumber | undefined;
declare const mnnTransposeClamped: (value: MidiNoteNumber, interval: PitchInterval) => MidiNoteNumber;
declare const mnnTransposeModded: (value: MidiNoteNumber, interval: PitchInterval) => MidiNoteNumber;
declare const pcTranspose: (value: PitchClass, interval: PitchIntervalClass) => PitchClass;
declare const pcFromMnn: (mnn: MidiNoteNumber) => PitchClass;
declare const piBetweenMnn: (from: MidiNoteNumber, to: MidiNoteNumber) => PitchInterval;
declare const picBetweenPc: (from: PitchClass, to: PitchClass) => PitchIntervalClass;
/**
* Gets the pitch interval class of the pitch interval.
*
* @example
* ```ts
* import * as PI from "brand-music/PitchInterval";
* import * as PIC from "brand-music/PitchIntervalClass";
*
* const picOfPi = PIC.fromPi(PI.from(-2)); // 10
* const picOfSemitones = PIC.fromSemitones(PI.semitones(PI.from(-2))); // 2
* ```
*/
declare const picFromPi: (pi: PitchInterval) => PitchIntervalClass;
declare const picFromSemitones: (semitones: Semitones) => PitchIntervalClass;
declare const stFromPi: (pi: PitchInterval) => Semitones;
declare const stBetweenMnn: (a: MidiNoteNumber, b: MidiNoteNumber) => Semitones;
export { fromNumRound as $, ALL$1 as A, mark$2 as B, C4 as C, markNum$2 as D, markUnknown$2 as E, pcFromMnn as F, G9 as G, piBetweenMnn as H, type IntervalClass as I, stBetweenMnn as J, mnnTransposeChecked as K, mnnTransposeClamped as L, MAX$1 as M, mnnTransposeModded as N, picBetweenPc as O, pcTranspose as P, type PitchInterval as Q, type PitchIntervalBrand as R, type Shape$3 as S, add as T, addChecked as U, direction as V, divChecked as W, divRound as X, divTrunc as Y, from$1 as Z, fromNum$1 as _, type IntervalClassBrand as a, fromNumTrunc as a0, fromUnknown$1 as a1, hasShape$1 as a2, mark$1 as a3, markNum$1 as a4, markUnknown$1 as a5, mul as a6, mulChecked as a7, mulRound as a8, mulTrunc as a9, octaves$1 as aa, picFromPi as ab, stFromPi as ac, sub as ad, subChecked as ae, picFromSemitones as af, MIN as ag, type Semitones as ah, type SemitonesBrand as ai, from as aj, fromIntAbs as ak, fromNum as al, fromUnknown as am, hasShape as an, mark as ao, markNum as ap, markUnknown as aq, octaves as ar, MIN$2 as b, fromIntClamp$1 as c, fromIntMod$1 as d, fromNum$3 as e, from$3 as f, icFromPic as g, fromUnknown$3 as h, icBetweenPc as i, hasShape$3 as j, markNum$3 as k, markUnknown$3 as l, mark$3 as m, ALL as n, C_1 as o, MAX as p, MIN$1 as q, type MidiNoteNumber as r, type MidiNoteNumberBrand as s, type Shape$2 as t, from$2 as u, fromIntClamp as v, fromIntMod as w, fromNum$2 as x, fromUnknown$2 as y, hasShape$2 as z };