mosfez-xen-types
Version:
Basic xen number types for microtonal scale representation and manipulation with TypeScript / JavaScript.
58 lines (56 loc) • 2.23 kB
TypeScript
declare const isNumber: (input: unknown) => input is number;
declare const isString: (input: unknown) => input is string;
declare const stringToNumber: (str: string) => number;
declare const toDecimal: (value: number, places: number) => number;
declare const toDecimalString: (value: number, places: number) => string;
declare class Cents {
value: number;
constructor(cents: number);
constructor(stringToParse: string);
constructor(ratio: Ratio);
constructor(ed2: Ed2);
static parse(str: string): number;
static fromEd2(ed2: Ed2): number;
static fromRatio(ratio: Ratio): number;
toString(): string;
toDecimal(places: number): number;
toDecimalString(places: number): string;
toScl(places: number): string;
toMultiplier(): number;
}
declare class Ratio {
numerator: number;
denominator: number;
constructor(numerator: number, denominator: number);
constructor(stringToParse: string);
static parse(str: string): [number, number];
get value(): [number, number];
toMultiplier(): number;
toString(): string;
toScl(): string;
}
declare class Ed2 {
steps: number;
divisions: number;
constructor(steps: number, divisions: number);
constructor(stringToParse: string);
static parse(str: string): [number, number];
get value(): [number, number];
toString(): string;
toScl(places: number): string;
toMultiplier(): number;
}
declare type Pitch = Cents | Ratio | Ed2;
declare function cents(cents: number): Cents;
declare function cents(centsInstance: Cents): Cents;
declare function cents(stringToParse: string): Cents;
declare function cents(ratio: Ratio): Cents;
declare function cents(ed2: Ed2): Cents;
declare function ratio(ratio: Ratio): Ratio;
declare function ratio(stringToParse: string): Ratio;
declare function ratio(numerator: number, denominator: number): Ratio;
declare function ed2(ed2: Ed2): Ed2;
declare function ed2(stringToParse: string): Ed2;
declare function ed2(steps: number, divisions: number): Ed2;
declare const parse: (input: string) => Pitch | "ignore" | "invalid";
export { Cents, Ed2, Pitch, Ratio, cents, ed2, isNumber, isString, parse, ratio, stringToNumber, toDecimal, toDecimalString };