@tspro/web-music-score 5.4.2 → 5.5.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/LICENSE +24 -0
  3. package/README.md +8 -546
  4. package/dist/audio/index.d.ts +1 -1
  5. package/dist/audio/index.js +1748 -5
  6. package/dist/audio/index.mjs +9 -6
  7. package/dist/audio-cg/index.js +17487 -46
  8. package/dist/audio-cg/index.mjs +7 -5
  9. package/dist/audio-synth/index.js +18434 -32
  10. package/dist/audio-synth/index.mjs +12 -7
  11. package/dist/chunk-7GVRGM3N.mjs +101 -0
  12. package/dist/chunk-AUOH7S2E.mjs +3877 -0
  13. package/dist/{chunk-MMWSQGVR.mjs → chunk-BZE5UGTJ.mjs} +3 -3
  14. package/dist/{chunk-CVYTUTL6.mjs → chunk-FLBNOYUN.mjs} +2 -2
  15. package/dist/{chunk-42IBAVOC.mjs → chunk-KKIFSIFK.mjs} +18 -13
  16. package/dist/chunk-L7VPSGMT.mjs +18381 -0
  17. package/dist/core/index.js +2 -2
  18. package/dist/core/index.mjs +4 -4
  19. package/dist/{guitar-CNOxM4ZK.d.ts → guitar-CarHGDAt.d.ts} +1 -1
  20. package/dist/iife/audio-cg.global.js +1 -1
  21. package/dist/iife/index.global.js +13 -13
  22. package/dist/{music-objects-DqoO-Sfv.d.mts → music-objects-CcJvZxS6.d.mts} +123 -96
  23. package/dist/{music-objects-T8u8bnNP.d.ts → music-objects-l5Ai97QA.d.ts} +125 -98
  24. package/dist/{note-RVXvpfyV.d.ts → note-CJuq5aBy.d.ts} +1 -1
  25. package/dist/pieces/index.d.mts +12 -6
  26. package/dist/pieces/index.d.ts +14 -8
  27. package/dist/pieces/index.js +25 -13
  28. package/dist/pieces/index.mjs +25 -14
  29. package/dist/react-ui/index.d.mts +1 -1
  30. package/dist/react-ui/index.d.ts +5 -5
  31. package/dist/react-ui/index.js +2274 -22
  32. package/dist/react-ui/index.mjs +18 -15
  33. package/dist/{scale-CUYFBo-8.d.ts → scale-DulPFco_.d.ts} +2 -2
  34. package/dist/score/index.d.mts +51 -3
  35. package/dist/score/index.d.ts +54 -6
  36. package/dist/score/index.js +4941 -872
  37. package/dist/score/index.mjs +1282 -729
  38. package/dist/{tempo-DwuZsv2T.d.ts → tempo-BnUjm25M.d.ts} +1 -1
  39. package/dist/theory/index.d.ts +6 -6
  40. package/dist/theory/index.js +2687 -136
  41. package/dist/theory/index.mjs +41 -49
  42. package/package.json +4 -5
  43. package/dist/chunk-ROBXPR34.mjs +0 -9
package/CHANGELOG.md CHANGED
@@ -1,4 +1,19 @@
1
1
  # Changelog
2
+ ## [5.5.1] - 2026-01-05
3
+ ### Deprecated
4
+ - Deprecated `@tspro/web-music-score`, use `web-music-score` instead.
5
+
6
+ ## [5.5.0] - 2025-11-19
7
+ ### Added
8
+ - Coloring document.
9
+ - Instrument name starts with "!" (hide name) and "!{" (hide name and left brace).
10
+ - Pieces.createAll() to get array of all demo pieces.
11
+
12
+ ### Fixes
13
+ - Extension line update: connect to right side element.
14
+ - Vertical staff/bar line update on row groups.
15
+ - Moved bundled deps to devDeps.
16
+
2
17
  ## [5.4.2] - 2025-11-05
3
18
  ## Fixed
4
19
  - Weird tab rendering bug where sad face appear on canvas.
package/LICENSE CHANGED
@@ -55,3 +55,27 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
55
55
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
56
56
  SOFTWARE.
57
57
 
58
+ ---
59
+
60
+ * Color Name to Code (https://github.com/simbo/color-name-to-code)
61
+
62
+ The MIT License (MIT)
63
+
64
+ Copyright © 2023 Simon Lepel <simbo@simbo.de>
65
+
66
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
67
+ this software and associated documentation files (the "Software"), to deal in
68
+ the Software without restriction, including without limitation the rights to
69
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
70
+ the Software, and to permit persons to whom the Software is furnished to do so,
71
+ subject to the following conditions:
72
+
73
+ The above copyright notice and this permission notice shall be included in all
74
+ copies or substantial portions of the Software.
75
+
76
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
77
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
78
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
79
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
80
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
81
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,555 +1,17 @@
1
1
  # Web Music Score
2
2
 
3
- Homepage (docs, examples and demos): [Web Music Score](https://pahkasoft.github.io/web-music-score)
4
-
5
- ## About
6
-
7
3
  This library allows you to view and play music scores (notation) in the browser.
8
4
 
9
- I'm not a professional musician. I began learning classical guitar on my own,
10
- later taking lessons in classical guitar. I've also studied music theory independently.
11
-
12
- This is a work in progress project. Lately there has been improvements that required major
13
- version update. As the project matures there might be less major updates, and more minor
14
- updates and patches.
15
-
16
- ## Version 5 Update
17
-
18
- Version 5.0.0 updated audio interface, instrument bundles are no longer dependant of the main lib and can be loaded in browser environment as independent modules.
19
-
20
- - How to add and use instrument, see sections [Instruments](#instruments)
21
- - How to add and use instrument browser version, see sections [Browser Modules](#browser-modules)
22
-
23
- ## Help Wanted
24
-
25
- If someone has piano or keyboard and can record samples for me I'd be happy to add a new instrument.
26
- About ten mp3 samples between C2 to C6 would be fine (named "E2.mp3", etc).
27
- My email can be found on [GitHub](https://github.com/pahkasoft) (visible for signed in users).
28
-
29
- ## Installation
30
-
31
- ```sh
32
- npm i @tspro/web-music-score
33
- ```
34
-
35
- ## Import
36
-
37
- ```js
38
- // Import core module, it does not contain much.
39
- import * as Core from "@tspro/web-music-score/core";
40
-
41
- // Import audio module, it can play notes.
42
- import * as Audio from "@tspro/web-music-score/audio";
43
-
44
- // Import theory module, it contains all music theory stuff.
45
- import * as Theory from "@tspro/web-music-score/theory";
46
-
47
- // Import score module, it contains music score stuff.
48
- import * as Score from "@tspro/web-music-score/score";
49
-
50
- // Import react-ui module, it contains all react components.
51
- // React is peer dependency "^18.0.0 || ^19.0.0".
52
- import * as ScoreUI from "@tspro/web-music-score/react-ui";
53
-
54
- // Import pieces module, it contains demo songs.
55
- import * as Pieces from "@tspro/web-music-score/pieces";
56
-
57
- // You can also use require
58
- const Score = require("@tspro/web-music-score/score");
59
- ```
60
-
61
- ## Browser Modules
62
-
63
- IIFE bundle for browser use is available via `unpkg` and `jsdeliv` cdn's. This bundle
64
- declares global name `WebMusicScore` that contains `Core`, `Audio`, `Theory`, `Score`,
65
- and `Pieces` as corresponding subpath modules.
66
-
67
- React module `react-ui` is not included available for browser usage.
68
-
69
- ```html
70
- <!--
71
- It is recommended to use exact version number and direct link to the bundle so
72
- that if something breaks between versions then your web site does not stop working.
73
- -->
74
- <script src="https://unpkg.com/@tspro/web-music-score@5.4.2/dist/iife/index.global.js"></script>
75
- <script src="https://cdn.jsdelivr.net/npm/@tspro/web-music-score@5.4.2/dist/iife/index.global.js"></script>
76
-
77
- <!--
78
- Classical guitar now also available for browser module.
79
- -->
80
- <script src="https://unpkg.com/@tspro/web-music-score@5.4.2/dist/iife/audio-cg.global.js"></script>
81
- <script src="https://cdn.jsdelivr.net/npm/@tspro/web-music-score@5.4.2/dist/iife/audio-cg.global.js"></script>
82
-
83
- <script>
84
- // The lib is available via global name WebMusicScore.
85
- const { Core, Audio, Theory, Score, Pieces } = window.WebMusicScore;
86
-
87
- // Classical guitar instrument is available via global name Audio_CG.
88
- const { ClassicalGuitar } = window.Audio_CG;
89
-
90
- // Add and use classical guitar instrument.
91
- Audio.addInstrument(ClassicalGuitar);
92
- </script>
93
- ```
94
-
95
- ## API
96
-
97
- Following is introduction to the main interface with the help of simple examples.
98
-
99
- ### Using `DocumentBuilder`
100
-
101
- ```js
102
- let doc = new Score.DocumentBuilder()
103
- .addScoreConfiguration({ type: "staff", clef: "G", isOctavewDown: true })
104
- .setMeasuresPerRow(4)
105
- .addMeasure()
106
- .addNote(1, "C3", "4n")
107
- .addChord(1, ["C3", "E3", "G3"], "4n").addLabel("chord", "C")
108
- .addRest(1, "4n")
109
- // etc.
110
- .getDEocument();
111
- ```
112
-
113
- **Hint:**
114
- ```js
115
- // In following examples this:
116
- .addNote(...)
117
-
118
- // means call to the DocumentBuilder object:
119
- documentBuilder.addNote(...)
120
-
121
- // It is just shortened for simplicity.
122
- ```
123
-
124
- ### Set Score Configuration
125
- New score configuration takes place in the first measure of next row.
126
-
127
- #### Using preset values
128
-
129
- For staff presets you can use `Score.StaffPreset` enum values (e.g. `Score.StaffPreset.Treble`)
130
- or corresponding string values (e.g. `"treble"`).
131
-
132
- ```js
133
- .setScoreConfiguration("treble") // Staff with treble G-clef.
134
- .setScoreConfiguration("bass") // Staff with bass F-clef.
135
- .setScoreConfiguration("grand") // Both treble and bas staves.
136
- .setScoreConfiguration("guitarTreble") // Same as `Treble` but one octave down.
137
- .setScoreConfiguration("guitarTab") // Guitar tab only.
138
- .setScoreConfiguration("guitarCombined") // Treble and tab for guitar.
139
- ```
140
-
141
- #### Using configuration objects
142
- ```js
143
- .setScoreConfiguration({ type: "staff", clef: "G"}) // Staff with treble G-clef.
144
- .setScoreConfiguration({ type: "staff", clef: "F"}) // Staff with bass F-clef.
145
- .setScoreConfiguration({
146
- type: "staff",
147
- clef: "G", // G-clef.
148
- isOctaveDown: false, // (optional) octave down.
149
- name: "staff1", // (optional) staff name.
150
- minNote: "C2", // (optional) min allowed note.
151
- maxNote: "C6", // (optional) max allowed note.
152
- voiceId: [0, 1], // (optional) only present voices 0 and 1 in this staff.
153
- instrument: "Piano" // (optional) staves/tabs with same instrument are grouped together with left brace.
154
- })
155
- .setScoreConfiguration([
156
- { type: "staff", clef: "G", grandId: "grand1" },
157
- { type: "staff", clef: "F", grandId: "grand1" }
158
- ]) // Grand staff
159
- .setScoreConfiguration([
160
- { type: "staff", clef: "G", isOctaveDown: true },
161
- { type: "tab", tuning: "Drop D" }
162
- ]) // Staff and tab for guitar, tab with Drop D tuning.
163
- .setScoreConfiguration(
164
- {
165
- type: "tab",
166
- name: "tab1",
167
- tuning: ["E2", "A2", "D3", "G3", "B3", "E4"],
168
- voiceId: 4
169
- }) // Tab with guitar tuning, present only voiceId 4 in this tab.
170
- ```
171
-
172
- ### Set Automatic Measures Per Row
173
- ```ts
174
- .setMesuresPerRow(4) // Set 4 measures per row
175
- .setMesuresPerRow(Infinity) // Turn off auto row change (default)
176
- ```
177
-
178
- ### Set Header
179
- ```js
180
- .setHeader("Title", "Composer", "Arranger") // Set title, composer and arranger
181
- .setHeader("Title") // Set title only
182
- ```
183
-
184
- ### Add Measure
185
- ```js
186
- .addMeasure() // Add new measure
187
- ```
188
-
189
- ### End Row
190
- ```js
191
- .endRow() // Manually induce row change. Next measure that is added will begin new row.
192
- ```
193
-
194
- ### Set Key Signature
195
- For scale type you can use `Theory.ScaleType` enum values (e.g. `Theory.ScaleType.Major`)
196
- or corresponding string values (e.g. `"Major"`).
197
-
198
- ```js
199
- .setKeySignature("C Major") // Create C Major scale.
200
- .setKeySignature("D", "Major") // Create D Major scale.
201
- .setKeySignature("A", "Natural Minor") // Create A natural minor scale.
202
- ```
203
-
204
- ### Set Time Signature
205
- For time signature you can use `Theory.TimeSignatures` enum values (e.g. `Theory.TimeSignatures._2_4`)
206
- or corresponding string values (e.g. `"2/4"`).
207
-
208
- For optional beam grouping argument for 5/8 and 7/8 time signatures you can use `Theory.BeamGrouping`
209
- enum values (e.g. `Theory.BeamGrouping._2_2_3`) or corresponding string values (e.g. `"2-2-3"`).
210
-
211
- ```js
212
- .setTimeSignature("2/4") // Set 2/4 time signature.
213
- .setTimeSignature("3/4") // Set 3/4 time signature.
214
- .setTimeSignature("4/4") // Set 4/4 time signature.
215
- .setTimeSignature("3/8") // Set 3/8 time signature.
216
- .setTimeSignature("5/8", "2-3") // Set 5/8 time signature. Available beam groupings are "2-3" (default) and "3-2".
217
- .setTimeSignature("6/8") // Set 6/8 time signature.
218
- .setTimeSignature("7/8", "2-2-3") // Set 7/8 time signature. Available beam groupings are "2-2-3" (default) and "3-2-2".
219
- .setTimeSignature("9/8") // Set 9/8 time signature.
220
- .setTimeSignature(12, 8) // Set 12/8 time signature using number arguments.
221
- ```
222
-
223
- ### Set Tempo
224
- ```js
225
- .setTempo(100, "4n") // 100 beats per minute, beat length is quarter note.
226
- .setTempo(80, "4..") // 100 beats per minute, beat length is double dotted quarter note.
227
- ```
228
-
229
- ### Add Note
230
- ```js
231
- .addNote(0, "C4", "1n") // Add whole note "C4"
232
- .addNote(0, ["C4", "D4", "G4"], "1n") // Add three notes "C4", "D4", "G4" seuqentially (no chord).
233
- .addNote(0, "Bb4", "2..") // Add double dotted half note "Bb4"
234
- .addNote(0, "C4", "4n", { stem: "up" }) // Stem direction Up (could be also Down)
235
- .addNote(0, "C4", "4n", { staccate: true }) // Show staccato dot and play in short
236
- .addNote(0, "C4", "4n", { diamond: true }) // Show diamond shaped note head
237
- ```
238
-
239
- ### Add Chord
240
- ```js
241
- .addChord(1, ["C3", "E3", "G3"], "1n", { arpeggio: "down" }) // Create whole note chord of three notes, played in arpeggio.
242
- ```
243
-
244
- ### Add Rest
245
-
246
- ```js
247
- .addRest(0, "16n") // Add sixteenth rest
248
- .addRest(0, "4.") // Add dotted quarter rest
249
- .addRest(0, "4n", { staffPos: "D3" }) // Draw this quarter rest at level of "D3" note.
250
- .addRest(0, "4n", { hide: true }) // Invisible rest affects playing
251
- ```
252
-
253
- ### Add Tuplet
254
- This generic function works for any tuplet:
255
- ```js
256
- // Example: add triplet
257
- .addTuplet(0, { parts: 3, inTimeOf: 2 }, notes => {
258
- notes.addNote("G3", "8n")
259
- notes.addNote("B3", "8n")
260
- notes.addNote("D4", "8n")
261
- })
262
- ```
263
-
264
- Triplets can also be created using note length (e.g. NoteLength.EighthTriplet or "8t").
265
- ```js
266
- // Example: add triplet using triplet note length.
267
- .addNote(0, ["G3", "B3", "D4"], "8t")
268
- ```
269
-
270
- ### Add Lyrics
271
-
272
- For lyrics align you can use `Score.LyricsAlign` enum values (e.g. `Score.LyricsAlign.Left`)
273
- or corresponding string values (e.g. `"left"`).
274
-
275
- For lyrics hyphen you can use `Score.LyricsHyphen` enum values (e.g. `Score.LyricsHyphen.Hyphen`)
276
- or corresponding string values (e.g. `"-"`).
277
-
278
- ```js
279
- .addLyrics(1, "4n", "La") // Add lyrics text/syllable "La", quarter note length, verse 1.
280
- .addLyrics(1, "4n", ["La", "la", "la", "la"]) // Add multiple lysics texts/syllables, each quarter note length, verse 1.
281
- .addLyrics(2, "4n", "La", { align: "left" }) // Left align lyrics text/syllable.
282
- .addLyrics(2, "4n", "La", { align: "center" }) // Center align lyrics text/syllable.
283
- .addLyrics(2, "4n", "La", { align: "right" }) // Right align lyrics text/syllable.
284
- .addLyrics(3, "4n", "La", { hyphen: "-" }) // Add hyphen (short line '-') centered between this and next syllable.
285
- .addLyrics(3, "4n", "La", { hyphen: "---" }) // Add extender (long line) between this and next syllable.
286
- ```
287
-
288
- ### Add Fermata
289
-
290
- For fermata you can use `Score.Fermata` enum values (e.g. `Score.Fermata.AtNote`)
291
- or corresponding string values (e.g. `"atNote"`).
292
-
293
- ```js
294
- .addNote(0, "C3", "2n").addFermata("atNote") // Add fermata at note.
295
- .addFermata("atMeasureEnd") // Add fermata at measure end.
296
- ```
297
-
298
- ### Add Navigation
299
-
300
- Add navigation element to measure.
301
-
302
- For navigation you can use `Score.Navigation` enum values (e.g. `Score.Navigation.DC_al_Fine`)
303
- or corresponding string values (e.g. `"D.C. al Fine"`).
304
-
305
- ```js
306
- .addNavigation("D.C. al Fine") // Add "D.C. al Fine"
307
- .addNavigation("D.C. al Coda") // Add "D.C. al Coda"
308
- .addNavigation("D.S. al Fine") // Add "D.S. al Fine"
309
- .addNavigation("D.S. al Coda") // Add "D.S. al Coda"
310
- .addNavigation("Coda") // Add "Coda"
311
- .addNavigation("toCoda") // Ass "toCoda"
312
- .addNavigation("Segno") // Add "Segno" symbol
313
- .addNavigation("Fine") // Add "Fine"
314
- .addNavigation("startRepeat") // Add repeat sections start position
315
- .addNavigation("endRepeat", 3) // Add repeat sections end position, repeat sectionplayed 3 times
316
- .addNavigation("ending", 1, 2) // Add ending, played on 1st and 2nd run
317
- ```
318
-
319
- ### Add Annotation
320
-
321
- Add annotation text anchored to previously added note, chord or rest.
322
-
323
- For annotation you can use `Score.Annotation` enum values (e.g. `Score.Annotation.Tempo`)
324
- or corresponding string values (e.g. `"tempo"`).
325
-
326
- ```js
327
- .addAnnotation("dynamics", "ff") // Add dynamics annotation text.
328
- .addAnnotation("tempo", "accel.") // Add tempo annotation text.
329
- .addAnnotation("ppp") // Add annotation text, detect annotation type automatically (incomplete list of annotations supported).
330
- ```
331
-
332
- ### Add Label
333
-
334
- Add text label anchored to previously added note, chord or rest.
335
-
336
- For label you can use `Score.Label` enum values (e.g. `Score.Label.Chord`)
337
- or corresponding string values (e.g. `"chord"`).
338
-
339
- ```js
340
- .addLabel("chord", "Am") // Add chord label, positioned above staff by default.
341
- .addLabel("note", "C#5") // Add note label, positioned below staff by default.
342
- ```
343
-
344
- ### Positioning Elements
345
-
346
- `addLyrics`, `addFermata`, `addNavigation`, `addAnnotation` and `addLabel` functions have alternate versions
347
- `addLyricsTo`, `addFermataTo`, `addNavigationTo`, `addAnnotationTo` and `addLabelTo` that contain extra first argument.
348
-
349
- ```js
350
- .addLabelTo(0, "chord", "Am") // Add label to top (id 0) staff/tab.
351
- .addLabelTo([0, 1], "chord", "Am") // Add label to top two (id 0 and 1) staves/tabs.
352
- .addLabelTo("staff1", "chord", "Am") // Add label to staff/tab/group named "staff1".
353
- .addLabelTo("grp1", "chord", "Am") // Add label to staff/tab/group named "grp1".
354
-
355
- // Create staff groups
356
- .addStaffGroup("grp1", 0, "above") // This staff group layouts elements above top staff/tab.
357
- .addStaffGroup("grp2", [1], "below") // This staff group layouts elements below second staff/tab from top.
358
- .addStaffGroup("grp3", "tab1", "both") // This staff group layouts elements above and below tab named "tab1".
359
- .addStaffGroup("grp4", ["staff1", "tab1"], "auto") // This staff group layouts elements to their default locations in "staff1" and "tab1".
360
- ```
361
-
362
- ### Add Extension
363
-
364
- Adds extension line to previously added label or annotation.
365
-
366
- ```js
367
- .addExtension(ext => ext.notes("1n", 2)) // Add extension line, length is 2 whole notes
368
- .addExtension(ext => ext.measures(3).hide()) // Add extension line, length is 3 measures, hidden
369
- .addExtension(ext => ext.measures(1).notes("8n")) // Add extension line, length is 1 measure + 1 eigth note
370
- .addExtension(ext => ext.infinity()) // Add extension line, length is as long as possible
371
- .addExtension() // Add extension line, length is as long as possible
372
- ```
373
-
374
- ### Add Connective (tie, slur, slide)
375
-
376
- For connective you can use `Score.Connective` enum values (e.g. `Score.Connective.Tie`)
377
- or corresponding string values (e.g. `"tie"`).
378
-
379
- For note anchor you can use `Score.NoteAnchor` enum values (e.g. `Score.NoteAnchor.Above`)
380
- or corresponding string values (e.g. `"above"`).
381
-
382
-
383
- ```js
384
- .addConnective("tie") // Add tie
385
- .addConnective("slur") // Add slur
386
- .addConnective("slide") // Add slide
387
- .addConnective("tie", 3) // Add tie with span value (describes how many notes the connective is across).
388
- .addConnective("slur", 2, "above") // Add slur connected above note.
389
- .addConnective("slur", 2, "below") // Add slur connected below note.
390
- .addConnective("slur", 2, "center") // Add slur connected next to note.
391
- .addConnective("slur", 2, "stemTip") // Add slur connected at stem tip.
392
- ```
393
-
394
- ### Guitar Tab
395
-
396
- This library has simple guitar tab rendering.
397
-
398
- Add notes with `string` property to specify at what string the fret number is rendered in the tab.
399
-
400
- ```js
401
- .addNote(0, "G3", "8n", { string: 3 })
402
- .addChord(0, ["E4", "C3"], "8n", { string: [1, 5] })
403
- ```
404
-
405
- ### Beams
406
-
407
- Beams are detected using beam grouping logic that is defined for each time signature.
408
- These are the beam groupings for each time signature.
409
-
410
- | Time signature | Beam grouping |
411
- |----------------|---------------|
412
- | `2/4` | `2-2` |
413
- | `3/4` | `2-2-2` |
414
- | `4/4` | `4-4` and `2-2-2-2` together |
415
- | `3/8` | `3` |
416
- | `5/8` | `2-3` or `3-2`, user selectable |
417
- | `6/8` | `3-3` |
418
- | `7/8` | `2-2-3` or `3-2-2`, user selectable |
419
- | `9/8` | `3-3-3` |
420
- | `12/8` | `3-3-3-3` |
421
-
422
- How to set beam grouping for `5/8` and `7/8` time signatures,
423
- see [Set Time Signature](#set-time-signature) section above.
424
-
425
- ### Instruments
426
-
427
- Default instrument `Synthesizer` is available out of the box.
428
- Other instruments need to be registered manually.
429
-
430
- `Classical Guitar` is available via `audio-cg` module.
431
-
432
- ```js
433
- // Import classical guitar instrument.
434
- import { ClassicalGuitar } from "@tspro/web-music-score/audio-cg";
435
-
436
- // Add and use classical guitar instrument.
437
- Audio.addInstrument(ClassicalGuitar);
438
- ```
439
-
440
- You can easily create and register your own instrument.
441
- ```js
442
- class MyCoolInstrument implements Audio.Instrument {
443
- constructor() { }
444
- getName() { return "My Cool Instrument"; }
445
- playNote(note: string, duration: number, linearVolume: number) { }
446
- stop() { }
447
- }
448
-
449
- // Add and use my cool instrument.
450
- Audio.addInstrument(new MyCoolInstrument());
451
- ```
452
-
453
- ### Play Document
454
-
455
- ```js
456
- // Simple play
457
- doc.play();
458
-
459
- // More playback options:
460
- let player = new Score.MPlayer(doc);
461
-
462
- player.play();
463
- player.pause();
464
- player.stop();
465
-
466
- Score.MPlayer.stopAll();
467
- ```
468
-
469
- ### Viewing Using React JSX/TSX
470
-
471
- ```js
472
- // Draw document
473
- <ScoreUI.MusicScoreView doc={doc} />
474
-
475
- // Show playback buttons
476
- <ScoreUI.PlaybackButtons doc={doc} singlePlayStop /> // Single play/stop button.
477
- <ScoreUI.PlaybackButtons doc={doc} playStop /> // Play and stop buttons.
478
- <ScoreUI.PlaybackButtons doc={doc} playPauseStop /> // Play, pause and Stop buttons.
479
- <ScoreUI.PlaybackButtons doc={doc} /> // Default is play, pause and Stop buttons.
480
- ```
481
-
482
- Hint! Bootstrap is used for better visual appearance.
483
- - Install bootstrap: `npm install bootstrap`
484
- - Import in app entry: `import "bootstrap/dist/css/bootstrap.min.css";`
485
-
486
- ### Viewing Using Plain JS/TS
487
-
488
- ```html
489
- <!-- Add canvas -->
490
- <canvas id="canvasId"></canvas>
491
-
492
- <!-- Add play button -->
493
- <button id="playButtonId"></button>
494
- <!-- Add pause button -->
495
- <button id="pauseButtonId"></button>
496
- <!-- Add stop button -->
497
- <button id="stopButtonId"></button>
498
- <!-- Or add combined play/stop button -->
499
- <button id="playStopButtonId"></button>
500
- ```
501
-
502
- ```js
503
- // Draw document
504
- let r = new Score.MRenderContext().
505
- setCanvas("canvasId").
506
- setDocument(doc).
507
- draw();
508
-
509
- // Add playback buttons
510
- let p = new Score.MPlaybackButtons().
511
- setPlayButton("playButtonId").
512
- setPauseButton("pauseButtonId").
513
- setStopButton("stopButtonId").
514
- setDocument(doc);
515
-
516
- // You can also set combined play/stop button.
517
- p.setPlayStopButton("playStopButtonId");
518
-
519
- // You can also pass HTMLButtonElement instead of element id.
520
- p.setPlayButton(playButtonElement);
521
- ```
522
-
523
- ### MusicError
524
- ```js
525
- try {
526
- // Do your music stuff
527
- }
528
- catch (e) {
529
- if(e instanceof Core.MusicError) {
530
- // There was music error.
531
- }
532
- }
533
- ```
534
-
535
- ## Compatibility
536
- - This library is bundled to ESM, CJS and IIFE formats.
537
- - Target is to support ES6/ES2015.
538
- - No polyfills are included.
539
-
540
- While designed for compatibility in mind, the library has not been explicitly tested against specific Node.js or browser versions.
541
-
542
- ## Report a Bug
543
-
544
- Found a bug or unexpected behavior? Suggest a feature or impovement?
5
+ ## Deprcated!!!
545
6
 
546
- [Please open a new issue.](https://github.com/pahkasoft/web-music-score/issues/new/choose)
7
+ Package `@tspro/web-music-score` is now deprecated!!!
547
8
 
548
- Thanks for helping improve the project!
9
+ Package `web-music-score` continues from version 6.0.0 onwards.
549
10
 
550
- ## License
11
+ Learn more:
12
+ - Package: [web-music-score](https://www.npmjs.com/package/web-music-score)
13
+ - Website: [web-music-score.org](https://web-music-score.org)
551
14
 
552
- This project is licensed under the [MIT License](https://mit-license.org/).
15
+ ## Older Documentation
553
16
 
554
- It also bundles the [Tone.js](https://github.com/Tonejs/Tone.js) library,
555
- which is licensed under the [MIT License](https://opensource.org/license/mit).
17
+ If you need older documentation, look at [version 5.5.0](https://www.npmjs.com/package/@tspro/web-music-score/v/5.5.0).
@@ -1,4 +1,4 @@
1
- import { N as Note } from '../note-RVXvpfyV.js';
1
+ import { N as Note } from '../note-CJuq5aBy.js';
2
2
  import { I as Instrument } from '../instrument-DYboobMW.js';
3
3
  export { l as linearToDecibels } from '../instrument-DYboobMW.js';
4
4