fretboard-api
Version:
A kind of API for fretboard diagrams
153 lines (152 loc) • 4.28 kB
TypeScript
/**
* Fret number.
* Also finger number.
* null means non-played.
*/
export declare type Fret = number;
export declare type SingleFret = number | null;
/**
* Finger number.
* 0 means open-string.
*/
export declare type Finger = number;
/**
* Frets along a single string
*/
export declare type StringFrets = Fret[] | null;
/**
* All frets
*/
export declare type Frets = StringFrets[];
/**
* Fingers for a single string
*/
export declare type StringFingers = Finger[] | null;
/**
* All fingering
*/
export declare type Fingers = StringFingers[];
/**
* Intervals for a single string
* null means the string is not played
*/
export declare type StringIntervals = string[] | null;
/**
* All intervals
*/
export declare type ShapeIntervals = StringIntervals[];
/**
* Notes for a single string
* null means the string is not played
*/
export declare type StringNotes = string[] | null;
/**
* All notes
*/
export declare type ShapeNotes = StringNotes[];
/**
*
*/
export interface Position {
string: number;
fret: Fret;
}
/**
* A shape describe a set of fretted notes on a fretboard.
*
* It can includes informations such as:
* - fingering
* - intervals names
* - position of the root note
* - tuning of the strings
* - notes names
*
* Strings are numbered starting at 0 and from lowest pitched to the highest pitched.
* For a standard tuning, strings are 0=E, 1=A, 2=D, 3=G, 4=B, 5=E
*
* Frets are numbered starting at 0 and from the head of the neck towards the bridge.
* Fret number 0 is the nut, or the "zero fret" installed close the the nut on some guitars.
*
* A null values in frets means a non-played string.
*/
export interface ShapeType {
/**
* First dimensions is strings, second dimension is frets.
*/
frets: Frets;
/**
* First dimensions is strings, second dimension is frets.
*/
fingers?: Fingers;
/**
* Position of the root note of the shape.
*
* User specified or auto-computed.
*
* By default, if not specified, this will be the position of the first fretted note of the first played string.
*/
root: Position;
/**
* Position of the shape.
*
* User specified or auto-computed.
*
* Position is absolute (relative to the fretboard); position is always for the first played fret of the first played string.
*
* By default, if not specified, this will be the position of the first fretted note of the first played string.
*/
position: Position;
/**
* Added when played
*/
tuning?: string[];
/**
* Computed when played (because intervals depend on the tuning)
*/
intervals: ShapeIntervals;
/**
* Computed when played (because intervals depend on the tuning)
*/
notes: ShapeNotes;
/**
* Computed when played
*/
/**
* Computed when played
*/
/**
* Computed when played
*/
fromFret: number;
/**
* Computed when played
*/
toFret: number;
}
/**
* In string definition, use 'X' to denote a non-played string.
* In number[] definition, use 'null' to denote a non-played string.
* "022100" --> [[0], [2], [2], [1], [0], [0]]
* "8 10 10 9 8 8" --> [[8], [10], [10], [9], [8], [8]]
* [8, 10, 10, 9, 8, 8] --> [[8], [10], [10], [9], [8], [8]]
* "24,124,134,134,24,12" --> [[2, 4], [1, 2, 4], [1, 3, 4], [1, 3, 4], [2, 4], [1, 2]]
* "8 10, 7 8 10, 7 9 10, 7 9 10, 8 10, 7 8" --> [[8, 10], [7, 8, 10], [7, 9, 10], [7, 9, 10], [8, 10], [7, 8]]
* @param {?(array|string)} frets - frets.
* @return {array} array of fret numbers.
*/
declare function normalizeInputFormat(frets: string | SingleFret[]): Frets;
declare function create(frets: string): ShapeType;
declare function create(frets: Fret[]): ShapeType;
declare function create(shape: object): ShapeType;
/**
*
* @param shape
* @returns {*}
*/
declare function getFretPosition(shape: ShapeType): number;
export declare const Shape: {
create: typeof create;
normalizeInputFormat: typeof normalizeInputFormat;
getFretPosition: typeof getFretPosition;
};
export {};