UNPKG

ji-lattice

Version:

Algorithms for projecting just intonation and equally tempered scales onto the screen.

85 lines (84 loc) 3.13 kB
import { EdgeType } from './types'; /** * A vertex of a 3D graph. */ export type Vertex3D = { /** Horizontal coordinate. */ x: number; /** Vertical coordinate. */ y: number; /** Depthwise coordinate. */ z: number; /** Index to input array. */ index?: number; }; /** * An edge connecting two vertices of a 3D graph. */ export type Edge3D = { /** First horizontal coordinate. */ x1: number; /** First vertical coordinate. */ y1: number; /** First depthwise coordinate. */ z1: number; /** Second horizontal coordinate. */ x2: number; /** Second vertical coordinate. */ y2: number; /** Second depthwise coordinate. */ z2: number; /** Type of connection. */ type: EdgeType; }; /** * Options for {@link spanLattice3D}. */ export type LatticeOptions3D = { /** Mapping for prime x-coordinates. */ horizontalCoordinates: number[]; /** Mapping for prime y-coordinates. */ verticalCoordinates: number[]; /** Mapping for prime z-coordinates. */ depthwiseCoordinates: number[]; /** Maximum prime-wise distance for connecting two inputs. */ maxDistance?: number; /** Prime-count vectors of connections in addition the the primes. */ edgeMonzos?: number[][]; /** Flag to merge short edges into a long ones wherever possible. */ mergeEdges?: boolean; }; /** * Combine edges that share an endpoint and slope into longer ones. * @param edges Large number of short edges to merge. * @returns Smaller number of long edges. */ export declare function mergeEdges3D(edges: Edge3D[]): Edge3D[]; /** * Compute vertices and edges for a 2D graph representing the lattice of a musical scale in just intonation. * @param monzos Prime exponents of the musical intervals in the scale. * @param options Options for connecting vertices in the graph. * @returns Vertices and edges of the graph. */ export declare function spanLattice3D(monzos: number[][], options: LatticeOptions3D): { vertices: Vertex3D[]; edges: Edge3D[]; }; /** * Get Wilson-Grady-Pakkanen coordinates for the first 9 primes. * @param equaveIndex Index of the prime to use as the interval of equivalence. * @returns An array of horizontal coordinates for each prime and the same for vertical and depthwise coordinates. */ export declare function WGP9(equaveIndex?: number): LatticeOptions3D; /** * Compute coordinates based on sizes of primes that lie on the surface of a sphere offset on the x-axis. * @param equaveIndex Index of the prime to use as the interval of equivalence. * @param logs Logarithms of (formal) primes with the prime of equivalence first. Defaults to the first 24 actual primes. * @param searchResolution Search resolution for optimizing orthogonality of the resulting set. * @returns An array of horizontal coordinates for each prime and the same for vertical and depthwise coordinates. */ export declare function primeSphere(equaveIndex?: number, logs?: number[], searchResolution?: number): { horizontalCoordinates: number[]; verticalCoordinates: number[]; depthwiseCoordinates: number[]; };