@dsebastien/music-notation 0.4.0 → 0.5.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.
- package/README.md +20 -2
- package/dist/blocks/block-source.d.ts +5 -0
- package/dist/blocks/renderers.d.ts +3 -0
- package/dist/chord/guitar.d.ts +4 -0
- package/dist/chord/transitions.d.ts +46 -0
- package/dist/chord/triads.d.ts +43 -0
- package/dist/convert/chord-sheet.d.ts +2 -0
- package/dist/convert/text-tab.d.ts +5 -0
- package/dist/fretboard/fretboard.d.ts +2 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1269 -24
- package/dist/index.js.map +16 -10
- package/dist/keyboard/keyboard.d.ts +2 -0
- package/dist/music-notation.css +216 -0
- package/dist/music-notation.publish.min.js +239 -13
- package/dist/music-notation.tab.min.js +527 -0
- package/dist/playback/controls.d.ts +21 -0
- package/dist/playback/player.d.ts +50 -0
- package/dist/publish/auto.d.ts +3 -0
- package/dist/publish/index.js +881 -24
- package/dist/publish/index.js.map +14 -10
- package/dist/tab/auto.d.ts +16 -0
- package/dist/tab/index.d.ts +97 -0
- package/dist/tab/index.js +1043 -0
- package/dist/tab/index.js.map +19 -0
- package/package.json +21 -2
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ labels: intervals
|
|
|
37
37
|
```
|
|
38
38
|
````
|
|
39
39
|
|
|
40
|
-
Chords in words or recognized from their frets, every way to play a chord, scale positions and modes:
|
|
40
|
+
Chords in words or recognized from their frets, every way to play a chord, triads, chord transitions, scale positions and modes:
|
|
41
41
|
|
|
42
42
|
````markdown
|
|
43
43
|
```chord
|
|
@@ -51,6 +51,16 @@ A Major
|
|
|
51
51
|
voicings: 6
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
+
```chord
|
|
55
|
+
G
|
|
56
|
+
triads: 1-3
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```chord
|
|
60
|
+
from: C x32010
|
|
61
|
+
to: Am
|
|
62
|
+
```
|
|
63
|
+
|
|
54
64
|
```fretboard
|
|
55
65
|
A minor pentatonic
|
|
56
66
|
positions: all
|
|
@@ -61,6 +71,12 @@ modes: C major
|
|
|
61
71
|
```
|
|
62
72
|
````
|
|
63
73
|
|
|
74
|
+

|
|
75
|
+
|
|
76
|
+

|
|
77
|
+
|
|
78
|
+

|
|
79
|
+
|
|
64
80
|
Several diagrams side by side, separated by `---`, with shared settings first; vertical or horizontal, and left-handed:
|
|
65
81
|
|
|
66
82
|
````markdown
|
|
@@ -93,6 +109,8 @@ if (!result.ok) console.warn(result.error)
|
|
|
93
109
|
|
|
94
110
|
- `renderBlock(language, source, host, options)` appends the rendering to `host` and never throws. It returns `{ ok, el, error, destroy() }`.
|
|
95
111
|
- `@dsebastien/music-notation/voicings` adds about 1,800 guitar voicings, found by chord symbol (`chord` blocks with only a symbol). It's a separate entry point because the data weighs about 230 KB.
|
|
112
|
+
- **Hear the diagrams**: with the `play` option, a playback bar on each diagram (on hover): chords strum, scales go up and down, a click plays a note.
|
|
113
|
+
- **Tabs and scores**: `@dsebastien/music-notation/tab` draws `tab and `score blocks (alphaTex, or Guitar Pro and MusicXML files) with [alphaTab](https://alphatab.net), with a player; it also converts score files, text tabs and chord sheets, and exports Guitar Pro 7 and MIDI.
|
|
96
114
|
- `generateVoicings(symbol, options)` finds every playable voicing of a chord on any tuning, easiest first, with fingers and shape names; `fingerVoicing(frets)` fingers any voicing.
|
|
97
115
|
- The renderers (`renderGuitarDiagram`, `renderKeyboard`, `renderFretboard`, `renderChart`), the parsers and the theory helpers (`parseChord`, `transposeChord`, `chordNoteSet`, `scaleNoteSet`…) are exported too.
|
|
98
116
|
- Styles: `injectStyles(document)`, or ship `@dsebastien/music-notation/music-notation.css`. Colors follow Obsidian's theme variables, with fallbacks for any page.
|
|
@@ -103,7 +121,7 @@ Add this to your site's `publish.js`. It loads the bundle only on pages that hav
|
|
|
103
121
|
|
|
104
122
|
```js
|
|
105
123
|
;(() => {
|
|
106
|
-
const VERSION = '0.
|
|
124
|
+
const VERSION = '0.4.0'
|
|
107
125
|
const SELECTOR = ['chord', 'chords', 'keyboard', 'fretboard']
|
|
108
126
|
.map((l) => `pre > code.language-${l}`)
|
|
109
127
|
.join(', ')
|
|
@@ -10,6 +10,11 @@ export interface BlockSource {
|
|
|
10
10
|
export declare function parseBlockSource(source: string): BlockSource;
|
|
11
11
|
/** "5-8", "5", "0 - 12" → [from, to]; null when invalid. */
|
|
12
12
|
export declare function parseRange(text: string): [number, number] | null;
|
|
13
|
+
/**
|
|
14
|
+
* String numbers the way guitarists count them (1 = the highest): "1-3", "1 2 3", "2,4". Throws a
|
|
15
|
+
* message for the user when one is outside 1..count.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseStrings(text: string, count: number): number[];
|
|
13
18
|
/**
|
|
14
19
|
* The parts of a block whose diagrams are separated by `---` lines, without the empty ones;
|
|
15
20
|
* null when the block has no separator.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { VoicingLookup } from '../voicings/index.js';
|
|
2
|
+
import type { PlayOptions } from '../playback/controls.js';
|
|
2
3
|
import { type LayoutDefaults } from '../render/layout.js';
|
|
3
4
|
import { type BlockSource } from './block-source.js';
|
|
4
5
|
import type { Instrument, PropertyNames } from './properties.js';
|
|
@@ -17,6 +18,8 @@ export interface RenderOptions extends LayoutDefaults {
|
|
|
17
18
|
propertyNames?: Partial<PropertyNames>;
|
|
18
19
|
/** The note's instrument; from its tags when absent. */
|
|
19
20
|
instrument?: Instrument;
|
|
21
|
+
/** A playback bar on chord, keyboard and fretboard diagrams (true for the defaults). */
|
|
22
|
+
play?: boolean | PlayOptions;
|
|
20
23
|
}
|
|
21
24
|
export type Renderer = (doc: Document, source: string, options: RenderOptions) => Element;
|
|
22
25
|
/** Renders one diagram from a parsed block (the parts of a row share settings, see renderBlock). */
|
package/dist/chord/guitar.d.ts
CHANGED
|
@@ -19,6 +19,10 @@ export interface GuitarDiagramOptions {
|
|
|
19
19
|
orientation?: Orientation;
|
|
20
20
|
/** Left-handed: mirrored (the low string on the right, or the nut on the right). */
|
|
21
21
|
hand?: Hand;
|
|
22
|
+
/** Text in each string's dot instead of its finger (intervals, note names); null for none. */
|
|
23
|
+
labels?: (string | null)[];
|
|
24
|
+
/** Chord transitions: fingers that stay (anchor) or slide (guide), per string. */
|
|
25
|
+
marks?: ('anchor' | 'guide' | null)[];
|
|
22
26
|
}
|
|
23
27
|
/** "x02220", "x-10-12-12-11-10", "x 10 12 12 11 10" → frets; null when invalid. */
|
|
24
28
|
export declare function parseFrets(text: string): (number | null)[] | null;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chord transitions (#21): which voicing of the next chord the hand reaches most easily from the
|
|
3
|
+
* one it holds, and the voicings of a whole progression with the least movement. Fingers that stay
|
|
4
|
+
* on their fret (anchors) and slide along their string (guides) make changes clean.
|
|
5
|
+
*/
|
|
6
|
+
import { type GeneratedVoicing } from './generate.js';
|
|
7
|
+
export interface TransitionStep {
|
|
8
|
+
voicing: GeneratedVoicing;
|
|
9
|
+
/** Strings (indexes, lowest first) whose finger stays on the same fret. */
|
|
10
|
+
anchors: number[];
|
|
11
|
+
/** Strings whose finger slides along the string to another fret. */
|
|
12
|
+
guides: number[];
|
|
13
|
+
/** Frets the hand moves along the neck (between the lowest fretted notes). */
|
|
14
|
+
shift: number;
|
|
15
|
+
/** How much the hand moves: fingers lifted and placed, slides, the shift. Lower is easier. */
|
|
16
|
+
movement: number;
|
|
17
|
+
/** What to do, in plain words. */
|
|
18
|
+
tips: string[];
|
|
19
|
+
}
|
|
20
|
+
export interface TransitionOptions {
|
|
21
|
+
/** Open-string pitches (MIDI), lowest string first; standard guitar by default. */
|
|
22
|
+
tuning?: number[];
|
|
23
|
+
/** The fingers of the voicing held (worked out when absent). */
|
|
24
|
+
fromFingers?: (string | null)[];
|
|
25
|
+
/** How many of the next chord's easiest voicings to consider (30 by default). */
|
|
26
|
+
candidates?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The next chord's voicings, ranked by how easily the hand gets there from the one it holds:
|
|
30
|
+
* anchors and guides first, then a small move, then an easy shape. Empty when the chord is
|
|
31
|
+
* unknown.
|
|
32
|
+
*/
|
|
33
|
+
export declare function transition(from: readonly (number | null)[], toChord: string, options?: TransitionOptions): TransitionStep[];
|
|
34
|
+
export interface ProgressionStep extends Partial<Omit<TransitionStep, 'voicing'>> {
|
|
35
|
+
chord: string;
|
|
36
|
+
voicing: GeneratedVoicing;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The voicing of each chord that makes the whole progression easiest: the shapes' ease and the
|
|
40
|
+
* moves between them, together (each chord's easiest 12 voicings are weighed). The first step has
|
|
41
|
+
* no move. Empty when a chord is unknown.
|
|
42
|
+
*/
|
|
43
|
+
export declare function smoothProgression(chords: readonly string[], options?: {
|
|
44
|
+
tuning?: number[];
|
|
45
|
+
candidates?: number;
|
|
46
|
+
}): ProgressionStep[];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type GeneratedVoicing } from './generate.js';
|
|
2
|
+
export interface Triad extends GeneratedVoicing {
|
|
3
|
+
/** 0 root position, 1 first inversion (third in the bass), 2 second (fifth in the bass). */
|
|
4
|
+
inversion: number;
|
|
5
|
+
/** The chord tone on top, as triad charts say it: R, 3, b3, 5… */
|
|
6
|
+
top: string;
|
|
7
|
+
}
|
|
8
|
+
export interface TriadOptions {
|
|
9
|
+
/** Three adjacent strings (1 = the highest): [1, 2, 3], [2, 3, 4]… */
|
|
10
|
+
strings: number[];
|
|
11
|
+
/** One inversion (0, 1, 2) or all of them (the default). */
|
|
12
|
+
inversion?: number | 'any';
|
|
13
|
+
/** Open-string pitches (MIDI), lowest string first; standard guitar by default. */
|
|
14
|
+
tuning?: number[];
|
|
15
|
+
/** The highest fret used, 15 by default. */
|
|
16
|
+
maxFret?: number;
|
|
17
|
+
}
|
|
18
|
+
/** The inversion's name: "root position", "1st inversion", "2nd inversion". */
|
|
19
|
+
export declare const inversionName: (inversion: number) => string;
|
|
20
|
+
/**
|
|
21
|
+
* Close triads (the three notes within four frets) of a three-note chord (major, minor, diminished, augmented, sus) on a string set,
|
|
22
|
+
* up the neck (then root position first). Empty for other chords or a string set that isn't three
|
|
23
|
+
* adjacent strings.
|
|
24
|
+
*/
|
|
25
|
+
export declare function triadVoicings(symbol: string, options: TriadOptions): Triad[];
|
|
26
|
+
export interface KeyTriad {
|
|
27
|
+
/** "I", "ii", "iii", "IV", "V", "vi", "vii°". */
|
|
28
|
+
numeral: string;
|
|
29
|
+
symbol: string;
|
|
30
|
+
triad: Triad;
|
|
31
|
+
}
|
|
32
|
+
/** "G major", "E minor" (natural minor): the tonic and the mode; null otherwise. */
|
|
33
|
+
export declare function parseKey(text: string): {
|
|
34
|
+
tonic: string;
|
|
35
|
+
minor: boolean;
|
|
36
|
+
} | null;
|
|
37
|
+
/**
|
|
38
|
+
* A key's seven triads on a string set, one inversion, moving up the neck: each one at or above
|
|
39
|
+
* the previous one when it can be. Null when the key can't be read.
|
|
40
|
+
*/
|
|
41
|
+
export declare function keyTriads(key: string, options: Omit<TriadOptions, 'inversion'> & {
|
|
42
|
+
inversion?: number;
|
|
43
|
+
}): KeyTriad[] | null;
|
|
@@ -15,5 +15,7 @@ export interface FretboardOptions {
|
|
|
15
15
|
/** Only these notes (a scale position); the frets shown follow them. */
|
|
16
16
|
cells?: Cell[];
|
|
17
17
|
marks?: NoteMarks;
|
|
18
|
+
/** Only notes on these strings (indexes, lowest first): triads on a string set. */
|
|
19
|
+
strings?: number[];
|
|
18
20
|
}
|
|
19
21
|
export declare function renderFretboard(doc: Document, set: NoteSet, options?: FretboardOptions): SVGElement;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,10 @@ export type { RenderOptions, NotationLanguage } from './blocks/renderers.js';
|
|
|
4
4
|
export { STYLES, injectStyles } from './styles.js';
|
|
5
5
|
export { renderGuitarDiagram, parseFrets, parseFingers, baseFretOf, STANDARD_TUNING, type FrettedVoicing, type GuitarDiagramOptions } from './chord/guitar.js';
|
|
6
6
|
export { generateVoicings, fingerVoicing, voicingShape, MAX_GENERATED_STRINGS, type GeneratedVoicing, type VoicingOptions, type VoicingShape } from './chord/generate.js';
|
|
7
|
+
export { sequenceOf, lengthOf, lightPlayer, pluckedString, pianoTone, DEFAULT_SEQUENCE, type NoteEvent, type NotePlayer, type PlayHandle, type PlayKind, type Sound, type SequenceOptions } from './playback/player.js';
|
|
8
|
+
export { attachPlayback, type PlayOptions } from './playback/controls.js';
|
|
9
|
+
export { transition, smoothProgression, type TransitionStep, type TransitionOptions, type ProgressionStep } from './chord/transitions.js';
|
|
10
|
+
export { triadVoicings, keyTriads, parseKey, inversionName, type Triad, type TriadOptions, type KeyTriad } from './chord/triads.js';
|
|
7
11
|
export { renderKeyboard, parseKeyRange, keyRangeOf, type KeyboardOptions } from './keyboard/keyboard.js';
|
|
8
12
|
export { renderFretboard, type FretboardOptions } from './fretboard/fretboard.js';
|
|
9
13
|
export { parseTuning } from './fretboard/tuning.js';
|
|
@@ -19,3 +23,5 @@ export { detectChordFromFrets, detectChordFromPitches, type DetectedChord } from
|
|
|
19
23
|
export { scaleName, modesOf, scaleTypes, characteristicIntervals, isScaleWithoutRoot } from './theory/scales.js';
|
|
20
24
|
export { scalePosition, positionCount, CAGED_SHAPES, type Cell, type PositionSystem } from './fretboard/positions.js';
|
|
21
25
|
export { blockFromProperties, instrumentOf, DEFAULT_PROPERTY_NAMES, type PropertyNames, type Instrument } from './blocks/properties.js';
|
|
26
|
+
export { textTabToAlphaTex } from './convert/text-tab.js';
|
|
27
|
+
export { chordSheetToChordPro } from './convert/chord-sheet.js';
|