@tspro/web-music-score 1.1.0 → 3.0.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +337 -204
  3. package/dist/audio/index.d.mts +22 -0
  4. package/dist/audio/index.d.ts +22 -0
  5. package/dist/audio/index.js +147 -0
  6. package/dist/audio/index.mjs +109 -0
  7. package/dist/audio-cg/index.d.mts +4 -0
  8. package/dist/audio-cg/index.d.ts +4 -0
  9. package/dist/audio-cg/index.js +124 -0
  10. package/dist/audio-cg/index.mjs +91 -0
  11. package/dist/chunk-ZWFAOHYM.mjs +9 -0
  12. package/dist/core/index.d.mts +21 -0
  13. package/dist/core/index.d.ts +21 -0
  14. package/dist/core/index.js +72 -0
  15. package/dist/core/index.mjs +45 -0
  16. package/dist/guitar-BIFwFT31.d.ts +24 -0
  17. package/dist/guitar-zASF7B1g.d.mts +24 -0
  18. package/dist/iife/index.global.js +221 -0
  19. package/dist/interface-CLb7xa7_.d.mts +1768 -0
  20. package/dist/interface-DXyXwLBB.d.ts +1768 -0
  21. package/dist/note-B5ZtlHc8.d.mts +99 -0
  22. package/dist/note-B5ZtlHc8.d.ts +99 -0
  23. package/dist/pieces/index.d.mts +15 -0
  24. package/dist/pieces/index.d.ts +15 -0
  25. package/dist/pieces/index.js +56 -0
  26. package/dist/pieces/index.mjs +29 -0
  27. package/dist/react-ui/index.d.mts +170 -0
  28. package/dist/react-ui/index.d.ts +170 -0
  29. package/dist/react-ui/index.js +624 -0
  30. package/dist/react-ui/index.mjs +582 -0
  31. package/dist/scale-B_2MZaT9.d.ts +87 -0
  32. package/dist/scale-C-YS5iVG.d.mts +87 -0
  33. package/dist/score/index.d.mts +43 -0
  34. package/dist/score/index.d.ts +43 -0
  35. package/dist/score/index.js +7753 -0
  36. package/dist/score/index.mjs +7669 -0
  37. package/dist/tempo-DoJd-UYT.d.ts +120 -0
  38. package/dist/tempo-TjQKn46X.d.mts +120 -0
  39. package/dist/theory/index.d.mts +48 -0
  40. package/dist/theory/index.d.ts +48 -0
  41. package/dist/theory/index.js +1783 -0
  42. package/dist/theory/index.mjs +1716 -0
  43. package/package.json +98 -55
  44. package/dist/index.cjs.js +0 -41053
  45. package/dist/index.d.ts +0 -1281
  46. package/dist/index.esm.mjs +0 -41044
  47. package/dist/index.umd.min.js +0 -9
package/README.md CHANGED
@@ -2,336 +2,478 @@
2
2
 
3
3
  This library allows you to view and play music scores (notation) in the browser.
4
4
 
5
- Note: I'm not a professional musician. I began learning classical guitar on my own,
5
+ I'm not a professional musician. I began learning classical guitar on my own,
6
6
  later taking lessons in classical guitar. I've also studied music theory independently.
7
7
 
8
- This project has been a slow and steady effort over several years. It's now ready for
9
- public release — though please note that there may still be bugs or unexpected behavior.
8
+ This is a work in progress project. Expect changes, bugs, or unexpected behavior.
9
+
10
+ ## Version 2 Update
11
+
12
+ **Breaking:** Version 2 is major update and brought many changes.
13
+
14
+ * Introduced subpath modules instead of one big main module. There is no main export.
15
+ * Theory module had big refactor that affected whole library. Renamed all musical terms that
16
+ were wrong (e.g. pitch => diatonicId, noteId => chromaticId).
17
+ * Score module stayed mostly same. Some changes (e.g. enum StaffKind => StaffPreset) but nothing major.
18
+ * Classical guitar audio was put into separate module (audio-cg) because it bundles over 1MB of audio
19
+ samples. Also improved default synthesizer audio.
20
+ * Numerous small changes/improvements.
21
+
22
+ Enough changes until next major update!
23
+
24
+ ## Version 3 Update
25
+
26
+ **Breaking:** Version 3 is another major update and brought some important changes.
27
+
28
+ * Support score configuration with multiple notation lines (combination of staves and tabs).
29
+ * Introduced DocumentBuilder to create scores, removed old way.
30
+ * DocumentOptions functionality is replaced using functions addScoreConfiguration() and setMeasuresPerRow() in DocumentBuilder.
31
+ * Add ties, slurs and slides using addConnective() in DocumentBuilder. Tie and span options removed from NoteOptions.
10
32
 
11
33
  ## Installation
12
34
 
13
35
  ```sh
14
36
  npm i @tspro/web-music-score
15
-
16
- # React is required, it is peer dependency
17
- npm i react
18
37
  ```
19
38
 
20
- ## Usage And API Documentation
21
-
22
- ### Usage
39
+ ## Import
23
40
 
24
- #### Import (ESM)
25
41
  ```js
26
- // Import named exports
27
- import * as Score from "@tspro/web-music-score";
42
+ // Import core module, it does not contain much.
43
+ import * as Core from "@tspro/web-music-score/core";
28
44
 
29
- // Import default export
30
- import Score from "@tspro/web-music-score";
31
- ```
45
+ // Import audio module, it can play notes.
46
+ import * as Audio from "@tspro/web-music-score/audio";
32
47
 
33
- #### Require (CommonJS)
34
- ```js
35
- // Use require
36
- const Score = require("@tspro/web-music-score");
48
+ // Import theory module, it contains all music theory stuff.
49
+ import * as Theory from "@tspro/web-music-score/theory";
50
+
51
+ // Import score module, it contains music score stuff.
52
+ import * as Score from "@tspro/web-music-score/score";
53
+
54
+ // Import react-ui module, it contains all react components.
55
+ // React is peer dependency "^18.0.0 || ^19.0.0".
56
+ import * as ScoreUI from "@tspro/web-music-score/react-ui";
57
+
58
+ // Import pieces module, it contains demo songs.
59
+ import * as Pieces from "@tspro/web-music-score/pieces";
60
+
61
+ // You can also use require
62
+ const Core = require("@tspro/web-music-score/core");
63
+
64
+ // etc.
37
65
  ```
38
66
 
39
- #### Browser Script
40
- Use in browser via unpkg CDN.
41
- Browser version comes without React-components.
67
+ ## Browser Script
68
+
69
+ This is an experimental module that can be used in html page via unpkg CDN.
70
+ It declares global variable `WebMusicScore` that contains `Core`, `Audio`, `Theory`, `Score`,
71
+ and `Pieces` as corresponding subpath modules (excluding `react-ui` and `audio-cg`).
42
72
 
43
73
  ```html
44
- <script src="https://unpkg.com/@tspro/web-music-score@1"></script>
74
+ <script src="https://unpkg.com/@tspro/web-music-score@3"></script>
75
+ <script src="https://unpkg.com/@tspro/web-music-score@3.0.0"></script>
76
+ <script src="https://unpkg.com/@tspro/web-music-score@3.0.0/dist/iife/index.global.js"></script>
45
77
 
46
- <canvas id="scoreCanvas"></canvas><br />
47
- <button id="playButton"></button>
78
+ <!--
79
+ Use one of above. It is recommended to use version number (e.g. @3.0.0 or at least @3).
80
+ This way if there is breaking change between versions your code does not stop working.
81
+ -->
48
82
 
49
83
  <script>
50
- const Score = window.WebMusicScore;
84
+ const { Core, Audio, Theory, Score, Pieces } = window.WebMusicScore;
51
85
  // ...
52
86
  </script>
53
87
  ```
54
88
 
55
- ### Create Document
89
+ ## API
90
+
91
+ Typedoc API reference is available [here](https://pahkasoft.github.io).
92
+ It is not commented but is mostly self explanatory and gives idea of full API.
93
+
94
+ Following is the main interface explained.
95
+
96
+ ### Create DocumentBuilder
97
+
98
+ Documents are created using `DocumentBuilder`.
56
99
 
57
100
  ```js
58
- let doc = new Score.MDocument(Score.StaffKind.Treble, { measuresPerRow: 4 });
101
+ let builder = new Score.DocumentBuilder();
102
+
103
+ // Here build document, e.g.
104
+ builder
105
+ .addMEasure()
106
+ .addNote(0, "C3", Theory.NoteLength.Quarter)
107
+ // etc.
108
+
109
+ // When ready, get document:
110
+ let doc = builder.getDocument();
59
111
  ```
60
112
 
61
- First argument is `StaffKind`:
62
- * `Treble`: Staff with treble (G-) clef.
63
- * `Bass`: Staff with bass (F-) clef.
64
- * `Grand`: Both treble and bas staves.
65
- * `GuitarTreble`: `Treble` but one octave lower.
66
- * `GuitarTab`: Guitar tab only.
67
- * `GuitarTrebleAndTab`: Treble and tab for guitar.
113
+ ### Set Score Configuration
114
+ Setting score configuration takes place in first measure of next row.
68
115
 
69
- Second argument is optional `DocumentOptions`:
70
- ```ts
71
- DocumentOptions = { measuresPerRow?: number, tuning?: string }
116
+ #### Using preset values
117
+ ```js
118
+ builder.setScoreConfiguration(staffPreset: Score.StaffPreset);
72
119
  ```
73
120
 
74
- Default tuning is `"Standard"`. `TuningNameList` is array of available tuning names.
121
+ `staffPreset` can be:
122
+ * `Score.StaffPreset.Treble`: Staff with treble (G-) clef.
123
+ * `Score.StaffPreset.Bass`: Staff with bass (F-) clef.
124
+ * `Score.StaffPreset.Grand`: Both treble and bas staves.
125
+ * `Score.StaffPreset.GuitarTreble`: Same as `Treble` but one octave down.
126
+ * `Score.StaffPreset.GuitarTab`: Guitar tab only.
127
+ * `Score.StaffPreset.GuitarCombined`: Treble and tab for guitar.
75
128
 
76
- ### Set Header
129
+ ```js
130
+ // Example
131
+ builder.setScoreConfiguration(Score.StaffPreset.GuitarCombined);
132
+ ```
77
133
 
134
+ #### Using configuration objects
78
135
  ```js
79
- doc.setHeader("Title", "Composer", "Arranger");
80
- doc.setHeader("Title");
136
+ builder.setScoreConfiguration(config: Score.StaffConfig | Score.TabConfig);
137
+ builder.setScoreConfiguration(config: (Score.StaffConfig | Score.TabConfig)[]);
81
138
  ```
82
139
 
83
- Any of `title`, `composer` and `arranger` can be omitted/set undefined.
140
+ `config` is `StaffConfig`, `TabConfig` or array of combination.
84
141
 
85
- ### Add Measure
142
+ `StaffConfig` contains following properties:
143
+ * `type`: "staff"
144
+ * `clef`: Clef can be `Score.Clef.G` or `Score.Clef.F`.
145
+ * `isOctaveDown`: boolean (optional)
146
+ * `minNote`: string (optional), minimum note allowed in staff.
147
+ * `maxNote`: string (optional), maximum note allowed in staff.
148
+ * `voiceIds`: number[] (optional), array of voice ids are visible on this staff.
149
+ * `isGrand`: boolean (optional), use this to create grand staff.
150
+
151
+ `TabConfig` contains following properties:
152
+ * `type`: "tab"
153
+ * `tuning`: string | string[] (optional), tuning name or array of 6 note names for tuning.
154
+ * `voiceIds`: number[] (optional), array of voice ids are visible on this tab.
86
155
 
87
156
  ```js
88
- let m = doc.addMeasure();
157
+ // Example: Staff and tab for guitar
158
+ builder.setScoreConfiguration([
159
+ { type: "staff", clef: Score.Clef.G, isOctaveDown: true },
160
+ { type: "tab", tuning: "Drop D" }
161
+ ]);
162
+
163
+ // Example: Grand staff
164
+ builder.setScoreConfiguration([
165
+ { type: "staff", clef: Score.Clef.G, isGrand: true },
166
+ { type: "staff", clef: Score.Clef.F, isGrand: true }
167
+ ]);
89
168
  ```
90
169
 
91
- ### End Row
170
+ ### Set Automatic Measures Per Row
171
+ ```ts
172
+ builder.setMesuresPerRow(measuresPerRow: number)
173
+ ```
174
+
175
+ `measuresPerRow` can be integer >= 1, or Infinity (default).
92
176
 
177
+ ### Set Header
93
178
  ```js
94
- m.endRow();
95
- ```
179
+ builder.setHeader(title?: string, composer?: string, arranger?: string);
96
180
 
97
- Manually induce row change. Next measure will be added to new row.
181
+ // Example
182
+ builder.setHeader("Demo Song");
183
+ ```
98
184
 
99
- ### Set Signature
185
+ ### Add Measure
186
+ ```js
187
+ builder.addMeasure();
188
+ ```
100
189
 
190
+ ### End Row
101
191
  ```js
102
- m.setKeySignature("C", Score.ScaleType.Major);
192
+ builder.endRow();
103
193
  ```
104
194
 
105
- Firat argument is scale key note.
195
+ Manually induce row change. Next measure that is added will begin new row.
106
196
 
107
- Second argument is `ScaleType`, which can be `Major`, `NaturalMinor`, `HarmonicMinor`, `Ionian`, `Dorian`, `Phrygian`, `Lydian`, `Mixolydian`,
108
- `Aeolian`, `Locrian`, `MajorPentatonic`, `MinorPentatonic`, `MajorHexatonicBlues`, `MinorHexatonicBlues` or `HeptatonicBlues`.
197
+ ### Set Key Signature
109
198
 
110
199
  ```js
111
- m.setTimeSignature("4/4");
200
+ builder.setKeySignature(tonic: string, scaleType: Theory.ScaleType);
201
+
202
+ // Example: Am
203
+ builder.setKeySignature("A", Theory.ScaleType.Aeolian);
204
+ ```
205
+
206
+ `tonic` is scale tonic/root note, e.g. "C" (in "C Major").
207
+
208
+ `scaleType` can be
209
+ - `Theory.ScaleType.Major`
210
+ - `Theory.ScaleType.NaturalMinor`
211
+ - `Theory.ScaleType.HarmonicMinor`
212
+ - `Theory.ScaleType.Ionian`
213
+ - `Theory.ScaleType.Dorian`
214
+ - `Theory.ScaleType.Phrygian`
215
+ - `Theory.ScaleType.Lydian`
216
+ - `Theory.ScaleType.Mixolydian`
217
+ - `Theory.ScaleType.Aeolian`
218
+ - `Theory.ScaleType.Locrian`
219
+ - `Theory.ScaleType.MajorPentatonic`
220
+ - `Theory.ScaleType.MinorPentatonic`
221
+ - `Theory.ScaleType.MajorHexatonicBlues`
222
+ - `Theory.ScaleType.MinorHexatonicBlues`
223
+ - `Theory.ScaleType.HeptatonicBlues`
224
+
225
+ ### Set Time Signature
226
+ ```js
227
+ builder.setTimeSignature(timeSignature: string);
228
+
229
+ // Example
230
+ builder.setTimeSignature("3/4");
112
231
  ```
113
232
 
114
- Time signature can be `"2/4"`, `"3/4"`, `"4/4"`, `"6/8"` or `"9/8"`.
233
+ timeSignature can be:
234
+ - `"2/4"`
235
+ - `"3/4"`
236
+ - `"4/4"`
237
+ - `"6/8"`
238
+ - `"9/8"`
115
239
 
240
+ ### Set Tempo
116
241
  ```js
117
- m.setTempo(80, Score.NoteLength.Quarter, false);
118
- m.setTempo(80);
242
+ builder.setTempo(beatsPerMinute: number, beatLength?: Theory.NoteLength, dotted?: boolean);
243
+
244
+ // Example
245
+ builder.setTempo(100, Theory.NoteLength.Quarter);
119
246
  ```
120
247
 
121
- First argument is beats per minute.
248
+ `beatsPerMinute` is self explanatory.
249
+
250
+ `beatLength` tells the length of each beat, e.g. Theory.NoteLength.Quarter.
122
251
 
123
- Second argument is beat length. Third argument tells if beat length is dotted. Second and third arguments can be omitted.
252
+ `dotted` tells if `beatLength` is dotted.
124
253
 
125
254
  ### Add Note Or Chord
126
255
 
127
256
  ```js
128
- m.addNote(voiceId, note, noteLength, noteOptions?);
129
- m.addChord(voiceId, notes, noteLength, noteOptions);
130
- ```
131
-
132
- * `voiceId`: Voice track id `0`, `1`, `2` or `3`
133
- * `note`: note `string | Note` (e.g. `"C3"`)
134
- * `notes`: array of notes `(string | Note)[]` (e.g. `["C3", "E3"]`)
135
- * `noteLength`: Note length (e.g. `NoteLength.Half`), see below
136
- * `noteOptions`: Optional note otions, see below
257
+ builder.addNote(voiceId: number, note: string, noteLength: Theory.NoteLength, noteOptions?: Score.NoteOptions);
258
+ builder.addChord(voiceId: number, notes: string[], noteLength: Theory.NoteLength, noteOptions?: Score.NoteOptions);
137
259
 
138
- Examples:
139
- ```js
140
- m.addNote(0, "C3", Score.NoteLength.Quarter);
141
- m.addChord(1, ["C3", "E3", "G3", "C4"], Score.NoteLength.Half, { dotted: true });
260
+ // Examples
261
+ builder.addNote(0, "C4", Theory.NoteLength.Half, { dotted: true });
262
+ builder.addChord(1, ["C3", "E3", "G3"], Theory.NoteLength.Whole, { arpeggio: Score.Arpeggio.Down });
142
263
  ```
143
264
 
144
- #### NoteLength
265
+ `voiceId` can be `0`, `1`, `2` or `3`.
145
266
 
146
- * `NoteLength.Whole`
147
- * `NoteLength.Half`
148
- * `NoteLength.Quarter`
149
- * `NoteLength.Eighth`
150
- * `NoteLength.Sixteenth`
151
- * `NoteLength.ThirtySecond`
152
- * `NoteLength.SixtyFourth`
267
+ `note` is note name, e.g. `"G#3"`, `"Db3"`.
153
268
 
154
- #### NoteOptions
269
+ `notes`: array of notes `string[]` (e.g. `["C3", "E3"]`)
155
270
 
156
- Optional object of note options (e.g. `{ stem: Stem.Up }`):
271
+ `noteLength` can be:
272
+ * `Theory.NoteLength.Whole`
273
+ * `Theory.NoteLength.Half`
274
+ * `Theory.NoteLength.Quarter`
275
+ * `Theory.NoteLength.Eighth`
276
+ * `Theory.NoteLength.Sixteenth`
277
+ * `Theory.NoteLength.ThirtySecond`
278
+ * `Theory.NoteLength.SixtyFourth`
157
279
 
158
- | Note option | Type | |
159
- |-------------|-------------------------|--------------------|
160
- | dotted | `boolean` | Create dotted note. |
161
- | stem | `Stem` | Set stem direction (`Stem.Auto`/`Up`/`Down`) |
162
- | arpeggio | `Arpeggio` | Play column in arpeggio `Arpeggio.Up`/`Down` |
280
+ `noteOptions` is optional object of note options (e.g. `{ dotted: true }`):
281
+
282
+ | Note option | Type | |
283
+ |-------------|---------------------------|---------------------|
284
+ | dotted | `boolean` | Create dotted note. |
285
+ | stem | `Score.Stem.Auto/Up/Down` | Set stem direction. |
286
+ | arpeggio | `Score.Arpeggio.Up/Down` \| `boolean` | Play column in arpeggio. |
163
287
  | staccato | `boolean` | Play column in staccato. |
164
288
  | diamond | `boolean` | Diamond shaped note head. |
165
- | tieSpan | `number` \| `TieLength` | How many notes tied, or `TieLength.Short`/`ToMeasureEnd` |
166
- | tiePos | `ArcPos` | Tie attach point: `Arc.Auto`/`Above`/`Middle`/`Below`/`StemTip` |
167
- | slurSpan | `number` | How many notes slurred. |
168
- | slurPos | `ArcPos` | Slur attach point: `Arc.Auto`/`Above`/`Middle`/`Below`/`StemTip` |
169
- | triplet | `boolean` | Make this note part of triplet. |
170
- | string | `number` \| `number[]` | What string does the note fret number belong to in guitar tab. Array of strings for chord. |
289
+ | triplet | `boolean` | Set this note part of triplet. |
290
+ | string | `number` \| `number[]` | String number for guitar tab. Array of string numbers for chord. |
171
291
 
172
292
  ### Add Rest
173
293
 
174
294
  ```js
175
- m.addRest(voideId, restLength, restOptions?);
295
+ builder.addRest(voideId: number, restLength: Theory.NoteLength, restOptions?: Score.RestOptions);
296
+
297
+ // Example
298
+ builder.addRest(0, Theory.NoteLength.Sixteenth);
176
299
  ```
177
300
 
178
- * `voiceId`: Voice track id `0`, `1`, `2` or `3`.
179
- * `restLength`: Rest length using `NoteLength` (e.g. `NoteLength.Half`), see above.
180
- * `restOptions`: Optional rest otions, see below.
301
+ `voiceId` can be `0`, `1`, `2` or `3`.
181
302
 
182
- Example:
183
- ```js
184
- m.addRest(0, Score.NoteLength.Quarter);
185
- ```
303
+ `restLength` is length of rest, similar as noteLength above.
186
304
 
187
- #### RestOptions
305
+ `restOptions` is optional object of rest options (e.g. `{ hide: true }`):
188
306
 
189
- Optional object of rest options (e.g. `{ hide: true }`):
190
- | Rest option | Type | |
191
- |-------------|------------------------|--------------------|
192
- | dotted | `boolean` | Create dotted rest |
193
- | pitch | `string` \| `Note` | Positions rest at level of note (e.g. `"C3"`) |
194
- | hide | `boolean` | Add invisible rest |
195
- | triplet | `boolean` | Make this rest part of triplet |
307
+ | Rest option | Type | |
308
+ |-------------|--------------|---------------------|
309
+ | dotted | `boolean` | Create dotted rest. |
310
+ | staffPos | `string` | Staff positions (e.g. `"C3"`). |
311
+ | hide | `boolean` | Add invisible rest. |
312
+ | triplet | `boolean` | Set this rest part of triplet. |
196
313
 
197
314
  ### Add Fermata
198
315
 
199
316
  ```js
200
- m.addNote(0, "C3", Score.NoteLength.Quarter).addFermata(Score.Fermata.AtNote);
201
- m.addRest(0, Score.NoteLength.Quarter).addFermata();
202
- ```
203
-
204
- Adds fermata anchored to previously added note or rest.
317
+ builder.addFermata(fermata?: Score.Fermata);
205
318
 
206
- ```js
207
- m.addFermata(Score.Fermata.AtMeasureEnd);
319
+ // Example
320
+ builder.addFermata(Score.Fermata.AtMeasureEnd);
208
321
  ```
209
322
 
210
- Adds fermata at measure end.
323
+ `fermata` is typeof `Score.Fermata` and can be:
324
+ - `Score.Fermata.AtNote`: Adds fermata anchored to previously added note, chord or rest.
325
+ - `Score.Fermata.AtMeasureEnd`: Adds fermata at the end of measure.
211
326
 
212
- ### Add Navigation
327
+ ### Add Connective (tie, slur)
213
328
 
214
329
  ```js
215
- m.addNavigation(Score.Navigation.DC_al_Fine);
216
- ```
330
+ // Add tie
331
+ builder.addConnective(connective: Score.Connetive.Tie, span?: Score.ConnectiveSpan, noteAnchor?: Score.NoteAnchor);
217
332
 
218
- Adds navigational element to measure.
333
+ // Add slur
334
+ builder.addConnective(connective: Score.Connetive.Slur, span?: Score.ConnectiveSpan, noteAnchor?: Score.NoteAnchor);
219
335
 
220
- Available navigations are:
336
+ // Add slide
337
+ builder.addConnective(connective: Score.Connetive.Slide, noteAnchor?: Score.NoteAnchor);
338
+ ```
339
+
340
+ - `span` describes how many notes the connective is across.
341
+ It is integer >= 2 (for tie it can be also `Score.TieType.Stub|ToMeasureEnd`).
342
+ Default value is 2.
343
+ - `noteAnchor` describes the attach point of connective to note.
344
+ It can be `Score.NoteAnchor.Auto|Above|Center|Below|StemTip`.
345
+ Default value is `Score.NoteAnchor.Auto`.
221
346
 
222
- * `Navigation.DC_al_Fine`
223
- * `Navigation.DC_al_Coda`
224
- * `Navigation.DS_al_Fine`
225
- * `Navigation.DS_al_Coda`
226
- * `Navigation.Coda`
227
- * `Navigation.toCoda`
228
- * `Navigation.Segno`
229
- * `Navigation.Fine`
230
- * `Navigation.StartRepeat`
231
- * `Navigation.EndRepeat`
232
- * `Navigation.Ending`
347
+ ### Add Navigation
233
348
 
234
- `Navigation.EndRepeat` Takes optional second argument which is number of repeats. Defaults to 1 if omitted.
349
+ Add navigational element to measure.
235
350
 
236
351
  ```js
237
- m.addNavigation(Score.Navigation.EndRepeat, 2);
352
+ builder.addNavigation(navigation: Score.Navigation, ...args?);
353
+
354
+ // Examples
355
+ builder.addNavigation(Score.Navigation.StartRepeat);
356
+ builder.addNavigation(Score.Navigation.EndRepeat, 3);
357
+ builder.addNavigation(Score.Navigation.Ending, 1, 2);
238
358
  ```
239
359
 
240
- `Navigation.Ending` takes variable number of arguments, each is a passage number.
360
+ `navigation` can be:
361
+ * `Score.Navigation.DC_al_Fine`
362
+ * `Score.Navigation.DC_al_Coda`
363
+ * `Score.Navigation.DS_al_Fine`
364
+ * `Score.Navigation.DS_al_Coda`
365
+ * `Score.Navigation.Coda`
366
+ * `Score.Navigation.toCoda`
367
+ * `Score.Navigation.Segno`
368
+ * `Score.Navigation.Fine`
369
+ * `Score.Navigation.StartRepeat`
370
+ * `Score.Navigation.EndRepeat`
371
+ * `Score.Navigation.Ending`
241
372
 
242
- ```js
243
- m.addNavigation(Score.Navigation.Ending, 1, 2);
244
- m.addNavigation(Score.Navigation.Ending, 3);
245
- ```
373
+ `Score.Navigation.EndRepeat` takes optional second arg which is number of times to repeat (once if omitted).
374
+
375
+ `Score.Navigation.Ending` takes variable number of number args, each is a passage number.
246
376
 
247
377
  ### Add Label
248
378
 
379
+ Add text label anchored to previously added note, chord or rest.
380
+
249
381
  ```js
250
- m.addChord(0, ["D3", "F3", "A3"], Score.NoteLength.Quarter).addLabel(Score.Label.Chord, "Dm");
251
- ```
382
+ builder.addLabel(label: Score.Label, text: string);
252
383
 
253
- Available Label types are:
384
+ // Example
385
+ builder.addLabel(Score.Label.Chord, "Am);
386
+ ```
254
387
 
255
- * `Label.Note` is used to label notes and is positioned below note.
256
- * `Label.Chord` is used to label chords and is positioned on top.
388
+ `label` can be:
389
+ * `Score.Label.Note`: Used to label notes and is positioned below note.
390
+ * `Score.Label.Chord`: Used to label chords and is positioned on top.
257
391
 
258
392
  ### Add Annotation
259
393
 
260
- ```js
261
- m.addNote(0, "C3", Score.NoteLength.Quarter).addAnnotation(Score.Annotation.Dynamics, "fff");
262
- ```
394
+ Add annotation text anchored to previously added note, chord or rest.
263
395
 
264
- First argument is `Annotation`, second argument is the annotation text.
396
+ ```js
397
+ builder.addAnnotation(annotation: Score.Annotation, text: string);
265
398
 
266
- Available annotations are:
399
+ // Example
400
+ builder.addAnnotation(Score.Annotation.Tempo, "accel.");
401
+ ```
267
402
 
268
- * `Annotation.Dynamics` could be for example `"fff"`, `"cresc."`, `"dim."`, etc.
269
- * `Annotation.Tempo` could be for example `"accel."`, `"rit."`, `"a tempo"`, etc.
403
+ `annotation` can be:
404
+ * `Score.Annotation.Dynamics`: `text` could be for example `"fff"`, `"cresc."`, `"dim."`, etc.
405
+ * `Score.Annotation.Tempo`: `text` could be for example `"accel."`, `"rit."`, `"a tempo"`, etc.
270
406
 
271
407
  ### Add Extension
272
408
 
409
+ Adds extension line to element, for example to previously added annotation.
410
+
273
411
  ```js
274
- m.addNote(0, "C3", Score.NoteLength.Quarter).
275
- addAnnotation(Score.Annotation.Tempo, "accel.").
276
- addExtension(Score.NoteLength.Whole * 2, true);
277
- ```
412
+ builder.addExtension(extensionLength: number, visible?: boolean);
278
413
 
279
- Adds extension line to element, annotation in this case.
414
+ // Example
415
+ builder.addAnnotation(Score.Annotation.Tempo, "accel.").addExtension(Theory.NoteLength.Whole * 2, true);
416
+ ```
280
417
 
281
- First argument is extension length, of type number. `NoteLength` values can be used as number, and `NoteLength` values can be multiplied to set desired extension length.
418
+ `extensionLength` is `number` but `Theory.NoteLength` values can be used as number and multiplied to set desired extension length.
282
419
 
283
- Second argument is `true`/`false` whether extension line is visible. This argument cvan be omitted, extension line is visible by default.
420
+ `visible` sets visibility of extension line, visible by default (if omitted).
284
421
 
285
422
  ### Guitar Tab
286
423
 
287
- Has preliminary support for rendering guitar tabs.
288
- Create document with `StaffKind.GuitarTab` or `StaffKind.GuitarTrebleAndTab`, and specify tuning (optional, defaults to Standard tuning):
424
+ This library has preliminary guitar tabs rendering.
425
+ Create document with `Score.StaffPreset.GuitarTab` or `Score.StaffPreset.GuitarCombined`, or set score configuration with TabConfig.
289
426
 
290
- ```js
291
- let doc = new Score.MDocument(Score.StaffKind.GuitarTrebleAndTab, { tuning: "Standard" });
292
- ```
293
-
294
- Add notes with `string` option to specify which string the fret number is rendered in tab view.
427
+ Add notes with `{ string: number | number[] }` to specify which string the fret number is rendered in guitar tab.
295
428
 
296
429
  ```js
297
430
  // Single note
298
- m.addNote(0, "G3", Score.NoteLength.Eighth, { string: 3 });
431
+ builder.addNote(0, "G3", Theory.NoteLength.Eighth, { string: 3 });
299
432
 
300
433
  // Multi note
301
- m.addChord(0, ["E4", "C3"], Score.NoteLength.Eighth, { string: [1, 5] });
434
+ builder.addChord(0, ["E4", "C3"], Theory.NoteLength.Eighth, { string: [1, 5] });
302
435
  ```
303
436
 
304
-
305
437
  ### Queueing
306
438
 
307
- Adding stuff to measures can be queued like this:
439
+ `DocumentBuilder` operations can be queued.
308
440
 
309
441
  ```js
310
- doc.addMeasure()
311
- .addNote(1, "C3", Score.NoteLength.Quarter)
312
- .addChord(1, ["C3", "E3", "G3"], Score.NoteLength.Quarter).addLabel(Score.Label.Chord, "C")
313
- .addRest(1, Score.NoteLength.Quarter);
442
+ let doc = new Score.DocumentBuilder()
443
+ .addScoreConfiguration({ type: "staff", clef: Score.Clef.G, isOctavewDown: true })
444
+ .setMeasuresPerRow(4)
445
+ .addMeasure()
446
+ .addNote(1, "C3", Theory.NoteLength.Quarter)
447
+ .addChord(1, ["C3", "E3", "G3"], Theory.NoteLength.Quarter).addLabel(Score.Label.Chord, "C")
448
+ .addRest(1, Theory.NoteLength.Quarter)
449
+ // etc.
450
+ .getDEocument();
314
451
  ```
315
452
 
316
453
  ### Beams
317
454
 
318
455
  Beams are detected and added automatically.
319
456
 
320
- ### Play Document
457
+ ### Classical Guitar Audio Module
321
458
 
322
- ```js
323
- Score.Audio.setInstrument(Score.Audio.Instrument.ClassicalGuitar);
324
- ```
459
+ Default instrument is `Synthesizer`.
325
460
 
326
- Sets instrument. Instrument can be ClassicalGuitar or Synth.
461
+ `Classical Guitar` is available via `audio-cg` module.
462
+ It was included as separate module because it contains over 1MB of audio samples bundled in it.
327
463
 
328
464
  ```js
329
- doc.play();
465
+ import { registerClassicalGuitar } from "@tspro/web-music-score/audio-cg";
466
+
467
+ registerClassicalGuitar();
330
468
  ```
331
469
 
332
- Plays the document.
470
+ ### Play Document
333
471
 
334
472
  ```js
473
+ // Simple play
474
+ doc.play();
475
+
476
+ // More playback options:
335
477
  let player = new MPlayer(doc);
336
478
 
337
479
  player.play();
@@ -341,21 +483,19 @@ player.stop();
341
483
  MPlayer.stopAll();
342
484
  ```
343
485
 
344
- More playback methods.
345
-
346
486
  ### Viewing Using React JSX/TSX
347
487
 
348
488
  ```js
349
489
  // Draw document
350
- <Score.MusicScoreView doc={doc} />
490
+ <ScoreUI.MusicScoreView doc={doc} />
351
491
 
352
492
  // Add playback buttons
353
- <Score.PlaybackButtons doc={doc} buttonLayout={Score.PlaybackButtonsLayout.PlayStopSingle}/> // Single Play/Stopo button
354
- <Score.PlaybackButtons doc={doc} buttonLayout={Score.PlaybackButtonsLayout.PlayStop}/> // Play and Stop buttons
355
- <Score.PlaybackButtons doc={doc} buttonLayout={Score.PlaybackButtonsLayout.PlayPauseStop}/> // Play, Pause and Stop buttons
493
+ <ScoreUI.PlaybackButtons doc={doc} buttonLayout={ScoreUI.PlaybackButtonsLayout.PlayStopSingle}/> // Single Play/Stopo button
494
+ <ScoreUI.PlaybackButtons doc={doc} buttonLayout={ScoreUI.PlaybackButtonsLayout.PlayStop}/> // Play and Stop buttons
495
+ <ScoreUI.PlaybackButtons doc={doc} buttonLayout={ScoreUI.PlaybackButtonsLayout.PlayPauseStop}/> // Play, Pause and Stop buttons
356
496
  ```
357
497
 
358
- Bootstrap is used for better visual appearance but you must load it.
498
+ Bootstrap is used for better visual appearance, but it needs to be installed and loaded.
359
499
 
360
500
  ### Viewing Using Plain JS/TS
361
501
 
@@ -394,29 +534,22 @@ p.setPlayStopButton("playStopButtonId")
394
534
  p.setPlayButton(playButtonElement)
395
535
  ```
396
536
 
397
- ### Error Handling
398
-
537
+ ### MusicError
399
538
  ```js
400
539
  try {
401
- // Invalid note "C" without octave.
402
- m.addNote(0, "C", Score.NoteLength.Quarter);
540
+ // Do your music stuff
403
541
  }
404
- catch(e) {
405
- // MusicError is raised on errors.
406
- if(e instanceof Score.MusicError) {
407
- console.log(e);
542
+ catch (e) {
543
+ if(e instanceof Core.MusicError) {
544
+ // There was music error.
408
545
  }
409
546
  }
410
547
  ```
411
548
 
412
549
  ## Compatibility
413
-
414
- This library is bundled to ESM, CJS and UMD formats.
415
-
416
- * CJS and UMD bundles are transpiled with Babel for ES5/IE11 compatibility.
417
- * ESM bundle targets modern environments (ES6+).
418
- * Uses ES6 features like Map, etc.
419
- * No polyfills are included.
550
+ - This library is bundled to ESM, CJS and IIFE formats.
551
+ - Target is to support ES6/ES2015.
552
+ - No polyfills are included.
420
553
 
421
554
  While designed for compatibility in mind, the library has not been explicitly tested against specific Node.js or browser versions.
422
555