moment-of-symmetry
Version:
Moment of Symmetry (MOS) musical scale generation and analysis for Javascript
159 lines (158 loc) • 8.44 kB
TypeScript
import { ModeInfo, MosInfo, MosScaleInfo, RangeInfo } from './info';
export * from './hardness';
export * from './names';
export * from './generator-ratio';
export * from './info';
export * from './notation';
/**
* Parameters for various function.
*/
export type BaseOptions = {
/** How many bright generators to go downwards. Also the number of small/minor intervals in the resulting scale. Default = 0. */
down?: number;
/** How many bright generators to go upwards. Also the number of large/major intervals in the resulting scale. Defaults to the maximum possible. */
up?: number;
};
/**
* Parameters for the {@link modeInfo} function.
*/
export interface ModeInfoOptions extends BaseOptions {
/** If true adds extra mode names in parenthesis such as Ionian (Major). */
extraNames?: boolean;
}
/**
* Parameters for the {@link mos} function.
*/
export interface MosOptions extends BaseOptions {
/** Size of the large step. Default = 2.*/
sizeOfLargeStep?: number;
/** Size of small step. Default = 1. */
sizeOfSmallStep?: number;
}
/**
* Parameters for the {@link mosWithParent} function.
*/
export interface MosWithParentOptions extends MosOptions {
/** How the main scale relates to the parent. Defaults to 'sharp'. */
accidentals?: 'flat' | 'sharp';
}
/**
* Parameters for the {@link mosWithDaughter} function.
*/
export interface MosWithDaughterOptions extends MosOptions {
/** How the daughter scale(s) relates to the main scale. Defaults to 'sharp'. */
accidentals?: 'flat' | 'sharp' | 'both';
}
/**
* Produce an array of booleans that is mixed as evenly as possible.
* @param numberOfTrue Number of true elements
* @param numberOfFalse Number of false elements
* @returns The array of evenly mixed booleans
*/
export declare function euclid(numberOfTrue: number, numberOfFalse: number): boolean[];
/**
* Obtain the bright generator of the MOS scale expressed as multipliers of the size of the large and small steps.
* @param numberOfLargeSteps Number of large steps in the MOS pattern.
* @param numberOfSmallSteps Number of small steps in the MOS pattern.
* @returns An array of [number of large steps in the bright generator, number of small steps in the bright generator].
*/
export declare function brightGeneratorMonzo(numberOfLargeSteps: number, numberOfSmallSteps: number): [number, number];
/**
* Obtain an abstract string like 'LLsLLLs' corresponding to the mode specified.
* @param numberOfLargeSteps Number of large steps in the MOS pattern.
* @param numberOfSmallSteps Number of small steps in the MOS pattern.
* @param options Options for brightness of the scale.
* @returns String with the given number of 'L' and 's' characters in the specified mode.
*/
export declare function stepString(numberOfLargeSteps: number, numberOfSmallSteps: number, options?: BaseOptions): string;
/**
* Generate MOS pattern as a subset of an EDO.
* @param numberOfLargeSteps Number of large steps in the MOS pattern.
* @param numberOfSmallSteps Number of small steps in the MOS pattern.
* @param options Options for sizes of the steps and brightness of the scale.
* @returns An array of integers representing the EDO subset. The 0 degree is not included, but the final degree representing the size of the EDO is.
*/
export declare function mos(numberOfLargeSteps: number, numberOfSmallSteps: number, options?: MosOptions): number[];
/**
* Generate MOS pattern as a subset of an EDO with parent MOS relationship indicated.
* @param numberOfLargeSteps Number of large steps in the MOS pattern.
* @param numberOfSmallSteps Number of small steps in the MOS pattern.
* @param options Options for sizes of the steps, brightness of the scale and flat/sharp relationship.
* @returns A map of integers representing the EDO subset to booleans indicating if the scale degree belongs to the parent MOS or not.
* The 0 degree is not included, but the final degree representing the size of the EDO is.
*/
export declare function mosWithParent(numberOfLargeSteps: number, numberOfSmallSteps: number, options?: MosWithParentOptions): Map<number, boolean>;
/**
* Generate the daughter MOS pattern as a subset of an EDO with parent MOS relationship indicated.
* @param numberOfLargeSteps Number of large steps in the parent MOS.
* @param numberOfSmallSteps Number of small steps in the parent MOS.
* @param options Options for sizes of the steps, brightness of the scale and flat/sharp relationship.
* @returns A map of integers representing the EDO subset to booleans indicating if the scale degree belongs to the parent MOS or not.
* The 0 degree is not included, but the final degree representing the size of the EDO is.
*/
export declare function mosWithDaughter(numberOfLargeSteps: number, numberOfSmallSteps: number, options?: MosWithDaughterOptions): Map<number, "flat" | "sharp" | "both" | "parent">;
/**
* Information about the modes of a MOS scale.
* @param numberOfLargeSteps Number of large steps in the MOS pattern.
* @param numberOfSmallSteps Number of small steps in the MOS pattern.
* @param extraNames If true adds extra mode names in parenthesis such as Ionian (Major).
* @returns An array of mode information.
*/
export declare function mosModes(numberOfLargeSteps: number, numberOfSmallSteps: number, extraNames?: boolean): ModeInfo[];
/**
* Information about a mode of a MOS scale.
* @param numberOfLargeSteps Number of large steps in the MOS pattern.
* @param numberOfSmallSteps Number of small steps in the MOS pattern.
* @param options Options for brightness of the scale and for adding extra names like Ionian (Major).
* @returns An array of mode information.
*/
export declare function modeInfo(numberOfLargeSteps: number, numberOfSmallSteps: number, options?: ModeInfoOptions): ModeInfo;
/**
* Split a string like "5L 2s" into [5, 2].
* @param mosPattern MOS pattern such as "5L 2s".
* @returns A pair of intergers representing the number of large and small steps.
*/
export declare function splitMosPattern(mosPattern: string): [number, number];
/**
* Calculate the parent MOS of a given MOS pattern.
* @param mosPattern MOS pattern such as "5L 2s".
* @returns Information about the parent MOS.
*/
export declare function parentMos(mosPattern: string): MosInfo;
/**
* Calculate the parent MOS of a given MOS pattern.
* @param numberOfLargeSteps Number of large steps in the MOS pattern.
* @param numberOfSmallSteps Number of small steps in the MOS pattern.
* @returns Information about the parent MOS.
*/
export declare function parentMos(numberOfLargeSteps: number, numberOfSmallSteps: number): MosInfo;
export declare function mosScaleInfo(numberOfLargeSteps: number, numberOfSmallSteps: number, sizeOfLargeStep?: number, sizeOfSmallStep?: number): MosScaleInfo;
export declare function daughterMos(numberOfLargeSteps: number, numberOfSmallSteps: number, sizeOfLargeStep: number, sizeOfSmallStep: number): MosScaleInfo;
/**
* Construct a mapping from EDO size to supported MOS scales.
* @param maxSize Maximum size of the MOS patterns to include.
* @returns A mapping from EDO size to an array of information about the supported MOS scales.
*/
export declare function makeEdoMap(maxSize?: number): Map<number, MosScaleInfo[]>;
/**
* Find a MOS scale supported by the given EDO.
* @param edo Size of the EDO.
* @returns Information about the supported MOS scale.
*/
export declare function anyForEdo(edo: number): MosScaleInfo;
/**
* Find all MOS scales supported by the given EDO within the given constraints.
* @param edo Size of the EDO.
* @param minSize Minimum size of a MOS scale in the result.
* @param maxSize Maximum size of a MOS scale in the result.
* @param maxHardness Maximum hardness of the step ratio L/s.
* @returns Array of information about the supported MOS scales.
*/
export declare function allForEdo(edo: number, minSize?: number, maxSize?: number, maxHardness?: number): MosScaleInfo[];
/**
* Find the ranges of all (equally tempered) fractions of the equave that span MOS scales.
* @param size Size of the scales to consider.
* @param includeMultiPeriods Include scales that split the equave into multiple periods.
* @returns Information about the ranges of generator that span MOS. Ranges are grouped by period and otherwise sorted in ascending order.
*/
export declare function generatorRanges(size: number, includeMultiPeriods?: boolean): RangeInfo[];