@datamoc/mw_games 0.20.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +128 -0
- package/dist/audio/Channels.d.ts +19 -0
- package/dist/audio/Channels.d.ts.map +1 -1
- package/dist/audio/Channels.js +33 -4
- package/dist/audio/Channels.js.map +1 -1
- package/dist/audio/LoopTags.d.ts +37 -0
- package/dist/audio/LoopTags.d.ts.map +1 -0
- package/dist/audio/LoopTags.js +116 -0
- package/dist/audio/LoopTags.js.map +1 -0
- package/dist/audio/Midi.d.ts +29 -0
- package/dist/audio/Midi.d.ts.map +1 -1
- package/dist/audio/Midi.js +30 -1
- package/dist/audio/Midi.js.map +1 -1
- package/dist/audio/MidiRender.d.ts +3 -2
- package/dist/audio/MidiRender.d.ts.map +1 -1
- package/dist/audio/MidiRender.js +2 -2
- package/dist/audio/MidiRender.js.map +1 -1
- package/dist/audio/humanize/Groove.d.ts +80 -0
- package/dist/audio/humanize/Groove.d.ts.map +1 -0
- package/dist/audio/humanize/Groove.js +102 -0
- package/dist/audio/humanize/Groove.js.map +1 -0
- package/dist/audio/humanize/GrooveConverter.d.ts +49 -0
- package/dist/audio/humanize/GrooveConverter.d.ts.map +1 -0
- package/dist/audio/humanize/GrooveConverter.js +344 -0
- package/dist/audio/humanize/GrooveConverter.js.map +1 -0
- package/dist/audio/humanize/GrooveExtractor.d.ts +49 -0
- package/dist/audio/humanize/GrooveExtractor.d.ts.map +1 -0
- package/dist/audio/humanize/GrooveExtractor.js +179 -0
- package/dist/audio/humanize/GrooveExtractor.js.map +1 -0
- package/dist/audio/humanize/GrooveHumanizer.d.ts +34 -0
- package/dist/audio/humanize/GrooveHumanizer.d.ts.map +1 -0
- package/dist/audio/humanize/GrooveHumanizer.js +37 -0
- package/dist/audio/humanize/GrooveHumanizer.js.map +1 -0
- package/dist/audio/humanize/Humanize.d.ts +54 -0
- package/dist/audio/humanize/Humanize.d.ts.map +1 -0
- package/dist/audio/humanize/Humanize.js +239 -0
- package/dist/audio/humanize/Humanize.js.map +1 -0
- package/dist/audio/humanize/HumanizerFactory.d.ts +68 -0
- package/dist/audio/humanize/HumanizerFactory.d.ts.map +1 -0
- package/dist/audio/humanize/HumanizerFactory.js +84 -0
- package/dist/audio/humanize/HumanizerFactory.js.map +1 -0
- package/dist/audio/humanize/LiteHumanizer.d.ts +30 -0
- package/dist/audio/humanize/LiteHumanizer.d.ts.map +1 -0
- package/dist/audio/humanize/LiteHumanizer.js +35 -0
- package/dist/audio/humanize/LiteHumanizer.js.map +1 -0
- package/dist/audio/humanize/Onsets.d.ts +26 -0
- package/dist/audio/humanize/Onsets.d.ts.map +1 -0
- package/dist/audio/humanize/Onsets.js +164 -0
- package/dist/audio/humanize/Onsets.js.map +1 -0
- package/dist/audio/index.d.ts +14 -1
- package/dist/audio/index.d.ts.map +1 -1
- package/dist/audio/index.js +7 -0
- package/dist/audio/index.js.map +1 -1
- package/dist/board/bitboard.d.ts +132 -0
- package/dist/board/bitboard.d.ts.map +1 -0
- package/dist/board/bitboard.js +495 -0
- package/dist/board/bitboard.js.map +1 -0
- package/dist/board/chess.d.ts +16 -0
- package/dist/board/chess.d.ts.map +1 -1
- package/dist/board/chess.js +43 -0
- package/dist/board/chess.js.map +1 -1
- package/dist/board/index.d.ts +9 -1
- package/dist/board/index.d.ts.map +1 -1
- package/dist/board/index.js +5 -1
- package/dist/board/index.js.map +1 -1
- package/dist/board/openings.d.ts +58 -0
- package/dist/board/openings.d.ts.map +1 -0
- package/dist/board/openings.js +45 -0
- package/dist/board/openings.js.map +1 -0
- package/dist/board/tablebase.d.ts +118 -0
- package/dist/board/tablebase.d.ts.map +1 -0
- package/dist/board/tablebase.js +414 -0
- package/dist/board/tablebase.js.map +1 -0
- package/dist/board/tourney.d.ts +90 -0
- package/dist/board/tourney.d.ts.map +1 -0
- package/dist/board/tourney.js +1013 -0
- package/dist/board/tourney.js.map +1 -0
- package/dist/core/JavaRandom.d.ts +55 -0
- package/dist/core/JavaRandom.d.ts.map +1 -0
- package/dist/core/JavaRandom.js +81 -0
- package/dist/core/JavaRandom.js.map +1 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/mw_games.global.js +123 -116
- package/dist/rpg/EventRunner.d.ts +7 -0
- package/dist/rpg/EventRunner.d.ts.map +1 -1
- package/dist/rpg/EventRunner.js +6 -0
- package/dist/rpg/EventRunner.js.map +1 -1
- package/dist/rpg/MoveRoute.d.ts +35 -4
- package/dist/rpg/MoveRoute.d.ts.map +1 -1
- package/dist/rpg/MoveRoute.js +40 -11
- package/dist/rpg/MoveRoute.js.map +1 -1
- package/dist/two-d/render/FogLayer.d.ts +68 -0
- package/dist/two-d/render/FogLayer.d.ts.map +1 -0
- package/dist/two-d/render/FogLayer.js +83 -0
- package/dist/two-d/render/FogLayer.js.map +1 -0
- package/dist/two-d/render/LiquidLayer.d.ts +62 -0
- package/dist/two-d/render/LiquidLayer.d.ts.map +1 -0
- package/dist/two-d/render/LiquidLayer.js +102 -0
- package/dist/two-d/render/LiquidLayer.js.map +1 -0
- package/dist/two-d/render/RpgmAutotile.d.ts +42 -0
- package/dist/two-d/render/RpgmAutotile.d.ts.map +1 -1
- package/dist/two-d/render/RpgmAutotile.js +71 -4
- package/dist/two-d/render/RpgmAutotile.js.map +1 -1
- package/dist/two-d/render/TileMap.d.ts +50 -2
- package/dist/two-d/render/TileMap.d.ts.map +1 -1
- package/dist/two-d/render/TileMap.js +120 -2
- package/dist/two-d/render/TileMap.js.map +1 -1
- package/dist/two-d/render/index.d.ts +7 -3
- package/dist/two-d/render/index.d.ts.map +1 -1
- package/dist/two-d/render/index.js +3 -1
- package/dist/two-d/render/index.js.map +1 -1
- package/dist/two-d/ui/Label.d.ts.map +1 -1
- package/dist/two-d/ui/Label.js +11 -2
- package/dist/two-d/ui/Label.js.map +1 -1
- package/dist/two-d/ui/ListView.d.ts +24 -0
- package/dist/two-d/ui/ListView.d.ts.map +1 -1
- package/dist/two-d/ui/ListView.js +97 -4
- package/dist/two-d/ui/ListView.js.map +1 -1
- package/dist/two-d/ui/MessageLog.d.ts +62 -0
- package/dist/two-d/ui/MessageLog.d.ts.map +1 -0
- package/dist/two-d/ui/MessageLog.js +114 -0
- package/dist/two-d/ui/MessageLog.js.map +1 -0
- package/dist/two-d/ui/RadioGroup.d.ts +68 -0
- package/dist/two-d/ui/RadioGroup.d.ts.map +1 -0
- package/dist/two-d/ui/RadioGroup.js +177 -0
- package/dist/two-d/ui/RadioGroup.js.map +1 -0
- package/dist/two-d/ui/TextModel.d.ts +26 -1
- package/dist/two-d/ui/TextModel.d.ts.map +1 -1
- package/dist/two-d/ui/TextModel.js +56 -7
- package/dist/two-d/ui/TextModel.js.map +1 -1
- package/dist/two-d/ui/TextSharpness.d.ts +33 -0
- package/dist/two-d/ui/TextSharpness.d.ts.map +1 -0
- package/dist/two-d/ui/TextSharpness.js +56 -0
- package/dist/two-d/ui/TextSharpness.js.map +1 -0
- package/dist/two-d/ui/index.d.ts +5 -0
- package/dist/two-d/ui/index.d.ts.map +1 -1
- package/dist/two-d/ui/index.js +3 -0
- package/dist/two-d/ui/index.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +19 -7
- package/sbom.cdx.json +194 -32
- package/tools/build-tablebases.d.mts +22 -0
- package/tools/build-tablebases.mjs +549 -0
- package/tools/compile-openings.d.mts +20 -0
- package/tools/compile-openings.mjs +130 -0
- package/tools/play-uci.d.mts +26 -0
- package/tools/play-uci.mjs +194 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Onset detection, for the audio path of `GrooveExtractor`: when a groove has to come
|
|
3
|
+
* from a recording rather than from a pair of MIDI files, something has to find the hits
|
|
4
|
+
* first. Spectral flux over a short sliding window is the usual measure (what aubio and
|
|
5
|
+
* Essentia reach for), and it is cheap enough to hand-roll: a radix-2 FFT, the rise in
|
|
6
|
+
* magnitude bin by bin, then a local threshold with a minimum gap so one attack is not
|
|
7
|
+
* reported again by its own decay.
|
|
8
|
+
*
|
|
9
|
+
* The timings are what a groove lives or dies on, so the frame geometry is worth stating.
|
|
10
|
+
* Frames are padded by half a window either side, which is what lets a hit at sample 0 be
|
|
11
|
+
* measured with the window's full weight instead of its zeroed edge. A Hann window makes
|
|
12
|
+
* flux peak a quarter of a window plus half a hop after the hit it is reacting to; the
|
|
13
|
+
* detector subtracts that constant, leaving only the half-hop of frame quantization.
|
|
14
|
+
*
|
|
15
|
+
* Flux alone is not enough to call something an onset, which is what `ENERGY_RISE` below
|
|
16
|
+
* is for: everything else in this file is about locating a hit, that gate is about
|
|
17
|
+
* refusing to find one where there is none.
|
|
18
|
+
*/
|
|
19
|
+
const FRAME = 256;
|
|
20
|
+
const HOP = 64;
|
|
21
|
+
/** frames either side of a peak that make up its local mean and spread */
|
|
22
|
+
const NEIGHBOURHOOD = 10;
|
|
23
|
+
/**
|
|
24
|
+
* How far above its neighbourhood a peak has to sit. Two is the balance point: an attack
|
|
25
|
+
* lands well above it however loud the rest of the file is, while three lets the
|
|
26
|
+
* neighbourhood of a sparse attack (mostly zeros) put the peak back within reach.
|
|
27
|
+
*/
|
|
28
|
+
const FLUX_SIGMAS = 2;
|
|
29
|
+
/**
|
|
30
|
+
* An onset has to multiply its frame's energy by this much. This is what tells a hit apart
|
|
31
|
+
* from a sustained note: flux alone reports the beating of a steady tone as a train of
|
|
32
|
+
* onsets, because the tone's energy sloshes between bins while its own envelope is flat. A
|
|
33
|
+
* real onset multiplies the frame's energy many times over; a steady tone moves it by a
|
|
34
|
+
* couple of per cent. The previous frame may carry the rise, since flux compares against
|
|
35
|
+
* the frame it came from and so trails the energy by up to one frame.
|
|
36
|
+
*/
|
|
37
|
+
const ENERGY_RISE = 0.05;
|
|
38
|
+
/** minimum gap between two onsets, in frames: one attack, not its own ringing */
|
|
39
|
+
const MIN_GAP_FRAMES = 4;
|
|
40
|
+
/** where a Hann window's derivative puts the flux peak behind the hit: FRAME/4 + HOP/2 */
|
|
41
|
+
const FLUX_PEAK_DELAY = FRAME / 4 + HOP / 2;
|
|
42
|
+
/** in-place iterative radix-2 FFT; `real` and `imaginary` must be a power of two long */
|
|
43
|
+
function fft(real, imaginary) {
|
|
44
|
+
const length = real.length;
|
|
45
|
+
let j = 0;
|
|
46
|
+
for (let i = 1; i < length; i++) {
|
|
47
|
+
let bit = length >> 1;
|
|
48
|
+
while (j & bit) {
|
|
49
|
+
j ^= bit;
|
|
50
|
+
bit >>= 1;
|
|
51
|
+
}
|
|
52
|
+
j ^= bit;
|
|
53
|
+
if (i < j) {
|
|
54
|
+
let swap = real[i];
|
|
55
|
+
real[i] = real[j];
|
|
56
|
+
real[j] = swap;
|
|
57
|
+
swap = imaginary[i];
|
|
58
|
+
imaginary[i] = imaginary[j];
|
|
59
|
+
imaginary[j] = swap;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
for (let size = 2; size <= length; size <<= 1) {
|
|
63
|
+
const angle = (-2 * Math.PI) / size;
|
|
64
|
+
const stepReal = Math.cos(angle);
|
|
65
|
+
const stepImaginary = Math.sin(angle);
|
|
66
|
+
const half = size >> 1;
|
|
67
|
+
for (let start = 0; start < length; start += size) {
|
|
68
|
+
let weightReal = 1;
|
|
69
|
+
let weightImaginary = 0;
|
|
70
|
+
for (let k = 0; k < half; k++) {
|
|
71
|
+
const even = start + k;
|
|
72
|
+
const odd = even + half;
|
|
73
|
+
const oddReal = real[odd] * weightReal - imaginary[odd] * weightImaginary;
|
|
74
|
+
const oddImaginary = real[odd] * weightImaginary + imaginary[odd] * weightReal;
|
|
75
|
+
real[odd] = real[even] - oddReal;
|
|
76
|
+
imaginary[odd] = imaginary[even] - oddImaginary;
|
|
77
|
+
real[even] += oddReal;
|
|
78
|
+
imaginary[even] += oddImaginary;
|
|
79
|
+
const nextReal = weightReal * stepReal - weightImaginary * stepImaginary;
|
|
80
|
+
weightImaginary = weightReal * stepImaginary + weightImaginary * stepReal;
|
|
81
|
+
weightReal = nextReal;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* When each onset in a mono signal happens, in seconds from its start.
|
|
88
|
+
*
|
|
89
|
+
* Returns an empty array rather than throwing when there is nothing to find; the caller
|
|
90
|
+
* decides whether silence is a valid extraction result (it is not, and it says so).
|
|
91
|
+
*/
|
|
92
|
+
export function detectOnsets(samples, sampleRate) {
|
|
93
|
+
if (samples.length === 0 || sampleRate <= 0)
|
|
94
|
+
return [];
|
|
95
|
+
const pad = FRAME / 2;
|
|
96
|
+
const padded = new Float32Array(samples.length + pad * 2);
|
|
97
|
+
padded.set(samples, pad);
|
|
98
|
+
const window = new Float64Array(FRAME);
|
|
99
|
+
for (let i = 0; i < FRAME; i++)
|
|
100
|
+
window[i] = 0.5 - 0.5 * Math.cos((2 * Math.PI * i) / (FRAME - 1));
|
|
101
|
+
const real = new Float64Array(FRAME);
|
|
102
|
+
const imaginary = new Float64Array(FRAME);
|
|
103
|
+
const previous = new Float64Array(FRAME / 2);
|
|
104
|
+
const flux = [];
|
|
105
|
+
const energyRise = [];
|
|
106
|
+
let previousEnergy = 0;
|
|
107
|
+
for (let start = 0; start + FRAME <= padded.length; start += HOP) {
|
|
108
|
+
let energy = 0;
|
|
109
|
+
for (let i = 0; i < FRAME; i++) {
|
|
110
|
+
real[i] = padded[start + i] * window[i];
|
|
111
|
+
imaginary[i] = 0;
|
|
112
|
+
energy += real[i] * real[i];
|
|
113
|
+
}
|
|
114
|
+
//nothing against nothing is no change, but a frame that finally carries signal is
|
|
115
|
+
//an unbounded one, which is what the first frame of any file is
|
|
116
|
+
energyRise.push(previousEnergy === 0 ? (energy === 0 ? 0 : Infinity) : energy / previousEnergy - 1);
|
|
117
|
+
previousEnergy = energy;
|
|
118
|
+
fft(real, imaginary);
|
|
119
|
+
let rise = 0;
|
|
120
|
+
for (let k = 0; k < FRAME / 2; k++) {
|
|
121
|
+
const magnitude = Math.hypot(real[k], imaginary[k]);
|
|
122
|
+
const difference = magnitude - previous[k];
|
|
123
|
+
if (difference > 0)
|
|
124
|
+
rise += difference;
|
|
125
|
+
previous[k] = magnitude;
|
|
126
|
+
}
|
|
127
|
+
flux.push(rise);
|
|
128
|
+
}
|
|
129
|
+
const onsets = [];
|
|
130
|
+
let lastFrame = -Infinity;
|
|
131
|
+
for (let i = 0; i < flux.length; i++) {
|
|
132
|
+
const from = Math.max(0, i - NEIGHBOURHOOD);
|
|
133
|
+
const to = Math.min(flux.length - 1, i + NEIGHBOURHOOD);
|
|
134
|
+
const span = to - from + 1;
|
|
135
|
+
let mean = 0;
|
|
136
|
+
for (let k = from; k <= to; k++)
|
|
137
|
+
mean += flux[k];
|
|
138
|
+
mean /= span;
|
|
139
|
+
let variance = 0;
|
|
140
|
+
for (let k = from; k <= to; k++)
|
|
141
|
+
variance += (flux[k] - mean) ** 2;
|
|
142
|
+
const threshold = mean + FLUX_SIGMAS * Math.sqrt(variance / span);
|
|
143
|
+
//`<= 0` first: a silent file has flux of exactly zero everywhere, and its last
|
|
144
|
+
//frame would otherwise pass every later test and report an onset at the end
|
|
145
|
+
if (flux[i] <= 0 || flux[i] < threshold)
|
|
146
|
+
continue;
|
|
147
|
+
//and an attack has to have moved the envelope, not just the bin balance
|
|
148
|
+
if (energyRise[i] < ENERGY_RISE && (i === 0 || energyRise[i - 1] < ENERGY_RISE))
|
|
149
|
+
continue;
|
|
150
|
+
// the last frame of a flat top wins, so the plateau an impulse leaves behind
|
|
151
|
+
// resolves to one onset rather than the first frame of the plateau
|
|
152
|
+
if (i > 0 && flux[i - 1] > flux[i])
|
|
153
|
+
continue;
|
|
154
|
+
if (i + 1 < flux.length && flux[i + 1] >= flux[i])
|
|
155
|
+
continue;
|
|
156
|
+
if (i - lastFrame < MIN_GAP_FRAMES)
|
|
157
|
+
continue;
|
|
158
|
+
const time = (i * HOP + pad - FLUX_PEAK_DELAY) / sampleRate;
|
|
159
|
+
onsets.push(Math.max(0, time));
|
|
160
|
+
lastFrame = i;
|
|
161
|
+
}
|
|
162
|
+
return onsets;
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=Onsets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Onsets.js","sourceRoot":"","sources":["../../../src/audio/humanize/Onsets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,KAAK,GAAG,GAAG,CAAC;AAClB,MAAM,GAAG,GAAG,EAAE,CAAC;AACf,0EAA0E;AAC1E,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB;;;;GAIG;AACH,MAAM,WAAW,GAAG,CAAC,CAAC;AACtB;;;;;;;GAOG;AACH,MAAM,WAAW,GAAG,IAAI,CAAC;AACzB,iFAAiF;AACjF,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,0FAA0F;AAC1F,MAAM,eAAe,GAAG,KAAK,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;AAE5C,yFAAyF;AACzF,SAAS,GAAG,CAAC,IAAkB,EAAE,SAAuB;IACvD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAE3B,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACjC,IAAI,GAAG,GAAG,MAAM,IAAI,CAAC,CAAC;QACtB,OAAO,CAAC,GAAG,GAAG,EAAE,CAAC;YAChB,CAAC,IAAI,GAAG,CAAC;YACT,GAAG,KAAK,CAAC,CAAC;QACX,CAAC;QACD,CAAC,IAAI,GAAG,CAAC;QACT,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACX,IAAI,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACnB,IAAI,CAAC,CAAC,CAAC,GAAG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,CAAC,CAAC;QAElE,+EAA+E;QAC/E,4EAA4E;QAC5E,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,SAAS;YAAE,SAAS;QAClD,wEAAwE;QACxE,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG,WAAW,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC;YAAE,SAAS;QAC1F,6EAA6E;QAC7E,mEAAmE;QACnE,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;YAAE,SAAS;QAC7C,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;YAAE,SAAS;QAC5D,IAAI,CAAC,GAAG,SAAS,GAAG,cAAc;YAAE,SAAS;QAE7C,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,eAAe,CAAC,GAAG,UAAU,CAAC;QAC5D,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;QAC/B,SAAS,GAAG,CAAC,CAAC;IACf,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC"}
|
package/dist/audio/index.d.ts
CHANGED
|
@@ -17,8 +17,21 @@ export type { RenderMidiOptions, RenderMidiAsyncOptions, RenderedMidi } from './
|
|
|
17
17
|
export { collectSoundFontUsage, parseSoundFont, subsetSoundFont } from './SoundFont.ts';
|
|
18
18
|
export type { SoundFont, SoundFontProgram, SoundFontSample, SoundFontVoice } from './SoundFont.ts';
|
|
19
19
|
export { Channel, AudioBus } from './Channels.ts';
|
|
20
|
-
export
|
|
20
|
+
export { parseVorbisLoopTags, loopRegionFromTags } from './LoopTags.ts';
|
|
21
|
+
export type { VorbisLoopTags } from './LoopTags.ts';
|
|
22
|
+
export type { LoopRegion, ChannelPlayOptions, ChannelState, BusMixerLevel } from './Channels.ts';
|
|
21
23
|
export type { BusKind, BusTrack, SavedBusTrack, LoadedTrack, BusLoader, BusSnapshot, AudioBusOptions, } from './Channels.ts';
|
|
22
24
|
export { AudioListener, SoundSource, audioGain, audioPan } from './Positional.ts';
|
|
23
25
|
export type { AudioPoint, AudioFalloff, SoundSourceOptions } from './Positional.ts';
|
|
26
|
+
export { subdivisionCount, assertGrooveTemplate } from './humanize/Groove.ts';
|
|
27
|
+
export type { GridSubdivision, GrooveOffset, GrooveTemplate } from './humanize/Groove.ts';
|
|
28
|
+
export { LiteHumanizer } from './humanize/LiteHumanizer.ts';
|
|
29
|
+
export { GrooveHumanizer } from './humanize/GrooveHumanizer.ts';
|
|
30
|
+
export { GrooveExtractor } from './humanize/GrooveExtractor.ts';
|
|
31
|
+
export type { GrooveExtractorEngine } from './humanize/GrooveExtractor.ts';
|
|
32
|
+
export { GrooveConverter } from './humanize/GrooveConverter.ts';
|
|
33
|
+
export type { GrooveConverterEngine, GrooveFormat } from './humanize/GrooveConverter.ts';
|
|
34
|
+
export { HumanizerFactory, humanizeMidi } from './humanize/HumanizerFactory.ts';
|
|
35
|
+
export type { HumanizeRequest } from './humanize/HumanizerFactory.ts';
|
|
36
|
+
export type { HumanizationOptions, HumanizeStyle, HumanizerTier, MidiHumanizerEngine } from './humanize/Humanize.ts';
|
|
24
37
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/audio/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,Y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@@ export { parseMidi, scheduleMidi, noteToFrequency, midiLoopStart, MidiPlayer } f
|
|
|
8
8
|
export { renderMidiToBuffer, renderMidiToBufferAsync } from './MidiRender.js';
|
|
9
9
|
export { collectSoundFontUsage, parseSoundFont, subsetSoundFont } from './SoundFont.js';
|
|
10
10
|
export { Channel, AudioBus } from './Channels.js';
|
|
11
|
+
export { parseVorbisLoopTags, loopRegionFromTags } from './LoopTags.js';
|
|
11
12
|
export { AudioListener, SoundSource, audioGain, audioPan } from './Positional.js';
|
|
13
|
+
export { subdivisionCount, assertGrooveTemplate } from './humanize/Groove.js';
|
|
14
|
+
export { LiteHumanizer } from './humanize/LiteHumanizer.js';
|
|
15
|
+
export { GrooveHumanizer } from './humanize/GrooveHumanizer.js';
|
|
16
|
+
export { GrooveExtractor } from './humanize/GrooveExtractor.js';
|
|
17
|
+
export { GrooveConverter } from './humanize/GrooveConverter.js';
|
|
18
|
+
export { HumanizerFactory, humanizeMidi } from './humanize/HumanizerFactory.js';
|
|
12
19
|
//# sourceMappingURL=index.js.map
|
package/dist/audio/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/audio/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAahG,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,iBAA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,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { type ChessSide, type ChessState, type PromotionKind } from './chess.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Chess on bitboards: the first slice of the tournament engine (item 390).
|
|
4
|
+
*
|
|
5
|
+
* Twelve 64-bit boards (`pieces[color * 6 + kind]`, white 0-5, black 6-11, square 0 is
|
|
6
|
+
* a1 exactly like `chess.ts`), side to move, castling rights, en passant square, the
|
|
7
|
+
* halfmove clock and both king squares. Everything in it is plain data (`bigint`
|
|
8
|
+
* included), so a position structured-clones into a worker untouched.
|
|
9
|
+
*
|
|
10
|
+
* Two implementations of the rules now exist on purpose: `chess.ts` is the readable
|
|
11
|
+
* reference a minigame runs directly, this one is the fast mutable board a search
|
|
12
|
+
* makes and unmakes millions of times. `tests/board-bitboard.test.ts` keeps them
|
|
13
|
+
* honest two ways: every legal move of one is a legal move of the other on a suite of
|
|
14
|
+
* positions, and perft counts match the published node counts.
|
|
15
|
+
*/
|
|
16
|
+
export interface BitboardState {
|
|
17
|
+
/** twelve bitboards: white pawn..king, then black pawn..king */
|
|
18
|
+
pieces: bigint[];
|
|
19
|
+
turn: ChessSide;
|
|
20
|
+
/** castling rights as a mask: 1 white kingside, 2 white queenside, 4 black kingside, 8 black queenside */
|
|
21
|
+
castling: number;
|
|
22
|
+
/** a square a pawn could capture onto, left behind by a double push */
|
|
23
|
+
enPassant: number | null;
|
|
24
|
+
halfmove: number;
|
|
25
|
+
/** king squares, white then black: maintained on every move, so checks never scan */
|
|
26
|
+
kings: [number, number];
|
|
27
|
+
}
|
|
28
|
+
export interface BitboardMove {
|
|
29
|
+
from: number;
|
|
30
|
+
to: number;
|
|
31
|
+
promotion?: PromotionKind;
|
|
32
|
+
}
|
|
33
|
+
/** everything `makeMove` changes besides the moved piece, handed back to `unmakeMove` */
|
|
34
|
+
export interface BitboardUndo {
|
|
35
|
+
captured: {
|
|
36
|
+
color: 0 | 1;
|
|
37
|
+
kind: number;
|
|
38
|
+
} | null;
|
|
39
|
+
castling: number;
|
|
40
|
+
enPassant: number | null;
|
|
41
|
+
halfmove: number;
|
|
42
|
+
kingSquare: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Reads a `chess.ts` position onto bitboards: the bridge the differential tests cross
|
|
46
|
+
* in both directions, and the way a FEN reaches the fast board.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { bitboardFromChess, bitboardMoves, startingChess } from '@datamoc/mw_games/board';
|
|
51
|
+
*
|
|
52
|
+
* const moves = bitboardMoves(bitboardFromChess(startingChess()));
|
|
53
|
+
* console.log(moves.length); // 20 - the opening position's own count
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare function bitboardFromChess(state: ChessState): BitboardState;
|
|
57
|
+
/**
|
|
58
|
+
* The standard opening array on bitboards, white to move with every right intact.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { bitboardMoves, startingBitboard } from '@datamoc/mw_games/board';
|
|
63
|
+
*
|
|
64
|
+
* console.log(bitboardMoves(startingBitboard()).length); // 20 - 16 pawn moves, 4 knight moves
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function startingBitboard(): BitboardState;
|
|
68
|
+
/**
|
|
69
|
+
* Every legal move for the side to play, in stable square order: pseudo-moves that leave
|
|
70
|
+
* their own king safe, each tried with `makeMove` and taken back with `unmakeMove`.
|
|
71
|
+
* Castling needs its rights, an empty passage and no check on the way over; en passant
|
|
72
|
+
* pins fall out of the make-and-test filter rather than special-casing.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* import { bitboardMoves, startingBitboard } from '@datamoc/mw_games/board';
|
|
77
|
+
*
|
|
78
|
+
* const moves = bitboardMoves(startingBitboard());
|
|
79
|
+
* console.log(moves.every((move) => move.from >= 0 && move.to < 64)); // true
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export declare function bitboardMoves(board: BitboardState): BitboardMove[];
|
|
83
|
+
/**
|
|
84
|
+
* Plays a move, mutating the position, and returns what `unmakeMove` needs to take it
|
|
85
|
+
* back. Special moves are read off the position rather than flagged on the move: a pawn
|
|
86
|
+
* onto the en passant square captures the pawn behind it, a king stepping two squares
|
|
87
|
+
* swings its rook, a pawn stride of sixteen leaves a square behind it.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* import { bitboardMoves, makeMove, startingBitboard, unmakeMove } from '@datamoc/mw_games/board';
|
|
92
|
+
*
|
|
93
|
+
* const board = startingBitboard();
|
|
94
|
+
* const move = bitboardMoves(board)[0];
|
|
95
|
+
* const undo = makeMove(board, move);
|
|
96
|
+
* console.log(board.turn); // 'black' - the move is played
|
|
97
|
+
* unmakeMove(board, move, undo);
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export declare function makeMove(board: BitboardState, move: BitboardMove): BitboardUndo;
|
|
101
|
+
/**
|
|
102
|
+
* Takes back exactly what `makeMove` played: the mover returns, the taken piece (or the
|
|
103
|
+
* en passant pawn behind the landing square) is restored, and rights, en passant
|
|
104
|
+
* square, halfmove clock and king square come back from the undo.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* import { bitboardMoves, makeMove, startingBitboard, unmakeMove } from '@datamoc/mw_games/board';
|
|
109
|
+
*
|
|
110
|
+
* const board = startingBitboard();
|
|
111
|
+
* const move = bitboardMoves(board)[0];
|
|
112
|
+
* const undo = makeMove(board, move);
|
|
113
|
+
* unmakeMove(board, move, undo);
|
|
114
|
+
* console.log(board.turn, bitboardMoves(board).length); // 'white' 20 - taken back whole
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
export declare function unmakeMove(board: BitboardState, move: BitboardMove, undo: BitboardUndo): void;
|
|
118
|
+
/**
|
|
119
|
+
* Move-generation node count: 1 at depth 0, else the sum over every legal move. The
|
|
120
|
+
* position is played and taken back as it goes, so it reads identical afterwards.
|
|
121
|
+
* Counts match the published perft numbers, which is the whole point: a wrong move
|
|
122
|
+
* generator cannot hide from them.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```ts
|
|
126
|
+
* import { perft, startingBitboard } from '@datamoc/mw_games/board';
|
|
127
|
+
*
|
|
128
|
+
* console.log(perft(startingBitboard(), 2)); // 400 - the opening's two-ply count
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
export declare function perft(board: BitboardState, depth: number): number;
|
|
132
|
+
//# sourceMappingURL=bitboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitboard.d.ts","sourceRoot":"","sources":["../../src/board/bitboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhH;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,aAAa;IAC7B,gEAAgE;IAChE,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,EAAE,SAAS,CAAC;IAChB,0GAA0G;IAC1G,QAAQ,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,qFAAqF;IACrF,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED,yFAAyF;AACzF,MAAM,WAAW,YAAY;IAC5B,QAAQ,EAAE;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