string-fingerings
Version:
Utilities for calculating fingerings on string instruments
52 lines • 2.67 kB
TypeScript
import type { Instrument, InstrumentString, Note, NoteInput, PitchClass, Stop, StopCalculationData } from './types.js';
export declare function tryParse(noteText: string): Note | string;
export declare function parse(noteText: string): Note;
/**
* Parses a note with an optional octave. If the octave is present, returns a Note.
* If the octave is absent, returns a PitchClass (e.g. "C", "C#", "Db", "Ebb", "Fx").
*/
export declare function tryParseInput(noteText: string): NoteInput | string;
export declare function isNote(input: NoteInput): input is Note;
/**
* Expands a PitchClass into all Notes whose MIDI number falls within [minMidi, maxMidi].
*/
export declare function expandPitchClass(pc: PitchClass, minMidi: number, maxMidi: number): Note[];
/**
* Generates all possible Note[] combinations from NoteInput[].
* Notes with octaves produce a single option; PitchClasses are expanded
* into all octaves within the given MIDI range.
*/
export declare function generateNoteCombinations(inputs: NoteInput[], minMidi: number, maxMidi: number): Note[][];
/**
* Gets the MIDI note number from a text representation (middle C is 'C4')
* @param noteName Can include sharp (#) and flat (b) alterations, like Db5 or F#2.
* @returns The MIDI note number or a string with an explanatory error message.
*/
export declare function noteNumber(noteName: string): number | string;
export declare function nn(noteName: string): number;
export declare function noteName(noteNumber: number): string;
export declare function abcnote(noteNumber: number): string;
/**
* Returns the stop position relative to a string of length 1
* @param stopIndex semitone index (number of semitones above the open string)
*/
export declare function getStopRelPos(stopIndex: number): number;
declare global {
interface Array<T> {
pairwise(): Array<[T, T]>;
}
}
export declare function fingeringHardness<TString extends InstrumentString>(instrument: Instrument<TString>, fingering: StopCalculationData[]): number;
export declare function hasNoGaps(_instrument: any, fingering: {
stringIndex: number;
}[]): boolean;
export declare function hasPossibleStretch<TString extends InstrumentString>(instrument: Instrument<TString>, fingering: Stop[]): boolean;
/**
* Calculates the fingerings for an instrument and a set of notes.
* @param instrument
* @param notes
* @param validations
* @param includeNaturalHarmonics
*/
export declare function calculateFingerings<TString extends InstrumentString>(instrument: Instrument<TString>, notes: number[], validations: Function[], includeNaturalHarmonics?: boolean): Stop[][];
//# sourceMappingURL=fingerings.d.ts.map