UNPKG

@logic-pad/core

Version:
50 lines (49 loc) 2.52 kB
import { AnyConfig } from '../config.js'; import { GridChangeHandler } from '../events/onGridChange.js'; import { GridResizeHandler } from '../events/onGridResize.js'; import { SetGridHandler } from '../events/onSetGrid.js'; import GridData from '../grid.js'; import { RuleState } from '../primitives.js'; import { ControlLine } from './musicControlLine.js'; import Rule, { SearchVariant } from './rule.js'; export default class MusicGridRule extends Rule implements GridChangeHandler, SetGridHandler, GridResizeHandler { readonly controlLines: readonly ControlLine[]; readonly track: GridData | null; readonly normalizeVelocity: boolean; private static readonly EXAMPLE_GRID; private static readonly CONFIGS; private static readonly SEARCH_VARIANTS; /** * **Music Grid: Listen to the solution** * @param controlLines Denote changes in the playback settings. At least one control line at column 0 should be present to enable playback. * @param track The grid to be played when "listen" is clicked. Set as null to play the solution. * @param normalizeVelocity Whether to normalize the velocity of the notes by their pitch such that lower notes are played softer. */ constructor(controlLines: readonly ControlLine[], track: GridData | null, normalizeVelocity?: boolean); get id(): string; get explanation(): string; get configs(): readonly AnyConfig[] | null; createExampleGrid(): GridData; get searchVariants(): SearchVariant[]; validateGrid(_grid: GridData): RuleState; onSetGrid(_oldGrid: GridData, newGrid: GridData, _solution: GridData | null): GridData; onGridChange(newGrid: GridData): this; onGridResize(_grid: GridData, mode: 'insert' | 'remove', direction: 'row' | 'column', index: number): this | null; /** * Add or replace a control line. * @param controlLine The control line to set. * @returns A new rule with the control line set. */ setControlLine(controlLine: ControlLine): this; withTrack(track: GridData | null): this; copyWith({ controlLines, track, normalizeVelocity, }: { controlLines?: readonly ControlLine[]; track?: GridData | null; normalizeVelocity?: boolean; }): this; get validateWithSolution(): boolean; get isSingleton(): boolean; static mergeControlLines(...lines: ControlLine[]): ControlLine; static deduplicateControlLines(lines: readonly ControlLine[]): ControlLine[]; } export declare const instance: MusicGridRule;