@vielzeug/codex 26.11.20 → 26.11.21
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/data/catalog.json +48 -48
- package/data/llms-full.txt +32 -32
- package/data/llms.txt +1 -1
- package/data/manifest.json +1 -1
- package/data/packages/bard.json +1 -1
- package/package.json +2 -2
package/data/catalog.json
CHANGED
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"rune"
|
|
39
39
|
],
|
|
40
40
|
"slug": "archive",
|
|
41
|
-
"version": "26.11.
|
|
41
|
+
"version": "26.11.20"
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
"availableDocPages": [
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"coins"
|
|
112
112
|
],
|
|
113
113
|
"slug": "arsenal",
|
|
114
|
-
"version": "26.11.
|
|
114
|
+
"version": "26.11.20"
|
|
115
115
|
},
|
|
116
116
|
{
|
|
117
117
|
"availableDocPages": [
|
|
@@ -166,7 +166,7 @@
|
|
|
166
166
|
"refine"
|
|
167
167
|
],
|
|
168
168
|
"slug": "assay",
|
|
169
|
-
"version": "26.11.
|
|
169
|
+
"version": "26.11.20"
|
|
170
170
|
},
|
|
171
171
|
{
|
|
172
172
|
"availableDocPages": [
|
|
@@ -198,7 +198,7 @@
|
|
|
198
198
|
"necromancer"
|
|
199
199
|
],
|
|
200
200
|
"slug": "bard",
|
|
201
|
-
"version": "26.11.
|
|
201
|
+
"version": "26.11.20"
|
|
202
202
|
},
|
|
203
203
|
{
|
|
204
204
|
"availableDocPages": [
|
|
@@ -237,7 +237,7 @@
|
|
|
237
237
|
"vault"
|
|
238
238
|
],
|
|
239
239
|
"slug": "beacon",
|
|
240
|
-
"version": "26.11.
|
|
240
|
+
"version": "26.11.20"
|
|
241
241
|
},
|
|
242
242
|
{
|
|
243
243
|
"availableDocPages": [
|
|
@@ -279,7 +279,7 @@
|
|
|
279
279
|
"ward"
|
|
280
280
|
],
|
|
281
281
|
"slug": "clockwork",
|
|
282
|
-
"version": "26.11.
|
|
282
|
+
"version": "26.11.20"
|
|
283
283
|
},
|
|
284
284
|
{
|
|
285
285
|
"availableDocPages": [
|
|
@@ -311,7 +311,7 @@
|
|
|
311
311
|
"refine"
|
|
312
312
|
],
|
|
313
313
|
"slug": "codex",
|
|
314
|
-
"version": "26.11.
|
|
314
|
+
"version": "26.11.20"
|
|
315
315
|
},
|
|
316
316
|
{
|
|
317
317
|
"availableDocPages": [
|
|
@@ -381,7 +381,7 @@
|
|
|
381
381
|
"spell"
|
|
382
382
|
],
|
|
383
383
|
"slug": "coins",
|
|
384
|
-
"version": "26.11.
|
|
384
|
+
"version": "26.11.20"
|
|
385
385
|
},
|
|
386
386
|
{
|
|
387
387
|
"availableDocPages": [
|
|
@@ -422,7 +422,7 @@
|
|
|
422
422
|
"rune"
|
|
423
423
|
],
|
|
424
424
|
"slug": "conduit",
|
|
425
|
-
"version": "26.11.
|
|
425
|
+
"version": "26.11.20"
|
|
426
426
|
},
|
|
427
427
|
{
|
|
428
428
|
"availableDocPages": [
|
|
@@ -464,7 +464,7 @@
|
|
|
464
464
|
"postmaster"
|
|
465
465
|
],
|
|
466
466
|
"slug": "courier",
|
|
467
|
-
"version": "26.11.
|
|
467
|
+
"version": "26.11.20"
|
|
468
468
|
},
|
|
469
469
|
{
|
|
470
470
|
"availableDocPages": [
|
|
@@ -510,7 +510,7 @@
|
|
|
510
510
|
"refine"
|
|
511
511
|
],
|
|
512
512
|
"slug": "dnd",
|
|
513
|
-
"version": "26.11.
|
|
513
|
+
"version": "26.11.20"
|
|
514
514
|
},
|
|
515
515
|
{
|
|
516
516
|
"availableDocPages": [
|
|
@@ -552,7 +552,7 @@
|
|
|
552
552
|
"herald"
|
|
553
553
|
],
|
|
554
554
|
"slug": "familiar",
|
|
555
|
-
"version": "26.11.
|
|
555
|
+
"version": "26.11.20"
|
|
556
556
|
},
|
|
557
557
|
{
|
|
558
558
|
"availableDocPages": [
|
|
@@ -619,7 +619,7 @@
|
|
|
619
619
|
"courier"
|
|
620
620
|
],
|
|
621
621
|
"slug": "flux",
|
|
622
|
-
"version": "26.11.
|
|
622
|
+
"version": "26.11.20"
|
|
623
623
|
},
|
|
624
624
|
{
|
|
625
625
|
"availableDocPages": [
|
|
@@ -659,7 +659,7 @@
|
|
|
659
659
|
"ore"
|
|
660
660
|
],
|
|
661
661
|
"slug": "focus",
|
|
662
|
-
"version": "26.11.
|
|
662
|
+
"version": "26.11.20"
|
|
663
663
|
},
|
|
664
664
|
{
|
|
665
665
|
"availableDocPages": [
|
|
@@ -701,7 +701,7 @@
|
|
|
701
701
|
"assay"
|
|
702
702
|
],
|
|
703
703
|
"slug": "forge",
|
|
704
|
-
"version": "26.11.
|
|
704
|
+
"version": "26.11.20"
|
|
705
705
|
},
|
|
706
706
|
{
|
|
707
707
|
"availableDocPages": [
|
|
@@ -739,7 +739,7 @@
|
|
|
739
739
|
"keymap"
|
|
740
740
|
],
|
|
741
741
|
"slug": "gesture",
|
|
742
|
-
"version": "26.11.
|
|
742
|
+
"version": "26.11.20"
|
|
743
743
|
},
|
|
744
744
|
{
|
|
745
745
|
"availableDocPages": [
|
|
@@ -783,7 +783,7 @@
|
|
|
783
783
|
"familiar"
|
|
784
784
|
],
|
|
785
785
|
"slug": "herald",
|
|
786
|
-
"version": "26.11.
|
|
786
|
+
"version": "26.11.20"
|
|
787
787
|
},
|
|
788
788
|
{
|
|
789
789
|
"availableDocPages": [
|
|
@@ -826,7 +826,7 @@
|
|
|
826
826
|
"tempo"
|
|
827
827
|
],
|
|
828
828
|
"slug": "illusionist",
|
|
829
|
-
"version": "26.11.
|
|
829
|
+
"version": "26.11.20"
|
|
830
830
|
},
|
|
831
831
|
{
|
|
832
832
|
"availableDocPages": [
|
|
@@ -871,7 +871,7 @@
|
|
|
871
871
|
"ore"
|
|
872
872
|
],
|
|
873
873
|
"slug": "keymap",
|
|
874
|
-
"version": "26.11.
|
|
874
|
+
"version": "26.11.20"
|
|
875
875
|
},
|
|
876
876
|
{
|
|
877
877
|
"availableDocPages": [
|
|
@@ -918,7 +918,7 @@
|
|
|
918
918
|
"vault"
|
|
919
919
|
],
|
|
920
920
|
"slug": "ledger",
|
|
921
|
-
"version": "26.11.
|
|
921
|
+
"version": "26.11.20"
|
|
922
922
|
},
|
|
923
923
|
{
|
|
924
924
|
"availableDocPages": [
|
|
@@ -963,7 +963,7 @@
|
|
|
963
963
|
"courier"
|
|
964
964
|
],
|
|
965
965
|
"slug": "lingua",
|
|
966
|
-
"version": "26.11.
|
|
966
|
+
"version": "26.11.20"
|
|
967
967
|
},
|
|
968
968
|
{
|
|
969
969
|
"availableDocPages": [
|
|
@@ -1001,7 +1001,7 @@
|
|
|
1001
1001
|
"herald"
|
|
1002
1002
|
],
|
|
1003
1003
|
"slug": "mesh",
|
|
1004
|
-
"version": "26.11.
|
|
1004
|
+
"version": "26.11.20"
|
|
1005
1005
|
},
|
|
1006
1006
|
{
|
|
1007
1007
|
"availableDocPages": [
|
|
@@ -1038,7 +1038,7 @@
|
|
|
1038
1038
|
"ore"
|
|
1039
1039
|
],
|
|
1040
1040
|
"slug": "necromancer",
|
|
1041
|
-
"version": "26.11.
|
|
1041
|
+
"version": "26.11.20"
|
|
1042
1042
|
},
|
|
1043
1043
|
{
|
|
1044
1044
|
"availableDocPages": [
|
|
@@ -1078,7 +1078,7 @@
|
|
|
1078
1078
|
"prism"
|
|
1079
1079
|
],
|
|
1080
1080
|
"slug": "orbit",
|
|
1081
|
-
"version": "26.11.
|
|
1081
|
+
"version": "26.11.20"
|
|
1082
1082
|
},
|
|
1083
1083
|
{
|
|
1084
1084
|
"availableDocPages": [
|
|
@@ -1146,7 +1146,7 @@
|
|
|
1146
1146
|
"orbit"
|
|
1147
1147
|
],
|
|
1148
1148
|
"slug": "ore",
|
|
1149
|
-
"version": "26.11.
|
|
1149
|
+
"version": "26.11.20"
|
|
1150
1150
|
},
|
|
1151
1151
|
{
|
|
1152
1152
|
"availableDocPages": [
|
|
@@ -1190,7 +1190,7 @@
|
|
|
1190
1190
|
"vault"
|
|
1191
1191
|
],
|
|
1192
1192
|
"slug": "patchwork",
|
|
1193
|
-
"version": "26.11.
|
|
1193
|
+
"version": "26.11.20"
|
|
1194
1194
|
},
|
|
1195
1195
|
{
|
|
1196
1196
|
"availableDocPages": [
|
|
@@ -1234,7 +1234,7 @@
|
|
|
1234
1234
|
"ripple"
|
|
1235
1235
|
],
|
|
1236
1236
|
"slug": "postmaster",
|
|
1237
|
-
"version": "26.11.
|
|
1237
|
+
"version": "26.11.20"
|
|
1238
1238
|
},
|
|
1239
1239
|
{
|
|
1240
1240
|
"availableDocPages": [
|
|
@@ -1278,7 +1278,7 @@
|
|
|
1278
1278
|
"orbit"
|
|
1279
1279
|
],
|
|
1280
1280
|
"slug": "prism",
|
|
1281
|
-
"version": "26.11.
|
|
1281
|
+
"version": "26.11.20"
|
|
1282
1282
|
},
|
|
1283
1283
|
{
|
|
1284
1284
|
"availableDocPages": [
|
|
@@ -1342,7 +1342,7 @@
|
|
|
1342
1342
|
"clockwork"
|
|
1343
1343
|
],
|
|
1344
1344
|
"slug": "pulse",
|
|
1345
|
-
"version": "26.11.
|
|
1345
|
+
"version": "26.11.20"
|
|
1346
1346
|
},
|
|
1347
1347
|
{
|
|
1348
1348
|
"availableDocPages": [
|
|
@@ -1475,7 +1475,7 @@
|
|
|
1475
1475
|
"keymap"
|
|
1476
1476
|
],
|
|
1477
1477
|
"slug": "refine",
|
|
1478
|
-
"version": "26.11.
|
|
1478
|
+
"version": "26.11.20"
|
|
1479
1479
|
},
|
|
1480
1480
|
{
|
|
1481
1481
|
"availableDocPages": [
|
|
@@ -1520,7 +1520,7 @@
|
|
|
1520
1520
|
"ledger"
|
|
1521
1521
|
],
|
|
1522
1522
|
"slug": "ripple",
|
|
1523
|
-
"version": "26.11.
|
|
1523
|
+
"version": "26.11.20"
|
|
1524
1524
|
},
|
|
1525
1525
|
{
|
|
1526
1526
|
"availableDocPages": [
|
|
@@ -1574,7 +1574,7 @@
|
|
|
1574
1574
|
"familiar"
|
|
1575
1575
|
],
|
|
1576
1576
|
"slug": "rune",
|
|
1577
|
-
"version": "26.11.
|
|
1577
|
+
"version": "26.11.20"
|
|
1578
1578
|
},
|
|
1579
1579
|
{
|
|
1580
1580
|
"availableDocPages": [
|
|
@@ -1615,7 +1615,7 @@
|
|
|
1615
1615
|
"refine"
|
|
1616
1616
|
],
|
|
1617
1617
|
"slug": "sandbox",
|
|
1618
|
-
"version": "26.11.
|
|
1618
|
+
"version": "26.11.20"
|
|
1619
1619
|
},
|
|
1620
1620
|
{
|
|
1621
1621
|
"availableDocPages": [
|
|
@@ -1665,7 +1665,7 @@
|
|
|
1665
1665
|
"ripple"
|
|
1666
1666
|
],
|
|
1667
1667
|
"slug": "scout",
|
|
1668
|
-
"version": "26.11.
|
|
1668
|
+
"version": "26.11.20"
|
|
1669
1669
|
},
|
|
1670
1670
|
{
|
|
1671
1671
|
"availableDocPages": [
|
|
@@ -1707,7 +1707,7 @@
|
|
|
1707
1707
|
"archive"
|
|
1708
1708
|
],
|
|
1709
1709
|
"slug": "scribe",
|
|
1710
|
-
"version": "26.11.
|
|
1710
|
+
"version": "26.11.20"
|
|
1711
1711
|
},
|
|
1712
1712
|
{
|
|
1713
1713
|
"availableDocPages": [
|
|
@@ -1760,7 +1760,7 @@
|
|
|
1760
1760
|
"refine"
|
|
1761
1761
|
],
|
|
1762
1762
|
"slug": "scroll",
|
|
1763
|
-
"version": "26.11.
|
|
1763
|
+
"version": "26.11.20"
|
|
1764
1764
|
},
|
|
1765
1765
|
{
|
|
1766
1766
|
"availableDocPages": [
|
|
@@ -1807,7 +1807,7 @@
|
|
|
1807
1807
|
"gesture"
|
|
1808
1808
|
],
|
|
1809
1809
|
"slug": "sentinel",
|
|
1810
|
-
"version": "26.11.
|
|
1810
|
+
"version": "26.11.20"
|
|
1811
1811
|
},
|
|
1812
1812
|
{
|
|
1813
1813
|
"availableDocPages": [
|
|
@@ -1847,7 +1847,7 @@
|
|
|
1847
1847
|
"refine"
|
|
1848
1848
|
],
|
|
1849
1849
|
"slug": "sigil",
|
|
1850
|
-
"version": "26.11.
|
|
1850
|
+
"version": "26.11.20"
|
|
1851
1851
|
},
|
|
1852
1852
|
{
|
|
1853
1853
|
"availableDocPages": [
|
|
@@ -1892,7 +1892,7 @@
|
|
|
1892
1892
|
"wayfinder"
|
|
1893
1893
|
],
|
|
1894
1894
|
"slug": "sourcerer",
|
|
1895
|
-
"version": "26.11.
|
|
1895
|
+
"version": "26.11.20"
|
|
1896
1896
|
},
|
|
1897
1897
|
{
|
|
1898
1898
|
"availableDocPages": [
|
|
@@ -1952,7 +1952,7 @@
|
|
|
1952
1952
|
"vault"
|
|
1953
1953
|
],
|
|
1954
1954
|
"slug": "spell",
|
|
1955
|
-
"version": "26.11.
|
|
1955
|
+
"version": "26.11.20"
|
|
1956
1956
|
},
|
|
1957
1957
|
{
|
|
1958
1958
|
"availableDocPages": [
|
|
@@ -1995,7 +1995,7 @@
|
|
|
1995
1995
|
"archive"
|
|
1996
1996
|
],
|
|
1997
1997
|
"slug": "tabula",
|
|
1998
|
-
"version": "26.11.
|
|
1998
|
+
"version": "26.11.20"
|
|
1999
1999
|
},
|
|
2000
2000
|
{
|
|
2001
2001
|
"availableDocPages": [
|
|
@@ -2036,7 +2036,7 @@
|
|
|
2036
2036
|
"ripple"
|
|
2037
2037
|
],
|
|
2038
2038
|
"slug": "tandem",
|
|
2039
|
-
"version": "26.11.
|
|
2039
|
+
"version": "26.11.20"
|
|
2040
2040
|
},
|
|
2041
2041
|
{
|
|
2042
2042
|
"availableDocPages": [
|
|
@@ -2086,7 +2086,7 @@
|
|
|
2086
2086
|
"herald"
|
|
2087
2087
|
],
|
|
2088
2088
|
"slug": "tavern",
|
|
2089
|
-
"version": "26.11.
|
|
2089
|
+
"version": "26.11.20"
|
|
2090
2090
|
},
|
|
2091
2091
|
{
|
|
2092
2092
|
"availableDocPages": [
|
|
@@ -2147,7 +2147,7 @@
|
|
|
2147
2147
|
"vault"
|
|
2148
2148
|
],
|
|
2149
2149
|
"slug": "tempo",
|
|
2150
|
-
"version": "26.11.
|
|
2150
|
+
"version": "26.11.20"
|
|
2151
2151
|
},
|
|
2152
2152
|
{
|
|
2153
2153
|
"availableDocPages": [
|
|
@@ -2197,7 +2197,7 @@
|
|
|
2197
2197
|
"ripple"
|
|
2198
2198
|
],
|
|
2199
2199
|
"slug": "vault",
|
|
2200
|
-
"version": "26.11.
|
|
2200
|
+
"version": "26.11.20"
|
|
2201
2201
|
},
|
|
2202
2202
|
{
|
|
2203
2203
|
"availableDocPages": [
|
|
@@ -2243,7 +2243,7 @@
|
|
|
2243
2243
|
"refine"
|
|
2244
2244
|
],
|
|
2245
2245
|
"slug": "ward",
|
|
2246
|
-
"version": "26.11.
|
|
2246
|
+
"version": "26.11.20"
|
|
2247
2247
|
},
|
|
2248
2248
|
{
|
|
2249
2249
|
"availableDocPages": [
|
|
@@ -2300,8 +2300,8 @@
|
|
|
2300
2300
|
"herald"
|
|
2301
2301
|
],
|
|
2302
2302
|
"slug": "wayfinder",
|
|
2303
|
-
"version": "26.11.
|
|
2303
|
+
"version": "26.11.20"
|
|
2304
2304
|
}
|
|
2305
2305
|
],
|
|
2306
|
-
"version": "26.11.
|
|
2306
|
+
"version": "26.11.20"
|
|
2307
2307
|
}
|
package/data/llms-full.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Vielzeug: Full Documentation
|
|
2
2
|
|
|
3
|
-
> Complete documentation for 47 packages. Version: 26.11.
|
|
3
|
+
> Complete documentation for 47 packages. Version: 26.11.20
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -2963,30 +2963,30 @@ Returned by `play()` and `synth()`.
|
|
|
2963
2963
|
|
|
2964
2964
|
### PlayOptions
|
|
2965
2965
|
|
|
2966
|
-
| Option | Type | Default | Notes
|
|
2967
|
-
| ----------------------- | ---------------------- | ------------- |
|
|
2968
|
-
| `bus` | `string` | `'sfx'` | Destination bus
|
|
2969
|
-
| `volume` | `number` | `1` | Linear 0..1
|
|
2970
|
-
| `pan` | `number` | `0` | -1..1; voices always route via a panner
|
|
2971
|
-
| `loop` | `boolean` | `false` | Loops the buffer or sprite region
|
|
2972
|
-
| `loopStart` / `loopEnd` | `number` | — | Absolute buffer seconds
|
|
2973
|
-
| `offset` | `number` | `0` | Start offset in seconds
|
|
2974
|
-
| `detune` | `number \| [min, max]` | — | Cents; ranges sampled per voice
|
|
2975
|
-
| `rate` | `number \| [min, max]` | — | Playback rate; shifts pitch on buffers
|
|
2976
|
-
| `maxVoices` | `number` | — | Per-key cap; oldest copy is stolen
|
|
2977
|
-
| `fadeIn` | `number` | — | Seconds from 0 to `volume`
|
|
2978
|
-
| `random` | `() => number` | `Math.random` | Deterministic sampling in tests
|
|
2966
|
+
| Option | Type | Default | Notes |
|
|
2967
|
+
| ----------------------- | ---------------------- | ------------- | --------------------------------------- |
|
|
2968
|
+
| `bus` | `string` | `'sfx'` | Destination bus |
|
|
2969
|
+
| `volume` | `number` | `1` | Linear 0..1 |
|
|
2970
|
+
| `pan` | `number` | `0` | -1..1; voices always route via a panner |
|
|
2971
|
+
| `loop` | `boolean` | `false` | Loops the buffer or sprite region |
|
|
2972
|
+
| `loopStart` / `loopEnd` | `number` | — | Absolute buffer seconds |
|
|
2973
|
+
| `offset` | `number` | `0` | Start offset in seconds |
|
|
2974
|
+
| `detune` | `number \| [min, max]` | — | Cents; ranges sampled per voice |
|
|
2975
|
+
| `rate` | `number \| [min, max]` | — | Playback rate; shifts pitch on buffers |
|
|
2976
|
+
| `maxVoices` | `number` | — | Per-key cap; oldest copy is stolen |
|
|
2977
|
+
| `fadeIn` | `number` | — | Seconds from 0 to `volume` |
|
|
2978
|
+
| `random` | `() => number` | `Math.random` | Deterministic sampling in tests |
|
|
2979
2979
|
|
|
2980
2980
|
### SynthOptions
|
|
2981
2981
|
|
|
2982
|
-
| Option
|
|
2983
|
-
|
|
|
2984
|
-
| `type`
|
|
2985
|
-
| `freq`
|
|
2986
|
-
| `duration`
|
|
2987
|
-
| `envelope`
|
|
2988
|
-
| `filter`
|
|
2989
|
-
| `bus` / `volume` / `pan` / `detune`
|
|
2982
|
+
| Option | Type | Default | Notes |
|
|
2983
|
+
| ----------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------- |
|
|
2984
|
+
| `type` | `'sine' \| 'square' \| 'sawtooth' \| 'triangle' \| 'noise'` | `'sine'` | `'noise'` uses a cached white-noise buffer |
|
|
2985
|
+
| `freq` | `number \| [from, to]` | `440` | Tuple sweeps exponentially; maps to filter cutoff for `'noise'` |
|
|
2986
|
+
| `duration` | `number` | `0.3` | Total seconds including release; must be positive |
|
|
2987
|
+
| `envelope` | `SynthEnvelope` | `{ attack: 0.005, decay: 0.05, sustain: 0.6, release: 0.1 }` | ADSR; `sustain` is a level |
|
|
2988
|
+
| `filter` | `SynthFilter` | — | Biquad stage before the envelope |
|
|
2989
|
+
| `bus` / `volume` / `pan` / `detune` | as in `PlayOptions` | | |
|
|
2990
2990
|
|
|
2991
2991
|
---
|
|
2992
2992
|
|
|
@@ -3021,16 +3021,16 @@ While the `source` bus has active voices, `target` ramps to `gain`; when they en
|
|
|
3021
3021
|
|
|
3022
3022
|
### MusicDeck
|
|
3023
3023
|
|
|
3024
|
-
| Member | Signature
|
|
3025
|
-
| --------------------------------------------- |
|
|
3026
|
-
| `current` | `string \| null`
|
|
3027
|
-
| `playing` | `boolean`
|
|
3028
|
-
| `transition(key, options?)` | `(string, TransitionOptions?) => void`
|
|
3029
|
-
| `queue(keys, options?)` | `(readonly string[], QueueOptions?) => void`
|
|
3030
|
-
| `next()` / `previous()` | `() => void`
|
|
3031
|
-
| `pause()` / `play()` | `() => void`
|
|
3032
|
-
| `stop(options?)` | `(FadeOptions?) => void`
|
|
3033
|
-
| `dispose()` / `disposed` / `[Symbol.dispose]` |
|
|
3024
|
+
| Member | Signature | Notes |
|
|
3025
|
+
| --------------------------------------------- | -------------------------------------------- | ---------------------------------------------------- |
|
|
3026
|
+
| `current` | `string \| null` | Active track key |
|
|
3027
|
+
| `playing` | `boolean` | `false` while paused or stopped |
|
|
3028
|
+
| `transition(key, options?)` | `(string, TransitionOptions?) => void` | Crossfades; transitioning to the live key is a no-op |
|
|
3029
|
+
| `queue(keys, options?)` | `(readonly string[], QueueOptions?) => void` | Replaces the queue and starts its first track |
|
|
3030
|
+
| `next()` / `previous()` | `() => void` | No-op without a queue |
|
|
3031
|
+
| `pause()` / `play()` | `() => void` | `play()` resumes from the paused offset |
|
|
3032
|
+
| `stop(options?)` | `(FadeOptions?) => void` | Stops and clears queue and slot |
|
|
3033
|
+
| `dispose()` / `disposed` / `[Symbol.dispose]` | | Releases a Media Session claim |
|
|
3034
3034
|
|
|
3035
3035
|
`TransitionOptions`: `fade`, `loop`, `loopStart`, `loopEnd`, `offset`.
|
|
3036
3036
|
`QueueOptions`: `shuffle`, `crossfade`, `repeat`, `random`.
|
package/data/llms.txt
CHANGED
package/data/manifest.json
CHANGED
package/data/packages/bard.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"apiSource": "// Public root surface of @vielzeug/bard. Every public export goes through this file.\nexport { createBard } from './bard';\nexport { BardDisposedError, BardError, BardLoadError, BardUnsupportedError } from './errors';\nexport type {\n AssetDefinition,\n AssetManifest,\n AssetMeta,\n Bard,\n BardEvent,\n BardOptions,\n BardState,\n BusController,\n DeckOptions,\n DuckingRule,\n FadeOptions,\n MediaImage,\n MusicDeck,\n PlayOptions,\n QueueOptions,\n SoundHandle,\n SynthEnvelope,\n SynthFilter,\n SynthOptions,\n SynthWaveform,\n TransitionOptions,\n} from './types';\n",
|
|
3
3
|
"docs": {
|
|
4
4
|
"index": "---\ntitle: 'Bard'\ndescription: 'Lifecycle-owned Web Audio mixing: buses with ducking, buffered SFX and sprites, procedural synth, streamed tracks, and crossfading music decks'\npackage: bard\ncategory: utilities\nkeywords: [web-audio, audio, sfx, soundboard, crossfade, ducking, audio-sprites]\nrelated: [necromancer]\nexports: [createBard, BardError, BardLoadError]\nenvironments: [browser, node]\n---\n\n<!-- markdownlint-disable MD025 MD033 MD060 -->\n\n<PackageHero package=\"bard\" />\n\n## Why Bard?\n\nThe Web Audio API gives you nodes and params but no lifecycle: nothing stops voices, removes gesture listeners, or closes the context when your feature unmounts. Bard wraps a lazily created `AudioContext` in one disposable engine with named buses, ducking, voice caps, and a crossfading music deck.\n\n```ts\n// Before: hand-rolled graph, listeners, and teardown you must remember\nconst ctx = new AudioContext();\nconst source = ctx.createBufferSource();\nsource.connect(ctx.destination);\n// ...who disconnects this on unmount?\n\n// After\nconst bard = createBard({ ducking: [{ source: 'voice', target: 'music', gain: 0.3 }] });\nawait bard.load({ confirm: '/confirm.wav' });\nbard.play('confirm');\nbard.dispose(); // stops voices, removes listeners, closes the context\n```\n\n| Feature | Native Web Audio | Bard | Howler.js |\n| ----------------- | -------------------------------------------- | -------------------------------------------- | -------------------------------------------- |\n| Bundle size | 0 B | <PackageInfo package=\"bard\" type=\"size\" /> | ~30 kB |\n| Root dependencies | <ore-icon name=\"check\" size=\"16\"></ore-icon> | <ore-icon name=\"check\" size=\"16\"></ore-icon> | <ore-icon name=\"check\" size=\"16\"></ore-icon> |\n| Lifecycle | Manual node teardown | `dispose()` + `Symbol.dispose` | Per-sound unload |\n| Mixing | Hand-built gain graph | Named buses, ducking rules, voice caps | Per-sound volume only |\n| Music transitions | Manual crossfade scheduling | `deck.transition()` with loop points, queue | Not built in |\n\n<div class=\"decision-callout\">\n\n**Use Bard when** an interactive app needs owned audio: UI SFX with voice caps, narration that ducks music, or game-state music transitions with crossfades and loop points.\n\n**Consider a plain `HTMLAudioElement` when** you need one background track with no mixing, sprites, or lifecycle requirements.\n\n</div>\n\n## Installation\n\n::: code-group\n\n```sh [pnpm]\npnpm add @vielzeug/bard\n```\n\n```sh [npm]\nnpm install @vielzeug/bard\n```\n\n```sh [yarn]\nyarn add @vielzeug/bard\n```\n\n:::\n\n## Quick Start\n\nCreate the engine once per app, load assets, and dispose it when the owning feature unmounts. Nothing touches `AudioContext` or the DOM until the first call that needs audio, so server rendering is safe.\n\n```ts\nimport { createBard } from '@vielzeug/bard';\n\nconst bard = createBard({\n ducking: [{ source: 'voice', target: 'music', gain: 0.3 }],\n});\n\nawait bard.load({\n music: { src: '/theme.mp3', stream: true },\n dice: { src: '/sfx.wav', sprites: { roll: [0, 1.2] } },\n});\n\nconst deck = bard.createDeck();\ndeck.transition('music', { loop: true });\nbard.play('dice:roll', { detune: [-60, 60] });\n\nbard.dispose();\n```\n\n## Features\n\n<div class=\"features-grid\">\n\n- **`createBard()`**: one disposable owner for the context, buses, voices, and decks.\n- **`bus()`**: named gain buses (`music`, `sfx`, `voice`) with click-free volume ramps.\n- **`ducking`**: declarative rules that ramp a target bus while a source bus has active voices.\n- **`play()`**: buffered playback with sprites, voice caps, oldest-first stealing, and detune/rate variance.\n- **`synth()`**: zero-asset oscillator and noise voices with ADSR and frequency sweeps.\n- **`createDeck()`**: two-slot crossfader with loop points, queue with shuffle, and opt-in Media Session.\n- **`tap()`**: observability events for state changes, steals, ducks, and track changes.\n\n</div>\n\n## Documentation\n\n<div class=\"doc-links\">\n\n- [Usage Guide](./usage.md)\n- [API Reference](./api.md)\n- [Examples](./examples.md)\n- [Migration](./migration.md)\n\n</div>\n\n## See Also\n\n<div class=\"see-also\">\n\n- [Necromancer](/necromancer/): pair visual transitions with deck music transitions from the same game-state change.\n- [Arsenal](/arsenal/): general-purpose utilities used across the monorepo.\n\n</div>\n\n<!-- markdownlint-enable MD025 MD033 MD060 -->\n",
|
|
5
|
-
"api": "---\ntitle: 'Bard: API Reference'\ndescription: Public API of @vielzeug/bard.\n---\n\n[[toc]]\n\n## API Overview\n\n| Symbol | Purpose | Execution | Common gotcha |\n| ---------------------- | ------------------------------------------- | --------- | ------------------------------------------------------------------------ |\n| `createBard` | Creates the disposable audio engine | Sync | Context is still created lazily on first audio use |\n| `BardError` | Base error for invalid keys, buses, regions | — | Subclasses: `BardLoadError`, `BardDisposedError`, `BardUnsupportedError` |\n| `BardLoadError` | A manifest entry failed to fetch or decode | — | Original failure is in `cause` |\n| `BardDisposedError` | A method ran after `dispose()` | — | Thrown by every engine method except `dispose` |\n| `BardUnsupportedError` | No `AudioContext` in the runtime | — | `unlock()` rejects with it on servers without Web Audio |\n\n## Package Entry Point\n\n| Import | Purpose |\n| ------------------------ | --------------------------------------- |\n| `@vielzeug/bard` | Complete public Bard API |\n| `@vielzeug/bard/testing` | Deterministic Web Audio fakes for tests |\n\n## Engine\n\n### createBard\n\n```ts\nfunction createBard(options?: BardOptions): Bard;\n```\n\nCreates the engine. Touches no browser global until the first method that needs audio.\n\n| Option | Type | Default | Notes |\n| --------------------- | ------------------------ | --------------------------- | --------------------------------------------------------------------------- |\n| `buses` | `readonly string[]` | `['music', 'sfx', 'voice']` | `'master'` is reserved and throws if declared |\n| `volume` | `number` | `1` | Master volume, linear 0..1 |\n| `ducking` | `readonly DuckingRule[]` | `[]` | See Ducking |\n| `maxVoices` | `number` | `32` | Engine-wide concurrent voice cap |\n| `autoUnlock` | `boolean` | `true` | Gesture listeners resume a suspended context |\n| `autoSuspendOnHidden` | `boolean` | `false` | Suspend on page hide, resume on show (only resumes its own suspends) |\n| `context` | `() => AudioContext` | lazy `new AudioContext()` | Injection seam for tests; injected contexts are never closed by `dispose()` |\n\nReturns the `Bard` engine.\n\n```ts\nimport { createBard } from '@vielzeug/bard';\n\nconst bard = createBard({ volume: 0.9 });\n```\n\n### Bard\n\n| Member | Signature | Notes |\n| ----------------------------- | ----------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |\n| `state` | `'idle' \\| 'suspended' \\| 'running' \\| 'interrupted' \\| 'closed'` | `'idle'` until first lazy context creation; `'interrupted'` occurs on iOS calls |\n| `context` | `AudioContext \\| null` | Native context for advanced graph work |\n| `unlock()` | `() => Promise<void>` | Creates and resumes the context |\n| `load(manifest, options?)` | `(AssetManifest, { signal? }) => Promise<void>` | Deduplicates concurrent fetches per URL |\n| `unload(keys?)` | `(string \\| readonly string[]) => void` | Stops active voices for the dropped keys |\n| `has(key)` | `(string) => boolean` | Resolves `'key:sprite'` to its parent asset |\n| `play(key, options?)` | `(string, PlayOptions?) => SoundHandle` | Throws `BardError` for unknown keys and streamed assets |\n| `synth(options)` | `(SynthOptions) => SoundHandle` | Procedural voice, self-cleaning |\n| `bus(name)` | `(string) => BusController` | `'master'` is valid; unknown names throw |\n| `createDeck(options?)` | `(DeckOptions?) => MusicDeck` | Multiple decks share the engine |\n| `suspend()` / `resume()` | `() => Promise<void>` | Engine-wide pause for the whole context |\n| `tap(handler, options?)` | `(BardEvent) => void` → unsubscribe | Handler errors are swallowed; auto-detaches on `signal` |\n| `dispose()` | `() => void` | Stops voices and decks, aborts loads, removes listeners, closes an owned context; idempotent |\n| `disposed` / `disposalSignal` | `boolean` / `AbortSignal` | Standard disposal contract |\n\n---\n\n## Playback\n\n### SoundHandle\n\nReturned by `play()` and `synth()`.\n\n| Member | Signature | Notes |\n| --------------------------------------------- | -------------------------------- | ------------------------------------------- |\n| `stop(options?)` | `(FadeOptions?) => void` | Fades (default 15 ms micro-fade) then stops |\n| `setVolume(volume, options?)` | `(number, FadeOptions?) => void` | Ramped, never clicks |\n| `setPan(pan)` | `(-1..1) => void` | Every voice has a panner |\n| `finished` | `Promise<void>` | Resolves on natural end, stop, or dispose |\n| `dispose()` / `disposed` / `[Symbol.dispose]` | | Immediate stop and node release |\n\n### PlayOptions\n\n| Option | Type | Default | Notes |\n| ----------------------- | ---------------------- | ------------- | -------------------------------------- |\n| `bus` | `string` | `'sfx'` | Destination bus |\n| `volume` | `number` | `1` | Linear 0..1 |\n| `pan` | `number` | `0` | -1..1; voices always route via a panner |\n| `loop` | `boolean` | `false` | Loops the buffer or sprite region |\n| `loopStart` / `loopEnd` | `number` | — | Absolute buffer seconds |\n| `offset` | `number` | `0` | Start offset in seconds |\n| `detune` | `number \\| [min, max]` | — | Cents; ranges sampled per voice |\n| `rate` | `number \\| [min, max]` | — | Playback rate; shifts pitch on buffers |\n| `maxVoices` | `number` | — | Per-key cap; oldest copy is stolen |\n| `fadeIn` | `number` | — | Seconds from 0 to `volume` |\n| `random` | `() => number` | `Math.random` | Deterministic sampling in tests |\n\n### SynthOptions\n\n| Option | Type | Default | Notes |\n| ---------------------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------- |\n| `type` | `'sine' \\| 'square' \\| 'sawtooth' \\| 'triangle' \\| 'noise'` | `'sine'` | `'noise'` uses a cached white-noise buffer |\n| `freq` | `number \\| [from, to]` | `440` | Tuple sweeps exponentially; maps to filter cutoff for `'noise'` |\n| `duration` | `number` | `0.3` | Total seconds including release; must be positive |\n| `envelope` | `SynthEnvelope` | `{ attack: 0.005, decay: 0.05, sustain: 0.6, release: 0.1 }` | ADSR; `sustain` is a level |\n| `filter` | `SynthFilter` | — | Biquad stage before the envelope |\n| `bus` / `volume` / `pan` / `detune` | as in `PlayOptions` | | |\n\n---\n\n## Mixing\n\n### DuckingRule\n\n```ts\ninterface DuckingRule {\n readonly source: string;\n readonly target: string;\n readonly gain: number; // duck level, linear 0..1\n readonly attack?: number; // seconds, default 0.2\n readonly release?: number; // seconds, default 0.8\n}\n```\n\nWhile the `source` bus has active voices, `target` ramps to `gain`; when they end it ramps back to 1. Multiple rules on one target take the lowest active gain.\n\n### BusController\n\n| Member | Notes |\n| ----------------------------------- | -------------------------------------- |\n| `name` | Bus name |\n| `volume` / `setVolume(v, options?)` | User volume stage, ramped |\n| `muted` / `mute()` / `unmute()` | Ramped mute |\n| `duckLevel` | Current duck multiplier (1 = unducked) |\n\n---\n\n## Music Deck\n\n### MusicDeck\n\n| Member | Signature | Notes |\n| --------------------------------------------- | --------------------------------------------- | ----------------------------------------------- |\n| `current` | `string \\| null` | Active track key |\n| `playing` | `boolean` | `false` while paused or stopped |\n| `transition(key, options?)` | `(string, TransitionOptions?) => void` | Crossfades; transitioning to the live key is a no-op |\n| `queue(keys, options?)` | `(readonly string[], QueueOptions?) => void` | Replaces the queue and starts its first track |\n| `next()` / `previous()` | `() => void` | No-op without a queue |\n| `pause()` / `play()` | `() => void` | `play()` resumes from the paused offset |\n| `stop(options?)` | `(FadeOptions?) => void` | Stops and clears queue and slot |\n| `dispose()` / `disposed` / `[Symbol.dispose]` | | Releases a Media Session claim |\n\n`TransitionOptions`: `fade`, `loop`, `loopStart`, `loopEnd`, `offset`.\n`QueueOptions`: `shuffle`, `crossfade`, `repeat`, `random`.\n\n### DeckOptions\n\n| Option | Type | Default | Notes |\n| -------------- | --------- | --------- | ------------------------------------------------------ |\n| `bus` | `string` | `'music'` | Destination bus |\n| `mediaSession` | `boolean` | `false` | Claims `navigator.mediaSession`; a second claim throws |\n| `fade` | `number` | `2` | Default crossfade seconds |\n\n---\n\n## Assets\n\n### AssetManifest\n\n```ts\ntype AssetManifest = Readonly<Record<string, string | AssetDefinition>>;\n\ninterface AssetDefinition {\n readonly src: string;\n readonly sprites?: Readonly<Record<string, readonly [start: number, duration: number]>>;\n readonly stream?: boolean; // deck-only playback via an owned <audio> element\n readonly meta?: AssetMeta; // Media Session metadata\n}\n```\n\nA bare string is shorthand for `{ src }`. Sprite regions are `[startSeconds, durationSeconds]` and play as `'key:sprite'`; out-of-bounds regions throw `BardError`.\n\n---\n\n## Observability\n\n### BardEvent\n\n| Event | Payload | Fires |\n| ------------ | ---------------------- | ---------------------------------------- |\n| `state` | `state` | Context lifecycle changes |\n| `load` | `key` | A manifest entry finished loading |\n| `load-error` | `key`, `error` | A load failed |\n| `steal` | `key` | A voice was stolen past a cap |\n| `duck` | `bus`, `level`, `ramp` | A bus duck level changed |\n| `track` | `key \\| null` | The deck changed tracks |\n| `dispose` | — | Emitted once at the start of `dispose()` |\n\n---\n\n## Testing\n\n`@vielzeug/bard/testing` exports `FakeAudioContext` (manual clock via `advance(seconds)`, recorded `FakeAudioParam` automation), `FakeMediaElement`, `FakeMediaSession`, and `flush()`. Inject the fake with `createBard({ context: () => fake })`.\n\n---\n\n## Errors\n\n| Error | Trigger | Notes |\n| ------------------- | ---------------------------------------------------------------- | --------------------------------------------------------- |\n| `BardError` | Unknown key/bus/sprite, reserved bus name, streamed-asset misuse | Base class |\n| `BardLoadError` | Fetch or `decodeAudioData` failure | `cause` carries the original error or `{ status }` |\n| `BardDisposedError` | Engine use after `dispose()` | Also `BardUnsupportedError` when no `AudioContext` exists |\n",
|
|
5
|
+
"api": "---\ntitle: 'Bard: API Reference'\ndescription: Public API of @vielzeug/bard.\n---\n\n[[toc]]\n\n## API Overview\n\n| Symbol | Purpose | Execution | Common gotcha |\n| ---------------------- | ------------------------------------------- | --------- | ------------------------------------------------------------------------ |\n| `createBard` | Creates the disposable audio engine | Sync | Context is still created lazily on first audio use |\n| `BardError` | Base error for invalid keys, buses, regions | — | Subclasses: `BardLoadError`, `BardDisposedError`, `BardUnsupportedError` |\n| `BardLoadError` | A manifest entry failed to fetch or decode | — | Original failure is in `cause` |\n| `BardDisposedError` | A method ran after `dispose()` | — | Thrown by every engine method except `dispose` |\n| `BardUnsupportedError` | No `AudioContext` in the runtime | — | `unlock()` rejects with it on servers without Web Audio |\n\n## Package Entry Point\n\n| Import | Purpose |\n| ------------------------ | --------------------------------------- |\n| `@vielzeug/bard` | Complete public Bard API |\n| `@vielzeug/bard/testing` | Deterministic Web Audio fakes for tests |\n\n## Engine\n\n### createBard\n\n```ts\nfunction createBard(options?: BardOptions): Bard;\n```\n\nCreates the engine. Touches no browser global until the first method that needs audio.\n\n| Option | Type | Default | Notes |\n| --------------------- | ------------------------ | --------------------------- | --------------------------------------------------------------------------- |\n| `buses` | `readonly string[]` | `['music', 'sfx', 'voice']` | `'master'` is reserved and throws if declared |\n| `volume` | `number` | `1` | Master volume, linear 0..1 |\n| `ducking` | `readonly DuckingRule[]` | `[]` | See Ducking |\n| `maxVoices` | `number` | `32` | Engine-wide concurrent voice cap |\n| `autoUnlock` | `boolean` | `true` | Gesture listeners resume a suspended context |\n| `autoSuspendOnHidden` | `boolean` | `false` | Suspend on page hide, resume on show (only resumes its own suspends) |\n| `context` | `() => AudioContext` | lazy `new AudioContext()` | Injection seam for tests; injected contexts are never closed by `dispose()` |\n\nReturns the `Bard` engine.\n\n```ts\nimport { createBard } from '@vielzeug/bard';\n\nconst bard = createBard({ volume: 0.9 });\n```\n\n### Bard\n\n| Member | Signature | Notes |\n| ----------------------------- | ----------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |\n| `state` | `'idle' \\| 'suspended' \\| 'running' \\| 'interrupted' \\| 'closed'` | `'idle'` until first lazy context creation; `'interrupted'` occurs on iOS calls |\n| `context` | `AudioContext \\| null` | Native context for advanced graph work |\n| `unlock()` | `() => Promise<void>` | Creates and resumes the context |\n| `load(manifest, options?)` | `(AssetManifest, { signal? }) => Promise<void>` | Deduplicates concurrent fetches per URL |\n| `unload(keys?)` | `(string \\| readonly string[]) => void` | Stops active voices for the dropped keys |\n| `has(key)` | `(string) => boolean` | Resolves `'key:sprite'` to its parent asset |\n| `play(key, options?)` | `(string, PlayOptions?) => SoundHandle` | Throws `BardError` for unknown keys and streamed assets |\n| `synth(options)` | `(SynthOptions) => SoundHandle` | Procedural voice, self-cleaning |\n| `bus(name)` | `(string) => BusController` | `'master'` is valid; unknown names throw |\n| `createDeck(options?)` | `(DeckOptions?) => MusicDeck` | Multiple decks share the engine |\n| `suspend()` / `resume()` | `() => Promise<void>` | Engine-wide pause for the whole context |\n| `tap(handler, options?)` | `(BardEvent) => void` → unsubscribe | Handler errors are swallowed; auto-detaches on `signal` |\n| `dispose()` | `() => void` | Stops voices and decks, aborts loads, removes listeners, closes an owned context; idempotent |\n| `disposed` / `disposalSignal` | `boolean` / `AbortSignal` | Standard disposal contract |\n\n---\n\n## Playback\n\n### SoundHandle\n\nReturned by `play()` and `synth()`.\n\n| Member | Signature | Notes |\n| --------------------------------------------- | -------------------------------- | ------------------------------------------- |\n| `stop(options?)` | `(FadeOptions?) => void` | Fades (default 15 ms micro-fade) then stops |\n| `setVolume(volume, options?)` | `(number, FadeOptions?) => void` | Ramped, never clicks |\n| `setPan(pan)` | `(-1..1) => void` | Every voice has a panner |\n| `finished` | `Promise<void>` | Resolves on natural end, stop, or dispose |\n| `dispose()` / `disposed` / `[Symbol.dispose]` | | Immediate stop and node release |\n\n### PlayOptions\n\n| Option | Type | Default | Notes |\n| ----------------------- | ---------------------- | ------------- | --------------------------------------- |\n| `bus` | `string` | `'sfx'` | Destination bus |\n| `volume` | `number` | `1` | Linear 0..1 |\n| `pan` | `number` | `0` | -1..1; voices always route via a panner |\n| `loop` | `boolean` | `false` | Loops the buffer or sprite region |\n| `loopStart` / `loopEnd` | `number` | — | Absolute buffer seconds |\n| `offset` | `number` | `0` | Start offset in seconds |\n| `detune` | `number \\| [min, max]` | — | Cents; ranges sampled per voice |\n| `rate` | `number \\| [min, max]` | — | Playback rate; shifts pitch on buffers |\n| `maxVoices` | `number` | — | Per-key cap; oldest copy is stolen |\n| `fadeIn` | `number` | — | Seconds from 0 to `volume` |\n| `random` | `() => number` | `Math.random` | Deterministic sampling in tests |\n\n### SynthOptions\n\n| Option | Type | Default | Notes |\n| ----------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------- |\n| `type` | `'sine' \\| 'square' \\| 'sawtooth' \\| 'triangle' \\| 'noise'` | `'sine'` | `'noise'` uses a cached white-noise buffer |\n| `freq` | `number \\| [from, to]` | `440` | Tuple sweeps exponentially; maps to filter cutoff for `'noise'` |\n| `duration` | `number` | `0.3` | Total seconds including release; must be positive |\n| `envelope` | `SynthEnvelope` | `{ attack: 0.005, decay: 0.05, sustain: 0.6, release: 0.1 }` | ADSR; `sustain` is a level |\n| `filter` | `SynthFilter` | — | Biquad stage before the envelope |\n| `bus` / `volume` / `pan` / `detune` | as in `PlayOptions` | | |\n\n---\n\n## Mixing\n\n### DuckingRule\n\n```ts\ninterface DuckingRule {\n readonly source: string;\n readonly target: string;\n readonly gain: number; // duck level, linear 0..1\n readonly attack?: number; // seconds, default 0.2\n readonly release?: number; // seconds, default 0.8\n}\n```\n\nWhile the `source` bus has active voices, `target` ramps to `gain`; when they end it ramps back to 1. Multiple rules on one target take the lowest active gain.\n\n### BusController\n\n| Member | Notes |\n| ----------------------------------- | -------------------------------------- |\n| `name` | Bus name |\n| `volume` / `setVolume(v, options?)` | User volume stage, ramped |\n| `muted` / `mute()` / `unmute()` | Ramped mute |\n| `duckLevel` | Current duck multiplier (1 = unducked) |\n\n---\n\n## Music Deck\n\n### MusicDeck\n\n| Member | Signature | Notes |\n| --------------------------------------------- | -------------------------------------------- | ---------------------------------------------------- |\n| `current` | `string \\| null` | Active track key |\n| `playing` | `boolean` | `false` while paused or stopped |\n| `transition(key, options?)` | `(string, TransitionOptions?) => void` | Crossfades; transitioning to the live key is a no-op |\n| `queue(keys, options?)` | `(readonly string[], QueueOptions?) => void` | Replaces the queue and starts its first track |\n| `next()` / `previous()` | `() => void` | No-op without a queue |\n| `pause()` / `play()` | `() => void` | `play()` resumes from the paused offset |\n| `stop(options?)` | `(FadeOptions?) => void` | Stops and clears queue and slot |\n| `dispose()` / `disposed` / `[Symbol.dispose]` | | Releases a Media Session claim |\n\n`TransitionOptions`: `fade`, `loop`, `loopStart`, `loopEnd`, `offset`.\n`QueueOptions`: `shuffle`, `crossfade`, `repeat`, `random`.\n\n### DeckOptions\n\n| Option | Type | Default | Notes |\n| -------------- | --------- | --------- | ------------------------------------------------------ |\n| `bus` | `string` | `'music'` | Destination bus |\n| `mediaSession` | `boolean` | `false` | Claims `navigator.mediaSession`; a second claim throws |\n| `fade` | `number` | `2` | Default crossfade seconds |\n\n---\n\n## Assets\n\n### AssetManifest\n\n```ts\ntype AssetManifest = Readonly<Record<string, string | AssetDefinition>>;\n\ninterface AssetDefinition {\n readonly src: string;\n readonly sprites?: Readonly<Record<string, readonly [start: number, duration: number]>>;\n readonly stream?: boolean; // deck-only playback via an owned <audio> element\n readonly meta?: AssetMeta; // Media Session metadata\n}\n```\n\nA bare string is shorthand for `{ src }`. Sprite regions are `[startSeconds, durationSeconds]` and play as `'key:sprite'`; out-of-bounds regions throw `BardError`.\n\n---\n\n## Observability\n\n### BardEvent\n\n| Event | Payload | Fires |\n| ------------ | ---------------------- | ---------------------------------------- |\n| `state` | `state` | Context lifecycle changes |\n| `load` | `key` | A manifest entry finished loading |\n| `load-error` | `key`, `error` | A load failed |\n| `steal` | `key` | A voice was stolen past a cap |\n| `duck` | `bus`, `level`, `ramp` | A bus duck level changed |\n| `track` | `key \\| null` | The deck changed tracks |\n| `dispose` | — | Emitted once at the start of `dispose()` |\n\n---\n\n## Testing\n\n`@vielzeug/bard/testing` exports `FakeAudioContext` (manual clock via `advance(seconds)`, recorded `FakeAudioParam` automation), `FakeMediaElement`, `FakeMediaSession`, and `flush()`. Inject the fake with `createBard({ context: () => fake })`.\n\n---\n\n## Errors\n\n| Error | Trigger | Notes |\n| ------------------- | ---------------------------------------------------------------- | --------------------------------------------------------- |\n| `BardError` | Unknown key/bus/sprite, reserved bus name, streamed-asset misuse | Base class |\n| `BardLoadError` | Fetch or `decodeAudioData` failure | `cause` carries the original error or `{ status }` |\n| `BardDisposedError` | Engine use after `dispose()` | Also `BardUnsupportedError` when no `AudioContext` exists |\n",
|
|
6
6
|
"usage": "---\ntitle: 'Bard: Usage Guide'\ndescription: Play sounds, mix buses with ducking, generate synth SFX, and crossfade music with @vielzeug/bard.\n---\n\n[[toc]]\n\n## Basic Usage\n\nCreate one engine per app, load a manifest, and play through a bus. Dispose the engine when its owning feature unmounts.\n\n```ts\nimport { createBard } from '@vielzeug/bard';\n\nconst bard = createBard();\nawait bard.load({ click: '/click.wav', boom: '/boom.wav' });\n\nconst handle = bard.play('boom', { volume: 0.8, pan: -0.3 });\nawait handle.finished;\nbard.dispose();\n```\n\n`play()` returns a `SoundHandle` immediately; audio starts once the browser allows it. `finished` resolves when the voice ends, is stopped, or is disposed.\n\n## Unlocking Audio\n\nBrowsers start the `AudioContext` suspended until a user gesture. Bard attaches capture-phase listeners for `pointerup`, `touchend`, `keydown`, and `click` and resumes the context inside the first one. All listeners are removed once the context is running.\n\n```ts\nconst bard = createBard(); // listeners attach on first audio use\nawait bard.unlock(); // or resume programmatically inside your own handler\n```\n\n`autoUnlock: false` skips the gesture listeners entirely; call `resume()` from your own gesture handler instead.\n\n## Buses and Volume\n\nVoices route to a named bus: `voice -> [pan] -> bus -> master -> destination`. The defaults are `music`, `sfx`, and `voice`; override with `buses`. Volume changes always ramp, so they never click.\n\n```ts\nconst music = bard.bus('music');\nmusic.setVolume(0.6, { fade: 0.5 });\nmusic.mute();\nmusic.unmute();\n```\n\n`bard.bus('master')` controls the output stage for every bus.\n\n## Ducking\n\nA ducking rule ramps a target bus down while the source bus has active voices, and back up when they end. Narration over music is the canonical case.\n\n```ts\nconst bard = createBard({\n ducking: [{ source: 'voice', target: 'music', gain: 0.3, attack: 0.2, release: 0.8 }],\n});\n\nawait bard.load({ announce: '/announce.wav' });\nconst voice = bard.play('announce', { bus: 'voice' });\n// music is now at 30% until the announcement ends\nawait voice.finished; // music ramps back to 100%\n```\n\nDucking uses its own gain stage per bus, so it never fights user volume automation.\n\n## Sound Sprites\n\nBundle many short SFX into one file and address regions with `key:sprite`. The region is `[startSeconds, durationSeconds]`.\n\n```ts\nawait bard.load({\n ui: { src: '/ui.wav', sprites: { open: [0, 0.4], close: [0.5, 0.4] } },\n});\n\nbard.play('ui:open');\nbard.play('ui:close', { bus: 'sfx' });\n```\n\n## Voice Caps and Variance\n\n`maxVoices` caps concurrent copies of one key; the oldest copy is stolen with a micro-fade. The engine-wide cap is `maxVoices` in `createBard` (default 32). Ranges for `detune` and `rate` keep repeated hits from sounding identical.\n\n```ts\nfor (let i = 0; i < 10; i += 1) {\n bard.play('ui:open', { maxVoices: 3, detune: [-100, 100], rate: [0.95, 1.05] });\n}\n```\n\nNote: `rate` shifts pitch on buffer sources. Pitch-preserving playback belongs on a streamed `HTMLAudioElement`.\n\n## Procedural Synth\n\n`synth()` builds an oscillator or noise burst with an ADSR envelope and optional filter, and disconnects itself when done. No assets required.\n\n```ts\n// countdown tick\nbard.synth({ type: 'square', freq: 880, duration: 0.08 });\n\n// descending error buzz with a lowpass\nbard.synth({\n type: 'sawtooth',\n freq: [220, 55],\n duration: 0.6,\n filter: { type: 'lowpass', frequency: [2400, 400] },\n});\n```\n\n## Music Deck\n\nA deck crossfades between two slots. Transition to game states, loop the body of a track after its intro, or queue continuous playback.\n\n```ts\nconst deck = bard.createDeck({ fade: 2.5 });\n\n// intro plays once, then the region loops seamlessly\ndeck.transition('bossTheme', { loop: true, loopStart: 12.5 });\n\n// later: crossfade to the victory track\ndeck.transition('victory', { fade: 4 });\n\n// continuous ambient playback with deterministic shuffle\ndeck.queue(['forest', 'cave', 'village'], { shuffle: true, crossfade: 6, repeat: true });\ndeck.next();\n```\n\n`pause()` then `play()` resumes from the paused position. A manual `transition()` takes over from the queue.\n\n## Streaming Long Tracks\n\nMark an asset `stream: true` to play it through an owned `<audio>` element instead of decoding it into an `AudioBuffer`. Mobile devices never spike RAM on ten-minute ambient tracks. Streamed assets are deck-only; `play()` on them throws.\n\n```ts\nawait bard.load({\n ambient: { src: 'https://cdn.example.com/forest.mp3', stream: true },\n});\nbard.createDeck().transition('ambient', { loop: true });\n```\n\nThe element requests CORS (`crossOrigin: 'anonymous'`); a CDN without CORS headers plays silent through Web Audio. Streamed loops cover the whole file: `loopStart`/`loopEnd` throw.\n\n## Media Session\n\n`mediaSession: true` claims `navigator.mediaSession` for one deck: metadata from the asset's `meta`, hardware play/pause/next/previous. A second claim throws instead of stealing controls; disposing the deck releases the claim.\n\n```ts\nawait bard.load({\n theme: { src: '/theme.mp3', meta: { title: 'Hunt Theme', artist: 'Bard' } },\n});\nconst deck = bard.createDeck({ mediaSession: true });\ndeck.transition('theme');\n```\n\n## Testing\n\n`@vielzeug/bard/testing` ships deterministic fakes: a context with a manual clock, recorded param automation, and fake media elements. Bard's own suite uses them.\n\n```ts\nimport { createBard } from '@vielzeug/bard';\nimport { FakeAudioContext } from '@vielzeug/bard/testing';\n\nconst ctx = new FakeAudioContext();\nconst bard = createBard({ context: () => ctx });\nawait bard.load({ ping: '/ping.wav' });\nbard.play('ping');\nctx.advance(2); // clock moves, sources past their stop time fire 'ended'\n```\n\n## Framework Integration\n\n::: code-group\n\n```tsx [React]\nimport { useEffect, useState } from 'react';\nimport { createBard, type Bard } from '@vielzeug/bard';\n\nexport function useBard() {\n const [bard, setBard] = useState<Bard | null>(null);\n useEffect(() => {\n const engine = createBard();\n setBard(engine);\n return () => engine.dispose();\n }, []);\n return bard;\n}\n```\n\n```vue [Vue 3]\n<script setup lang=\"ts\">\nimport { onMounted, onUnmounted, shallowRef } from 'vue';\nimport { createBard } from '@vielzeug/bard';\n\nconst bard = shallowRef<ReturnType<typeof createBard> | null>(null);\nonMounted(() => (bard.value = createBard()));\nonUnmounted(() => bard.value?.dispose());\n</script>\n```\n\n```svelte [Svelte]\n<script lang=\"ts\">\n import { createBard } from '@vielzeug/bard';\n import { onDestroy } from 'svelte';\n\n const bard = createBard();\n onDestroy(() => bard.dispose());\n</script>\n```\n\n:::\n\nCreate the engine in a mount hook, not at module scope: only mount lifecycle proves a browser runtime exists.\n\n## Best Practices\n\n- Create one engine per app and pass it down; contexts are a limited hardware resource.\n- Dispose the engine with its owning feature; `using` works via `Symbol.dispose`.\n- Keep streamed assets for tracks longer than a few minutes; buffers are better for SFX.\n- Give narration its own `voice` bus and duck `music` from it, rather than fading tracks by hand.\n- Inject `random` in tests so detune, rate, and shuffle are deterministic.\n- Watch `tap()` events (`steal`, `duck`, `load-error`) in development to catch mixing problems early.\n- Call `unlock()` from your own first-gesture UI when you want audio live before the next interaction.\n",
|
|
7
7
|
"examples": "---\ntitle: 'Bard Examples'\ndescription: Practical sound, ducking, and music-transition recipes for @vielzeug/bard.\n---\n\n## Examples\n\n- [Game-State Music Transitions](./examples/game-state-music-transitions.md)\n- [Duck Music Under Narration](./examples/duck-music-under-narration.md)\n- [UI SFX Without Assets](./examples/ui-sfx-without-assets.md)\n"
|
|
8
8
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vielzeug/codex",
|
|
3
|
-
"version": "26.11.
|
|
3
|
+
"version": "26.11.21",
|
|
4
4
|
"description": "MCP server exposing all Vielzeug docs to AI clients",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/node": "^26.6.6",
|
|
55
|
-
"@vielzeug/refine": "26.11.
|
|
55
|
+
"@vielzeug/refine": "26.11.21",
|
|
56
56
|
"typescript": "^6.0.3",
|
|
57
57
|
"vitest": "^5.1.0"
|
|
58
58
|
}
|