@dsebastien/music-notation 0.9.0 → 0.10.1

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.
@@ -1,8 +1,3 @@
1
- /**
2
- * Blocks from a note's properties: an empty ```chord block in a chord note, or ```fretboard /
3
- * ```keyboard in a scale note, draws what the note's frontmatter says, so the body repeats nothing.
4
- * Used by Music Practice in Obsidian and by the Publish bundle with the page's properties.
5
- */
6
1
  /** Property names, as Music Practice and the Obsidian Starter Kit write them by default. */
7
2
  export interface PropertyNames {
8
3
  chordSymbol: string;
@@ -18,10 +13,24 @@ export interface PropertyNames {
18
13
  shape: string;
19
14
  fingeringRight: string;
20
15
  tags: string;
16
+ /** Strumming patterns: the pattern ("D DU UDU", or one bar per list item). */
17
+ strumPattern: string;
18
+ /** Strumming patterns: the time signature ("3/4", "6/8"). */
19
+ timeSignature: string;
20
+ /** Strumming patterns: the feel ("straight", "swing", "60%"). */
21
+ strumFeel: string;
22
+ /** The current BPM: a strumming pattern's tempo (20 to 240). */
23
+ bpmCurrent: string;
21
24
  }
22
25
  export declare const DEFAULT_PROPERTY_NAMES: PropertyNames;
23
26
  export type Instrument = 'guitar' | 'piano';
24
27
  type Properties = Record<string, unknown>;
28
+ /**
29
+ * The kind of a music note, from its type tag as Music Practice reads it: the last segment of
30
+ * `type/music/<subject>/<kind>` (or `type/music/<kind>`), lowercased: `arpeggio`, `chord`,
31
+ * `strum`. Null without such a tag.
32
+ */
33
+ export declare function kindOf(properties: Properties, names: PropertyNames): string | null;
25
34
  /** Piano when a tag has a `piano` segment (`type/music/piano/chord`), else guitar. */
26
35
  export declare function instrumentOf(properties: Properties, names: PropertyNames): Instrument;
27
36
  /**
@@ -12,7 +12,7 @@ export interface RenderOptions extends LayoutDefaults {
12
12
  /**
13
13
  * The note's properties (or a function of the block's element returning them, read at each
14
14
  * render, so a page can tell embeds from the note itself): an empty
15
- * `chord`, `fretboard` or `keyboard` block draws from them (see `blockFromProperties`).
15
+ * `chord`, `fretboard`, `keyboard` or `strum` block draws from them (see `blockFromProperties`).
16
16
  */
17
17
  properties?: Record<string, unknown> | ((el: Element) => Record<string, unknown> | null | undefined) | null;
18
18
  /** Property names, when they differ from the defaults. */
@@ -89,6 +89,17 @@ export declare function fingerVoicing(frets: readonly (number | null)[]): (strin
89
89
  * `isBarreVoicing` (an "E shape" held with a full barre is the E-shape barre chord).
90
90
  */
91
91
  export declare function voicingShape(frets: readonly (number | null)[], symbol: string, tuning?: readonly number[], _fingers?: readonly (string | null)[] | null): VoicingShape | null;
92
+ /**
93
+ * One voicing per shape: leaves out a voicing that is another one of the list with its highest
94
+ * strings muted (A x0222x and 57765x, copies of x02220 and 577655), then draws the rest up the neck (lowest
95
+ * fretted note; ties keep the list's order, the easiest first). `count` voicings are kept, the
96
+ * easiest ones, before they are put in neck order (#72).
97
+ */
98
+ export declare function distinctShapes<T extends {
99
+ frets: readonly (number | null)[];
100
+ }>(voicings: readonly T[], count?: number): T[];
101
+ /** Whether standard-tuning frets are one of the known jazz grips, at any fret (#72). */
102
+ export declare function isJazzGrip(frets: readonly (number | null)[]): boolean;
92
103
  /**
93
104
  * Every playable voicing of a chord, easiest first; empty when the chord is unknown or nothing
94
105
  * fits the options. See VoicingOptions for the filters.
@@ -24,6 +24,11 @@ export interface GuitarDiagramOptions {
24
24
  orientation?: Orientation;
25
25
  /** Left-handed: mirrored (the low string on the right, or the nut on the right). */
26
26
  hand?: Hand;
27
+ /**
28
+ * Fingers worked out for a voicing written without any (`fingerVoicing`): only its full
29
+ * barres are drawn from them (F 133211 keeps its bar); its dots stay without numbers (#73).
30
+ */
31
+ barreFingers?: readonly (string | null)[] | null;
27
32
  /** Text in each string's dot instead of its finger (intervals, note names); null for none. */
28
33
  labels?: (string | null)[];
29
34
  /** Chord transitions: fingers that stay (anchor) or slide (guide), per string. */
@@ -37,8 +37,9 @@ export interface Meter {
37
37
  * 0.4 of a column and with plain note values, then within a column (a tab written a column off),
38
38
  * then on a grid that falls on columns, with ties. A grid step is a column wide at least, and
39
39
  * equal gaps get equal lengths. The bar runs from `pad` (the dashes every bar starts with) to
40
- * its end, or `pad` columns less; when the first beat comes later, from its start too (a rest
41
- * first). Null when nothing fits (a sketch, not a rhythm).
40
+ * its end, or `pad` columns less; from fewer dashes than `pad` to its end (a bar that starts with
41
+ * a rest); when the first beat comes later, from its start too (a rest first). Null when nothing
42
+ * fits (a sketch, not a rhythm).
42
43
  */
43
44
  export declare function positionsOf(cols: number[], width: number, pad: number, meter?: Meter): number[] | null;
44
45
  /** A bar's events: a beat (its index) or a rest (-1), and its length in sixteenths. */
@@ -50,9 +51,13 @@ export type Rhythm = {
50
51
  * A bar's rhythm when no grid fits its columns (see positionsOf): the bar's most frequent gap
51
52
  * between beats is an eighth (a sixteenth when eighths overrun the bar), other gaps a whole number
52
53
  * of them (one at least), the last beat one, and rests fill the rest of the bar (4/4 unless
53
- * `meter` says). Every beat a sixteenth when even that is too long.
54
+ * `meter` says). Before eighths give way to sixteenths, the hammer-ons, pull-offs and slides
55
+ * (`legato`: the beats that lead on to the next one) take one eighth for both notes of the pair,
56
+ * a sixteenth each, as many pairs as the bar needs, first ones first (#71): the letter written
57
+ * between the two frets takes a column that isn't time. Every beat a sixteenth when even that is
58
+ * too long.
54
59
  */
55
- export declare function sketchRhythmOf(cols: number[], meter?: Meter): Rhythm;
60
+ export declare function sketchRhythmOf(cols: number[], meter?: Meter, legato?: readonly number[]): Rhythm;
56
61
  /**
57
62
  * alphaTex for a plain-text tab; null when no tab lines are found. String lines are mostly dashes
58
63
  * with a bar line or a name; one named line is enough, unnamed ones need three. A drum tab becomes