@dsebastien/music-notation 0.1.2 → 0.2.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 +14 -6
- package/dist/blocks/block-source.d.ts +5 -0
- package/dist/blocks/renderers.d.ts +11 -1
- package/dist/chord/guitar.d.ts +5 -0
- package/dist/fretboard/fretboard.d.ts +5 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1603 -1
- package/dist/index.js.map +21 -3
- package/dist/keyboard/keyboard.d.ts +3 -0
- package/dist/music-notation.css +80 -0
- package/dist/music-notation.publish.min.js +84 -3
- package/dist/publish/auto.d.ts +2 -0
- package/dist/publish/index.js +450 -167
- package/dist/publish/index.js.map +13 -10
- package/dist/render/dom.d.ts +4 -0
- package/dist/render/layout.d.ts +57 -0
- package/dist/render/render-block.d.ts +4 -2
- package/dist/voicings/index.js +80 -6
- package/dist/voicings/index.js.map +6 -4
- package/package.json +2 -2
- package/dist/chunks/index-26cddyf5.js +0 -82
- package/dist/chunks/index-26cddyf5.js.map +0 -11
package/README.md
CHANGED
|
@@ -37,6 +37,19 @@ labels: intervals
|
|
|
37
37
|
```
|
|
38
38
|
````
|
|
39
39
|
|
|
40
|
+
Several diagrams side by side, separated by `---`, with shared settings first; vertical or horizontal, and left-handed:
|
|
41
|
+
|
|
42
|
+
````markdown
|
|
43
|
+
```chord
|
|
44
|
+
orientation: horizontal
|
|
45
|
+
hand: left
|
|
46
|
+
---
|
|
47
|
+
G 320003 210003
|
|
48
|
+
---
|
|
49
|
+
C x32010 x32010
|
|
50
|
+
```
|
|
51
|
+
````
|
|
52
|
+
|
|
40
53
|
The full syntax is in the [guide](https://dsebastien.github.io/music-notation/), with [live examples](https://dsebastien.github.io/music-notation/examples.html) and a [playground](https://dsebastien.github.io/music-notation/playground.html). Mistakes show an inline message and leave the source untouched.
|
|
41
54
|
|
|
42
55
|
## Install
|
|
@@ -55,7 +68,7 @@ if (!result.ok) console.warn(result.error)
|
|
|
55
68
|
```
|
|
56
69
|
|
|
57
70
|
- `renderBlock(language, source, host, options)` appends the rendering to `host` and never throws. It returns `{ ok, el, error, destroy() }`.
|
|
58
|
-
- `@dsebastien/music-notation/voicings` adds about
|
|
71
|
+
- `@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.
|
|
59
72
|
- The renderers (`renderGuitarDiagram`, `renderKeyboard`, `renderFretboard`, `renderChart`), the parsers and the theory helpers (`parseChord`, `transposeChord`, `chordNoteSet`, `scaleNoteSet`…) are exported too.
|
|
60
73
|
- Styles: `injectStyles(document)`, or ship `@dsebastien/music-notation/music-notation.css`. Colors follow Obsidian's theme variables, with fallbacks for any page.
|
|
61
74
|
|
|
@@ -84,11 +97,6 @@ Add this to your site's `publish.js`. It loads the bundle only on pages that hav
|
|
|
84
97
|
|
|
85
98
|
The bundle renders every block, now and as you navigate, and hides a block's source only once it rendered.
|
|
86
99
|
|
|
87
|
-
## Roadmap
|
|
88
|
-
|
|
89
|
-
- 0.1: chord diagrams (guitar, piano), keyboards, fretboards, ChordPro charts, the Publish bundle.
|
|
90
|
-
- 0.2: tabs and scores (alphaTab) with playback, imports (Guitar Pro, MusicXML, text tabs, chords over lyrics).
|
|
91
|
-
|
|
92
100
|
## Credits and licenses
|
|
93
101
|
|
|
94
102
|
MIT. Built on [tonal](https://github.com/tonaljs/tonal) (MIT) for music theory and [chords-db](https://github.com/tombatossals/chords-db) (MIT) for guitar voicings.
|
|
@@ -10,3 +10,8 @@ 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
|
+
* The parts of a block whose diagrams are separated by `---` lines, without the empty ones;
|
|
15
|
+
* null when the block has no separator.
|
|
16
|
+
*/
|
|
17
|
+
export declare function splitParts(source: string): string[] | null;
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import type { VoicingLookup } from '../voicings/index.js';
|
|
2
|
-
|
|
2
|
+
import { type LayoutDefaults } from '../render/layout.js';
|
|
3
|
+
import { type BlockSource } from './block-source.js';
|
|
4
|
+
export interface RenderOptions extends LayoutDefaults {
|
|
3
5
|
/** Finds guitar voicings for chord blocks that only give a symbol (see `/voicings`). */
|
|
4
6
|
voicings?: VoicingLookup;
|
|
5
7
|
/** Semitones to transpose chord charts by. */
|
|
6
8
|
transpose?: number;
|
|
7
9
|
}
|
|
8
10
|
export type Renderer = (doc: Document, source: string, options: RenderOptions) => Element;
|
|
11
|
+
/** Renders one diagram from a parsed block (the parts of a row share settings, see renderBlock). */
|
|
12
|
+
export type DiagramRenderer = (doc: Document, block: BlockSource, options: RenderOptions) => Element;
|
|
13
|
+
/** Languages that draw diagrams, and so can hold several of them (separated by `---`). */
|
|
14
|
+
export type DiagramLanguage = 'chord' | 'keyboard' | 'fretboard';
|
|
15
|
+
/** Keys a row's shared settings may hold, per language (plus `columns`, for the row itself). */
|
|
16
|
+
export declare const SHARED_KEYS: Record<DiagramLanguage, readonly string[]>;
|
|
17
|
+
/** Diagram languages and their renderers. */
|
|
18
|
+
export declare const DIAGRAMS: Record<DiagramLanguage, DiagramRenderer>;
|
|
9
19
|
/** Block languages (code fence names) and their renderers. */
|
|
10
20
|
export declare const RENDERERS: {
|
|
11
21
|
chord: Renderer;
|
package/dist/chord/guitar.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Hand, type Orientation } from '../render/layout.js';
|
|
1
2
|
/** Standard tuning, lowest string first. */
|
|
2
3
|
export declare const STANDARD_TUNING: number[];
|
|
3
4
|
export interface FrettedVoicing {
|
|
@@ -14,6 +15,10 @@ export interface GuitarDiagramOptions {
|
|
|
14
15
|
root?: number | null;
|
|
15
16
|
/** Open-string pitches (MIDI), lowest first. */
|
|
16
17
|
tuning?: number[];
|
|
18
|
+
/** Vertical (default): the nut on top. Horizontal: the high string on top, the nut on the left. */
|
|
19
|
+
orientation?: Orientation;
|
|
20
|
+
/** Left-handed: mirrored (the low string on the right, or the nut on the right). */
|
|
21
|
+
hand?: Hand;
|
|
17
22
|
}
|
|
18
23
|
/** "x02220", "x-10-12-12-11-10", "x 10 12 12 11 10" → frets; null when invalid. */
|
|
19
24
|
export declare function parseFrets(text: string): (number | null)[] | null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Hand, type Orientation } from '../render/layout.js';
|
|
1
2
|
import { type NoteLabel, type NoteSet } from '../theory/note-set.js';
|
|
2
3
|
export interface FretboardOptions {
|
|
3
4
|
/** Open-string pitches (MIDI), lowest string first. */
|
|
@@ -6,5 +7,9 @@ export interface FretboardOptions {
|
|
|
6
7
|
frets?: [number, number];
|
|
7
8
|
label?: NoteLabel;
|
|
8
9
|
title?: string;
|
|
10
|
+
/** Horizontal (default) or vertical. */
|
|
11
|
+
orientation?: Orientation;
|
|
12
|
+
/** Left-handed: mirrored (the nut on the right, or the low string on the right). */
|
|
13
|
+
hand?: Hand;
|
|
9
14
|
}
|
|
10
15
|
export declare function renderFretboard(doc: Document, set: NoteSet, options?: FretboardOptions): SVGElement;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { renderBlock, LANGUAGES, isNotationLanguage, type RenderResult } from './render/render-block.js';
|
|
1
|
+
export { renderBlock, LANGUAGES, isNotationLanguage, MAX_DIAGRAMS, type RenderResult } from './render/render-block.js';
|
|
2
|
+
export { parseOrientation, parseHand, layoutDefaults, type Orientation, type Hand, type LayoutDefaults } from './render/layout.js';
|
|
2
3
|
export type { RenderOptions, NotationLanguage } from './blocks/renderers.js';
|
|
3
4
|
export { STYLES, injectStyles } from './styles.js';
|
|
4
5
|
export { renderGuitarDiagram, parseFrets, parseFingers, baseFretOf, STANDARD_TUNING, type FrettedVoicing, type GuitarDiagramOptions } from './chord/guitar.js';
|