@dsebastien/music-notation 0.18.1 → 0.19.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.
package/README.md CHANGED
@@ -162,12 +162,17 @@ if (!result.ok) console.warn(result.error)
162
162
  - **Strumming patterns**: `strum` blocks draw a pattern (`D DU UDU`, `D - D U - U D U`) on a beat grid with counts, accents, muted and ghost strums and chord changes; with playback on, they play over their chords, with loop, tempo and a count-in. `playStrum(pattern, { bpm, chord, tuning })` plays one from code.
163
163
  - **Practice in time**: `progression` blocks and ChordPro charts get a bar that plays their chords in time, one chord a bar (or as a chart's bar lines say), with a metronome click, a count-in and a loop. Each chord is strummed on the beats, once a bar, as an arpeggio or to a strumming pattern, and the chord playing lights up. `playProgression(chords, { bpm, strum, pattern, click, countIn, loop })` does it from code, with your own player.
164
164
  - **Harmonize a scale**: a `progression` block with `harmonize: triads`, `sevenths`, `sus` or `power` and any 7-note scale as its `key:` (`A harmonic minor`, `D dorian`) draws the chord on each degree with its numeral and a diagram, ready to play in time. `harmonize(scale, { kind })` gives the same chords from code.
165
+ - **Capo**: a capo bar on any guitar chord or fretboard, with the chord it sounds in the caption (`sounds: yes`) or in the title (`sounds: title`: an Em shape with `capo: 3` is "Gm (Em shape)").
166
+ - **Fingering in words**: `caption: fingering` writes how to play a chord under its diagram, in `chord` and `progression` blocks (guitar and piano).
167
+ - **Formulas**: `caption: formula` writes a chord's notes, formula (1 b3 5 b7), quality in words and other symbols, or a scale's notes, formula and steps (W W H), under chord diagrams, keyboards and fretboards (`chordFormula`, `scaleFormula`).
168
+ - **Accessible diagrams**: every diagram has a description for screen readers (the fingering in words, the keys, the notes on each string), and `root-mark: shape` (or the `rootMark` option) draws the root as a shape too, not only a color.
165
169
  - **Fingerpicking patterns**: `picking` blocks draw a pattern in PIMA letters (p, p' for the alternate bass, i, m, a) or string numbers as a small tab, over a chord or a progression, and play it in time. Travis, alternate bass and 1-2-3-4 come by name. `playPicking(pattern, { chord, chords, bpm })` plays one from code.
166
170
  - **Tabs and scores**: `@dsebastien/music-notation/tab` draws `tab` and `score` blocks (alphaTex, or Guitar Pro and MusicXML files) with [alphaTab](https://alphatab.net), and adds a player. It also converts score files, text tabs and chord sheets, and exports Guitar Pro 7 and MIDI.
167
171
  - `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. `fingeringInWords(chord)` writes a guitar or piano chord's fingering in plain sentences, as `caption: fingering` shows it under a diagram.
168
172
  - The renderers (`renderGuitarDiagram`, `renderKeyboard`, `renderFretboard`, `renderChart`, `renderStrum`, `renderPicking`, `renderCircle`), the parsers and the theory helpers (`parseChord`, `transposeChord`, `chordNoteSet`, `scaleNoteSet`…) are exported too.
169
173
  - Note names in solfège (Do Ré Mi) or German (H for B): `naming: solfege` or `naming: german` in a block, or as an option; notes may be written in any of the three systems.
170
174
  - A pick layer for drills: with `pick`, every string × fret of a fretboard and every key of a keyboard is a target that a click or the keyboard picks; the app marks picks right or wrong (`attachPick`).
175
+ - **Export as images**: `toSvgString(el)` and `toPng(el)` give a standalone SVG or a PNG of a diagram or a whole block (titles and captions included, every style inlined), in the page's colors or a light or dark theme; the picture button on each bar copies the selected diagram to the clipboard (Shift: the whole block), also with playback off (`copy: false` leaves it out).
171
176
  - Styles: `injectStyles(document)`, or ship `@dsebastien/music-notation/music-notation.css`. Colors follow Obsidian's theme variables, with fallbacks for any page.
172
177
 
173
178
  ## Check your notes
@@ -186,7 +191,7 @@ Add this to your site's `publish.js`. It loads the bundle only on pages that hav
186
191
 
187
192
  ```js
188
193
  ;(() => {
189
- const VERSION = '0.18.1'
194
+ const VERSION = '0.19.0'
190
195
  const CDN = `https://cdn.jsdelivr.net/npm/@dsebastien/music-notation@${VERSION}/dist`
191
196
  const selector = (languages) => languages.map((l) => `pre > code.language-${l}`).join(', ')
192
197
  const BLOCKS = selector([
@@ -56,33 +56,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
56
56
  SOFTWARE.
57
57
  ```
58
58
 
59
- ## @acemir/cssom
60
-
61
- Shipped in: cli.js
62
-
63
- ```
64
- Copyright (c) Nikita Vasilyev
65
-
66
- Permission is hereby granted, free of charge, to any person obtaining
67
- a copy of this software and associated documentation files (the
68
- "Software"), to deal in the Software without restriction, including
69
- without limitation the rights to use, copy, modify, merge, publish,
70
- distribute, sublicense, and/or sell copies of the Software, and to
71
- permit persons to whom the Software is furnished to do so, subject to
72
- the following conditions:
73
-
74
- The above copyright notice and this permission notice shall be
75
- included in all copies or substantial portions of the Software.
76
-
77
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
78
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
79
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
80
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
81
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
82
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
83
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
84
- ```
85
-
86
59
  ## boolbase
87
60
 
88
61
  Shipped in: cli.js
@@ -139,6 +112,214 @@ THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRE
139
112
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
140
113
  ```
141
114
 
115
+ ## cssomnom
116
+
117
+ Shipped in: cli.js
118
+
119
+ ```
120
+ Apache License
121
+ Version 2.0, January 2004
122
+ http://www.apache.org/licenses/
123
+
124
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
125
+
126
+ 1. Definitions.
127
+
128
+ "License" shall mean the terms and conditions for use, reproduction,
129
+ and distribution as defined by Sections 1 through 9 of this document.
130
+
131
+ "Licensor" shall mean the copyright owner or entity authorized by
132
+ the copyright owner that is granting the License.
133
+
134
+ "Legal Entity" shall mean the union of the acting entity and all
135
+ other entities that control, are controlled by, or are under common
136
+ control with that entity. For the purposes of this definition,
137
+ "control" means (i) the power, direct or indirect, to cause the
138
+ direction or management of such entity, whether by contract or
139
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
140
+ outstanding shares, or (iii) beneficial ownership of such entity.
141
+
142
+ "You" (or "Your") shall mean an individual or Legal Entity
143
+ exercising permissions granted by this License.
144
+
145
+ "Source" form shall mean the preferred form for making modifications,
146
+ including but not limited to software source code, documentation
147
+ source, and configuration files.
148
+
149
+ "Object" form shall mean any form resulting from mechanical
150
+ transformation or translation of a Source form, including but
151
+ not limited to compiled object code, generated documentation,
152
+ and conversions to other media types.
153
+
154
+ "Work" shall mean the work of authorship, whether in Source or
155
+ Object form, made available under the License, as indicated by a
156
+ copyright notice that is included in or attached to the work
157
+ (an example is provided in the Appendix below).
158
+
159
+ "Derivative Works" shall mean any work, whether in Source or Object
160
+ form, that is based on (or derived from) the Work and for which the
161
+ editorial revisions, annotations, elaborations, or other modifications
162
+ represent, as a whole, an original work of authorship. For the purposes
163
+ of this License, Derivative Works shall not include works that remain
164
+ separable from, or merely link (or bind by name) to the interfaces of,
165
+ the Work and Derivative Works thereof.
166
+
167
+ "Contribution" shall mean any work of authorship, including
168
+ the original version of the Work and any modifications or additions
169
+ to that Work or Derivative Works thereof, that is intentionally
170
+ submitted to Licensor for inclusion in the Work by the copyright owner
171
+ or by an individual or Legal Entity authorized to submit on behalf of
172
+ the copyright owner. For the purposes of this definition, "submitted"
173
+ means any form of electronic, verbal, or written communication sent
174
+ to the Licensor or its representatives, including but not limited to
175
+ communication on electronic mailing lists, source code control systems,
176
+ and issue tracking systems that are managed by, or on behalf of, the
177
+ Licensor for the purpose of discussing and improving the Work, but
178
+ excluding communication that is conspicuously marked or otherwise
179
+ designated in writing by the copyright owner as "Not a Contribution."
180
+
181
+ "Contributor" shall mean Licensor and any individual or Legal Entity
182
+ on behalf of whom a Contribution has been received by Licensor and
183
+ subsequently incorporated within the Work.
184
+
185
+ 2. Grant of Copyright License. Subject to the terms and conditions of
186
+ this License, each Contributor hereby grants to You a perpetual,
187
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
188
+ copyright license to reproduce, prepare Derivative Works of,
189
+ publicly display, publicly perform, sublicense, and distribute the
190
+ Work and such Derivative Works in Source or Object form.
191
+
192
+ 3. Grant of Patent License. Subject to the terms and conditions of
193
+ this License, each Contributor hereby grants to You a perpetual,
194
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
195
+ (except as stated in this section) patent license to make, have made,
196
+ use, offer to sell, sell, import, and otherwise transfer the Work,
197
+ where such license applies only to those patent claims licensable
198
+ by such Contributor that are necessarily infringed by their
199
+ Contribution(s) alone or by combination of their Contribution(s)
200
+ with the Work to which such Contribution(s) was submitted. If You
201
+ institute patent litigation against any entity (including a
202
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
203
+ or a Contribution incorporated within the Work constitutes direct
204
+ or contributory patent infringement, then any patent licenses
205
+ granted to You under this License for that Work shall terminate
206
+ as of the date such litigation is filed.
207
+
208
+ 4. Redistribution. You may reproduce and distribute copies of the
209
+ Work or Derivative Works thereof in any medium, with or without
210
+ modifications, and in Source or Object form, provided that You
211
+ meet the following conditions:
212
+
213
+ (a) You must give any other recipients of the Work or
214
+ Derivative Works a copy of this License; and
215
+
216
+ (b) You must cause any modified files to carry prominent notices
217
+ stating that You changed the files; and
218
+
219
+ (c) You must retain, in the Source form of any Derivative Works
220
+ that You distribute, all copyright, patent, trademark, and
221
+ attribution notices from the Source form of the Work,
222
+ excluding those notices that do not pertain to any part of
223
+ the Derivative Works; and
224
+
225
+ (d) If the Work includes a "NOTICE" text file as part of its
226
+ distribution, then any Derivative Works that You distribute must
227
+ include a readable copy of the attribution notices contained
228
+ within such NOTICE file, excluding those notices that do not
229
+ pertain to any part of the Derivative Works, in at least one
230
+ of the following places: within a NOTICE text file distributed
231
+ as part of the Derivative Works; within the Source form or
232
+ documentation, if provided along with the Derivative Works; or,
233
+ within a display generated by the Derivative Works, if and
234
+ wherever such third-party notices normally appear. The contents
235
+ of the NOTICE file are for informational purposes only and
236
+ do not modify the License. You may add Your own attribution
237
+ notices within Derivative Works that You distribute, alongside
238
+ or as an addendum to the NOTICE text from the Work, provided
239
+ that such additional attribution notices cannot be construed
240
+ as modifying the License.
241
+
242
+ You may add Your own copyright statement to Your modifications and
243
+ may provide additional or different license terms and conditions
244
+ for use, reproduction, or distribution of Your modifications, or
245
+ for any such Derivative Works as a whole, provided Your use,
246
+ reproduction, and distribution of the Work otherwise complies with
247
+ the conditions stated in this License.
248
+
249
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
250
+ any Contribution intentionally submitted for inclusion in the Work
251
+ by You to the Licensor shall be under the terms and conditions of
252
+ this License, without any additional terms or conditions.
253
+ Notwithstanding the above, nothing herein shall supersede or modify
254
+ the terms of any separate license agreement you may have executed
255
+ with Licensor regarding such Contributions.
256
+
257
+ 6. Trademarks. This License does not grant permission to use the trade
258
+ names, trademarks, service marks, or product names of the Licensor,
259
+ except as required for reasonable and customary use in describing the
260
+ origin of the Work and reproducing the content of the NOTICE file.
261
+
262
+ 7. Disclaimer of Warranty. Unless required by applicable law or
263
+ agreed to in writing, Licensor provides the Work (and each
264
+ Contributor provides its Contributions) on an "AS IS" BASIS,
265
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
266
+ implied, including, without limitation, any warranties or conditions
267
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
268
+ PARTICULAR PURPOSE. You are solely responsible for determining the
269
+ appropriateness of using or redistributing the Work and assume any
270
+ risks associated with Your exercise of permissions under this License.
271
+
272
+ 8. Limitation of Liability. In no event and under no legal theory,
273
+ whether in tort (including negligence), contract, or otherwise,
274
+ unless required by applicable law (such as deliberate and grossly
275
+ negligent acts) or agreed to in writing, shall any Contributor be
276
+ liable to You for damages, including any direct, indirect, special,
277
+ incidental, or consequential damages of any character arising as a
278
+ result of this License or out of the use or inability to use the
279
+ Work (including but not limited to damages for loss of goodwill,
280
+ work stoppage, computer failure or malfunction, or any and all
281
+ other commercial damages or losses), even if such Contributor
282
+ has been advised of the possibility of such damages.
283
+
284
+ 9. Accepting Warranty or Additional Liability. While redistributing
285
+ the Work or Derivative Works thereof, You may choose to offer,
286
+ and charge a fee for, acceptance of support, warranty, indemnity,
287
+ or other liability obligations and/or rights consistent with this
288
+ License. However, in accepting such obligations, You may act only
289
+ on Your own behalf and on Your sole responsibility, not on behalf
290
+ of any other Contributor, and only if You agree to indemnify,
291
+ defend, and hold each Contributor harmless for any liability
292
+ incurred by, or claims asserted against, such Contributor by reason
293
+ of your accepting any such warranty or additional liability.
294
+
295
+ END OF TERMS AND CONDITIONS
296
+
297
+ APPENDIX: How to apply the Apache License to your work.
298
+
299
+ To apply the Apache License to your work, attach the following
300
+ boilerplate notice, with the fields enclosed by brackets "[]"
301
+ replaced with your own identifying information. (Don't include
302
+ the brackets!) The text should be enclosed in the appropriate
303
+ comment syntax for the file format. We also recommend that a
304
+ file or class name and description of purpose be included on the
305
+ same "printed page" as the copyright notice for easier
306
+ identification within third-party archives.
307
+
308
+ Copyright [yyyy] [name of copyright owner]
309
+
310
+ Licensed under the Apache License, Version 2.0 (the "License");
311
+ you may not use this file except in compliance with the License.
312
+ You may obtain a copy of the License at
313
+
314
+ http://www.apache.org/licenses/LICENSE-2.0
315
+
316
+ Unless required by applicable law or agreed to in writing, software
317
+ distributed under the License is distributed on an "AS IS" BASIS,
318
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
319
+ See the License for the specific language governing permissions and
320
+ limitations under the License.
321
+ ```
322
+
142
323
  ## dom-serializer
143
324
 
144
325
  Shipped in: cli.js
@@ -0,0 +1,10 @@
1
+ /** The `caption:` key of diagram blocks (#53, #52). */
2
+ import type { BlockSource } from './block-source.js';
3
+ type Caption = 'fingering' | 'formula';
4
+ /**
5
+ * `caption:` (#53, #52): `fingering` writes the fingering in words under the diagram (chord
6
+ * blocks), `formula` the notes and intervals of its chord or scale, both with a list
7
+ * (`fingering, formula`, fingering first); `none` writes nothing.
8
+ */
9
+ export declare function captionsOf(block: BlockSource, fingering?: boolean): Caption[];
10
+ export {};
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import type { PickOptions } from '../render/pick.js';
6
6
  import type { Naming } from '../theory/naming.js';
7
+ import type { RootMark } from '../render/root-mark.js';
7
8
  import type { VoicingLookup } from '../voicings/index.js';
8
9
  import type { PlayOptions } from '../playback/controls.js';
9
10
  import { type LayoutDefaults } from '../render/layout.js';
@@ -28,6 +29,11 @@ export interface RenderOptions extends LayoutDefaults {
28
29
  instrument?: Instrument;
29
30
  /** A playback bar on diagrams, strum and picking patterns, progressions and charts (true for the defaults). */
30
31
  play?: boolean | PlayOptions;
32
+ /**
33
+ * Copy as image (#11), on by default: the button on each play bar, or, without `play`, a small
34
+ * bar of its own under each block that draws (it copies the whole block). `false` leaves it out.
35
+ */
36
+ copy?: boolean;
31
37
  /**
32
38
  * The chords used row of `chords` blocks, when a chart has no `{diagrams}`: `'top'`,
33
39
  * `'bottom'` or `'off'` (the default). Guitar or piano diagrams follow `instrument`.
@@ -51,6 +57,11 @@ export interface RenderOptions extends LayoutDefaults {
51
57
  * A block's `naming:` line wins. Input reads all three.
52
58
  */
53
59
  naming?: Naming;
60
+ /**
61
+ * How diagrams mark their root (#14): `color` (default) or `shape` (also a square, so the root
62
+ * doesn't rest on color alone). A block's `root-mark:` line wins.
63
+ */
64
+ rootMark?: RootMark;
54
65
  }
55
66
  export type Renderer = (doc: Document, source: string, options: RenderOptions) => Element;
56
67
  /** Renders one diagram from a parsed block (the parts of a row share settings, see renderBlock). */