@dsebastien/music-notation 0.15.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,64 @@
1
+ export type Naming = 'letters' | 'solfege' | 'german';
2
+ export declare const NAMINGS: readonly Naming[];
3
+ /** A naming from a block or an option ("Solfège", "GERMAN"); throws what to write otherwise. */
4
+ export declare function parseNaming(text: string): Naming;
5
+ /** A naming given by an app (any value): a valid one, else null. */
6
+ export declare function namingOf(value: unknown): Naming | null;
7
+ export interface ReadOptions {
8
+ /** One chord: a space between a solfège root and its quality is allowed (`Ré m7`). */
9
+ chord?: boolean;
10
+ /** Read H as B natural (true by default; blocks read it only where it was an error). */
11
+ h?: boolean;
12
+ }
13
+ /**
14
+ * Note names, chords, ranges and scale roots in solfège, German or letters, read into letters:
15
+ * `Rém Sol7` → `Dm G7`, `La mineur` → `A minor`, `H7` → `B7`. Letters first: what reads in letters
16
+ * stays (`Do` is D diminished), except with the solfège naming. A bare `B` is B flat only with the
17
+ * german naming. Solfège roots are capitalized (`la`, `do` are words).
18
+ */
19
+ export declare function toLetters(text: string, naming?: Naming, options?: ReadOptions): string;
20
+ export interface BlockReading {
21
+ /** The source in letters. */
22
+ text: string;
23
+ /** The block's own naming (its `naming:` line or `{naming: …}` directive); null without one. */
24
+ naming: Naming | null;
25
+ /** What was read: [as written, in letters], to quote the user in messages. */
26
+ changes: [string, string][];
27
+ /** Titles written by hand (`title:`), never rewritten when shown. */
28
+ titles: string[];
29
+ /** A chart's wrong `{naming: …}`: drawn as a warning, the chart read as letters. */
30
+ warning: string | null;
31
+ }
32
+ /**
33
+ * A block's source read into letters, its own naming (its `naming:` line, taken out; charts: a
34
+ * `{naming: …}` directive), what was read and the hand-written titles. Without its own naming a
35
+ * block reads letters first, and H only in the values of keys (where it was an error); a chart
36
+ * without a `{naming: …}` directive is left as written. Reads the values of the keys that hold
37
+ * notes, the shorthand line of diagrams and the circle, progression lines, strum and picking chord
38
+ * changes (`[Sol]`), chart chords and directives; never titles, lyrics or patterns. Throws what to
39
+ * write for a wrong naming (charts: a warning instead).
40
+ */
41
+ export declare function lettersInBlock(language: string, text: string): BlockReading;
42
+ /** A message with what the user wrote in place of what it was read as ("H dorian", not "B dorian"). */
43
+ export declare function quoteAsWritten(message: string, changes: readonly [string, string][]): string;
44
+ /** A note name (letters: "F#", "Bb", "E♭") in a naming: "Fa♯", "Si♭"; German "H", "B". */
45
+ export declare function noteInNaming(name: string, naming: Naming): string;
46
+ /** A chord symbol in a naming: solfège "Ré m7", "Do/Sol"; German "H7", "Bmaj7". Signs as written. */
47
+ export declare function chordInNaming(symbol: string, naming: Naming): string;
48
+ /**
49
+ * A generated text with its chords and notes in a naming: "Fretboard: A minor pentatonic" →
50
+ * "Fretboard: La minor pentatonic". A letter and 5, 6, 7 or 9 is a chord (`G7`) unless it stands
51
+ * among other notes with octaves (`C5 E5 G5`); a CAGED shape keeps its letter (`E shape`); a lone
52
+ * A before a word that isn't a scale or mode word stays (the English article).
53
+ */
54
+ export declare function shownText(text: string, naming: Naming): string;
55
+ /**
56
+ * Draws under a naming: what `shown` gives inside `draw`. `titles` written by hand are never
57
+ * rewritten (nor a name that starts with one). Letters again after, even on a throw.
58
+ */
59
+ export declare function withNaming<T>(naming: Naming, draw: () => T, titles?: readonly string[]): T;
60
+ /**
61
+ * A text as the drawing in progress shows it (letters outside `withNaming`). A title written by
62
+ * hand, or the start of a name that is one, stays as written.
63
+ */
64
+ export declare function shown(text: string): string;