jackboyla commited on
Commit
b2f2f57
·
verified ·
1 Parent(s): acfbbbe

Deploy checked Hendrix D26 browser demo

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. README.md +58 -4
  3. assets/PianoRollCanvas-xSq9nagc.js +1 -0
  4. assets/local-56CJnE36.css +1 -0
  5. assets/local-DblFrGk8.js +0 -0
  6. assets/ort-wasm-simd-threaded.asyncify-CvvOzbbq.wasm +3 -0
  7. assets/spessasynth_processor.min-tdOdhV7p.js +0 -0
  8. assets/style-BAFoxh21.css +2 -0
  9. assets/style-CdJLhYve.js +0 -0
  10. deployment.json +242 -0
  11. diagnostic.wav +0 -0
  12. favicon.png +0 -0
  13. index.html +16 -17
  14. local.html +18 -0
  15. models/fp32/cross_cache.onnx +3 -0
  16. models/fp32/decoder_step.onnx +3 -0
  17. models/fp32/encoder.onnx +3 -0
  18. models/fp32/manifest.json +111 -0
  19. ort/ort-wasm-simd-threaded.jsep.mjs +106 -0
  20. ort/ort-wasm-simd-threaded.jsep.wasm +3 -0
  21. source/demo/web/compare.html +27 -0
  22. source/demo/web/index.html +29 -0
  23. source/demo/web/local.html +14 -0
  24. source/demo/web/package.json +34 -0
  25. source/demo/web/pnpm-lock.yaml +1025 -0
  26. source/demo/web/public/favicon.png +0 -0
  27. source/demo/web/src/App.tsx +385 -0
  28. source/demo/web/src/audio.ts +528 -0
  29. source/demo/web/src/compare.tsx +779 -0
  30. source/demo/web/src/components/ConditioningPanel.tsx +195 -0
  31. source/demo/web/src/components/Controls.tsx +123 -0
  32. source/demo/web/src/components/DropOverlay.tsx +24 -0
  33. source/demo/web/src/components/Footer.tsx +46 -0
  34. source/demo/web/src/components/InstrumentList.tsx +208 -0
  35. source/demo/web/src/components/OutputBar.tsx +192 -0
  36. source/demo/web/src/components/PianoRollCanvas.tsx +188 -0
  37. source/demo/web/src/components/WelcomeScreen.tsx +186 -0
  38. source/demo/web/src/components/icons.tsx +80 -0
  39. source/demo/web/src/hooks/useAudioEngine.ts +17 -0
  40. source/demo/web/src/hooks/useTranscription.ts +235 -0
  41. source/demo/web/src/instruments.ts +202 -0
  42. source/demo/web/src/local.tsx +329 -0
  43. source/demo/web/src/local/codec.ts +210 -0
  44. source/demo/web/src/local/dsp.ts +147 -0
  45. source/demo/web/src/local/float16.ts +17 -0
  46. source/demo/web/src/local/local.css +51 -0
  47. source/demo/web/src/local/midi.ts +57 -0
  48. source/demo/web/src/local/model.ts +359 -0
  49. source/demo/web/src/main.tsx +8 -0
  50. source/demo/web/src/pianoroll.ts +501 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ source/docs/assets/choir_bwv407.wav filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,10 +1,64 @@
1
  ---
2
  title: Hendrix
3
- emoji: 📚
4
- colorFrom: yellow
5
  colorTo: pink
6
  sdk: static
7
- pinned: false
 
 
 
 
 
 
 
 
 
 
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  title: Hendrix
3
+ emoji: 🎹
4
+ colorFrom: purple
5
  colorTo: pink
6
  sdk: static
7
+ app_file: index.html
8
+ fullWidth: true
9
+ short_description: Music to MIDI on your device. Your audio stays local.
10
+ tags:
11
+ - music
12
+ - automatic-music-transcription
13
+ - audio-to-midi
14
+ - onnx
15
+ - webgpu
16
+ custom_headers:
17
+ cross-origin-embedder-policy: require-corp
18
+ cross-origin-opener-policy: same-origin
19
+ cross-origin-resource-policy: cross-origin
20
  ---
21
 
22
+ # Hendrix
23
+
24
+ Choose an audio file, record with your microphone, or try the short Bach
25
+ example. Hendrix predicts notes and instrument families, draws a piano roll,
26
+ plays the result, and lets you download a MIDI file.
27
+
28
+ Audio decoding and model inference run on your device. The app does not upload
29
+ your recording. It downloads the checked 195.3 MB FP32 D26 model on first use.
30
+ WebGPU is preferred; WebAssembly supplies a CPU fallback. Start with two
31
+ seconds: speed and memory use depend on your browser and device.
32
+
33
+ If the embedded app runs slowly, [open the app directly](https://jackboyla-hendrix.hf.space/)
34
+ to enable browser isolation and up to four CPU threads. Microphone access also
35
+ depends on browser permissions. Predictions are a research result and may
36
+ miss notes, assign the wrong instrument, or give poor note endings. MIDI
37
+ playback uses a simple browser synth.
38
+
39
+ The example is a two-second excerpt of our synthetic Bach BWV 407 chorale
40
+ rendering, made from a public-domain score. We do not redistribute the local
41
+ YouTube diagnostic audio.
42
+
43
+ Model: 46.5M-parameter D26, derived from YPTF-MoE+Multi. `models/fp32/manifest.json`
44
+ records the source checkpoint and graph hashes. `deployment.json` records the
45
+ app build and file hashes. This Space includes only the checked FP32 release.
46
+
47
+ [Source, methods, results, and deployment commands](https://github.com/jackboyla/hendrix)
48
+
49
+ This is a static Space: hosting requires no server-side inference or GPU.
50
+
51
+ The `source/` directory contains the app source used for this deployment.
52
+ To rebuild and publish from that snapshot:
53
+
54
+ ```bash
55
+ cd source
56
+ npx --yes pnpm@10.20.0 --dir demo/web install --frozen-lockfile
57
+ hf auth login
58
+ uv run --no-project --with huggingface_hub==0.36.2 python \
59
+ scripts/deploy_huggingface_space.py --graph-dir ../models/fp32 --upload
60
+ ```
61
+
62
+ Omit `--upload` to build and check a local package. Each run prints the staging
63
+ directory. The script keeps the model hashes fixed and refuses to change an
64
+ existing Space's visibility or SDK.
assets/PianoRollCanvas-xSq9nagc.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{o as e,r as t,t as n}from"./style-CdJLhYve.js";var r=e(),i=t();function a(e){let{rollRef:t,audio:a,setUserScrolled:o}=e,s=(0,r.useRef)(null);return(0,r.useEffect)(()=>{let e=s.current,r=new n(e);t.current=r;let i=t=>{t.preventDefault();let n=e.getBoundingClientRect(),i=Math.exp(-t.deltaY*.01);if(t.altKey){r.zoomPitch(i,t.clientY-n.top),o(!0);return}if(t.ctrlKey||t.metaKey){r.zoomTime(i,t.clientX-n.left),o(!0);return}if(t.shiftKey){let e=t.deltaX===0?t.deltaY:t.deltaX;e!==0&&r.scrollBy(e/r.pxPerSec)}else t.deltaX!==0&&r.scrollBy(t.deltaX/r.pxPerSec),t.deltaY!==0&&r.scrollPitchBy(-t.deltaY);o(!0)},c=null,l=t=>{let n=e.getBoundingClientRect(),i=t<n.left?0:Math.max(0,r.xToSeconds(t-n.left));a.scrubTo(i),r.setPlayhead(i)},u=null,d=t=>{let n=e.getBoundingClientRect(),r=t.clientX-n.left;r>=56?(c={wasPlaying:a.state===`started`},c.wasPlaying&&a.pause(),l(t.clientX)):u={x:r,y:t.clientY-n.top},t.preventDefault()},f=t=>{if(c){l(t.clientX);return}let n=e.getBoundingClientRect();if(u){let e=t.clientX-n.left,i=t.clientY-n.top,a=e-u.x,s=i-u.y;a!==0&&r.zoomPitch(Math.exp(a*.01),i),s!==0&&r.scrollPitchBy(s),u={x:e,y:i},o(!0);return}e.style.cursor=t.clientX-n.left<56?`ew-resize`:`default`},p=()=>{c&&=(a.seek(a.seconds),c.wasPlaying&&a.play(),null),u=null},m=null,h=null,g=e=>({dx:Math.abs(e[0].clientX-e[1].clientX),dy:Math.abs(e[0].clientY-e[1].clientY)}),_=e=>{e.touches.length===2?(h=g(e.touches),m=null,e.preventDefault()):e.touches.length===1&&(m={x:e.touches[0].clientX,y:e.touches[0].clientY})},v=t=>{let n=e.getBoundingClientRect();if(h&&t.touches.length===2){t.preventDefault();let e=g(t.touches),i=(t.touches[0].clientX+t.touches[1].clientX)/2-n.left,a=(t.touches[0].clientY+t.touches[1].clientY)/2-n.top;h.dx>12&&e.dx>12&&r.zoomTime(e.dx/h.dx,i),h.dy>12&&e.dy>12&&r.zoomPitch(e.dy/h.dy,a),h=e,o(!0)}else if(m&&t.touches.length===1){t.preventDefault();let e=t.touches[0];r.scrollBy(-(e.clientX-m.x)/r.pxPerSec),r.scrollPitchBy(e.clientY-m.y),m={x:e.clientX,y:e.clientY},o(!0)}},y=e=>{e.touches.length<2&&(h=null),e.touches.length===0&&(m=null)};return e.addEventListener(`wheel`,i,{passive:!1}),e.addEventListener(`touchstart`,_,{passive:!1}),e.addEventListener(`touchmove`,v,{passive:!1}),e.addEventListener(`touchend`,y,{passive:!1}),e.addEventListener(`mousedown`,d),window.addEventListener(`mousemove`,f),window.addEventListener(`mouseup`,p),()=>{e.removeEventListener(`wheel`,i),e.removeEventListener(`touchstart`,_),e.removeEventListener(`touchmove`,v),e.removeEventListener(`touchend`,y),e.removeEventListener(`mousedown`,d),window.removeEventListener(`mousemove`,f),window.removeEventListener(`mouseup`,p)}},[a,t,o]),(0,i.jsx)(`section`,{className:`relative col-start-1 overflow-hidden rounded-card border border-line bg-[linear-gradient(180deg,rgba(255,255,255,0.02),transparent_60px),#0a0b0e] p-0 shadow-[0_1px_0_rgba(255,255,255,0.04)_inset,0_18px_40px_-28px_rgba(0,0,0,0.9)] animate-rise [animation-delay:0.12s]`,children:(0,i.jsx)(`canvas`,{className:`block h-[420px] w-full`,width:1200,height:400,ref:s})})}export{a as t};
assets/local-56CJnE36.css ADDED
@@ -0,0 +1 @@
 
 
1
+ :root{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark}body{color:#f2f0e9;background:#090a0d;margin:0}.local-shell{width:min(1120px,100% - 28px);padding:max(24px, env(safe-area-inset-top)) 0 56px;gap:18px;margin:0 auto;font-family:Inter,ui-sans-serif,system-ui,sans-serif;display:grid}.local-hero{border-bottom:1px solid #30323a;padding:clamp(24px,6vw,72px) 4px 20px}.local-kicker{color:#ff627d;letter-spacing:.18em;font-size:12px;font-weight:800;text-decoration:none}.local-hero h1{letter-spacing:-.06em;max-width:850px;margin:14px 0;font-family:Georgia,serif;font-size:clamp(54px,11vw,124px);font-weight:500;line-height:.82}.local-hero p{color:#b7bac4;max-width:700px;margin:26px 0 0;font-size:clamp(16px,2vw,21px);line-height:1.5}.local-card{background:#111319;border:1px solid #2d3038;border-radius:16px;box-shadow:inset 0 1px #ffffff0a}.capability-card{color:#c7cad2;align-items:center;gap:10px;padding:14px 18px;font-size:13px;display:flex}.status-dot{background:#ff627d;border-radius:50%;width:9px;height:9px;box-shadow:0 0 14px #ff627d88}.status-dot.ready{background:#70e09b;box-shadow:0 0 14px #70e09b88}.input-card{padding:clamp(18px,4vw,34px)}.file-row,.action-row,.result-bar{flex-wrap:wrap;align-items:center;gap:10px;display:flex}.primary-button,.secondary-button,.record-button{appearance:none;font:inherit;cursor:pointer;border:1px solid #0000;border-radius:999px;padding:12px 18px;font-weight:750;text-decoration:none}.primary-button{color:#090a0d;background:#f2f0e9}.secondary-button{color:#f2f0e9;background:#1b1e25;border-color:#3a3e48}.record-button{color:#fff;background:#d83455;animation:1.3s infinite pulse-record}button:disabled{cursor:not-allowed;opacity:.38}.primary-button:has(input:disabled){cursor:not-allowed;opacity:.38}.limit-label{color:#9da1ac;align-items:center;gap:8px;margin-left:auto;font-size:13px;display:flex}.limit-label select{color:#fff;background:#171920;border:1px solid #3a3e48;border-radius:8px;padding:8px}.chosen-file{color:#f2f0e9;text-overflow:ellipsis;white-space:nowrap;margin:22px 0;font-family:ui-monospace,monospace;overflow:hidden}.progress-track{background:#262933;border-radius:9px;height:5px;margin-top:22px;overflow:hidden}.progress-track>div{background:linear-gradient(90deg,#f57,#f3b65c);height:100%;transition:width .2s}.run-status{color:#aeb1bb;min-height:1.5em;margin:12px 0 0;font-size:14px}.run-status.error{color:#ff8ca0}.diagnostic-output{overflow-wrap:anywhere;color:#858994;margin:10px 0 0;font:11px/1.5 ui-monospace,monospace}.result-bar{background:#111319;border:1px solid #2d3038;border-radius:16px;padding:16px 18px}.result-bar>div{min-width:80px}.result-bar strong{font-family:Georgia,serif;font-size:30px;font-weight:500;display:block}.result-bar span{color:#8f939e;letter-spacing:.12em;text-transform:uppercase;font-size:11px}.result-bar button{margin-left:auto}.roll-stage{position:relative}.roll-empty{color:#b7bac4;pointer-events:none;background:#111319e8;border:1px solid #3a3e48;border-radius:999px;width:max-content;max-width:80%;padding:11px 16px;font-size:13px;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.local-footer{color:#858994;grid-template-columns:minmax(0,1fr) auto;align-items:start;gap:16px 36px;padding:8px 4px 0;font-size:12px;line-height:1.5;display:grid}.local-footer p{max-width:650px;margin:0}.local-footer-links{flex-wrap:wrap;justify-content:flex-end;gap:8px 16px;max-width:380px;display:flex}.local-footer a{color:#d9dce5;text-underline-offset:3px;text-decoration-color:#626670}@keyframes pulse-record{50%{box-shadow:0 0 0 7px #d8345522}}@media (width<=640px){.local-shell{width:min(100% - 20px,1120px)}.local-hero h1{font-size:58px}.limit-label{width:100%;margin:8px 0 0}.result-bar button{margin-left:0}.local-footer{grid-template-columns:1fr}.local-footer-links{justify-content:flex-start}}.run-hint{color:#aeb1bb;margin:16px 0 0;font-size:13px;line-height:1.5}.run-diagnostics{color:#aeb1bb;margin-top:12px;font-size:12px}.run-diagnostics summary{cursor:pointer}.primary-button:focus-within,button:focus-visible,a:focus-visible,select:focus-visible{outline-offset:4px;outline:2px solid #ff627d}
assets/local-DblFrGk8.js ADDED
The diff for this file is too large to render. See raw diff
 
assets/ort-wasm-simd-threaded.asyncify-CvvOzbbq.wasm ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7e83cd6cee77e478bc96a7e91b198144fb5e4126287daf1f9b54bb195ebcd55a
3
+ size 24254953
assets/spessasynth_processor.min-tdOdhV7p.js ADDED
The diff for this file is too large to render. See raw diff
 
assets/style-BAFoxh21.css ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ /*! tailwindcss v4.3.2 | MIT License | https://tailwindcss.com */
2
+ @layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:"Hanken Grotesk", system-ui, -apple-system, sans-serif;--font-serif:"Instrument Serif", Georgia, "Times New Roman", serif;--font-mono:"JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;--color-red-300:oklch(80.8% .114 19.571);--color-red-500:oklch(63.7% .237 25.331);--color-white:#fff;--spacing:.25rem;--container-md:28rem;--container-3xl:48rem;--container-7xl:80rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--text-5xl:3rem;--text-5xl--line-height:1;--font-weight-normal:400;--font-weight-semibold:600;--font-weight-bold:700;--leading-snug:1.375;--leading-relaxed:1.625;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--blur-sm:8px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-bg:#0b0c10;--color-surface:#121319;--color-surface-2:#16171f;--color-line:#ffffff12;--color-line-strong:#ffffff21;--color-content:#edecf0;--color-muted:#aaacb9;--color-faint:#5a5c68;--color-accent:#ff5b7a;--color-accent-soft:#ff5b7a21;--color-accent-glow:#ff5b7a80;--color-ok:#4ad295;--radius-card:12px;--ease-fluid:cubic-bezier(.22, 1, .36, 1);--animate-rise:rise .7s var(--ease-fluid) both;--animate-drag-glow:drag-glow 1.7s var(--ease-fluid) infinite}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}html{-webkit-font-smoothing:antialiased;text-rendering:optimizelegibility}body{font-family:var(--font-sans);min-height:100vh;color:var(--color-content);background-color:#1b1c21;background-image:radial-gradient(900px 500px at 88% -8%,#ff5b7a1a,#0000 60%),none;background-position:0 0,0 0;background-repeat:repeat,repeat;background-size:auto,auto;background-attachment:fixed;background-origin:padding-box,padding-box;background-clip:border-box,border-box}button{font-family:var(--font-sans);color:var(--color-content);background:var(--color-surface-2);border:1px solid var(--color-line-strong);cursor:pointer;transition:background .15s var(--ease-fluid), border-color .15s var(--ease-fluid), transform 80ms var(--ease-fluid);border-radius:9px;padding:8px 16px;font-size:13px;font-weight:500}button:hover{background:#20212b;border-color:#fff3}button:active{transform:translateY(1px)}button:focus-visible{outline:2px solid var(--color-accent);outline-offset:2px}button:disabled{opacity:.4;cursor:not-allowed;transform:none}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.inset-0{inset:0}.inset-x-0{inset-inline:0}.top-\[calc\(100\%\+5px\)\]{top:calc(100% + 5px)}.top-\[calc\(100\%\+8px\)\]{top:calc(100% + 8px)}.right-0{right:0}.left-0{left:0}.z-20{z-index:20}.z-30{z-index:30}.z-\[200\]{z-index:200}.col-span-full{grid-column:1/-1}.col-start-1{grid-column-start:1}.col-start-2{grid-column-start:2}.m-0{margin:0}.mx-auto{margin-inline:auto}.-my-1{margin-block:calc(var(--spacing) * -1)}.mt-1\.5{margin-top:calc(var(--spacing) * 1.5)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mt-5{margin-top:calc(var(--spacing) * 5)}.mb-1{margin-bottom:var(--spacing)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-3\.5{margin-bottom:calc(var(--spacing) * 3.5)}.ml-1\.5{margin-left:calc(var(--spacing) * 1.5)}.ml-auto{margin-left:auto}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-flex{display:inline-flex}.size-3{width:calc(var(--spacing) * 3);height:calc(var(--spacing) * 3)}.size-4{width:calc(var(--spacing) * 4);height:calc(var(--spacing) * 4)}.size-6{width:calc(var(--spacing) * 6);height:calc(var(--spacing) * 6)}.h-1{height:var(--spacing)}.h-3\.5{height:calc(var(--spacing) * 3.5)}.h-6{height:calc(var(--spacing) * 6)}.h-8{height:calc(var(--spacing) * 8)}.h-16{height:calc(var(--spacing) * 16)}.h-\[420px\]{height:420px}.h-\[clamp\(72px\,10vw\,110px\)\]{height:clamp(72px,10vw,110px)}.h-full{height:100%}.max-h-60{max-height:calc(var(--spacing) * 60)}.min-h-11{min-height:calc(var(--spacing) * 11)}.w-3\.5{width:calc(var(--spacing) * 3.5)}.w-32{width:calc(var(--spacing) * 32)}.w-60{width:calc(var(--spacing) * 60)}.w-auto{width:auto}.w-full{width:100%}.max-w-3xl{max-width:var(--container-3xl)}.max-w-7xl{max-width:var(--container-7xl)}.max-w-full{max-width:100%}.max-w-md{max-width:var(--container-md)}.min-w-0{min-width:0}.min-w-8{min-width:calc(var(--spacing) * 8)}.min-w-32{min-width:calc(var(--spacing) * 32)}.min-w-48{min-width:calc(var(--spacing) * 48)}.flex-1{flex:1}.shrink-0{flex-shrink:0}.grow{flex-grow:1}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.\[animation\:rise_0\.4s_var\(--ease-fluid\)_both\]{animation:rise .4s var(--ease-fluid) both}.animate-drag-glow{animation:var(--animate-drag-glow)}.animate-rise{animation:var(--animate-rise)}.cursor-help{cursor:help}.cursor-pointer{cursor:pointer}.cursor-text{cursor:text}.resize{resize:both}.list-none{list-style-type:none}.grid-cols-\[1fr_300px\]{grid-template-columns:1fr 300px}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-content-center{place-content:center}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:var(--spacing)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-3\.5{gap:calc(var(--spacing) * 3.5)}.gap-4{gap:calc(var(--spacing) * 4)}.gap-6{gap:calc(var(--spacing) * 6)}.self-start{align-self:flex-start}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.card{background:linear-gradient(180deg, #ffffff06, transparent 120px), var(--color-surface);border:1px solid var(--color-line);border-radius:var(--radius-card);box-shadow:inset 0 1px #ffffff0a,0 18px 40px -28px #000000e6}.rounded{border-radius:.25rem}.rounded-card{border-radius:var(--radius-card)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-none{border-radius:0}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-none{--tw-border-style:none;border-style:none}.btn-primary{background:linear-gradient(180deg, var(--color-accent), #e84668);color:#fff;box-shadow:0 0 0 1px #ff5b7a66, 0 8px 22px -10px var(--color-accent-glow);border-color:#0000;font-weight:600}.btn-primary:hover:not(:disabled){filter:brightness(1.08);background:linear-gradient(180deg, var(--color-accent), #e84668);border-color:#0000}.border-accent{border-color:var(--color-accent)}.border-accent-glow{border-color:var(--color-accent-glow)}.border-line{border-color:var(--color-line)}.border-line-strong{border-color:var(--color-line-strong)}.border-red-500\/40{border-color:#fb2c3666}@supports (color:color-mix(in lab, red, red)){.border-red-500\/40{border-color:color-mix(in oklab, var(--color-red-500) 40%, transparent)}}.border-transparent{border-color:#0000}.bg-\[linear-gradient\(180deg\,rgba\(255\,255\,255\,0\.02\)\,transparent_60px\)\,\#0a0b0e\]{background-color:linear-gradient(180deg,#ffffff05,transparent 60px),#0a0b0e}.bg-\[rgba\(11\,12\,16\,0\.78\)\]{background-color:#0b0c10c7}.bg-accent{background-color:var(--color-accent)}.bg-accent-soft{background-color:var(--color-accent-soft)}.bg-bg{background-color:var(--color-bg)}.bg-content{background-color:var(--color-content)}.bg-faint{background-color:var(--color-faint)}.bg-red-500\/10{background-color:#fb2c361a}@supports (color:color-mix(in lab, red, red)){.bg-red-500\/10{background-color:color-mix(in oklab, var(--color-red-500) 10%, transparent)}}.bg-surface{background-color:var(--color-surface)}.bg-surface-2{background-color:var(--color-surface-2)}.bg-transparent{background-color:#0000}.bg-white\/\[0\.06\]{background-color:#ffffff0f}@supports (color:color-mix(in lab, red, red)){.bg-white\/\[0\.06\]{background-color:color-mix(in oklab, var(--color-white) 6%, transparent)}}.fill-none{fill:none}.stroke-accent{stroke:var(--color-accent)}.stroke-current{stroke:currentColor}.\[stroke-width\:1\.5\]{stroke-width:1.5px}.stroke-2{stroke-width:2px}.p-0{padding:0}.p-1{padding:var(--spacing)}.px-0\.5{padding-inline:calc(var(--spacing) * .5)}.px-1{padding-inline:var(--spacing)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-3\.5{padding-inline:calc(var(--spacing) * 3.5)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-5{padding-inline:calc(var(--spacing) * 5)}.px-7{padding-inline:calc(var(--spacing) * 7)}.px-8{padding-inline:calc(var(--spacing) * 8)}.px-9{padding-inline:calc(var(--spacing) * 9)}.px-16{padding-inline:calc(var(--spacing) * 16)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:var(--spacing)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-7{padding-block:calc(var(--spacing) * 7)}.py-10{padding-block:calc(var(--spacing) * 10)}.py-11{padding-block:calc(var(--spacing) * 11)}.py-16{padding-block:calc(var(--spacing) * 16)}.pt-2{padding-top:calc(var(--spacing) * 2)}.pt-4{padding-top:calc(var(--spacing) * 4)}.pt-10{padding-top:calc(var(--spacing) * 10)}.pr-1\.5{padding-right:calc(var(--spacing) * 1.5)}.pb-5{padding-bottom:calc(var(--spacing) * 5)}.pb-6{padding-bottom:calc(var(--spacing) * 6)}.pb-12{padding-bottom:calc(var(--spacing) * 12)}.pl-3{padding-left:calc(var(--spacing) * 3)}.text-center{text-align:center}.text-left{text-align:left}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono)}.font-sans{font-family:var(--font-sans)}.font-serif{font-family:var(--font-serif)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-5xl{font-size:var(--text-5xl);line-height:var(--tw-leading,var(--text-5xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[10px\]{font-size:10px}.text-\[13px\]{font-size:13px}.text-\[clamp\(2rem\,8vw\,3rem\)\]{font-size:clamp(2rem,8vw,3rem)}.leading-\[1\.1\]{--tw-leading:1.1;line-height:1.1}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-snug{--tw-leading:var(--leading-snug);line-height:var(--leading-snug)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.text-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.text-\[\#15151b\]{color:#15151b}.text-\[\#ff5577\]{color:#f57}.text-\[\#ffcc44\]{color:#fc4}.text-accent{color:var(--color-accent)}.text-content{color:var(--color-content)}.text-faint{color:var(--color-faint)}.text-muted{color:var(--color-muted)}.text-red-300{color:var(--color-red-300)}.text-white{color:var(--color-white)}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.line-through{text-decoration-line:line-through}.underline{text-decoration-line:underline}.underline-offset-4{text-underline-offset:4px}.accent-accent{accent-color:var(--color-accent)}.opacity-0{opacity:0}.opacity-10{opacity:.1}.opacity-40{opacity:.4}.opacity-70{opacity:.7}.opacity-90{opacity:.9}.opacity-100{opacity:1}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-\[0_0_10px_-1px_currentColor\]{--tw-shadow:0 0 10px -1px var(--tw-shadow-color,currentColor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-\[0_1px_0_rgba\(255\,255\,255\,0\.04\)_inset\,0_18px_40px_-28px_rgba\(0\,0\,0\,0\.9\)\]{--tw-shadow:0 1px 0 var(--tw-shadow-color,#ffffff0a) inset, 0 18px 40px -28px var(--tw-shadow-color,#000000e6);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-\[0_18px_40px_-20px_rgba\(0\,0\,0\,0\.9\)\]{--tw-shadow:0 18px 40px -20px var(--tw-shadow-color,#000000e6);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-\[0_24px_60px_-24px_rgba\(0\,0\,0\,0\.9\)\]{--tw-shadow:0 24px 60px -24px var(--tw-shadow-color,#000000e6);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.backdrop-blur-sm{--tw-backdrop-blur:blur(var(--blur-sm));-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.transition-\[opacity\,background\,color\]{transition-property:opacity,background,color;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.ease-fluid{--tw-ease:var(--ease-fluid);transition-timing-function:var(--ease-fluid)}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.\[animation-delay\:0\.06s\]{animation-delay:60ms}.\[animation-delay\:0\.12s\]{animation-delay:.12s}.\[animation-delay\:0\.18s\]{animation-delay:.18s}.\[animation-delay\:0\.24s\]{animation-delay:.24s}.\[stroke-linecap\:round\]{stroke-linecap:round}.\[stroke-linejoin\:round\]{stroke-linejoin:round}.group-focus-within\/help\:opacity-100:is(:where(.group\/help):focus-within *){opacity:1}@media (hover:hover){.group-hover\:opacity-100:is(:where(.group):hover *),.group-hover\/help\:opacity-100:is(:where(.group\/help):hover *){opacity:1}}.placeholder\:text-faint::placeholder{color:var(--color-faint)}.focus-within\:border-accent:focus-within{border-color:var(--color-accent)}@media (hover:hover){.hover\:border-none:hover{--tw-border-style:none;border-style:none}.hover\:border-accent:hover{border-color:var(--color-accent)}.hover\:border-transparent:hover{border-color:#0000}.hover\:bg-\[\#20212b\]:hover{background-color:#20212b}.hover\:bg-accent:hover{background-color:var(--color-accent)}.hover\:bg-transparent:hover{background-color:#0000}.hover\:bg-white:hover{background-color:var(--color-white)}.hover\:bg-white\/10:hover{background-color:#ffffff1a}@supports (color:color-mix(in lab, red, red)){.hover\:bg-white\/10:hover{background-color:color-mix(in oklab, var(--color-white) 10%, transparent)}}.hover\:bg-white\/\[0\.04\]:hover{background-color:#ffffff0a}@supports (color:color-mix(in lab, red, red)){.hover\:bg-white\/\[0\.04\]:hover{background-color:color-mix(in oklab, var(--color-white) 4%, transparent)}}.hover\:bg-white\/\[0\.08\]:hover{background-color:#ffffff14}@supports (color:color-mix(in lab, red, red)){.hover\:bg-white\/\[0\.08\]:hover{background-color:color-mix(in oklab, var(--color-white) 8%, transparent)}}.hover\:text-content:hover{color:var(--color-content)}.hover\:opacity-100:hover{opacity:1}}.focus-visible\:border-accent:focus-visible{border-color:var(--color-accent)}.focus-visible\:text-content:focus-visible{color:var(--color-content)}@media (hover:hover){.enabled\:hover\:text-content:enabled:hover{color:var(--color-content)}}@media not all and (width>=760px){.max-\[760px\]\:col-start-1{grid-column-start:1}.max-\[760px\]\:ml-0{margin-left:0}.max-\[760px\]\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.max-\[760px\]\:flex-col{flex-direction:column}.max-\[760px\]\:items-start{align-items:flex-start}.max-\[760px\]\:pt-8{padding-top:calc(var(--spacing) * 8)}}@media (width>=40rem){.sm\:gap-5{gap:calc(var(--spacing) * 5)}}}.grain{pointer-events:none;z-index:100;opacity:.035;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");position:fixed;inset:0}body[data-state=transcribing] .status-dot{background:var(--color-accent);animation:ping 1.3s var(--ease-fluid) infinite}body[data-state=done] .status-dot{background:var(--color-ok)}body[data-state=error] .status-dot{background:var(--color-accent)}body.drag .drop-overlay{opacity:1}.mix-slider{appearance:none;background:linear-gradient(90deg, var(--color-muted), var(--color-accent));cursor:pointer;border-radius:999px;width:170px;height:4px}.mix-slider:disabled{cursor:not-allowed;filter:grayscale()}.mix-slider::-webkit-slider-thumb{appearance:none;border:2px solid var(--color-accent);width:16px;height:16px;transition:transform .1s var(--ease-fluid);background:#fff;border-radius:50%;box-shadow:0 2px 8px #00000080}.mix-slider::-webkit-slider-thumb:hover{transform:scale(1.15)}.mix-slider::-moz-range-thumb{border:2px solid var(--color-accent);background:#fff;border-radius:50%;width:16px;height:16px;box-shadow:0 2px 8px #00000080}@media (prefers-reduced-motion:reduce){*,:before,:after{transition:none!important;animation:none!important}}.compare-body{--lab-paper:#f1eee3;--lab-paper-deep:#e3dfd1;--lab-ink:#171714;--lab-ink-soft:#292925;--lab-muted:#6d6b62;--lab-rule:#17171447;--lab-rule-light:#f1eee333;--lab-signal:#ff573c;--lab-acid:#d9ef4a;--lab-blue:#55c4cf;--lab-focus:#116fdb;--lab-success:#88a829;--lab-warning:#d08a12;--lab-danger:#dc3f2d;--lab-display:"Bodoni Moda", Baskerville, "Times New Roman", serif;--lab-body:"Manrope", "Avenir Next", "Helvetica Neue", sans-serif;--lab-mono:"IBM Plex Mono", "Courier New", monospace;--lab-xs:.68rem;--lab-sm:.78rem;--lab-base:.96rem;--lab-lg:1.2rem;--lab-xl:clamp(2rem, 4vw, 4.4rem);--lab-2xl:clamp(3.8rem, 9vw, 9.5rem);--lab-1:.3rem;--lab-2:.6rem;--lab-3:.9rem;--lab-4:1.2rem;--lab-6:1.8rem;--lab-8:2.4rem;--lab-12:3.6rem;--lab-radius-sm:2px;--lab-radius-md:8px;--lab-shadow:8px 8px 0 #17171426;--lab-fast:.12s;--lab-base-duration:.24s;--lab-slow:.62s;--lab-ease:cubic-bezier(.22, 1, .36, 1);min-width:320px;color:var(--lab-ink);background-color:var(--lab-paper);font-family:var(--lab-body);background-image:linear-gradient(#17171406 1px,#0000 1px),linear-gradient(90deg,#17171405 1px,#0000 1px);background-size:28px 28px;background-attachment:fixed}.compare-body *,.compare-body :before,.compare-body :after{box-sizing:border-box}.compare-body button,.compare-body input{font:inherit}.compare-body button{min-height:44px;color:inherit;background:0 0;border:0;border-radius:0;padding:0}.compare-body button:hover{background:0 0;border-color:#0000}.compare-body button:focus-visible,.compare-body a:focus-visible,.compare-body input:focus-visible{outline:3px solid var(--lab-focus);outline-offset:3px}.compare-body button:active:not(:disabled){transform:translateY(1px)}.compare-body button:disabled,.compare-body input:disabled{opacity:.38;cursor:not-allowed}.compare-body a{color:inherit}.compare-app{isolation:isolate;min-height:100vh;position:relative}.compare-grain{z-index:100;pointer-events:none;opacity:.055;mix-blend-mode:multiply;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.65'/%3E%3C/svg%3E");position:fixed;inset:0}@keyframes lab-enter{0%{opacity:0;transform:translateY(18px)}to{opacity:1;transform:translateY(0)}}@keyframes signal-travel{0%{opacity:0;transform:translate(-16px)}40%,80%{opacity:1}to{opacity:0;transform:translate(16px)}}@keyframes signal-pulse{0%,to{box-shadow:0 0 0 0 color-mix(in srgb, var(--node-accent) 65%, transparent)}50%{box-shadow:0 0 0 7px #0000}}.compare-masthead{gap:var(--lab-8);border-bottom:2px solid var(--lab-ink);width:min(100% - 48px,1880px);min-height:430px;animation:lab-enter var(--lab-slow) var(--lab-ease) both;grid-template-columns:minmax(160px,.55fr) minmax(520px,2fr) minmax(190px,.65fr);align-items:start;margin:0 auto;padding:34px 0 42px;display:grid}.compare-wordmark{flex-direction:column;align-items:flex-start;width:fit-content;text-decoration:none;display:inline-flex}.compare-wordmark>span{font:700 clamp(1.35rem, 2.4vw, 2.4rem)/.9 var(--lab-body);letter-spacing:-.075em}.compare-wordmark>small,.compare-kicker,.section-index,.preset-label{font:600 var(--lab-xs)/1.2 var(--lab-mono);letter-spacing:.12em;text-transform:uppercase}.compare-wordmark>small{border-top:1px solid var(--lab-ink);margin-top:10px;padding-top:8px}.compare-intro{max-width:1040px;padding-top:46px}.compare-kicker{margin:0 0 var(--lab-4);color:var(--lab-danger)}.compare-intro h1{max-width:960px;font:600 var(--lab-2xl)/.78 var(--lab-display);letter-spacing:-.065em;text-wrap:balance;margin:0}.compare-intro h1 em{color:var(--lab-signal);font-weight:600}.compare-intro>p:last-child{border-left:7px solid var(--lab-acid);width:min(610px,75%);font-size:var(--lab-base);text-wrap:pretty;margin:40px 0 0 auto;padding-left:18px;line-height:1.65}.compare-config-button{text-align:left;width:100%;max-width:240px;transition:padding var(--lab-base-duration) var(--lab-ease), color var(--lab-fast);grid-template-columns:auto 1fr auto;justify-self:end;align-items:center;gap:10px;display:grid;border-top:1px solid var(--lab-ink)!important;border-bottom:1px solid var(--lab-ink)!important;font-size:var(--lab-sm)!important;padding:12px 0!important}.compare-config-button:hover{color:var(--lab-danger);padding-left:8px!important;padding-right:8px!important}.compare-config-button>.config-button-count{width:27px;height:27px;color:var(--lab-paper);background:var(--lab-ink);font:500 var(--lab-xs)/1 var(--lab-mono);place-items:center;display:grid}.compare-main{width:min(100% - 48px,1880px);margin:0 auto}.preset-strip{border-bottom:1px solid var(--lab-ink);contain:inline-size;max-width:100%;min-height:66px;animation:lab-enter var(--lab-slow) var(--lab-ease) 80ms both;align-items:stretch;display:flex}.preset-label{color:var(--lab-muted);align-items:center;padding-right:28px;display:flex}.preset-button{min-width:132px;position:relative;border-left:1px solid var(--lab-rule)!important;font-size:var(--lab-sm)!important;transition:color var(--lab-fast), background var(--lab-fast)!important;padding:0 20px!important;font-weight:600!important}.preset-button:hover,.preset-button.is-active{color:var(--lab-paper)!important;background:var(--lab-ink)!important}.preset-button.is-active:after{content:"";background:var(--lab-acid);width:7px;height:7px;position:absolute;top:8px;right:8px}.signal-rail{min-height:132px;color:var(--lab-paper);background:var(--lab-ink);border-bottom:1px solid var(--lab-ink);animation:lab-enter var(--lab-slow) var(--lab-ease) .13s both;grid-template-columns:115px 1fr 100px;align-items:stretch;display:grid;overflow:hidden}.signal-origin,.signal-output{font-family:var(--lab-mono);flex-direction:column;justify-content:center;gap:5px;padding:18px;display:flex}.signal-origin{border-right:1px solid var(--lab-rule-light)}.signal-output{border-left:1px solid var(--lab-rule-light);text-align:right}.signal-origin span,.signal-output span{color:#f1eee38c;letter-spacing:.16em;font-size:.6rem}.signal-origin strong,.signal-output strong{font-size:.88rem}.signal-track{grid-template-columns:repeat(var(--rail-count), minmax(125px, 1fr));align-items:center;gap:10px;padding:18px 32px;display:grid;position:relative;overflow-x:auto}.signal-track:before{content:"";background:#f1eee373;height:1px;position:absolute;top:50%;left:0;right:0}.signal-track:after{content:"";background:var(--lab-acid);width:24px;height:7px;animation:1.8s linear infinite signal-travel;position:absolute;top:calc(50% - 3px);left:12px}.signal-node{--node-accent:var(--lab-signal);z-index:1;min-width:128px;color:var(--lab-paper);background:var(--lab-ink-soft);animation:lab-enter .4s var(--lab-ease) var(--node-delay) both;border:1px solid #f1eee34d;grid-template-rows:auto auto;grid-template-columns:auto 1fr;align-items:center;column-gap:9px;padding:11px 12px;display:grid;position:relative;box-shadow:4px 4px #00000052}.signal-node strong{font-size:.78rem;line-height:1.2}.signal-node small{color:#f1eee38c;font:400 .6rem/1.2 var(--lab-mono);text-transform:uppercase;grid-column:2}.signal-light{border:2px solid var(--lab-ink-soft);background:#575751;outline:1px solid #f1eee359;grid-row:1/3;width:10px;height:10px}.signal-light.is-transcribing{background:var(--node-accent);animation:1.2s ease-out infinite signal-pulse}.signal-light.is-done{background:var(--lab-acid)}.signal-light.is-error,.signal-light.is-offline{background:var(--lab-danger)}.signal-empty{z-index:1;justify-self:center;position:relative;color:var(--lab-paper)!important;background:var(--lab-ink)!important;border:1px solid var(--lab-rule-light)!important;font-size:var(--lab-sm)!important;padding:0 18px!important}.source-console,.outputs-section{border-bottom:2px solid var(--lab-ink);padding:76px 0 80px}.source-console-head,.outputs-heading{grid-template-columns:minmax(280px,1fr) minmax(240px,.7fr);align-items:end;gap:40px;margin-bottom:28px;display:grid}.section-index{color:var(--lab-danger);margin-bottom:10px;display:block}.source-console-head h2,.outputs-heading h2{font:600 var(--lab-xl)/.95 var(--lab-display);letter-spacing:-.045em;margin:0}.source-console-head>p,.outputs-heading>p{max-width:430px;color:var(--lab-muted);font-size:var(--lab-sm);justify-self:end;margin:0;line-height:1.55}.source-actions{border:2px solid var(--lab-ink);box-shadow:var(--lab-shadow);grid-template-columns:minmax(210px,.75fr) minmax(300px,1.6fr) minmax(220px,.8fr);display:grid}.upload-plate,.run-button{flex-direction:column;justify-content:center;align-items:flex-start;min-height:136px;display:flex;transition:background var(--lab-fast), color var(--lab-fast)!important;padding:22px 24px!important}.upload-plate{border-right:1px solid var(--lab-ink)!important}.upload-plate svg{margin-bottom:15px}.upload-plate>span,.run-button>span{font-size:var(--lab-base);font-weight:700}.upload-plate>small,.run-button>small{color:var(--lab-muted);font:400 .62rem/1.4 var(--lab-mono);margin-top:6px}.upload-plate:hover{color:var(--lab-paper)!important;background:var(--lab-ink)!important}.upload-plate:hover small{color:#f1eee399}.selected-source{background:#ffffff3d;flex-direction:column;justify-content:center;min-width:0;padding:22px 30px;display:flex}.selected-source>span{color:var(--lab-muted);font:600 .62rem/1.2 var(--lab-mono);letter-spacing:.14em;margin-bottom:10px}.selected-source>strong{text-overflow:ellipsis;white-space:nowrap;max-width:100%;font:600 clamp(1.25rem, 2.5vw, 2.5rem)/1 var(--lab-display);letter-spacing:-.035em;overflow:hidden}.selected-source>small{color:var(--lab-muted);font-size:var(--lab-sm);margin-top:10px}.selected-source.has-file{background:var(--lab-acid)}.selected-source.has-file>span,.selected-source.has-file>small{color:#171714ad}.run-button{color:var(--lab-paper)!important;background:var(--lab-signal)!important;border-left:1px solid var(--lab-ink)!important}.run-button small{color:#1717149e}.run-button:hover:not(:disabled){background:var(--lab-ink)!important}.run-button:hover:not(:disabled) small{color:#f1eee399}.source-error{color:var(--lab-paper);background:var(--lab-danger);border-left:8px solid var(--lab-ink);font-size:var(--lab-sm);margin-top:18px;padding:14px 18px}.record-crate{margin-top:42px}.crate-heading{border-bottom:1px solid var(--lab-ink);justify-content:space-between;align-items:end;gap:20px;padding-bottom:13px;display:flex}.crate-heading>div{align-items:baseline;gap:18px;display:flex}.crate-heading span{color:var(--lab-danger);font:600 var(--lab-xs)/1.2 var(--lab-mono);letter-spacing:.12em}.crate-heading strong{font:600 var(--lab-lg)/1 var(--lab-display)}.crate-heading>small{max-width:520px;color:var(--lab-muted);font-size:var(--lab-xs);text-align:right}.crate-scroll{scrollbar-color:var(--lab-ink) var(--lab-paper-deep);grid-auto-columns:minmax(230px,1fr);grid-auto-flow:column;gap:1px;padding:1px 0 14px;display:grid;overflow-x:auto}.record-sleeve{text-align:left;flex-direction:column;align-items:flex-start;min-height:235px;display:flex;position:relative;overflow:hidden;border:1px solid var(--lab-ink)!important;transition:transform var(--lab-base-duration) var(--lab-ease), box-shadow var(--lab-base-duration) var(--lab-ease)!important;background:#dcd7c7!important;padding:18px!important}.record-sleeve:nth-child(4n+1){background:#e65a41!important}.record-sleeve:nth-child(4n+2){background:#67bdc8!important}.record-sleeve:nth-child(4n+3){background:#d5e45a!important}.record-sleeve:nth-child(4n+4){background:#e3b64a!important}.record-sleeve:after{content:"";border:28px solid #1717141f;border-radius:50%;width:150px;height:150px;position:absolute;bottom:-54px;right:-54px}.record-sleeve:hover:not(:disabled){z-index:2;box-shadow:7px 8px 0 var(--lab-ink);transform:translateY(-7px)rotate(-.4deg)}.record-sleeve:active:not(:disabled){transform:translateY(-2px)}.record-sleeve.is-loading{color:var(--lab-paper);background:var(--lab-ink)!important}.sleeve-number{font:500 .66rem/1 var(--lab-mono);margin-left:auto}.sleeve-genre{font:600 .62rem/1 var(--lab-mono);letter-spacing:.1em;text-transform:uppercase;margin-top:46px}.record-sleeve strong{z-index:1;max-width:94%;font:600 1.25rem/1.05 var(--lab-display);letter-spacing:-.025em;margin-top:9px;position:relative}.record-sleeve small{z-index:1;margin-top:auto;padding-top:18px;font-size:.66rem;line-height:1.35;position:relative}.crate-state{min-height:120px;color:var(--lab-muted);border-bottom:1px solid var(--lab-rule);font-size:var(--lab-sm);text-align:center;place-items:center;padding:20px;display:grid}.crate-state.is-error{color:var(--lab-danger)}.crate-state code{color:var(--lab-ink);background:var(--lab-paper-deep);font-family:var(--lab-mono);padding:2px 5px}.transport-console{z-index:20;min-height:78px;color:var(--lab-paper);border:1px solid var(--lab-ink);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);background:#171714f7;grid-template-columns:58px 112px minmax(140px,1fr) minmax(235px,auto) minmax(260px,auto);align-items:center;gap:18px;margin:26px 0;padding:10px 16px 10px 10px;display:grid;position:sticky;top:10px;box-shadow:6px 7px #1717142b}.transport-play{place-items:center;width:56px;height:56px;display:grid;min-height:56px!important;color:var(--lab-ink)!important;background:var(--lab-acid)!important}.transport-play:hover:not(:disabled){background:var(--lab-signal)!important}.transport-play svg{width:20px;height:20px}.transport-clock{font:500 .72rem/1 var(--lab-mono);font-variant-numeric:tabular-nums}.transport-seek,.transport-mix input{appearance:none;cursor:pointer;background:#f1eee352;height:3px}.transport-seek{width:100%}.transport-seek::-webkit-slider-thumb{appearance:none;background:var(--lab-signal);border:2px solid var(--lab-ink);outline:1px solid var(--lab-paper);border-radius:0;width:15px;height:15px}.transport-mix input::-webkit-slider-thumb{appearance:none;background:var(--lab-signal);border:2px solid var(--lab-ink);outline:1px solid var(--lab-paper);border-radius:0;width:15px;height:15px}.transport-seek::-moz-range-thumb{background:var(--lab-signal);border:2px solid var(--lab-paper);border-radius:0;width:12px;height:12px}.transport-mix input::-moz-range-thumb{background:var(--lab-signal);border:2px solid var(--lab-paper);border-radius:0;width:12px;height:12px}.transport-mix{color:#f1eee39e;font:500 .59rem/1 var(--lab-mono);text-transform:uppercase;grid-template-columns:auto minmax(90px,1fr) auto;align-items:center;gap:8px;display:grid}.listen-switch{justify-content:flex-end;align-items:center;gap:4px;display:flex;overflow-x:auto}.listen-switch>span{color:#f1eee37a;font:500 .58rem/1 var(--lab-mono);text-transform:uppercase;flex:none;margin-right:5px}.listen-switch button{flex:none;color:#f1eee3a6!important;border:1px solid var(--lab-rule-light)!important;min-height:36px!important;padding:0 10px!important;font-size:.68rem!important}.listen-switch button:hover:not(:disabled),.listen-switch button.is-active{color:var(--lab-ink)!important;background:var(--model-accent)!important;border-color:var(--model-accent)!important}.outputs-section{padding-top:56px}.model-grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,540px),1fr));align-items:start;gap:22px;display:grid}.model-panel{--model-accent:var(--lab-signal);background:var(--lab-ink);border:2px solid var(--lab-ink);min-width:0;animation:lab-enter var(--lab-slow) var(--lab-ease) calc(var(--panel-order) * 65ms) both;box-shadow:7px 7px #17171424}.model-panel.status-transcribing{box-shadow:7px 7px 0 var(--model-accent)}.model-panel.status-error{border-color:var(--lab-danger)}.model-panel-head{min-height:114px;color:var(--lab-paper);border-bottom:1px solid var(--lab-rule-light);justify-content:space-between;align-items:flex-start;gap:18px;padding:18px 20px;display:flex}.model-panel-head>div:first-child>span{color:var(--model-accent);font:600 .59rem/1 var(--lab-mono);letter-spacing:.12em;text-transform:uppercase}.model-panel h3{font:600 2.1rem/.95 var(--lab-display);letter-spacing:-.035em;margin:5px 0 3px}.model-panel-head>div:first-child>small{color:#f1eee380;font-size:.66rem}.model-metrics{text-align:right;grid-template-columns:repeat(2,auto);gap:8px 18px;display:grid}.model-state{color:#f1eee39e;font:500 .58rem/1 var(--lab-mono);text-transform:uppercase;grid-column:1/-1;justify-content:flex-end;align-items:center;gap:7px;display:flex}.model-state i{background:#5f5f58;width:8px;height:8px}.status-transcribing .model-state i{background:var(--model-accent);animation:1.2s ease-out infinite signal-pulse}.status-done .model-state i{background:var(--lab-acid)}.status-error .model-state i{background:var(--lab-danger)}.model-metrics>strong{font:500 .75rem/1.2 var(--lab-mono)}.model-metrics>strong>small{color:#f1eee361;text-transform:uppercase;margin-top:3px;font-size:.53rem;font-weight:400;display:block}.roll-frame{background:#0b0c10;min-height:390px;position:relative;overflow:hidden}.roll-frame canvas{width:100%;height:390px;display:block}.roll-state{color:#f1eee394;text-align:center;background:#0b0c10e6;flex-direction:column;justify-content:center;align-items:center;gap:6px;padding:35px;display:flex;position:absolute;inset:0}.roll-state>span{font:600 1.55rem/1 var(--lab-display);color:var(--lab-paper)}.roll-state>small{max-width:410px;font-size:.72rem;line-height:1.5}.roll-state.is-error{background:var(--lab-danger)}@supports (color:color-mix(in lab, red, red)){.roll-state.is-error{background:color-mix(in srgb, var(--lab-danger) 18%, #0b0c10f5)}}.roll-state button{margin-top:10px;color:var(--lab-paper)!important;border:1px solid #f1eee380!important;padding:0 14px!important;font-size:.7rem!important}.roll-state button:hover{color:var(--lab-ink)!important;background:var(--lab-paper)!important}.panel-progress{background:var(--model-accent);height:4px;transition:width .36s var(--lab-ease);position:absolute;bottom:0;left:0}.model-panel-foot{min-height:57px;color:var(--lab-paper);border-top:1px solid var(--lab-rule-light);align-items:center;gap:12px;padding:10px 14px;display:flex}.instrument-tape{scrollbar-width:thin;flex:1;align-items:center;gap:8px 12px;min-width:0;display:flex;overflow-x:auto}.instrument-tape>span{color:#f1eee394;flex:none;align-items:center;gap:5px;font-size:.61rem;display:inline-flex}.instrument-tape>span>i{width:8px;height:8px}.midi-download{background:var(--lab-acid);min-height:34px;font:600 .61rem/34px var(--lab-mono);flex:none;align-items:center;gap:5px;padding:0 10px;text-decoration:none;display:inline-flex;color:var(--lab-ink)!important}.midi-download:hover{background:var(--model-accent)}.outputs-empty{flex-direction:column;justify-content:center;align-items:center;gap:8px;width:100%;display:flex;border:2px dashed var(--lab-rule)!important;min-height:240px!important}.outputs-empty strong{font:600 1.8rem/1 var(--lab-display)}.outputs-empty span{color:var(--lab-muted);font-size:var(--lab-sm)}.outputs-empty:hover{color:var(--lab-paper)!important;background:var(--lab-ink)!important;border-color:var(--lab-ink)!important}.compare-footer{width:min(100% - 48px,1880px);min-height:180px;font-size:var(--lab-xs);grid-template-columns:1fr minmax(280px,1fr) auto;align-items:center;gap:30px;margin:0 auto;display:grid}.compare-footer>span{font:600 var(--lab-xs)/1.4 var(--lab-mono);letter-spacing:.1em}.compare-footer p{color:var(--lab-muted);line-height:1.5}.compare-footer a{border-bottom:1px solid var(--lab-ink);padding:10px 0;font-weight:700;text-decoration:none}.compare-footer a:hover{color:var(--lab-danger)}.drop-field{z-index:80;color:var(--lab-paper);border:4px solid var(--lab-acid);pointer-events:none;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);background:#171714f0;flex-direction:column;justify-content:center;align-items:center;display:flex;position:fixed;inset:18px}.drop-field span{color:var(--lab-acid);font:600 var(--lab-xs)/1 var(--lab-mono);letter-spacing:.16em}.drop-field strong{font:600 clamp(2rem, 6vw, 5rem)/.95 var(--lab-display);margin-top:12px}.config-backdrop{z-index:120;-webkit-backdrop-filter:blur(5px);backdrop-filter:blur(5px);background:#1717149e;justify-content:flex-end;display:flex;position:fixed;inset:0}.config-drawer{width:min(680px,100%);height:100%;color:var(--lab-ink);background:var(--lab-paper);border-left:2px solid var(--lab-ink);animation:lab-enter .34s var(--lab-ease) both;padding:34px;overflow-y:auto;box-shadow:-16px 0 #17171421}.config-drawer>header{border-bottom:2px solid var(--lab-ink);justify-content:space-between;align-items:flex-start;gap:20px;padding-bottom:22px;display:flex}.config-drawer>header span{color:var(--lab-danger);font:600 var(--lab-xs)/1 var(--lab-mono);letter-spacing:.12em}.config-drawer h2{font:600 clamp(2.4rem, 7vw, 4.4rem)/.9 var(--lab-display);letter-spacing:-.05em;margin:8px 0 0}.config-close{place-items:center;width:48px;display:grid;border:1px solid var(--lab-ink)!important;min-height:48px!important}.config-close:hover{color:var(--lab-paper)!important;background:var(--lab-ink)!important}.config-lede{max-width:530px;color:var(--lab-muted);font-size:var(--lab-sm);margin:22px 0;line-height:1.6}.config-presets{flex-wrap:wrap;gap:5px;margin-bottom:24px;display:flex}.config-presets button{border:1px solid var(--lab-rule)!important;min-height:36px!important;padding:0 12px!important;font-size:.68rem!important}.config-presets button:hover{color:var(--lab-paper)!important;background:var(--lab-ink)!important}.config-models{gap:10px;display:grid}.config-model{--model-accent:var(--lab-signal);border:1px solid var(--lab-rule);background:#ffffff42;grid-template-columns:1fr auto;gap:15px;padding:16px;display:grid;position:relative}.config-model:before{content:"";background:0 0;width:5px;position:absolute;inset:0 auto 0 0}.config-model.is-enabled:before{background:var(--model-accent)}.config-toggle{cursor:pointer;grid-column:1/-1;grid-template-columns:auto auto 1fr auto;align-items:center;gap:10px;display:grid}.config-toggle input{opacity:0;pointer-events:none;position:absolute}.config-toggle>span{border:1px solid var(--lab-ink);background:#bbb7a9;width:38px;height:21px;position:relative}.config-toggle>span:after{content:"";background:var(--lab-paper);border:1px solid var(--lab-ink);width:13px;height:13px;transition:transform var(--lab-fast);position:absolute;top:3px;left:3px}.config-toggle input:checked+span{background:var(--model-accent)}.config-toggle input:checked+span:after{transform:translate(17px)}.config-toggle input:focus-visible+span{outline:3px solid var(--lab-focus);outline-offset:3px}.config-toggle strong{font:600 1.18rem/1 var(--lab-display)}.config-toggle small{color:var(--lab-muted);font:500 .57rem/1 var(--lab-mono);text-transform:uppercase}.endpoint-field{gap:5px;min-width:0;display:grid}.endpoint-field>span{color:var(--lab-muted);font:500 .55rem/1 var(--lab-mono);text-transform:uppercase}.endpoint-field input{width:100%;min-width:0;height:37px;color:var(--lab-ink);background:var(--lab-paper);border:1px solid var(--lab-rule);font:400 .68rem/1 var(--lab-mono);border-radius:0;padding:0 9px}.endpoint-health{min-width:72px;height:37px;color:var(--lab-muted);font:500 .56rem/1 var(--lab-mono);text-transform:uppercase;align-self:end;align-items:center;gap:6px;display:flex}.endpoint-health i{background:var(--lab-warning);width:7px;height:7px}.endpoint-health.is-online i{background:var(--lab-success)}.endpoint-health.is-offline i{background:var(--lab-danger)}.config-note{border-top:1px solid var(--lab-rule);border-bottom:1px solid var(--lab-rule);font-size:var(--lab-xs);grid-template-columns:130px 1fr;gap:14px;margin:22px 0;padding:15px 0;line-height:1.5;display:grid}.config-note span{color:var(--lab-muted)}.config-note code{color:var(--lab-ink);font-family:var(--lab-mono)}.config-done{width:100%;min-height:58px!important;color:var(--lab-paper)!important;background:var(--lab-ink)!important;font-weight:700!important}.config-done:hover:not(:disabled){color:var(--lab-ink)!important;background:var(--lab-acid)!important}@media (width>=1600px){.model-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.source-actions{grid-template-columns:.65fr 1.8fr .7fr}}@media (width<=1180px){.compare-masthead{grid-template-columns:160px 1fr;min-height:390px}.compare-config-button{grid-area:2/1;place-self:end start}.compare-intro{grid-area:1/2/3}.signal-rail{grid-template-columns:90px 1fr 80px}.signal-track{padding-left:20px;padding-right:20px}.source-actions{grid-template-columns:.8fr 1.4fr}.run-button{grid-column:1/-1;min-height:88px;border-top:1px solid var(--lab-ink)!important;border-left:0!important}.transport-console{grid-template-columns:58px 105px 1fr minmax(220px,auto)}.listen-switch{grid-column:1/-1;justify-content:flex-start;padding:4px 0}}@media (width<=760px){.compare-masthead,.compare-main,.compare-footer{width:min(100% - 28px,1880px)}.compare-masthead{grid-template-columns:1fr auto;gap:24px;min-height:auto;padding:22px 0 32px}.compare-wordmark{grid-column:1}.compare-config-button{grid-area:1/2;place-items:center;width:48px;height:48px;min-height:48px;display:grid;border:1px solid var(--lab-ink)!important;padding:0!important}.compare-config-button:hover{padding:0!important}.compare-config-button>.config-button-label{display:none}.compare-config-button>svg{width:19px;height:19px}.compare-config-button>.config-button-count{width:21px;height:21px;margin:-34px 0 0 36px;font-size:.58rem;position:absolute}.compare-intro{grid-area:2/1/auto/-1;padding-top:22px}.compare-intro h1{font-size:clamp(3.5rem,18vw,6.8rem);line-height:.82}.compare-intro>p:last-child{width:100%;margin-top:30px}.preset-strip{overflow-x:auto}.preset-label{z-index:1;background:var(--lab-paper);padding:0 14px;position:sticky;left:0}.preset-button{min-width:126px}.signal-rail{grid-template-columns:68px minmax(0,1fr);min-height:118px}.signal-output{display:none}.signal-origin{padding:10px}.signal-track{grid-template-columns:none;grid-auto-columns:145px;grid-auto-flow:column;padding:15px}.source-console,.outputs-section{padding:54px 0}.source-console-head,.outputs-heading{grid-template-columns:1fr;gap:16px}.source-console-head>p,.outputs-heading>p{justify-self:start}.source-actions{grid-template-columns:1fr;box-shadow:5px 5px #17171426}.upload-plate{min-height:104px;border-right:0!important;border-bottom:1px solid var(--lab-ink)!important}.selected-source{min-height:112px;padding:22px}.run-button{grid-column:auto;min-height:86px}.crate-heading{flex-direction:column;align-items:flex-start}.crate-heading>small{text-align:left}.crate-scroll{grid-auto-columns:minmax(205px,78vw)}.record-sleeve{min-height:220px}.transport-console{grid-template-columns:52px 1fr;gap:11px;padding:8px;top:6px}.transport-play{width:50px;height:50px;min-height:50px!important}.transport-clock{text-align:right}.transport-seek,.transport-mix,.listen-switch{grid-column:1/-1}.transport-mix{padding:5px}.listen-switch{justify-content:flex-start}.model-grid{grid-template-columns:1fr}.model-panel-head{min-height:130px}.model-panel h3{font-size:1.8rem}.roll-frame,.roll-frame canvas{height:340px;min-height:340px}.compare-footer{grid-template-columns:1fr;gap:14px;padding:38px 0}.compare-footer p{margin:0}.compare-footer a{width:fit-content}.config-drawer{padding:22px 16px 32px}}@media (width<=460px){.compare-masthead,.compare-main,.compare-footer{width:min(100% - 20px,1880px)}.compare-intro h1{font-size:clamp(3rem,17vw,4.9rem)}.compare-intro>p:last-child{font-size:.86rem}.signal-origin{display:none}.signal-rail{grid-template-columns:1fr}.source-console-head h2,.outputs-heading h2{font-size:2.6rem}.selected-source>strong{font-size:1.5rem}.model-panel-head{flex-direction:column}.model-metrics{text-align:left;grid-template-columns:1fr auto auto;width:100%}.model-state{grid-column:auto;justify-content:flex-start}.model-metrics>strong{text-align:right}.roll-frame,.roll-frame canvas{height:300px;min-height:300px}.config-model{grid-template-columns:1fr}.endpoint-health{align-self:start;height:auto}.config-note{grid-template-columns:1fr}}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@keyframes ping{0%{box-shadow:0 0 0 0 var(--color-accent-glow)}70%{box-shadow:0 0 0 7px #0000}to{box-shadow:0 0 #0000}}@keyframes drag-glow{0%,to{box-shadow:0 0 0 1px var(--color-accent-soft), 0 0 14px -2px var(--color-accent-glow)}50%{box-shadow:0 0 0 1px var(--color-accent), 0 0 40px 2px var(--color-accent-glow)}}@keyframes rise{0%{opacity:0;transform:translateY(14px)}to{opacity:1;transform:none}}
assets/style-CdJLhYve.js ADDED
The diff for this file is too large to render. See raw diff
 
deployment.json ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema_version": 1,
3
+ "source_commit": "0ce98baefa7de35b185a66974c3f512ee6b7b4f5",
4
+ "source_branch": "main",
5
+ "source_dirty": true,
6
+ "build_command": "VITE_HENDRIX_SPACE=1 npx --yes pnpm@10.20.0 --dir demo/web build --manifest",
7
+ "checkpoint_sha256": "3df08bb38dce7ae30be23090524b63755c565d1a3242860aef6c9401fc125bbe",
8
+ "files": {
9
+ "README.md": {
10
+ "bytes": 2428,
11
+ "sha256": "1340d543066c6b908957e39a6e13d9c3f1d05372857fdeaee368d992d583bbb6"
12
+ },
13
+ "assets/PianoRollCanvas-xSq9nagc.js": {
14
+ "bytes": 3055,
15
+ "sha256": "05090a468a79f356f2603f7105b26205be5703f5fffcb37bb2502317d4f9836f"
16
+ },
17
+ "assets/local-56CJnE36.css": {
18
+ "bytes": 4149,
19
+ "sha256": "dfab143da9fda372f21e3513d3882baffdc7c40f4df51ad86f7ad3c01b34ef3d"
20
+ },
21
+ "assets/local-DblFrGk8.js": {
22
+ "bytes": 133988,
23
+ "sha256": "215ca24985995907cf196d12e0d63ba585fc25e4fd0ff5893629ba63f7be3d17"
24
+ },
25
+ "assets/ort-wasm-simd-threaded.asyncify-CvvOzbbq.wasm": {
26
+ "bytes": 24254953,
27
+ "sha256": "7e83cd6cee77e478bc96a7e91b198144fb5e4126287daf1f9b54bb195ebcd55a"
28
+ },
29
+ "assets/spessasynth_processor.min-tdOdhV7p.js": {
30
+ "bytes": 396249,
31
+ "sha256": "fd3e25623e191efc4068e6cc44c7b0f4e3b508404c9088a77b6beedc7dbf861f"
32
+ },
33
+ "assets/style-BAFoxh21.css": {
34
+ "bytes": 56584,
35
+ "sha256": "ba1247f859311f3b533b28aada5a316bf1edef2dd01be3216eecb0f1318f1205"
36
+ },
37
+ "assets/style-CdJLhYve.js": {
38
+ "bytes": 644106,
39
+ "sha256": "1be18fcb99a202c31bfe5ab4154afda3aaeb95af45706ae534653910c0b914dc"
40
+ },
41
+ "diagnostic.wav": {
42
+ "bytes": 65644,
43
+ "sha256": "1d2f1b3974848ea5a714c393b53e85a0d5c9d0d34cac846040ef293dbc961b8a"
44
+ },
45
+ "favicon.png": {
46
+ "bytes": 4671,
47
+ "sha256": "5ff57d04a630614e38703856834d410bc3df02e7d6656c09d017406c63c1925d"
48
+ },
49
+ "index.html": {
50
+ "bytes": 770,
51
+ "sha256": "ae09e25f5a38cb3af09085e6a4fd3379d8ed4b66d372289be41707ea40495f57"
52
+ },
53
+ "local.html": {
54
+ "bytes": 770,
55
+ "sha256": "ae09e25f5a38cb3af09085e6a4fd3379d8ed4b66d372289be41707ea40495f57"
56
+ },
57
+ "models/fp32/cross_cache.onnx": {
58
+ "bytes": 12648891,
59
+ "sha256": "cbfb5da1057eee995d5572c478705a5defb6c00d9fdcd96125cbe89072f24d53"
60
+ },
61
+ "models/fp32/decoder_step.onnx": {
62
+ "bytes": 93343733,
63
+ "sha256": "6367704e25f718c962686b719537b43b1f7c4bdbaa84c3b36bd307323ccf72ca"
64
+ },
65
+ "models/fp32/encoder.onnx": {
66
+ "bytes": 89354488,
67
+ "sha256": "786b70a7424531349f259cd867761b3eeb4c27696a0e5c7d03082678962bd912"
68
+ },
69
+ "models/fp32/manifest.json": {
70
+ "bytes": 2921,
71
+ "sha256": "af943495d8272d7729f73face746c5f15be7e1f251fccc74a0e8244fc4a81d77"
72
+ },
73
+ "ort/ort-wasm-simd-threaded.jsep.mjs": {
74
+ "bytes": 46614,
75
+ "sha256": "3ee381d20a80f51a788a1c4a5872f6f1d047538dd4342f4af00062de5f9ea4c6"
76
+ },
77
+ "ort/ort-wasm-simd-threaded.jsep.wasm": {
78
+ "bytes": 26827543,
79
+ "sha256": "78feeeb3d08f6bcee94d938ed322f69073bb8076b5f9d34697a574ffba8deb48"
80
+ },
81
+ "source/demo/web/compare.html": {
82
+ "bytes": 1141,
83
+ "sha256": "17aa0c9a8b01152b1c49057d30c80cc267373ce1f20744862e2f34335cfc5a62"
84
+ },
85
+ "source/demo/web/index.html": {
86
+ "bytes": 1207,
87
+ "sha256": "f08c8bef6f294e96ca88802160e0ec70564cf886719b6d208693fac6216f718b"
88
+ },
89
+ "source/demo/web/local.html": {
90
+ "bytes": 437,
91
+ "sha256": "7bff5d6d1f50e5a44aef947af1cefeb83abf244dd1b6360b0846225ca4afdd5d"
92
+ },
93
+ "source/demo/web/package.json": {
94
+ "bytes": 948,
95
+ "sha256": "2d31d01dedf4556b6ca4907fdbbb287df932e9720d43629cee6068925b6e4be8"
96
+ },
97
+ "source/demo/web/pnpm-lock.yaml": {
98
+ "bytes": 33463,
99
+ "sha256": "ddb399c0980adef3d3c4e33bb60787b4f9c5d9a072b9bbe95a9c4864e142dc5b"
100
+ },
101
+ "source/demo/web/public/favicon.png": {
102
+ "bytes": 4671,
103
+ "sha256": "5ff57d04a630614e38703856834d410bc3df02e7d6656c09d017406c63c1925d"
104
+ },
105
+ "source/demo/web/src/App.tsx": {
106
+ "bytes": 15167,
107
+ "sha256": "a7368c93040a5e59b8889ee94a8c2e2693f0fd6f0c19dcc8d94a0a24d20317ad"
108
+ },
109
+ "source/demo/web/src/audio.ts": {
110
+ "bytes": 19304,
111
+ "sha256": "8e9d876bbeef997e5d5fe740cee5b6d219f815aa2b821a02fd0c718b00dc6174"
112
+ },
113
+ "source/demo/web/src/compare.tsx": {
114
+ "bytes": 33406,
115
+ "sha256": "fbd9765e7dda9c2154a28d43e80a4224d37ef265ec110e2e919c095603545c96"
116
+ },
117
+ "source/demo/web/src/components/ConditioningPanel.tsx": {
118
+ "bytes": 7009,
119
+ "sha256": "2b94c6c9abf11a06e65f33048c37d2d23524d58ce3640daea0468914c1252df5"
120
+ },
121
+ "source/demo/web/src/components/Controls.tsx": {
122
+ "bytes": 4477,
123
+ "sha256": "3750944349448f2a5db019bae4545bf5133f3c355d7027dc8e776dcd3d3a9f58"
124
+ },
125
+ "source/demo/web/src/components/DropOverlay.tsx": {
126
+ "bytes": 1156,
127
+ "sha256": "cb35ddc8606134742af66760684ebda67aed1965e285ed8b60925bc5c9b78b6d"
128
+ },
129
+ "source/demo/web/src/components/Footer.tsx": {
130
+ "bytes": 1544,
131
+ "sha256": "e8c1200535086ed7cf702fee4efd33021f4514a31d93fd113ff874a68b81ed8c"
132
+ },
133
+ "source/demo/web/src/components/InstrumentList.tsx": {
134
+ "bytes": 7707,
135
+ "sha256": "abea54518c2130241aabf8123a02485add70d178db3cd0a1aebaa5e57588fe7e"
136
+ },
137
+ "source/demo/web/src/components/OutputBar.tsx": {
138
+ "bytes": 6629,
139
+ "sha256": "619254150609f6362acd9b43c9ad694c52a07511c9b9efbf42e7a8f1d322c3b9"
140
+ },
141
+ "source/demo/web/src/components/PianoRollCanvas.tsx": {
142
+ "bytes": 7960,
143
+ "sha256": "fc67a13f6d5f13102702c33b7707a9d10f171fc7e95ddfb748a56224ab5d11cd"
144
+ },
145
+ "source/demo/web/src/components/WelcomeScreen.tsx": {
146
+ "bytes": 6592,
147
+ "sha256": "d2677506ae098d98eae41b3ced56d3a88ba4b1a7b4947e22a6fbdef324cc490b"
148
+ },
149
+ "source/demo/web/src/components/icons.tsx": {
150
+ "bytes": 1913,
151
+ "sha256": "c09441e24c6ccf79b466852ec2ed72709dc6205820438c01638586222882ae2f"
152
+ },
153
+ "source/demo/web/src/hooks/useAudioEngine.ts": {
154
+ "bytes": 732,
155
+ "sha256": "c70379f29702324446ead26ba5308d21c307c6c59611b3ece6dfdf2fbd85b1d6"
156
+ },
157
+ "source/demo/web/src/hooks/useTranscription.ts": {
158
+ "bytes": 8771,
159
+ "sha256": "65c1604cdff77546e694222d5f72dfdc19b19269c62481a230c515bc6efbb37f"
160
+ },
161
+ "source/demo/web/src/instruments.ts": {
162
+ "bytes": 6027,
163
+ "sha256": "bbfe086dabe0e270ae70be6e3302818dff1d49e619a87370f06d40d066e415cf"
164
+ },
165
+ "source/demo/web/src/local/codec.ts": {
166
+ "bytes": 8414,
167
+ "sha256": "37c5bdc987216cb7b042f6b79ad61e2a592bd7ff98bc58702b505dc3a629d027"
168
+ },
169
+ "source/demo/web/src/local/dsp.ts": {
170
+ "bytes": 5633,
171
+ "sha256": "017ca4ab6ce2e3bc40307cdada62ce9597ea816df805ff93ff1710d93664c9d1"
172
+ },
173
+ "source/demo/web/src/local/float16.ts": {
174
+ "bytes": 787,
175
+ "sha256": "2124afe19c0654456ffe22a2ad247c7948d01dbdc0b0e4022556e0aeb25024dc"
176
+ },
177
+ "source/demo/web/src/local/local.css": {
178
+ "bytes": 4682,
179
+ "sha256": "d7060987283fc6b6d102e2e35077a74a46d6274db1a4a2e2b34ef4ec8c1591c4"
180
+ },
181
+ "source/demo/web/src/local/midi.ts": {
182
+ "bytes": 2445,
183
+ "sha256": "fffabd0db926f7a44541f50524f642931c88fe2aeb44953743524723f106c767"
184
+ },
185
+ "source/demo/web/src/local/model.ts": {
186
+ "bytes": 13379,
187
+ "sha256": "461a7c37240940c440694d7a65cc18c47090b8429bbeb1daa5a6175440c75c99"
188
+ },
189
+ "source/demo/web/src/local.tsx": {
190
+ "bytes": 15344,
191
+ "sha256": "e0ad3fe81c9272536e3f0dd0eea05365b10cdc49329d5f8f50646933d18446cb"
192
+ },
193
+ "source/demo/web/src/main.tsx": {
194
+ "bytes": 381,
195
+ "sha256": "76e1cac7b31bfb00a1f3582616a43fd669114adaa9110284481c2933277080af"
196
+ },
197
+ "source/demo/web/src/pianoroll.ts": {
198
+ "bytes": 19132,
199
+ "sha256": "e44be0447e0fe1f5923b9d815485855b0ec1bfa56adfa7de24cc9242d53ca295"
200
+ },
201
+ "source/demo/web/src/progress.ts": {
202
+ "bytes": 3563,
203
+ "sha256": "2a66fd30476dff84ce70772e57cbd92c53f1a6dec7f3a7077b57c8a648a9394b"
204
+ },
205
+ "source/demo/web/src/sse.ts": {
206
+ "bytes": 2194,
207
+ "sha256": "348773394753d61bfb89d900cbede71330b5943898041c115e94b1ba5e1b42ea"
208
+ },
209
+ "source/demo/web/src/style.css": {
210
+ "bytes": 39145,
211
+ "sha256": "0f2624ee4074d57ba3794980d22ebd6e2bd45e42877cfb4cc47acacf261cfd75"
212
+ },
213
+ "source/demo/web/src/vite-env.d.ts": {
214
+ "bytes": 38,
215
+ "sha256": "65996936fbb042915f7b74a200fcdde7e410f32a669b1ab9597cfaa4b0faddb5"
216
+ },
217
+ "source/demo/web/tsconfig.json": {
218
+ "bytes": 389,
219
+ "sha256": "6091edf460498911c41bafc771226fc718b17ae792f3dbaab24555ba40a56d07"
220
+ },
221
+ "source/demo/web/vite.config.ts": {
222
+ "bytes": 1158,
223
+ "sha256": "2e3e6765cca9de53a0f23e42a52f4f152b9789b36e630345c9e2e6fb3f1b8475"
224
+ },
225
+ "source/deploy/huggingface/README.md": {
226
+ "bytes": 2428,
227
+ "sha256": "1340d543066c6b908957e39a6e13d9c3f1d05372857fdeaee368d992d583bbb6"
228
+ },
229
+ "source/docs/assets/choir_bwv407.wav": {
230
+ "bytes": 960044,
231
+ "sha256": "2640f4fe1b68b6d5f8392c688d5a919ac0e89a6b017d3c3f41ebad5bb72d6e0f"
232
+ },
233
+ "source/scripts/check_huggingface_space.mjs": {
234
+ "bytes": 4632,
235
+ "sha256": "142f3dac4055c333601d21b741dc2cc26fd1518cf4e98e8842bbdbd7edc012de"
236
+ },
237
+ "source/scripts/deploy_huggingface_space.py": {
238
+ "bytes": 7745,
239
+ "sha256": "329be2f93c6eee411202c70a79f8cb3329fc48c937811c74d02a703f16f80562"
240
+ }
241
+ }
242
+ }
diagnostic.wav ADDED
Binary file (65.6 kB). View file
 
favicon.png ADDED
index.html CHANGED
@@ -1,19 +1,18 @@
1
  <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
  </html>
 
1
  <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
6
+ <meta name="theme-color" content="#090a0d" />
7
+ <link rel="icon" href="/favicon.png" />
8
+ <title>Hendrix — on-device transcription</title>
9
+ <script type="module" crossorigin src="/assets/local-DblFrGk8.js"></script>
10
+ <link rel="modulepreload" crossorigin href="/assets/style-CdJLhYve.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/PianoRollCanvas-xSq9nagc.js">
12
+ <link rel="stylesheet" crossorigin href="/assets/style-BAFoxh21.css">
13
+ <link rel="stylesheet" crossorigin href="/assets/local-56CJnE36.css">
14
+ </head>
15
+ <body>
16
+ <div id="root"></div>
17
+ </body>
 
18
  </html>
local.html ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
6
+ <meta name="theme-color" content="#090a0d" />
7
+ <link rel="icon" href="/favicon.png" />
8
+ <title>Hendrix — on-device transcription</title>
9
+ <script type="module" crossorigin src="/assets/local-DblFrGk8.js"></script>
10
+ <link rel="modulepreload" crossorigin href="/assets/style-CdJLhYve.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/PianoRollCanvas-xSq9nagc.js">
12
+ <link rel="stylesheet" crossorigin href="/assets/style-BAFoxh21.css">
13
+ <link rel="stylesheet" crossorigin href="/assets/local-56CJnE36.css">
14
+ </head>
15
+ <body>
16
+ <div id="root"></div>
17
+ </body>
18
+ </html>
models/fp32/cross_cache.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cbfb5da1057eee995d5572c478705a5defb6c00d9fdcd96125cbe89072f24d53
3
+ size 12648891
models/fp32/decoder_step.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6367704e25f718c962686b719537b43b1f7c4bdbaa84c3b36bd307323ccf72ca
3
+ size 93343733
models/fp32/encoder.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:786b70a7424531349f259cd867761b3eeb4c27696a0e5c7d03082678962bd912
3
+ size 89354488
models/fp32/manifest.json ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema_version": 1,
3
+ "checkpoint": {
4
+ "path": "yptf_allmetric_rwc_pg_support2_d26.pt",
5
+ "sha256": "3df08bb38dce7ae30be23090524b63755c565d1a3242860aef6c9401fc125bbe",
6
+ "file_bytes": 189496364
7
+ },
8
+ "source_revision": "5e66c1ea173a8186e0d20432b841d3180cc015b5",
9
+ "precision": "fp32",
10
+ "export_math_replacements": {
11
+ "rotary": 3,
12
+ "moe": 12
13
+ },
14
+ "runtime_contract": {
15
+ "sample_rate": 16000,
16
+ "input_frames": 32767,
17
+ "segment_seconds": 2.0479375,
18
+ "stft_shape": [
19
+ 1,
20
+ 110,
21
+ 1024
22
+ ],
23
+ "channels": 13,
24
+ "max_tokens": 256,
25
+ "decoder": "greedy cached autoregressive"
26
+ },
27
+ "graphs": {
28
+ "encoder": {
29
+ "path": "encoder.onnx",
30
+ "sha256": "786b70a7424531349f259cd867761b3eeb4c27696a0e5c7d03082678962bd912",
31
+ "bytes": 89354488,
32
+ "nodes": 1783,
33
+ "operators": {
34
+ "Add": 201,
35
+ "AveragePool": 3,
36
+ "Concat": 30,
37
+ "Conv": 7,
38
+ "Div": 27,
39
+ "Equal": 96,
40
+ "Expand": 2,
41
+ "Gemm": 300,
42
+ "LayerNormalization": 30,
43
+ "MatMul": 91,
44
+ "Mul": 318,
45
+ "Neg": 15,
46
+ "ReduceSum": 108,
47
+ "Relu": 6,
48
+ "Reshape": 130,
49
+ "Sigmoid": 96,
50
+ "Slice": 60,
51
+ "Softmax": 27,
52
+ "Squeeze": 30,
53
+ "TopK": 12,
54
+ "Transpose": 68,
55
+ "Unsqueeze": 30,
56
+ "Where": 96
57
+ },
58
+ "export_sec": 6.482101709989365,
59
+ "precision_conversion_sec": 0.0,
60
+ "ort_cpu_sec": 0.20406562398420647,
61
+ "max_abs_error": 3.552436828613281e-05,
62
+ "mean_abs_error": 8.357006322512461e-07
63
+ },
64
+ "cross_cache": {
65
+ "path": "cross_cache.onnx",
66
+ "sha256": "cbfb5da1057eee995d5572c478705a5defb6c00d9fdcd96125cbe89072f24d53",
67
+ "bytes": 12648891,
68
+ "nodes": 49,
69
+ "operators": {
70
+ "MatMul": 16,
71
+ "Reshape": 17,
72
+ "Transpose": 16
73
+ },
74
+ "export_sec": 0.6789736609789543,
75
+ "precision_conversion_sec": 0.0,
76
+ "ort_cpu_sec": 0.007953249965794384,
77
+ "worst_output_max_abs_error": 2.288818359375e-05
78
+ },
79
+ "decoder_step": {
80
+ "path": "decoder_step.onnx",
81
+ "sha256": "6367704e25f718c962686b719537b43b1f7c4bdbaa84c3b36bd307323ccf72ca",
82
+ "bytes": 93343733,
83
+ "nodes": 528,
84
+ "operators": {
85
+ "Add": 66,
86
+ "Concat": 16,
87
+ "Gather": 2,
88
+ "MatMul": 105,
89
+ "Mul": 91,
90
+ "Pow": 33,
91
+ "Reciprocal": 25,
92
+ "ReduceMean": 25,
93
+ "Reshape": 52,
94
+ "Softmax": 16,
95
+ "Sqrt": 25,
96
+ "Tanh": 8,
97
+ "Transpose": 64
98
+ },
99
+ "export_sec": 2.754342700005509,
100
+ "precision_conversion_sec": 0.0,
101
+ "ort_cpu_sec": 0.01502414100104943,
102
+ "logits": {
103
+ "max_abs_error": 0.000213623046875,
104
+ "mean_abs_error": 2.1228790501481853e-05
105
+ },
106
+ "argmax_equal": true,
107
+ "worst_cache_max_abs_error": 2.0265579223632812e-06
108
+ }
109
+ },
110
+ "total_graph_bytes": 195347112
111
+ }
ort/ort-wasm-simd-threaded.jsep.mjs ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ async function ortWasmThreaded(moduleArg={}){var moduleRtn;var f=moduleArg,aa=!!globalThis.window,ba=!!globalThis.WorkerGlobalScope,h=globalThis.process?.versions?.node&&"renderer"!=globalThis.process?.type,m=ba&&self.name?.startsWith("em-pthread");if(h){const {createRequire:a}=await import("module");var require=a(import.meta.url),ca=require("worker_threads");global.Worker=ca.Worker;m=(ba=!ca.Xd)&&"em-pthread"==ca.workerData}f.mountExternalData=(a,b)=>{a.startsWith("./")&&(a=a.substring(2));(f.Xc||(f.Xc=new Map)).set(a,b)};
2
+ f.unmountExternalData=()=>{delete f.Xc};var SharedArrayBuffer=globalThis.SharedArrayBuffer??(new WebAssembly.Memory({initial:0,maximum:0,shared:!0})).buffer.constructor;const da=a=>async(...b)=>{try{if(f.Yc)throw Error("Session already started");const d=f.Yc={Kd:b[0],errors:[]},c=await a(...b);if(f.Yc!==d)throw Error("Session mismatch");f.dd?.flush();const e=d.errors;if(0<e.length){let g=await Promise.all(e);g=g.filter(k=>k);if(0<g.length)throw Error(g.join("\n"));}return c}finally{f.Yc=null}};
3
+ f.jsepInit=(a,b)=>{if("webgpu"===a){[f.dd,f.Ad,f.Ed,f.ed,f.Dd,f.$b,f.Fd,f.Hd,f.Bd,f.Cd,f.Gd]=b;const d=f.dd;f.jsepRegisterBuffer=(c,e,g,k)=>d.registerBuffer(c,e,g,k);f.jsepGetBuffer=c=>d.getBuffer(c);f.jsepCreateDownloader=(c,e,g)=>d.createDownloader(c,e,g);f.jsepOnCreateSession=c=>{d.onCreateSession(c)};f.jsepOnReleaseSession=c=>{d.onReleaseSession(c)};f.jsepOnRunStart=c=>d.onRunStart(c);f.Id=(c,e)=>{d.upload(c,e)}}else if("webnn"===a){const d=b[0];[f.Sd,f.sd,f.webnnEnsureTensor,f.td,f.webnnDownloadTensor,
4
+ f.Rd,f.webnnEnableTraceEvent]=b.slice(1);f.webnnReleaseTensorId=f.sd;f.webnnUploadTensor=f.td;f.webnnRegisterMLContext=f.Rd;f.webnnOnRunStart=c=>d.onRunStart(c);f.webnnOnRunEnd=d.onRunEnd.bind(d);f.webnnOnReleaseSession=c=>{d.onReleaseSession(c)};f.webnnCreateMLTensorDownloader=(c,e)=>d.createMLTensorDownloader(c,e);f.webnnRegisterMLTensor=(c,e,g,k)=>d.registerMLTensor(c,e,g,k);f.webnnCreateMLContext=c=>d.createMLContext(c);f.webnnRegisterMLConstant=(c,e,g,k,l,n)=>d.registerMLConstant(c,e,g,k,l,f.Xc,
5
+ n);f.webnnRegisterGraphInput=d.registerGraphInput.bind(d);f.webnnIsGraphInput=d.isGraphInput.bind(d);f.webnnRegisterGraphOutput=d.registerGraphOutput.bind(d);f.webnnIsGraphOutput=d.isGraphOutput.bind(d);f.webnnCreateTemporaryTensor=d.createTemporaryTensor.bind(d);f.webnnIsGraphInputOutputTypeSupported=d.isGraphInputOutputTypeSupported.bind(d)}};
6
+ let fa=()=>{const a=b=>(...d)=>{const c=q;d=b(...d);return q!=c?ea():d};(b=>{for(const d of b)f[d]=a(f[d])})(["_OrtAppendExecutionProvider","_OrtCreateSession","_OrtRun","_OrtRunWithBinding","_OrtBindInput"]);"undefined"!==typeof da&&(f._OrtRun=da(f._OrtRun),f._OrtRunWithBinding=da(f._OrtRunWithBinding));fa=void 0};f.asyncInit=()=>{fa?.()};var ha="./this.program",ia=(a,b)=>{throw b;},ja=import.meta.url,ka="",la,ma;
7
+ if(h){var fs=require("fs");ja.startsWith("file:")&&(ka=require("path").dirname(require("url").fileURLToPath(ja))+"/");ma=a=>{a=na(a)?new URL(a):a;return fs.readFileSync(a)};la=async a=>{a=na(a)?new URL(a):a;return fs.readFileSync(a,void 0)};1<process.argv.length&&(ha=process.argv[1].replace(/\\/g,"/"));process.argv.slice(2);ia=(a,b)=>{process.exitCode=a;throw b;}}else if(aa||ba){try{ka=(new URL(".",ja)).href}catch{}h||(ba&&(ma=a=>{var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";
8
+ b.send(null);return new Uint8Array(b.response)}),la=async a=>{if(na(a))return new Promise((d,c)=>{var e=new XMLHttpRequest;e.open("GET",a,!0);e.responseType="arraybuffer";e.onload=()=>{200==e.status||0==e.status&&e.response?d(e.response):c(e.status)};e.onerror=c;e.send(null)});var b=await fetch(a,{credentials:"same-origin"});if(b.ok)return b.arrayBuffer();throw Error(b.status+" : "+b.url);})}var oa=console.log.bind(console),pa=console.error.bind(console);
9
+ if(h){var qa=require("util"),ra=a=>"object"==typeof a?qa.inspect(a):a;oa=(...a)=>fs.writeSync(1,a.map(ra).join(" ")+"\n");pa=(...a)=>fs.writeSync(2,a.map(ra).join(" ")+"\n")}var sa=oa,r=pa,ta,ua,t=!1,va,na=a=>a.startsWith("file://");function v(){x.buffer!=A.buffer&&wa()}var xa,ya;
10
+ if(h&&m){var za=ca.parentPort;za.on("message",a=>global.onmessage?.({data:a}));Object.assign(globalThis,{self:global,postMessage:a=>za.postMessage(a)});process.on("uncaughtException",a=>{postMessage({Sc:"uncaughtException",error:a});process.exit(1)})}var Aa;
11
+ if(m){var Ba=!1;self.onunhandledrejection=b=>{throw b.reason||b;};function a(b){try{var d=b.data,c=d.Sc;if("load"===c){let e=[];self.onmessage=g=>e.push(g);Aa=()=>{postMessage({Sc:"loaded"});for(let g of e)a(g);self.onmessage=a};for(const g of d.xd)if(!f[g]||f[g].proxy)f[g]=(...k)=>{postMessage({Sc:"callHandler",wd:g,args:k})},"print"==g&&(sa=f[g]),"printErr"==g&&(r=f[g]);x=d.Od;wa();ua=d.Pd;Ca();Da()}else if("run"===c){Ea(d.Rc);Fa(d.Rc,0,0,1,0,0);Ga();Ha(d.Rc);Ba||(Ia(),Ba=!0);try{Ja(d.Md,d.bd)}catch(e){if("unwind"!=
12
+ e)throw e;}}else"setimmediate"!==d.target&&("checkMailbox"===c?Ba&&Ka():c&&(r(`worker: received unknown command ${c}`),r(d)))}catch(e){throw La(),e;}}self.onmessage=a}var A,B,Ma,Na,C,D,Oa,E,F,Pa,Qa=!1;function wa(){var a=x.buffer;f.HEAP8=A=new Int8Array(a);Ma=new Int16Array(a);f.HEAPU8=B=new Uint8Array(a);Na=new Uint16Array(a);f.HEAP32=C=new Int32Array(a);f.HEAPU32=D=new Uint32Array(a);Oa=new Float32Array(a);E=new Float64Array(a);F=new BigInt64Array(a);Pa=new BigUint64Array(a)}
13
+ function Ra(){Qa=!0;m?Aa():G.sb()}function H(a){a="Aborted("+a+")";r(a);t=!0;a=new WebAssembly.RuntimeError(a+". Build with -sASSERTIONS for more info.");ya?.(a);throw a;}var Sa;async function Ta(a){if(!ta)try{var b=await la(a);return new Uint8Array(b)}catch{}if(a==Sa&&ta)a=new Uint8Array(ta);else if(ma)a=ma(a);else throw"both async and sync fetching of the wasm failed";return a}
14
+ async function Ua(a,b){try{var d=await Ta(a);return await WebAssembly.instantiate(d,b)}catch(c){r(`failed to asynchronously prepare wasm: ${c}`),H(c)}}async function Va(a){var b=Sa;if(!ta&&!na(b)&&!h)try{var d=fetch(b,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(d,a)}catch(c){r(`wasm streaming compile failed: ${c}`),r("falling back to ArrayBuffer instantiation")}return Ua(b,a)}
15
+ function Wa(){Xa={ma:Ya,gb:Za,g:$a,J:ab,f:bb,o:cb,h:db,ha:eb,b:fb,T:gb,Ha:hb,n:ib,$:jb,Xa:mb,Da:nb,Fa:ob,Ya:pb,Va:qb,Oa:rb,Ua:sb,ka:tb,Ea:ub,Ba:vb,Wa:wb,Ca:xb,bb:yb,ea:zb,wa:Ab,ua:Bb,da:Cb,O:Db,H:Eb,va:Fb,_:Gb,xa:Hb,Ra:Ib,za:Jb,Ia:Kb,sa:Lb,fa:Mb,Qa:Ha,_a:Nb,R:Ob,r:Pb,c:Qb,hb:Rb,y:Sb,M:Tb,D:Ub,l:Vb,s:Wb,ib:Xb,I:Yb,S:Zb,j:$b,u:ac,q:bc,k:cc,La:dc,Ma:ec,Na:fc,Ja:gc,Ka:hc,ta:ic,db:jc,ab:kc,v:lc,aa:mc,ga:nc,$a:oc,W:pc,Za:qc,Aa:rc,F:sc,U:tc,la:uc,ya:vc,fb:wc,eb:xc,Sa:yc,Ta:zc,Ga:Ac,V:Bc,ja:Cc,Pa:Dc,ia:Ec,
16
+ kb:Fc,na:Gc,lb:Hc,oa:Ic,G:Jc,e:Kc,t:Lc,w:Mc,B:Nc,mb:Oc,K:Pc,x:Qc,pa:Rc,Y:Sc,ba:Tc,nb:Uc,ob:Vc,P:Wc,qa:Xc,pb:Yc,N:Zc,Z:$c,d:ad,A:bd,m:cd,jb:dd,p:ed,z:fd,C:gd,E:hd,L:jd,qb:kd,Q:ld,ca:md,X:nd,rb:od,ra:pd,i:qd,a:x,cb:rd};return{a:Xa}}
17
+ async function Ca(){function a(c,e){var g=G=c.exports;c={};for(let [k,l]of Object.entries(g))"function"==typeof l?(g=sd(l),c[k]=g):c[k]=l;G=c;G=td();ud.push(G._b);c=G;vd=c.tb;Ia=c.ub;f._OrtInit=c.vb;f._OrtGetLastError=c.wb;f._OrtCreateSessionOptions=c.xb;f._OrtAppendExecutionProvider=c.yb;f._OrtAddFreeDimensionOverride=c.zb;f._OrtAddSessionConfigEntry=c.Ab;f._OrtReleaseSessionOptions=c.Bb;f._OrtCreateSession=c.Cb;f._OrtReleaseSession=c.Db;f._OrtGetInputOutputCount=c.Eb;f._OrtGetInputOutputMetadata=
18
+ c.Fb;f._OrtFree=c.Gb;f._OrtCreateTensor=c.Hb;f._OrtGetTensorData=c.Ib;f._OrtReleaseTensor=c.Jb;f._OrtCreateRunOptions=c.Kb;f._OrtAddRunConfigEntry=c.Lb;f._OrtReleaseRunOptions=c.Mb;f._OrtCreateBinding=c.Nb;f._OrtBindInput=c.Ob;f._OrtBindOutput=c.Pb;f._OrtClearBoundOutputs=c.Qb;f._OrtReleaseBinding=c.Rb;f._OrtRunWithBinding=c.Sb;f._OrtRun=c.Tb;f._OrtEndProfiling=c.Ub;f._JsepOutput=c.Vb;f._JsepGetNodeName=c.Wb;wd=c.Xb;I=f._free=c.Yb;xd=f._malloc=c.Zb;Fa=c.ac;La=c.bc;yd=c.cc;zd=c.dc;Ad=c.ec;Bd=c.fc;
19
+ Cd=c.gc;J=c.hc;Dd=c.ic;Ed=c.jc;K=c.kc;Fd=c.lc;L=c.mc;Gd=c.nc;Hd=c.oc;Id=c.pc;Jd=c.qc;dynCall_vii=c.rc;Kd=c.sc;dynCall_v=c.tc;Ld=c.uc;Md=c.vc;dynCall_iii=c.wc;Nd=c.xc;Od=c.yc;Pd=c.zc;Qd=c.Ac;dynCall_vi=c.Bc;Rd=c.Cc;Sd=c.Dc;Td=c.Ec;Ud=c.Fc;Vd=c.Gc;Wd=c.Hc;Xd=c.Ic;Yd=c.Jc;Zd=c.Kc;$d=c.Lc;ae=c.Mc;be=c.Nc;ce=c.Pc;de=c.Qc;ee=c.$c;fe=c.ad;ge=c.fd;he=c.jd;ie=c.kd;je=c.ld;ke=c.md;le=c.nd;me=c.od;ne=c.pd;oe=c.qd;pe=c.vd;qe=c.Td;re=c.Ud;se=c.Vd;te=c.Wd;ua=e;return G}var b=Wa();if(f.instantiateWasm)return new Promise(c=>
20
+ {f.instantiateWasm(b,(e,g)=>{c(a(e,g))})});if(m){var d=new WebAssembly.Instance(ua,Wa());return a(d,ua)}Sa??=f.locateFile?f.locateFile?f.locateFile("ort-wasm-simd-threaded.jsep.wasm",ka):ka+"ort-wasm-simd-threaded.jsep.wasm":(new URL("ort-wasm-simd-threaded.jsep.wasm",import.meta.url)).href;return function(c){return a(c.instance,c.module)}(await Va(b))}class ue{name="ExitStatus";constructor(a){this.message=`Program terminated with exit(${a})`;this.status=a}}
21
+ var ve=a=>{a.terminate();a.onmessage=()=>{}},we=[],xe=0,ye=null,Ce=a=>{0==M.length&&(ze(),Ae(M[0]));var b=M.pop();if(!b)return 6;Be.push(b);N[a.Rc]=b;b.Rc=a.Rc;var d={Sc:"run",Md:a.Ld,bd:a.bd,Rc:a.Rc};h&&b.unref();b.postMessage(d,a.rd);return 0},O=0,P=(a,b,...d)=>{var c=16*d.length,e=L(),g=Fd(c),k=g>>>3,l;for(l of d)"bigint"==typeof l?((v(),F)[k++>>>0]=1n,(v(),F)[k++>>>0]=l):((v(),F)[k++>>>0]=0n,(v(),E)[k++>>>0]=l);a=yd(a,0,c,g,b);K(e);return a};
22
+ function rd(a){if(m)return P(0,1,a);va=a;if(!(0<O)){for(var b of Be)ve(b);for(b of M)ve(b);M=[];Be=[];N={};t=!0}ia(a,new ue(a))}function De(a){if(m)return P(1,0,a);Ac(a)}var Ac=a=>{va=a;if(m)throw De(a),"unwind";rd(a)},M=[],Be=[],ud=[],N={};function Ee(){for(var a=f.numThreads-1;a--;)ze();we.push(async()=>{var b=Fe();xe++;await b;xe--;0==xe&&ye&&(b=ye,ye=null,b())})}var Ge=a=>{var b=a.Rc;delete N[b];M.push(a);Be.splice(Be.indexOf(a),1);a.Rc=0;zd(b)};function Ga(){ud.forEach(a=>a())}
23
+ var Ae=a=>new Promise(b=>{a.onmessage=g=>{var k=g.data;g=k.Sc;if(k.Zc&&k.Zc!=wd()){var l=N[k.Zc];l?l.postMessage(k,k.rd):r(`Internal error! Worker sent a message "${g}" to target pthread ${k.Zc}, but that thread no longer exists!`)}else if("checkMailbox"===g)Ka();else if("spawnThread"===g)Ce(k);else if("cleanupThread"===g)He(()=>{Ge(N[k.Nd])});else if("loaded"===g)a.loaded=!0,h&&!a.Rc&&a.unref(),b(a);else if("setimmediate"===k.target)a.postMessage(k);else if("uncaughtException"===g)a.onerror(k.error);
24
+ else if("callHandler"===g)f[k.wd](...k.args);else g&&r(`worker sent an unknown command ${g}`)};a.onerror=g=>{r(`${"worker sent an error!"} ${g.filename}:${g.lineno}: ${g.message}`);throw g;};h&&(a.on("message",g=>a.onmessage({data:g})),a.on("error",g=>a.onerror(g)));var d=[],c=[],e;for(e of c)f.propertyIsEnumerable(e)&&d.push(e);a.postMessage({Sc:"load",xd:d,Od:x,Pd:ua})});async function Fe(){if(!m)return Promise.all(M.map(Ae))}
25
+ function ze(){var a=new Worker(new URL(import.meta.url),{type:"module",workerData:"em-pthread",name:"em-pthread"});M.push(a)}function Ea(a){var b=(v(),D)[a+52>>>2>>>0];a=(v(),D)[a+56>>>2>>>0];Ed(b,b-a);K(b)}var Ja=(a,b)=>{O=0;a=Kd(a,b);0<O?va=a:Ad(a)},x,Ie=[],Je=0;function $a(a){a>>>=0;var b=new Ke(a);0==(v(),A)[b.Tc+12>>>0]&&(Le(b,!0),Je--);Me(b,!1);Ie.push(b);return Jd(a)}var Q=0,ab=()=>{J(0,0);var a=Ie.pop();Gd(a.cd);Q=0};
26
+ function Le(a,b){b=b?1:0;(v(),A)[a.Tc+12>>>0]=b}function Me(a,b){b=b?1:0;(v(),A)[a.Tc+13>>>0]=b}class Ke{constructor(a){this.cd=a;this.Tc=a-24}}var Ne=a=>{var b=Q;if(!b)return Dd(0),0;var d=new Ke(b);(v(),D)[d.Tc+16>>>2>>>0]=b;var c=(v(),D)[d.Tc+4>>>2>>>0];if(!c)return Dd(0),b;for(var e of a){if(0===e||e===c)break;if(Id(e,c,d.Tc+16))return Dd(e),b}Dd(c);return b};function bb(){return Ne([])}function cb(a){return Ne([a>>>0])}function db(a,b,d,c){return Ne([a>>>0,b>>>0,d>>>0,c>>>0])}
27
+ var eb=()=>{var a=Ie.pop();a||H("no exception to throw");var b=a.cd;0==(v(),A)[a.Tc+13>>>0]&&(Ie.push(a),Me(a,!0),Le(a,!1),Je++);Hd(b);Q=b;throw Q;};function fb(a,b,d){a>>>=0;var c=new Ke(a);b>>>=0;d>>>=0;(v(),D)[c.Tc+16>>>2>>>0]=0;(v(),D)[c.Tc+4>>>2>>>0]=b;(v(),D)[c.Tc+8>>>2>>>0]=d;Hd(a);Q=a;Je++;throw Q;}var gb=()=>Je;function Oe(a,b,d,c){return m?P(2,1,a,b,d,c):hb(a,b,d,c)}
28
+ function hb(a,b,d,c){a>>>=0;b>>>=0;d>>>=0;c>>>=0;if(!globalThis.SharedArrayBuffer)return 6;var e=[];if(m&&0===e.length)return Oe(a,b,d,c);a={Ld:d,Rc:a,bd:c,rd:e};return m?(a.Sc="spawnThread",postMessage(a,e),0):Ce(a)}function ib(a){Q||=a>>>0;throw Q;}
29
+ var Pe=globalThis.TextDecoder&&new TextDecoder,Qe=(a,b,d,c)=>{d=b+d;if(c)return d;for(;a[b]&&!(b>=d);)++b;return b},Re=(a,b=0,d,c)=>{b>>>=0;d=Qe(a,b,d,c);if(16<d-b&&a.buffer&&Pe)return Pe.decode(a.buffer instanceof ArrayBuffer?a.subarray(b,d):a.slice(b,d));for(c="";b<d;){var e=a[b++];if(e&128){var g=a[b++]&63;if(192==(e&224))c+=String.fromCharCode((e&31)<<6|g);else{var k=a[b++]&63;e=224==(e&240)?(e&15)<<12|g<<6|k:(e&7)<<18|g<<12|k<<6|a[b++]&63;65536>e?c+=String.fromCharCode(e):(e-=65536,c+=String.fromCharCode(55296|
30
+ e>>10,56320|e&1023))}}else c+=String.fromCharCode(e)}return c},R=(a,b,d)=>(a>>>=0)?Re((v(),B),a,b,d):"";function jb(a,b,d){return m?P(3,1,a,b,d):0}function mb(a,b){if(m)return P(4,1,a,b)}function nb(a,b){if(m)return P(5,1,a,b)}function ob(a,b,d){if(m)return P(6,1,a,b,d)}function pb(a,b,d){return m?P(7,1,a,b,d):0}function qb(a,b){if(m)return P(8,1,a,b)}function rb(a,b,d){if(m)return P(9,1,a,b,d)}function sb(a,b,d,c){if(m)return P(10,1,a,b,d,c)}function tb(a,b,d,c){if(m)return P(11,1,a,b,d,c)}
31
+ function ub(a,b,d,c){if(m)return P(12,1,a,b,d,c)}function vb(a){if(m)return P(13,1,a)}function wb(a,b){if(m)return P(14,1,a,b)}function xb(a,b,d){if(m)return P(15,1,a,b,d)}var yb=()=>H(""),S=a=>{a>>>=0;for(var b="";;){var d=(v(),B)[a++>>>0];if(!d)return b;b+=String.fromCharCode(d)}},Se={},Te={},Ue={},Ve=class extends Error{constructor(a){super(a);this.name="BindingError"}};
32
+ function We(a,b,d={}){var c=b.name;if(!a)throw new Ve(`type "${c}" must have a positive integer typeid pointer`);if(Te.hasOwnProperty(a)){if(d.yd)return;throw new Ve(`Cannot register type '${c}' twice`);}Te[a]=b;delete Ue[a];Se.hasOwnProperty(a)&&(b=Se[a],delete Se[a],b.forEach(e=>e()))}function T(a,b,d={}){return We(a,b,d)}
33
+ var Xe=(a,b,d)=>{switch(b){case 1:return d?c=>(v(),A)[c>>>0]:c=>(v(),B)[c>>>0];case 2:return d?c=>(v(),Ma)[c>>>1>>>0]:c=>(v(),Na)[c>>>1>>>0];case 4:return d?c=>(v(),C)[c>>>2>>>0]:c=>(v(),D)[c>>>2>>>0];case 8:return d?c=>(v(),F)[c>>>3>>>0]:c=>(v(),Pa)[c>>>3>>>0];default:throw new TypeError(`invalid integer width (${b}): ${a}`);}};
34
+ function zb(a,b,d,c,e){a>>>=0;d>>>=0;b=S(b>>>0);c=0n===c;let g=k=>k;if(c){const k=8*d;g=l=>BigInt.asUintN(k,l);e=g(e)}T(a,{name:b,Oc:g,Vc:(k,l)=>{"number"==typeof l&&(l=BigInt(l));return l},Uc:Xe(b,d,!c),Wc:null})}function Ab(a,b,d,c){a>>>=0;b=S(b>>>0);T(a,{name:b,Oc:function(e){return!!e},Vc:function(e,g){return g?d:c},Uc:function(e){return this.Oc((v(),B)[e>>>0])},Wc:null})}var Ye=[],U=[0,1,,1,null,1,!0,1,!1,1];function Qb(a){a>>>=0;9<a&&0===--U[a+1]&&(U[a]=void 0,Ye.push(a))}
35
+ var V=a=>{if(!a)throw new Ve(`Cannot use deleted val. handle = ${a}`);return U[a]},X=a=>{switch(a){case void 0:return 2;case null:return 4;case !0:return 6;case !1:return 8;default:const b=Ye.pop()||U.length;U[b]=a;U[b+1]=1;return b}};function Ze(a){return this.Oc((v(),D)[a>>>2>>>0])}var $e={name:"emscripten::val",Oc:a=>{var b=V(a);Qb(a);return b},Vc:(a,b)=>X(b),Uc:Ze,Wc:null};function Bb(a){return T(a>>>0,$e)}
36
+ var af=(a,b)=>{switch(b){case 4:return function(d){return this.Oc((v(),Oa)[d>>>2>>>0])};case 8:return function(d){return this.Oc((v(),E)[d>>>3>>>0])};default:throw new TypeError(`invalid float width (${b}): ${a}`);}};function Cb(a,b,d){a>>>=0;d>>>=0;b=S(b>>>0);T(a,{name:b,Oc:c=>c,Vc:(c,e)=>e,Uc:af(b,d),Wc:null})}function Db(a,b,d,c,e){a>>>=0;d>>>=0;b=S(b>>>0);let g=l=>l;if(0===c){var k=32-8*d;g=l=>l<<k>>>k;e=g(e)}T(a,{name:b,Oc:g,Vc:(l,n)=>n,Uc:Xe(b,d,0!==c),Wc:null})}
37
+ function Eb(a,b,d){function c(g){var k=(v(),D)[g>>>2>>>0];g=(v(),D)[g+4>>>2>>>0];return new e((v(),A).buffer,g,k)}a>>>=0;var e=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][b];d=S(d>>>0);T(a,{name:d,Oc:c,Uc:c},{yd:!0})}
38
+ var Y=(a,b,d)=>{var c=(v(),B);b>>>=0;if(0<d){var e=b;d=b+d-1;for(var g=0;g<a.length;++g){var k=a.codePointAt(g);if(127>=k){if(b>=d)break;c[b++>>>0]=k}else if(2047>=k){if(b+1>=d)break;c[b++>>>0]=192|k>>6;c[b++>>>0]=128|k&63}else if(65535>=k){if(b+2>=d)break;c[b++>>>0]=224|k>>12;c[b++>>>0]=128|k>>6&63;c[b++>>>0]=128|k&63}else{if(b+3>=d)break;c[b++>>>0]=240|k>>18;c[b++>>>0]=128|k>>12&63;c[b++>>>0]=128|k>>6&63;c[b++>>>0]=128|k&63;g++}}c[b>>>0]=0;a=b-e}else a=0;return a},bf=a=>{for(var b=0,d=0;d<a.length;++d){var c=
39
+ a.charCodeAt(d);127>=c?b++:2047>=c?b+=2:55296<=c&&57343>=c?(b+=4,++d):b+=3}return b};
40
+ function Fb(a,b){a>>>=0;b=S(b>>>0);T(a,{name:b,Oc(d){var c=(v(),D)[d>>>2>>>0];c=R(d+4,c,!0);I(d);return c},Vc(d,c){c instanceof ArrayBuffer&&(c=new Uint8Array(c));var e="string"==typeof c;if(!(e||ArrayBuffer.isView(c)&&1==c.BYTES_PER_ELEMENT))throw new Ve("Cannot pass non-string to std::string");var g=e?bf(c):c.length;var k=xd(4+g+1),l=k+4;(v(),D)[k>>>2>>>0]=g;e?Y(c,l,g+1):(v(),B).set(c,l>>>0);null!==d&&d.push(I,k);return k},Uc:Ze,Wc(d){I(d)}})}
41
+ var cf=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,df=(a,b,d)=>{a>>>=1;b=Qe((v(),Na),a,b/2,d);if(16<b-a&&cf)return cf.decode((v(),Na).slice(a,b));for(d="";a<b;++a){var c=(v(),Na)[a>>>0];d+=String.fromCharCode(c)}return d},ef=(a,b,d)=>{d??=2147483647;if(2>d)return 0;d-=2;var c=b;d=d<2*a.length?d/2:a.length;for(var e=0;e<d;++e){var g=a.charCodeAt(e);(v(),Ma)[b>>>1>>>0]=g;b+=2}(v(),Ma)[b>>>1>>>0]=0;return b-c},ff=a=>2*a.length,gf=(a,b,d)=>{var c="";a>>>=2;for(var e=0;!(e>=b/4);e++){var g=
42
+ (v(),D)[a+e>>>0];if(!g&&!d)break;c+=String.fromCodePoint(g)}return c},hf=(a,b,d)=>{b>>>=0;d??=2147483647;if(4>d)return 0;var c=b;d=c+d-4;for(var e=0;e<a.length;++e){var g=a.codePointAt(e);65535<g&&e++;(v(),C)[b>>>2>>>0]=g;b+=4;if(b+4>d)break}(v(),C)[b>>>2>>>0]=0;return b-c},jf=a=>{for(var b=0,d=0;d<a.length;++d)65535<a.codePointAt(d)&&d++,b+=4;return b};
43
+ function Gb(a,b,d){a>>>=0;b>>>=0;d>>>=0;d=S(d);if(2===b){var c=df;var e=ef;var g=ff}else c=gf,e=hf,g=jf;T(a,{name:d,Oc:k=>{var l=(v(),D)[k>>>2>>>0];l=c(k+4,l*b,!0);I(k);return l},Vc:(k,l)=>{if("string"!=typeof l)throw new Ve(`Cannot pass non-string to C++ string type ${d}`);var n=g(l),p=xd(4+n+b);(v(),D)[p>>>2>>>0]=n/b;e(l,p+4,n+b);null!==k&&k.push(I,p);return p},Uc:Ze,Wc(k){I(k)}})}function Hb(a,b){a>>>=0;b=S(b>>>0);T(a,{zd:!0,name:b,Oc:()=>{},Vc:()=>{}})}
44
+ function Ib(a){Fa(a>>>0,!ba,1,!aa,131072,!1);Ga()}var He=a=>{if(!t)try{if(a(),!(0<O))try{m?wd()&&Ad(va):Ac(va)}catch(b){b instanceof ue||"unwind"==b||ia(1,b)}}catch(b){b instanceof ue||"unwind"==b||ia(1,b)}},kf=!Atomics.waitAsync||globalThis.navigator?.userAgent&&91>Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2]);function Ha(a){a>>>=0;kf||(Atomics.waitAsync((v(),C),a>>>2,a).value.then(Ka),a+=128,Atomics.store((v(),C),a>>>2,1))}var Ka=()=>He(()=>{var a=wd();a&&(Ha(a),Cd())});
45
+ function Jb(a,b){a>>>=0;a==b>>>0?setTimeout(Ka):m?postMessage({Zc:a,Sc:"checkMailbox"}):(a=N[a])&&a.postMessage({Sc:"checkMailbox"})}var lf=[];function Kb(a,b,d,c,e){b>>>=0;e>>>=0;lf.length=0;d=e>>>3;for(c=e+c>>>3;d<c;){var g;(v(),F)[d++>>>0]?g=(v(),F)[d++>>>0]:g=(v(),E)[d++>>>0];lf.push(g)}return(b?mf[b]:nf[a])(...lf)}var Lb=()=>{O=0};function Mb(a){a>>>=0;m?postMessage({Sc:"cleanupThread",Nd:a}):Ge(N[a])}function Nb(a){h&&N[a>>>0].ref()}var of=a=>{try{a()}catch(b){H(b)}};
46
+ function sd(a){var b=(...d)=>{pf.push(a);try{return a(...d)}finally{t||(pf.pop(),q&&1===Z&&0===pf.length&&(Z=0,O+=1,of(re),"undefined"!=typeof Fibers&&Fibers.Zd()))}};qf.set(a,b);return b}var Z=0,q=null,rf=0,pf=[],sf=new Map,tf=new Map,qf=new Map,uf=0,vf=null,wf=[];function ea(){return new Promise((a,b)=>{vf={resolve:a,reject:b}})}
47
+ function xf(){var a=xd(65548),b=a+12;(v(),D)[a>>>2>>>0]=b;(v(),D)[a+4>>>2>>>0]=b+65536;b=pf[0];if(!sf.has(b)){var d=uf++;sf.set(b,d);tf.set(d,b)}b=sf.get(b);(v(),C)[a+8>>>2>>>0]=b;return a}function yf(){var a=(v(),C)[q+8>>>2>>>0];a=tf.get(a);a=qf.get(a);--O;return a()}
48
+ function zf(a){if(!t){if(0===Z){var b=!1,d=!1;a((c=0)=>{if(!t&&(rf=c,b=!0,d)){Z=2;of(()=>se(q));"undefined"!=typeof MainLoop&&MainLoop.ud&&MainLoop.resume();c=!1;try{var e=yf()}catch(l){e=l,c=!0}var g=!1;if(!q){var k=vf;k&&(vf=null,(c?k.reject:k.resolve)(e),g=!0)}if(c&&!g)throw e;}});d=!0;b||(Z=1,q=xf(),"undefined"!=typeof MainLoop&&MainLoop.ud&&MainLoop.pause(),of(()=>qe(q)))}else 2===Z?(Z=0,of(te),I(q),q=null,wf.forEach(He)):H(`invalid state: ${Z}`);return rf}}var Af=a=>zf(b=>{a().then(b)});
49
+ function Ob(a){a>>>=0;return Af(async()=>{var b=await V(a);return X(b)})}var Bf=[],Cf=a=>{var b=Bf.length;Bf.push(a);return b},Df=(a,b)=>{for(var d=Array(a),c=0;c<a;++c){var e=c,g=(v(),D)[b+4*c>>>2>>>0],k=Te[g];if(void 0===k)throw a=`parameter ${c}`,g=vd(g),b=S(g),I(g),new Ve(`${a} has unknown type ${b}`);d[e]=k}return d},Ef=(a,b,d)=>{var c=[];a=a(c,d);c.length&&((v(),D)[b>>>2>>>0]=X(c));return a},Ff={},Gf=a=>{var b=Ff[a];return void 0===b?S(a):b};
50
+ function Pb(a,b,d){var [c,...e]=Df(a,b>>>0);b=c.Vc.bind(c);var g=e.map(n=>n.Uc.bind(n));a--;var k={toValue:V};a=g.map((n,p)=>{var u=`argFromPtr${p}`;k[u]=n;return`${u}(args${p?"+"+8*p:""})`});switch(d){case 0:var l="toValue(handle)";break;case 2:l="new (toValue(handle))";break;case 3:l="";break;case 1:k.getStringOrSymbol=Gf,l="toValue(handle)[getStringOrSymbol(methodName)]"}l+=`(${a})`;c.zd||(k.toReturnWire=b,k.emval_returnValue=Ef,l=`return emval_returnValue(toReturnWire, destructorsRef, ${l})`);
51
+ l=`return function (handle, methodName, destructorsRef, args) {\n ${l}\n }`;d=(new Function(Object.keys(k),l))(...Object.values(k));l=`methodCaller<(${e.map(n=>n.name)}) => ${c.name}>`;return Cf(Object.defineProperty(d,"name",{value:l}))}function Rb(a,b){b>>>=0;a=V(a>>>0);b=V(b);return a==b}function Sb(a){a>>>=0;if(!a)return X(globalThis);a=Gf(a);return X(globalThis[a])}function Tb(a){a=Gf(a>>>0);return X(f[a])}function Ub(a,b){b>>>=0;a=V(a>>>0);b=V(b);return X(a[b])}
52
+ function Vb(a){a>>>=0;9<a&&(U[a+1]+=1)}function Wb(a,b,d,c,e){return Bf[a>>>0](b>>>0,d>>>0,c>>>0,e>>>0)}function Xb(a,b,d,c,e){return Wb(a>>>0,b>>>0,d>>>0,c>>>0,e>>>0)}function Yb(){return X([])}function Zb(a){a=V(a>>>0);for(var b=Array(a.length),d=0;d<a.length;d++)b[d]=a[d];return X(b)}function $b(a){return X(Gf(a>>>0))}function ac(){return X({})}function bc(a){a>>>=0;for(var b=V(a);b.length;){var d=b.pop();b.pop()(d)}Qb(a)}function cc(a,b,d){b>>>=0;d>>>=0;a=V(a>>>0);b=V(b);d=V(d);a[b]=d}
53
+ function dc(a,b){a=-9007199254740992>a||9007199254740992<a?NaN:Number(a);b>>>=0;a=new Date(1E3*a);(v(),C)[b>>>2>>>0]=a.getUTCSeconds();(v(),C)[b+4>>>2>>>0]=a.getUTCMinutes();(v(),C)[b+8>>>2>>>0]=a.getUTCHours();(v(),C)[b+12>>>2>>>0]=a.getUTCDate();(v(),C)[b+16>>>2>>>0]=a.getUTCMonth();(v(),C)[b+20>>>2>>>0]=a.getUTCFullYear()-1900;(v(),C)[b+24>>>2>>>0]=a.getUTCDay();a=(a.getTime()-Date.UTC(a.getUTCFullYear(),0,1,0,0,0,0))/864E5|0;(v(),C)[b+28>>>2>>>0]=a}
54
+ var Hf=a=>0===a%4&&(0!==a%100||0===a%400),If=[0,31,60,91,121,152,182,213,244,274,305,335],Jf=[0,31,59,90,120,151,181,212,243,273,304,334];
55
+ function ec(a,b){a=-9007199254740992>a||9007199254740992<a?NaN:Number(a);b>>>=0;a=new Date(1E3*a);(v(),C)[b>>>2>>>0]=a.getSeconds();(v(),C)[b+4>>>2>>>0]=a.getMinutes();(v(),C)[b+8>>>2>>>0]=a.getHours();(v(),C)[b+12>>>2>>>0]=a.getDate();(v(),C)[b+16>>>2>>>0]=a.getMonth();(v(),C)[b+20>>>2>>>0]=a.getFullYear()-1900;(v(),C)[b+24>>>2>>>0]=a.getDay();var d=(Hf(a.getFullYear())?If:Jf)[a.getMonth()]+a.getDate()-1|0;(v(),C)[b+28>>>2>>>0]=d;(v(),C)[b+36>>>2>>>0]=-(60*a.getTimezoneOffset());d=(new Date(a.getFullYear(),
56
+ 6,1)).getTimezoneOffset();var c=(new Date(a.getFullYear(),0,1)).getTimezoneOffset();a=(d!=c&&a.getTimezoneOffset()==Math.min(c,d))|0;(v(),C)[b+32>>>2>>>0]=a}
57
+ function fc(a){a>>>=0;var b=new Date((v(),C)[a+20>>>2>>>0]+1900,(v(),C)[a+16>>>2>>>0],(v(),C)[a+12>>>2>>>0],(v(),C)[a+8>>>2>>>0],(v(),C)[a+4>>>2>>>0],(v(),C)[a>>>2>>>0],0),d=(v(),C)[a+32>>>2>>>0],c=b.getTimezoneOffset(),e=(new Date(b.getFullYear(),6,1)).getTimezoneOffset(),g=(new Date(b.getFullYear(),0,1)).getTimezoneOffset(),k=Math.min(g,e);0>d?(v(),C)[a+32>>>2>>>0]=Number(e!=g&&k==c):0<d!=(k==c)&&(e=Math.max(g,e),b.setTime(b.getTime()+6E4*((0<d?k:e)-c)));(v(),C)[a+24>>>2>>>0]=b.getDay();d=(Hf(b.getFullYear())?
58
+ If:Jf)[b.getMonth()]+b.getDate()-1|0;(v(),C)[a+28>>>2>>>0]=d;(v(),C)[a>>>2>>>0]=b.getSeconds();(v(),C)[a+4>>>2>>>0]=b.getMinutes();(v(),C)[a+8>>>2>>>0]=b.getHours();(v(),C)[a+12>>>2>>>0]=b.getDate();(v(),C)[a+16>>>2>>>0]=b.getMonth();(v(),C)[a+20>>>2>>>0]=b.getYear();a=b.getTime();return BigInt(isNaN(a)?-1:a/1E3)}function gc(a,b,d,c,e,g,k){return m?P(16,1,a,b,d,c,e,g,k):-52}function hc(a,b,d,c,e,g){if(m)return P(17,1,a,b,d,c,e,g)}var Kf={},sc=()=>performance.timeOrigin+performance.now();
59
+ function ic(a,b){if(m)return P(18,1,a,b);Kf[a]&&(clearTimeout(Kf[a].id),delete Kf[a]);if(!b)return 0;var d=setTimeout(()=>{delete Kf[a];He(()=>Bd(a,performance.timeOrigin+performance.now()))},b);Kf[a]={id:d,Yd:b};return 0}
60
+ function jc(a,b,d,c){a>>>=0;b>>>=0;d>>>=0;c>>>=0;var e=(new Date).getFullYear(),g=(new Date(e,0,1)).getTimezoneOffset();e=(new Date(e,6,1)).getTimezoneOffset();var k=Math.max(g,e);(v(),D)[a>>>2>>>0]=60*k;(v(),C)[b>>>2>>>0]=Number(g!=e);b=l=>{var n=Math.abs(l);return`UTC${0<=l?"-":"+"}${String(Math.floor(n/60)).padStart(2,"0")}${String(n%60).padStart(2,"0")}`};a=b(g);b=b(e);e<g?(Y(a,d,17),Y(b,c,17)):(Y(a,c,17),Y(b,d,17))}var oc=()=>Date.now(),Lf=1;
61
+ function kc(a,b,d){d>>>=0;if(!(0<=a&&3>=a))return 28;if(0===a)a=Date.now();else if(Lf)a=performance.timeOrigin+performance.now();else return 52;a=Math.round(1E6*a);(v(),F)[d>>>3>>>0]=BigInt(a);return 0}var Mf=[],Nf=(a,b)=>{Mf.length=0;for(var d;d=(v(),B)[a++>>>0];){var c=105!=d;c&=112!=d;b+=c&&b%8?4:0;Mf.push(112==d?(v(),D)[b>>>2>>>0]:106==d?(v(),F)[b>>>3>>>0]:105==d?(v(),C)[b>>>2>>>0]:(v(),E)[b>>>3>>>0]);b+=c?8:4}return Mf};function lc(a,b,d){a>>>=0;b=Nf(b>>>0,d>>>0);return mf[a](...b)}
62
+ function mc(a,b,d){a>>>=0;b=Nf(b>>>0,d>>>0);return mf[a](...b)}var nc=()=>{};function pc(a,b){return r(R(a>>>0,b>>>0))}var qc=()=>{O+=1;throw"unwind";};function rc(){return 4294901760}var tc=()=>h?require("os").cpus().length:navigator.hardwareConcurrency,Of={},Pf=a=>{var b;return(b=/\bwasm-function\[\d+\]:(0x[0-9a-f]+)/.exec(a))?+b[1]:(b=/:(\d+):\d+(?:\)|$)/.exec(a))?2147483648|+b[1]:0},Qf=a=>{for(var b of a)(a=Pf(b))&&(Of[a]=b)};
63
+ function wc(){var a=Error().stack.toString().split("\n");"Error"==a[0]&&a.shift();Qf(a);Of.gd=Pf(a[3]);Of.Jd=a;return Of.gd}function uc(a){a=Of[a>>>0];if(!a)return 0;var b;if(b=/^\s+at .*\.wasm\.(.*) \(.*\)$/.exec(a))a=b[1];else if(b=/^\s+at (.*) \(.*\)$/.exec(a))a=b[1];else if(b=/^(.+?)@/.exec(a))a=b[1];else return 0;I(uc.hd??0);b=bf(a)+1;var d=xd(b);d&&Y(a,d,b);uc.hd=d;return uc.hd}
64
+ function vc(a){a>>>=0;var b=(v(),B).length;if(a<=b||4294901760<a)return!1;for(var d=1;4>=d;d*=2){var c=b*(1+.2/d);c=Math.min(c,a+100663296);a:{c=(Math.min(4294901760,65536*Math.ceil(Math.max(a,c)/65536))-x.buffer.byteLength+65535)/65536|0;try{x.grow(c);wa();var e=1;break a}catch(g){}e=void 0}if(e)return!0}return!1}
65
+ function xc(a,b,d){a>>>=0;b>>>=0;if(Of.gd==a)var c=Of.Jd;else c=Error().stack.toString().split("\n"),"Error"==c[0]&&c.shift(),Qf(c);for(var e=3;c[e]&&Pf(c[e])!=a;)++e;for(a=0;a<d&&c[a+e];++a)(v(),C)[b+4*a>>>2>>>0]=Pf(c[a+e]);return a}
66
+ var Rf={},Tf=()=>{if(!Sf){var a={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:ha||"./this.program"},b;for(b in Rf)void 0===Rf[b]?delete a[b]:a[b]=Rf[b];var d=[];for(b in a)d.push(`${b}=${a[b]}`);Sf=d}return Sf},Sf;function yc(a,b){if(m)return P(19,1,a,b);a>>>=0;b>>>=0;var d=0,c=0,e;for(e of Tf()){var g=b+d;(v(),D)[a+c>>>2>>>0]=g;d+=Y(e,g,Infinity)+1;c+=4}return 0}
67
+ function zc(a,b){if(m)return P(20,1,a,b);a>>>=0;b>>>=0;var d=Tf();(v(),D)[a>>>2>>>0]=d.length;a=0;for(var c of d)a+=bf(c)+1;(v(),D)[b>>>2>>>0]=a;return 0}function Bc(a){return m?P(21,1,a):52}function Cc(a,b,d,c){return m?P(22,1,a,b,d,c):52}function Dc(a,b,d,c){return m?P(23,1,a,b,d,c):70}var Uf=[null,[],[]];
68
+ function Ec(a,b,d,c){if(m)return P(24,1,a,b,d,c);b>>>=0;d>>>=0;c>>>=0;for(var e=0,g=0;g<d;g++){var k=(v(),D)[b>>>2>>>0],l=(v(),D)[b+4>>>2>>>0];b+=8;for(var n=0;n<l;n++){var p=a,u=(v(),B)[k+n>>>0],w=Uf[p];0===u||10===u?((1===p?sa:r)(Re(w)),w.length=0):w.push(u)}e+=l}(v(),D)[c>>>2>>>0]=e;return 0}function qd(a){return a>>>0}m||Ee();m||(x=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0}),wa());f.wasmBinary&&(ta=f.wasmBinary);f.stackSave=()=>L();f.stackRestore=a=>K(a);f.stackAlloc=a=>Fd(a);
69
+ f.setValue=function(a,b,d="i8"){d.endsWith("*")&&(d="*");switch(d){case "i1":(v(),A)[a>>>0]=b;break;case "i8":(v(),A)[a>>>0]=b;break;case "i16":(v(),Ma)[a>>>1>>>0]=b;break;case "i32":(v(),C)[a>>>2>>>0]=b;break;case "i64":(v(),F)[a>>>3>>>0]=BigInt(b);break;case "float":(v(),Oa)[a>>>2>>>0]=b;break;case "double":(v(),E)[a>>>3>>>0]=b;break;case "*":(v(),D)[a>>>2>>>0]=b;break;default:H(`invalid type for setValue: ${d}`)}};
70
+ f.getValue=function(a,b="i8"){b.endsWith("*")&&(b="*");switch(b){case "i1":return(v(),A)[a>>>0];case "i8":return(v(),A)[a>>>0];case "i16":return(v(),Ma)[a>>>1>>>0];case "i32":return(v(),C)[a>>>2>>>0];case "i64":return(v(),F)[a>>>3>>>0];case "float":return(v(),Oa)[a>>>2>>>0];case "double":return(v(),E)[a>>>3>>>0];case "*":return(v(),D)[a>>>2>>>0];default:H(`invalid type for getValue: ${b}`)}};f.UTF8ToString=R;f.stringToUTF8=Y;f.lengthBytesUTF8=bf;
71
+ var nf=[rd,De,Oe,jb,mb,nb,ob,pb,qb,rb,sb,tb,ub,vb,wb,xb,gc,hc,ic,yc,zc,Bc,Cc,Dc,Ec],mf={1003524:(a,b,d,c,e)=>{if("undefined"==typeof f||!f.Xc)return 1;a=R(Number(a>>>0));a.startsWith("./")&&(a=a.substring(2));a=f.Xc.get(a);if(!a)return 2;b=Number(b>>>0);d=Number(d>>>0);c=Number(c>>>0);if(b+d>a.byteLength)return 3;try{const g=a.subarray(b,b+d);switch(e){case 0:(v(),B).set(g,c>>>0);break;case 1:f.Qd?f.Qd(c,g):f.Id(c,g);break;default:return 4}return 0}catch{return 4}},1004348:(a,b,d)=>{f.td(a,(v(),B).subarray(b>>>
72
+ 0,b+d>>>0))},1004412:()=>f.Sd(),1004454:a=>{f.sd(a)},1004491:()=>{f.Bd()},1004522:()=>{f.Cd()},1004551:()=>{f.Gd()},1004576:a=>f.Ad(a),1004609:a=>f.Ed(a),1004641:(a,b,d)=>{f.ed(Number(a),Number(b),Number(d),!0)},1004704:(a,b,d)=>{f.ed(Number(a),Number(b),Number(d))},1004761:()=>"undefined"!==typeof wasmOffsetConverter,1004818:a=>{f.$b("Abs",a,void 0)},1004869:a=>{f.$b("Neg",a,void 0)},1004920:a=>{f.$b("Floor",a,void 0)},1004973:a=>{f.$b("Ceil",a,void 0)},1005025:a=>{f.$b("Reciprocal",a,void 0)},1005083:a=>
73
+ {f.$b("Sqrt",a,void 0)},1005135:a=>{f.$b("Exp",a,void 0)},1005186:a=>{f.$b("Erf",a,void 0)},1005237:a=>{f.$b("Sigmoid",a,void 0)},1005292:(a,b,d)=>{f.$b("HardSigmoid",a,{alpha:b,beta:d})},1005371:a=>{f.$b("Log",a,void 0)},1005422:a=>{f.$b("Sin",a,void 0)},1005473:a=>{f.$b("Cos",a,void 0)},1005524:a=>{f.$b("Tan",a,void 0)},1005575:a=>{f.$b("Asin",a,void 0)},1005627:a=>{f.$b("Acos",a,void 0)},1005679:a=>{f.$b("Atan",a,void 0)},1005731:a=>{f.$b("Sinh",a,void 0)},1005783:a=>{f.$b("Cosh",a,void 0)},1005835:a=>
74
+ {f.$b("Asinh",a,void 0)},1005888:a=>{f.$b("Acosh",a,void 0)},1005941:a=>{f.$b("Atanh",a,void 0)},1005994:a=>{f.$b("Tanh",a,void 0)},1006046:a=>{f.$b("Not",a,void 0)},1006097:(a,b,d)=>{f.$b("Clip",a,{min:b,max:d})},1006166:a=>{f.$b("Clip",a,void 0)},1006218:(a,b)=>{f.$b("Elu",a,{alpha:b})},1006276:a=>{f.$b("Gelu",a,void 0)},1006328:a=>{f.$b("Relu",a,void 0)},1006380:(a,b)=>{f.$b("LeakyRelu",a,{alpha:b})},1006444:(a,b)=>{f.$b("ThresholdedRelu",a,{alpha:b})},1006514:(a,b)=>{f.$b("Cast",a,{to:b})},1006572:a=>
75
+ {f.$b("Add",a,void 0)},1006623:a=>{f.$b("Sub",a,void 0)},1006674:a=>{f.$b("Mul",a,void 0)},1006725:a=>{f.$b("Div",a,void 0)},1006776:a=>{f.$b("Pow",a,void 0)},1006827:a=>{f.$b("Equal",a,void 0)},1006880:a=>{f.$b("Greater",a,void 0)},1006935:a=>{f.$b("GreaterOrEqual",a,void 0)},1006997:a=>{f.$b("Less",a,void 0)},1007049:a=>{f.$b("LessOrEqual",a,void 0)},1007108:(a,b,d,c,e)=>{f.$b("ReduceMean",a,{keepDims:!!b,noopWithEmptyAxes:!!d,axes:c?Array.from((v(),C).subarray(Number(c)>>>0,Number(e)>>>0)):[]})},
76
+ 1007283:(a,b,d,c,e)=>{f.$b("ReduceMax",a,{keepDims:!!b,noopWithEmptyAxes:!!d,axes:c?Array.from((v(),C).subarray(Number(c)>>>0,Number(e)>>>0)):[]})},1007457:(a,b,d,c,e)=>{f.$b("ReduceMin",a,{keepDims:!!b,noopWithEmptyAxes:!!d,axes:c?Array.from((v(),C).subarray(Number(c)>>>0,Number(e)>>>0)):[]})},1007631:(a,b,d,c,e)=>{f.$b("ReduceProd",a,{keepDims:!!b,noopWithEmptyAxes:!!d,axes:c?Array.from((v(),C).subarray(Number(c)>>>0,Number(e)>>>0)):[]})},1007806:(a,b,d,c,e)=>{f.$b("ReduceSum",a,{keepDims:!!b,noopWithEmptyAxes:!!d,
77
+ axes:c?Array.from((v(),C).subarray(Number(c)>>>0,Number(e)>>>0)):[]})},1007980:(a,b,d,c,e)=>{f.$b("ReduceL1",a,{keepDims:!!b,noopWithEmptyAxes:!!d,axes:c?Array.from((v(),C).subarray(Number(c)>>>0,Number(e)>>>0)):[]})},1008153:(a,b,d,c,e)=>{f.$b("ReduceL2",a,{keepDims:!!b,noopWithEmptyAxes:!!d,axes:c?Array.from((v(),C).subarray(Number(c)>>>0,Number(e)>>>0)):[]})},1008326:(a,b,d,c,e)=>{f.$b("ReduceLogSum",a,{keepDims:!!b,noopWithEmptyAxes:!!d,axes:c?Array.from((v(),C).subarray(Number(c)>>>0,Number(e)>>>
78
+ 0)):[]})},1008503:(a,b,d,c,e)=>{f.$b("ReduceSumSquare",a,{keepDims:!!b,noopWithEmptyAxes:!!d,axes:c?Array.from((v(),C).subarray(Number(c)>>>0,Number(e)>>>0)):[]})},1008683:(a,b,d,c,e)=>{f.$b("ReduceLogSumExp",a,{keepDims:!!b,noopWithEmptyAxes:!!d,axes:c?Array.from((v(),C).subarray(Number(c)>>>0,Number(e)>>>0)):[]})},1008863:a=>{f.$b("Where",a,void 0)},1008916:(a,b,d)=>{f.$b("Transpose",a,{perm:b?Array.from((v(),C).subarray(Number(b)>>>0,Number(d)>>>0)):[]})},1009040:(a,b,d,c)=>{f.$b("DepthToSpace",
79
+ a,{blocksize:b,mode:R(d),format:c?"NHWC":"NCHW"})},1009173:(a,b,d,c)=>{f.$b("DepthToSpace",a,{blocksize:b,mode:R(d),format:c?"NHWC":"NCHW"})},1009306:(a,b,d,c,e,g,k,l,n,p,u,w,y,z,W)=>{f.$b("ConvTranspose",a,{format:n?"NHWC":"NCHW",autoPad:b,dilations:[d],group:c,kernelShape:[e],pads:[g,k],strides:[l],wIsConst:()=>!!(v(),A)[p>>>0],outputPadding:u?Array.from((v(),C).subarray(Number(u)>>>0,Number(w)>>>0)):[],outputShape:y?Array.from((v(),C).subarray(Number(y)>>>0,Number(z)>>>0)):[],activation:R(W)})},
80
+ 1009739:(a,b,d,c,e,g,k,l,n,p,u,w,y,z)=>{f.$b("ConvTranspose",a,{format:l?"NHWC":"NCHW",autoPad:b,dilations:Array.from((v(),C).subarray(Number(d)>>>0,(Number(d)>>>0)+2>>>0)),group:c,kernelShape:Array.from((v(),C).subarray(Number(e)>>>0,(Number(e)>>>0)+2>>>0)),pads:Array.from((v(),C).subarray(Number(g)>>>0,(Number(g)>>>0)+4>>>0)),strides:Array.from((v(),C).subarray(Number(k)>>>0,(Number(k)>>>0)+2>>>0)),wIsConst:()=>!!(v(),A)[n>>>0],outputPadding:p?Array.from((v(),C).subarray(Number(p)>>>0,Number(u)>>>
81
+ 0)):[],outputShape:w?Array.from((v(),C).subarray(Number(w)>>>0,Number(y)>>>0)):[],activation:R(z)})},1010400:(a,b,d,c,e,g,k,l,n,p,u,w,y,z,W)=>{f.$b("ConvTranspose",a,{format:n?"NHWC":"NCHW",autoPad:b,dilations:[d],group:c,kernelShape:[e],pads:[g,k],strides:[l],wIsConst:()=>!!(v(),A)[p>>>0],outputPadding:u?Array.from((v(),C).subarray(Number(u)>>>0,Number(w)>>>0)):[],outputShape:y?Array.from((v(),C).subarray(Number(y)>>>0,Number(z)>>>0)):[],activation:R(W)})},1010833:(a,b,d,c,e,g,k,l,n,p,u,w,y,z)=>
82
+ {f.$b("ConvTranspose",a,{format:l?"NHWC":"NCHW",autoPad:b,dilations:Array.from((v(),C).subarray(Number(d)>>>0,(Number(d)>>>0)+2>>>0)),group:c,kernelShape:Array.from((v(),C).subarray(Number(e)>>>0,(Number(e)>>>0)+2>>>0)),pads:Array.from((v(),C).subarray(Number(g)>>>0,(Number(g)>>>0)+4>>>0)),strides:Array.from((v(),C).subarray(Number(k)>>>0,(Number(k)>>>0)+2>>>0)),wIsConst:()=>!!(v(),A)[n>>>0],outputPadding:p?Array.from((v(),C).subarray(Number(p)>>>0,Number(u)>>>0)):[],outputShape:w?Array.from((v(),
83
+ C).subarray(Number(w)>>>0,Number(y)>>>0)):[],activation:R(z)})},1011494:(a,b)=>{f.$b("GlobalAveragePool",a,{format:b?"NHWC":"NCHW"})},1011585:(a,b,d,c,e,g,k,l,n,p,u,w,y,z)=>{f.$b("AveragePool",a,{format:z?"NHWC":"NCHW",auto_pad:b,ceil_mode:d,count_include_pad:c,storage_order:e,dilations:g?Array.from((v(),C).subarray(Number(g)>>>0,Number(k)>>>0)):[],kernel_shape:l?Array.from((v(),C).subarray(Number(l)>>>0,Number(n)>>>0)):[],pads:p?Array.from((v(),C).subarray(Number(p)>>>0,Number(u)>>>0)):[],strides:w?
84
+ Array.from((v(),C).subarray(Number(w)>>>0,Number(y)>>>0)):[]})},1012064:(a,b)=>{f.$b("GlobalAveragePool",a,{format:b?"NHWC":"NCHW"})},1012155:(a,b,d,c,e,g,k,l,n,p,u,w,y,z)=>{f.$b("AveragePool",a,{format:z?"NHWC":"NCHW",auto_pad:b,ceil_mode:d,count_include_pad:c,storage_order:e,dilations:g?Array.from((v(),C).subarray(Number(g)>>>0,Number(k)>>>0)):[],kernel_shape:l?Array.from((v(),C).subarray(Number(l)>>>0,Number(n)>>>0)):[],pads:p?Array.from((v(),C).subarray(Number(p)>>>0,Number(u)>>>0)):[],strides:w?
85
+ Array.from((v(),C).subarray(Number(w)>>>0,Number(y)>>>0)):[]})},1012634:(a,b)=>{f.$b("GlobalMaxPool",a,{format:b?"NHWC":"NCHW"})},1012721:(a,b,d,c,e,g,k,l,n,p,u,w,y,z)=>{f.$b("MaxPool",a,{format:z?"NHWC":"NCHW",auto_pad:b,ceil_mode:d,count_include_pad:c,storage_order:e,dilations:g?Array.from((v(),C).subarray(Number(g)>>>0,Number(k)>>>0)):[],kernel_shape:l?Array.from((v(),C).subarray(Number(l)>>>0,Number(n)>>>0)):[],pads:p?Array.from((v(),C).subarray(Number(p)>>>0,Number(u)>>>0)):[],strides:w?Array.from((v(),
86
+ C).subarray(Number(w)>>>0,Number(y)>>>0)):[]})},1013196:(a,b)=>{f.$b("GlobalMaxPool",a,{format:b?"NHWC":"NCHW"})},1013283:(a,b,d,c,e,g,k,l,n,p,u,w,y,z)=>{f.$b("MaxPool",a,{format:z?"NHWC":"NCHW",auto_pad:b,ceil_mode:d,count_include_pad:c,storage_order:e,dilations:g?Array.from((v(),C).subarray(Number(g)>>>0,Number(k)>>>0)):[],kernel_shape:l?Array.from((v(),C).subarray(Number(l)>>>0,Number(n)>>>0)):[],pads:p?Array.from((v(),C).subarray(Number(p)>>>0,Number(u)>>>0)):[],strides:w?Array.from((v(),C).subarray(Number(w)>>>
87
+ 0,Number(y)>>>0)):[]})},1013758:(a,b,d,c,e)=>{f.$b("Gemm",a,{alpha:b,beta:d,transA:c,transB:e})},1013862:a=>{f.$b("MatMul",a,void 0)},1013916:(a,b,d,c)=>{f.$b("ArgMax",a,{keepDims:!!b,selectLastIndex:!!d,axis:c})},1014024:(a,b,d,c)=>{f.$b("ArgMin",a,{keepDims:!!b,selectLastIndex:!!d,axis:c})},1014132:(a,b)=>{f.$b("Softmax",a,{axis:b})},1014195:(a,b)=>{f.$b("Concat",a,{axis:b})},1014255:(a,b,d,c,e)=>{f.$b("Split",a,{axis:b,numOutputs:d,splitSizes:c?Array.from((v(),C).subarray(Number(c)>>>0,Number(e)>>>
88
+ 0)):[]})},1014411:a=>{f.$b("Expand",a,void 0)},1014465:(a,b)=>{f.$b("Gather",a,{axis:Number(b)})},1014536:(a,b)=>{f.$b("GatherElements",a,{axis:Number(b)})},1014615:(a,b)=>{f.$b("GatherND",a,{batch_dims:Number(b)})},1014694:(a,b,d,c,e,g,k,l,n,p,u)=>{f.$b("Resize",a,{antialias:b,axes:d?Array.from((v(),C).subarray(Number(d)>>>0,Number(c)>>>0)):[],coordinateTransformMode:R(e),cubicCoeffA:g,excludeOutside:k,extrapolationValue:l,keepAspectRatioPolicy:R(n),mode:R(p),nearestMode:R(u)})},1015056:(a,b,d,c,
89
+ e,g,k)=>{f.$b("Slice",a,{starts:b?Array.from((v(),C).subarray(Number(b)>>>0,Number(d)>>>0)):[],ends:c?Array.from((v(),C).subarray(Number(c)>>>0,Number(e)>>>0)):[],axes:g?Array.from((v(),C).subarray(Number(g)>>>0,Number(k)>>>0)):[]})},1015320:a=>{f.$b("Tile",a,void 0)},1015372:(a,b,d)=>{f.$b("InstanceNormalization",a,{epsilon:b,format:d?"NHWC":"NCHW"})},1015486:(a,b,d)=>{f.$b("InstanceNormalization",a,{epsilon:b,format:d?"NHWC":"NCHW"})},1015600:a=>{f.$b("Range",a,void 0)},1015653:(a,b)=>{f.$b("Einsum",
90
+ a,{equation:R(b)})},1015734:(a,b,d,c,e)=>{f.$b("Pad",a,{mode:b,value:d,pads:c?Array.from((v(),C).subarray(Number(c)>>>0,Number(e)>>>0)):[]})},1015877:(a,b,d,c,e,g)=>{f.$b("BatchNormalization",a,{epsilon:b,momentum:d,spatial:!!e,trainingMode:!!c,format:g?"NHWC":"NCHW"})},1016046:(a,b,d,c,e,g)=>{f.$b("BatchNormalization",a,{epsilon:b,momentum:d,spatial:!!e,trainingMode:!!c,format:g?"NHWC":"NCHW"})},1016215:(a,b,d)=>{f.$b("CumSum",a,{exclusive:Number(b),reverse:Number(d)})},1016312:(a,b,d)=>{f.$b("DequantizeLinear",
91
+ a,{axis:b,blockSize:d})},1016402:(a,b,d,c,e)=>{f.$b("GridSample",a,{align_corners:b,mode:R(d),padding_mode:R(c),format:e?"NHWC":"NCHW"})},1016572:(a,b,d,c,e)=>{f.$b("GridSample",a,{align_corners:b,mode:R(d),padding_mode:R(c),format:e?"NHWC":"NCHW"})},1016742:(a,b)=>{f.$b("ScatterND",a,{reduction:R(b)})},1016827:(a,b,d,c,e,g,k,l,n)=>{f.$b("Attention",a,{numHeads:b,isUnidirectional:d,maskFilterValue:c,scale:e,doRotary:g,qkvHiddenSizes:k?Array.from((v(),C).subarray(Number(l)>>>0,Number(l)+k>>>0)):[],
92
+ pastPresentShareBuffer:!!n})},1017099:a=>{f.$b("BiasAdd",a,void 0)},1017154:a=>{f.$b("BiasSplitGelu",a,void 0)},1017215:a=>{f.$b("FastGelu",a,void 0)},1017271:(a,b,d,c,e,g,k,l,n,p,u,w,y,z,W,kb)=>{f.$b("Conv",a,{format:w?"NHWC":"NCHW",auto_pad:b,dilations:d?Array.from((v(),C).subarray(Number(d)>>>0,Number(c)>>>0)):[],group:e,kernel_shape:g?Array.from((v(),C).subarray(Number(g)>>>0,Number(k)>>>0)):[],pads:l?Array.from((v(),C).subarray(Number(l)>>>0,Number(n)>>>0)):[],strides:p?Array.from((v(),C).subarray(Number(p)>>>
93
+ 0,Number(u)>>>0)):[],w_is_const:()=>!!(v(),A)[Number(y)>>>0],activation:R(z),activation_params:W?Array.from((v(),Oa).subarray(Number(W)>>>0,Number(kb)>>>0)):[]})},1017855:a=>{f.$b("Gelu",a,void 0)},1017907:(a,b,d,c,e,g,k,l,n)=>{f.$b("GroupQueryAttention",a,{numHeads:b,kvNumHeads:d,scale:c,softcap:e,doRotary:g,rotaryInterleaved:k,smoothSoftmax:l,localWindowSize:n})},1018124:(a,b,d,c)=>{f.$b("LayerNormalization",a,{axis:b,epsilon:d,simplified:!!c})},1018235:(a,b,d,c)=>{f.$b("LayerNormalization",a,{axis:b,
94
+ epsilon:d,simplified:!!c})},1018346:(a,b,d,c,e,g)=>{f.$b("MatMulNBits",a,{k:b,n:d,accuracyLevel:c,bits:e,blockSize:g})},1018473:(a,b,d,c,e,g)=>{f.$b("MultiHeadAttention",a,{numHeads:b,isUnidirectional:d,maskFilterValue:c,scale:e,doRotary:g})},1018632:(a,b)=>{f.$b("QuickGelu",a,{alpha:b})},1018696:(a,b,d,c,e)=>{f.$b("RotaryEmbedding",a,{interleaved:!!b,numHeads:d,rotaryEmbeddingDim:c,scale:e})},1018835:(a,b,d)=>{f.$b("SkipLayerNormalization",a,{epsilon:b,simplified:!!d})},1018937:(a,b,d)=>{f.$b("SkipLayerNormalization",
95
+ a,{epsilon:b,simplified:!!d})},1019039:(a,b,d,c)=>{f.$b("GatherBlockQuantized",a,{gatherAxis:b,quantizeAxis:d,blockSize:c})},1019160:a=>{f.Fd(a)},1019194:(a,b)=>f.Hd(Number(a),Number(b),f.Yc.Kd,f.Yc.errors)};function Za(a,b,d){return Af(async()=>{await f.Dd(Number(a),Number(b),Number(d))})}function Ya(){return"undefined"!==typeof wasmOffsetConverter}
96
+ var vd,Ia,wd,I,xd,Fa,La,yd,zd,Ad,Bd,Cd,J,Dd,Ed,K,Fd,L,Gd,Hd,Id,Jd,dynCall_vii,Kd,dynCall_v,Ld,Md,dynCall_iii,Nd,Od,Pd,Qd,dynCall_vi,Rd,Sd,Td,Ud,Vd,Wd,Xd,Yd,Zd,$d,ae,be,ce,de,ee,fe,ge,he,ie,je,ke,le,me,ne,oe,pe,qe,re,se,te,Xa;function Mc(a,b,d,c){var e=L();try{return Qd(a,b,d,c)}catch(g){K(e);if(g!==g+0)throw g;J(1,0)}}function Lc(a,b,d){var c=L();try{return dynCall_iii(a,b,d)}catch(e){K(c);if(e!==e+0)throw e;J(1,0)}}
97
+ function ad(a){var b=L();try{dynCall_v(a)}catch(d){K(b);if(d!==d+0)throw d;J(1,0)}}function Kc(a,b){var d=L();try{return Kd(a,b)}catch(c){K(d);if(c!==c+0)throw c;J(1,0)}}function cd(a,b,d){var c=L();try{dynCall_vii(a,b,d)}catch(e){K(c);if(e!==e+0)throw e;J(1,0)}}function bd(a,b){var d=L();try{dynCall_vi(a,b)}catch(c){K(d);if(c!==c+0)throw c;J(1,0)}}function Qc(a,b,d,c,e,g,k){var l=L();try{return Od(a,b,d,c,e,g,k)}catch(n){K(l);if(n!==n+0)throw n;J(1,0)}}
98
+ function gd(a,b,d,c,e,g){var k=L();try{Ld(a,b,d,c,e,g)}catch(l){K(k);if(l!==l+0)throw l;J(1,0)}}function ed(a,b,d,c){var e=L();try{Pd(a,b,d,c)}catch(g){K(e);if(g!==g+0)throw g;J(1,0)}}function fd(a,b,d,c,e){var g=L();try{Md(a,b,d,c,e)}catch(k){K(g);if(k!==k+0)throw k;J(1,0)}}function hd(a,b,d,c,e,g,k){var l=L();try{Sd(a,b,d,c,e,g,k)}catch(n){K(l);if(n!==n+0)throw n;J(1,0)}}function pd(a,b,d,c,e,g,k){var l=L();try{Td(a,b,d,c,e,g,k)}catch(n){K(l);if(n!==n+0)throw n;J(1,0)}}
99
+ function od(a,b,d,c,e,g,k,l){var n=L();try{Xd(a,b,d,c,e,g,k,l)}catch(p){K(n);if(p!==p+0)throw p;J(1,0)}}function Nc(a,b,d,c,e){var g=L();try{return Rd(a,b,d,c,e)}catch(k){K(g);if(k!==k+0)throw k;J(1,0)}}function Wc(a,b,d){var c=L();try{return Yd(a,b,d)}catch(e){K(c);if(e!==e+0)throw e;J(1,0)}}function jd(a,b,d,c,e,g,k,l){var n=L();try{Zd(a,b,d,c,e,g,k,l)}catch(p){K(n);if(p!==p+0)throw p;J(1,0)}}
100
+ function md(a,b,d,c,e,g,k,l,n,p,u,w){var y=L();try{Ud(a,b,d,c,e,g,k,l,n,p,u,w)}catch(z){K(y);if(z!==z+0)throw z;J(1,0)}}function Pc(a,b,d,c,e,g){var k=L();try{return Vd(a,b,d,c,e,g)}catch(l){K(k);if(l!==l+0)throw l;J(1,0)}}function Zc(a,b,d){var c=L();try{return $d(a,b,d)}catch(e){K(c);if(e!==e+0)throw e;J(1,0);return 0n}}function kd(a,b,d,c,e,g,k,l,n){var p=L();try{Nd(a,b,d,c,e,g,k,l,n)}catch(u){K(p);if(u!==u+0)throw u;J(1,0)}}
101
+ function Jc(a){var b=L();try{return ae(a)}catch(d){K(b);if(d!==d+0)throw d;J(1,0)}}function Yc(a,b){var d=L();try{return pe(a,b)}catch(c){K(d);if(c!==c+0)throw c;J(1,0);return 0n}}function Xc(a){var b=L();try{return be(a)}catch(d){K(b);if(d!==d+0)throw d;J(1,0);return 0n}}function Vc(a,b,d,c){var e=L();try{return he(a,b,d,c)}catch(g){K(e);if(g!==g+0)throw g;J(1,0)}}function Uc(a,b,d,c,e){var g=L();try{return ie(a,b,d,c,e)}catch(k){K(g);if(k!==k+0)throw k;J(1,0)}}
102
+ function Tc(a,b,d,c,e,g){var k=L();try{return je(a,b,d,c,e,g)}catch(l){K(k);if(l!==l+0)throw l;J(1,0)}}function Oc(a,b,d,c,e,g){var k=L();try{return ke(a,b,d,c,e,g)}catch(l){K(k);if(l!==l+0)throw l;J(1,0)}}function Rc(a,b,d,c,e,g,k,l){var n=L();try{return Wd(a,b,d,c,e,g,k,l)}catch(p){K(n);if(p!==p+0)throw p;J(1,0)}}function $c(a,b,d,c,e){var g=L();try{return le(a,b,d,c,e)}catch(k){K(g);if(k!==k+0)throw k;J(1,0);return 0n}}
103
+ function Ic(a,b,d,c){var e=L();try{return me(a,b,d,c)}catch(g){K(e);if(g!==g+0)throw g;J(1,0)}}function Gc(a,b,d,c){var e=L();try{return ne(a,b,d,c)}catch(g){K(e);if(g!==g+0)throw g;J(1,0)}}function Sc(a,b,d,c,e,g,k,l,n,p,u,w){var y=L();try{return oe(a,b,d,c,e,g,k,l,n,p,u,w)}catch(z){K(y);if(z!==z+0)throw z;J(1,0)}}function ld(a,b,d,c,e,g,k,l,n,p,u){var w=L();try{fe(a,b,d,c,e,g,k,l,n,p,u)}catch(y){K(w);if(y!==y+0)throw y;J(1,0)}}
104
+ function nd(a,b,d,c,e,g,k,l,n,p,u,w,y,z,W,kb){var Vf=L();try{ge(a,b,d,c,e,g,k,l,n,p,u,w,y,z,W,kb)}catch(lb){K(Vf);if(lb!==lb+0)throw lb;J(1,0)}}function Hc(a,b,d){var c=L();try{return ce(a,b,d)}catch(e){K(c);if(e!==e+0)throw e;J(1,0)}}function Fc(a,b,d){var c=L();try{return de(a,b,d)}catch(e){K(c);if(e!==e+0)throw e;J(1,0)}}function dd(a,b,d,c){var e=L();try{ee(a,b,d,c)}catch(g){K(e);if(g!==g+0)throw g;J(1,0)}}
105
+ function td(){var a=G;a=Object.assign({},a);var b=c=>e=>c(e)>>>0,d=c=>()=>c()>>>0;a.tb=b(a.tb);a.Xb=d(a.Xb);a.Zb=b(a.Zb);a.lc=b(a.lc);a.mc=d(a.mc);a.qc=b(a.qc);return a}function Da(){if(0<xe)ye=Da;else if(m)xa?.(f),Ra();else{for(var a=we;0<a.length;)a.shift()(f);0<xe?ye=Da:(f.calledRun=!0,t||(Ra(),xa?.(f)))}}var G;m||(G=await (Ca()),Da());f.PTR_SIZE=4;Qa?moduleRtn=f:moduleRtn=new Promise((a,b)=>{xa=a;ya=b});
106
+ ;return moduleRtn}export default ortWasmThreaded;var isPthread=globalThis.self?.name?.startsWith("em-pthread");var isNode=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";if(isNode)isPthread=(await import("worker_threads")).workerData==="em-pthread";isPthread&&ortWasmThreaded();
ort/ort-wasm-simd-threaded.jsep.wasm ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:78feeeb3d08f6bcee94d938ed322f69073bb8076b5f9d34697a574ffba8deb48
3
+ size 26827543
source/demo/web/compare.html ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Hendrix Listening Lab — compare transcription systems</title>
7
+ <link rel="icon" type="image/png" href="/favicon.png" />
8
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
9
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
10
+ <link
11
+ href="https://fonts.googleapis.com/css2?family=Bodoni+Moda:ital,opsz,wght@0,6..96,600;1,6..96,600&family=IBM+Plex+Mono:wght@400;500;600&family=Manrope:wght@400;500;600;700&display=swap"
12
+ rel="stylesheet"
13
+ media="print"
14
+ onload="this.media='all'"
15
+ />
16
+ <noscript>
17
+ <link
18
+ href="https://fonts.googleapis.com/css2?family=Bodoni+Moda:ital,opsz,wght@0,6..96,600;1,6..96,600&family=IBM+Plex+Mono:wght@400;500;600&family=Manrope:wght@400;500;600;700&display=swap"
19
+ rel="stylesheet"
20
+ />
21
+ </noscript>
22
+ </head>
23
+ <body data-state="idle" class="compare-body">
24
+ <div id="root"></div>
25
+ <script type="module" src="/src/compare.tsx"></script>
26
+ </body>
27
+ </html>
source/demo/web/index.html ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>muscriptor</title>
7
+ <link rel="icon" type="image/svg+xml" href="/muscriptor-mark-v4-pink.svg" />
8
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
9
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
10
+ <!-- Loaded non-render-blocking: the fallback stack paints instantly (this
11
+ tool may run offline), and the web fonts swap in once available. -->
12
+ <link
13
+ href="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Hanken+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap"
14
+ rel="stylesheet"
15
+ media="print"
16
+ onload="this.media='all'"
17
+ />
18
+ <noscript>
19
+ <link
20
+ href="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Hanken+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap"
21
+ rel="stylesheet"
22
+ />
23
+ </noscript>
24
+ </head>
25
+ <body data-state="idle">
26
+ <div id="root"></div>
27
+ <script type="module" src="/src/main.tsx"></script>
28
+ </body>
29
+ </html>
source/demo/web/local.html ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
6
+ <meta name="theme-color" content="#090a0d" />
7
+ <link rel="icon" href="/favicon.png" />
8
+ <title>Hendrix — on-device transcription</title>
9
+ </head>
10
+ <body>
11
+ <div id="root"></div>
12
+ <script type="module" src="/src/local.tsx"></script>
13
+ </body>
14
+ </html>
source/demo/web/package.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "muscriptor-web",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "packageManager": "pnpm@10.20.0",
7
+ "scripts": {
8
+ "dev": "vite",
9
+ "dev:proxy": "BACKEND_URL=https://muscriptor.kyutai.org vite",
10
+ "build": "tsc --noEmit && vite build",
11
+ "preview": "vite preview",
12
+ "test:local:e2e": "node --test ../../tests/browser_local_e2e.mjs",
13
+ "test:local:wasm": "node --test ../../tests/browser_local_wasm_e2e.mjs"
14
+ },
15
+ "devDependencies": {
16
+ "@tailwindcss/vite": "^4.3.2",
17
+ "@types/node": "^25.9.1",
18
+ "@types/react": "^19.2.17",
19
+ "@types/react-dom": "^19.2.3",
20
+ "@vitejs/plugin-react": "^6.0.3",
21
+ "playwright": "1.61.1",
22
+ "tailwindcss": "^4.3.2",
23
+ "typescript": "^6.0.3",
24
+ "vite": "^8.0.14"
25
+ },
26
+ "dependencies": {
27
+ "clsx": "^2.1.1",
28
+ "onnxruntime-web": "1.27.0",
29
+ "react": "^19.2.7",
30
+ "react-dom": "^19.2.7",
31
+ "spessasynth_lib": "^4.3.8",
32
+ "tone": "^15.1.22"
33
+ }
34
+ }
source/demo/web/pnpm-lock.yaml ADDED
@@ -0,0 +1,1025 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ lockfileVersion: '9.0'
2
+
3
+ settings:
4
+ autoInstallPeers: true
5
+ excludeLinksFromLockfile: false
6
+
7
+ importers:
8
+
9
+ .:
10
+ dependencies:
11
+ clsx:
12
+ specifier: ^2.1.1
13
+ version: 2.1.1
14
+ onnxruntime-web:
15
+ specifier: 1.27.0
16
+ version: 1.27.0
17
+ react:
18
+ specifier: ^19.2.7
19
+ version: 19.2.7
20
+ react-dom:
21
+ specifier: ^19.2.7
22
+ version: 19.2.7(react@19.2.7)
23
+ spessasynth_lib:
24
+ specifier: ^4.3.8
25
+ version: 4.3.8
26
+ tone:
27
+ specifier: ^15.1.22
28
+ version: 15.1.22
29
+ devDependencies:
30
+ '@tailwindcss/vite':
31
+ specifier: ^4.3.2
32
+ version: 4.3.2(vite@8.0.16(@types/node@25.9.2)(jiti@2.7.0))
33
+ '@types/node':
34
+ specifier: ^25.9.1
35
+ version: 25.9.2
36
+ '@types/react':
37
+ specifier: ^19.2.17
38
+ version: 19.2.17
39
+ '@types/react-dom':
40
+ specifier: ^19.2.3
41
+ version: 19.2.3(@types/react@19.2.17)
42
+ '@vitejs/plugin-react':
43
+ specifier: ^6.0.3
44
+ version: 6.0.3(vite@8.0.16(@types/node@25.9.2)(jiti@2.7.0))
45
+ playwright:
46
+ specifier: 1.61.1
47
+ version: 1.61.1
48
+ tailwindcss:
49
+ specifier: ^4.3.2
50
+ version: 4.3.2
51
+ typescript:
52
+ specifier: ^6.0.3
53
+ version: 6.0.3
54
+ vite:
55
+ specifier: ^8.0.14
56
+ version: 8.0.16(@types/node@25.9.2)(jiti@2.7.0)
57
+
58
+ packages:
59
+
60
+ '@babel/runtime@7.29.7':
61
+ resolution: {integrity: sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==}
62
+ engines: {node: '>=6.9.0'}
63
+
64
+ '@emnapi/core@1.10.0':
65
+ resolution: {integrity: sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==}
66
+
67
+ '@emnapi/runtime@1.10.0':
68
+ resolution: {integrity: sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==}
69
+
70
+ '@emnapi/wasi-threads@1.2.1':
71
+ resolution: {integrity: sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==}
72
+
73
+ '@jridgewell/gen-mapping@0.3.13':
74
+ resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==}
75
+
76
+ '@jridgewell/remapping@2.3.5':
77
+ resolution: {integrity: sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==}
78
+
79
+ '@jridgewell/resolve-uri@3.1.2':
80
+ resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==}
81
+ engines: {node: '>=6.0.0'}
82
+
83
+ '@jridgewell/sourcemap-codec@1.5.5':
84
+ resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==}
85
+
86
+ '@jridgewell/trace-mapping@0.3.31':
87
+ resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==}
88
+
89
+ '@napi-rs/wasm-runtime@1.1.4':
90
+ resolution: {integrity: sha512-3NQNNgA1YSlJb/kMH1ildASP9HW7/7kYnRI2szWJaofaS1hWmbGI4H+d3+22aGzXXN9IJ+n+GiFVcGipJP18ow==}
91
+ peerDependencies:
92
+ '@emnapi/core': ^1.7.1
93
+ '@emnapi/runtime': ^1.7.1
94
+
95
+ '@oxc-project/types@0.133.0':
96
+ resolution: {integrity: sha512-KzkdCd6Uxqnf6l3HOw1xfatAlUURA0g14cvBYFyJ5SaNOQbOUvBr9PKArcPcrNIeRsBdgcUzOGrhKveVpvOIGA==}
97
+
98
+ '@protobufjs/aspromise@1.1.2':
99
+ resolution: {integrity: sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==}
100
+
101
+ '@protobufjs/base64@1.1.2':
102
+ resolution: {integrity: sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==}
103
+
104
+ '@protobufjs/codegen@2.0.5':
105
+ resolution: {integrity: sha512-zgXFLzW3Ap33e6d0Wlj4MGIm6Ce8O89n/apUaGNB/jx+hw+ruWEp7EwGUshdLKVRCxZW12fp9r40E1mQrf/34g==}
106
+
107
+ '@protobufjs/eventemitter@1.1.1':
108
+ resolution: {integrity: sha512-vW1GmwMZNnL+gMRaovlh9yZX74kc+TTU3FObkkurpMaRtBfLP3ldjS9KQWlwZgraRE0+dheEEoAxdzcJQ8eXZg==}
109
+
110
+ '@protobufjs/fetch@1.1.1':
111
+ resolution: {integrity: sha512-GpptLrs57adMSuHi3VNj0mAF8dwh36LMaYF6XyJ6JMWlVsc+t42tm1HSEDmOs3A8fC9yyeisgLhsTVQokOZ0zw==}
112
+
113
+ '@protobufjs/float@1.0.2':
114
+ resolution: {integrity: sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==}
115
+
116
+ '@protobufjs/path@1.1.2':
117
+ resolution: {integrity: sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==}
118
+
119
+ '@protobufjs/pool@1.1.0':
120
+ resolution: {integrity: sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==}
121
+
122
+ '@protobufjs/utf8@1.1.2':
123
+ resolution: {integrity: sha512-b1UQwcEZ4yCnMCD8DAL1VlbvBJE9/IX4FTIp7BG1xYpf29SLazLSrqUkj4w7Y5y7cCVP6E5tcqqcI0xemPkHug==}
124
+
125
+ '@rolldown/binding-android-arm64@1.0.3':
126
+ resolution: {integrity: sha512-454rs7jHngixp/NMxd5srYD57OnzSlZ/eFTETjORQHLwJG1lRtmNOJcBerZlfu4GjKqeq8aCCIQrMdHyhI51Hw==}
127
+ engines: {node: ^20.19.0 || >=22.12.0}
128
+ cpu: [arm64]
129
+ os: [android]
130
+
131
+ '@rolldown/binding-darwin-arm64@1.0.3':
132
+ resolution: {integrity: sha512-PcAhP+ynjURNyy8SKGl5DQP94aGuB/7JrXJb/t7P+hanXvQVMWzUvRRhBAcg/lNRadBhoUPqSoP4xw5tR/KBEA==}
133
+ engines: {node: ^20.19.0 || >=22.12.0}
134
+ cpu: [arm64]
135
+ os: [darwin]
136
+
137
+ '@rolldown/binding-darwin-x64@1.0.3':
138
+ resolution: {integrity: sha512-9YpfeUvSE2RS7wysJ81uOZkXJz7f7Q55H2Gvp3VEw/EsahqDtrphrZ0EwDLK5vvKOzaCrBsjF8JmnMLcUt78Gg==}
139
+ engines: {node: ^20.19.0 || >=22.12.0}
140
+ cpu: [x64]
141
+ os: [darwin]
142
+
143
+ '@rolldown/binding-freebsd-x64@1.0.3':
144
+ resolution: {integrity: sha512-yB1IlAsSNHncV6SCTL27/MVGR5htvQsoGxIv5KMGXALp+Ll1wYsn+x98M9MW7qa+NdSbvrrY7ANI4wLJ0n1e6g==}
145
+ engines: {node: ^20.19.0 || >=22.12.0}
146
+ cpu: [x64]
147
+ os: [freebsd]
148
+
149
+ '@rolldown/binding-linux-arm-gnueabihf@1.0.3':
150
+ resolution: {integrity: sha512-Yi30IVAAfLUCy2MseFjbB1jAMDl1VMCAas5StnYp8da9+CKvMd2H2cbEjWcw5NPaPqzvYkVIaF1nNUG+b7u/sw==}
151
+ engines: {node: ^20.19.0 || >=22.12.0}
152
+ cpu: [arm]
153
+ os: [linux]
154
+
155
+ '@rolldown/binding-linux-arm64-gnu@1.0.3':
156
+ resolution: {integrity: sha512-jsO7R8To+AdlYgUmN5sHSCZbfhtMBkO0WUx8iORQnPcMMdgr7qM2DQmMwgabs3GhNztdmoKkMKQFHD6DTMCIQw==}
157
+ engines: {node: ^20.19.0 || >=22.12.0}
158
+ cpu: [arm64]
159
+ os: [linux]
160
+
161
+ '@rolldown/binding-linux-arm64-musl@1.0.3':
162
+ resolution: {integrity: sha512-VWkUHwWriDciit80wleYwKILoR/KMvxh/IdwS/paX+ZgpuRpCrKLUdadJbc0NpBEiyhpYawsJ73j9aCvOH+f7Q==}
163
+ engines: {node: ^20.19.0 || >=22.12.0}
164
+ cpu: [arm64]
165
+ os: [linux]
166
+
167
+ '@rolldown/binding-linux-ppc64-gnu@1.0.3':
168
+ resolution: {integrity: sha512-5f1laC0SlIR0yDbFCd8acUhvJIag6N3zC5P7oUPN6wX0aOma+uKJ0wBDH5aq7I1PVI2ttTlhJwzwRIBnLiSGEg==}
169
+ engines: {node: ^20.19.0 || >=22.12.0}
170
+ cpu: [ppc64]
171
+ os: [linux]
172
+
173
+ '@rolldown/binding-linux-s390x-gnu@1.0.3':
174
+ resolution: {integrity: sha512-Iq4ko0r4XsgbrF/LunNgHtAGLRRVE2kXonAXQ/MV0mC6jQpMOhW1SvtZja2EhC/kd05++bP78dsqBeIQyYJ6Yg==}
175
+ engines: {node: ^20.19.0 || >=22.12.0}
176
+ cpu: [s390x]
177
+ os: [linux]
178
+
179
+ '@rolldown/binding-linux-x64-gnu@1.0.3':
180
+ resolution: {integrity: sha512-B8m6tD5+/N5FeNQFbKlLA/2yVq9ycQP1SeedyEYYKWBNR3ZQbkvIUcNnDNM03lO1l5F2roiiFJGgvoLLyZXtSg==}
181
+ engines: {node: ^20.19.0 || >=22.12.0}
182
+ cpu: [x64]
183
+ os: [linux]
184
+
185
+ '@rolldown/binding-linux-x64-musl@1.0.3':
186
+ resolution: {integrity: sha512-pSdpdUJHkuCxun9LE7jvgUB9qsRgaiyNNCX7m/AvHTcq67AiT/Yhoxvw5zPfhrM8k/BfP8ce/hMOpthKDpEUow==}
187
+ engines: {node: ^20.19.0 || >=22.12.0}
188
+ cpu: [x64]
189
+ os: [linux]
190
+
191
+ '@rolldown/binding-openharmony-arm64@1.0.3':
192
+ resolution: {integrity: sha512-OXXS3RKJgX2uLwM+gYyuH5omcH8fL1LJs96pZGgtetVCahON57+d4SJHzTgZiOjxgGkSnpXpOsWuPDGAKAigEg==}
193
+ engines: {node: ^20.19.0 || >=22.12.0}
194
+ cpu: [arm64]
195
+ os: [openharmony]
196
+
197
+ '@rolldown/binding-wasm32-wasi@1.0.3':
198
+ resolution: {integrity: sha512-JTtb8BWFynicNSoPrehsCzBtOKjZ6jhMiPFEmOiuXg1Fl8dn2KHQob+GuPSGR0dryQa1PQJbzjF3dqO/whhjLg==}
199
+ engines: {node: ^20.19.0 || >=22.12.0}
200
+ cpu: [wasm32]
201
+
202
+ '@rolldown/binding-win32-arm64-msvc@1.0.3':
203
+ resolution: {integrity: sha512-gEdFFEN70A/jxb2svrWsN3aDL7OUtmvlOy+6fa2jxG8K0wQ1ZbdeLGnidov6Yu5/733dI5ySfzFlQ/cb0bSz1g==}
204
+ engines: {node: ^20.19.0 || >=22.12.0}
205
+ cpu: [arm64]
206
+ os: [win32]
207
+
208
+ '@rolldown/binding-win32-x64-msvc@1.0.3':
209
+ resolution: {integrity: sha512-eXB7CHuaQdqmJcc3koCNtNPmT/bj2gc999kUFgBxG8Ac0NdgXc4rkCHhqrgrhN3zddvvvrgzj1e90SuSfmyIXA==}
210
+ engines: {node: ^20.19.0 || >=22.12.0}
211
+ cpu: [x64]
212
+ os: [win32]
213
+
214
+ '@rolldown/pluginutils@1.0.1':
215
+ resolution: {integrity: sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==}
216
+
217
+ '@tailwindcss/node@4.3.2':
218
+ resolution: {integrity: sha512-yWP/sqEcBLaD8JuA6zNwxoYKr75qxTioYwlRwekj5Jr/I5GXnoJfjetH/psLUIv74cYTH2lBUEzBkinthoYcBg==}
219
+
220
+ '@tailwindcss/oxide-android-arm64@4.3.2':
221
+ resolution: {integrity: sha512-WHxqIuHpvZ5VtdX6GTl1Ik/Vp2YuN42Et+0CdeaVd/frQ9jAvGmvR8vLT+jk3e8/Q3x8kECB9+R17pgpp2BulA==}
222
+ engines: {node: '>= 20'}
223
+ cpu: [arm64]
224
+ os: [android]
225
+
226
+ '@tailwindcss/oxide-darwin-arm64@4.3.2':
227
+ resolution: {integrity: sha512-GZypeUY/IDJW3877KeM+O67vbXr3MBnbtEL4aYhNErv/JWZhye2vGSWWG9tB6iiqR2MqRNkY8IOUy4NdSZV26w==}
228
+ engines: {node: '>= 20'}
229
+ cpu: [arm64]
230
+ os: [darwin]
231
+
232
+ '@tailwindcss/oxide-darwin-x64@4.3.2':
233
+ resolution: {integrity: sha512-UIIzmefR6KO1sDU7MzRqAxC8iBpft/VhkGjTjnhoS6k7Z3rQ9wEgA1ODSiyH/tcSYssulNm4Ci3hOeK1jH7ccQ==}
234
+ engines: {node: '>= 20'}
235
+ cpu: [x64]
236
+ os: [darwin]
237
+
238
+ '@tailwindcss/oxide-freebsd-x64@4.3.2':
239
+ resolution: {integrity: sha512-GN+uAmcI6DNspnCDwtOAZrTz6oukJnp337qZvxqCGLd3BHBzJpO0ZbTLRvJNdztOeAmTzewewGIMPb0tk2R4WA==}
240
+ engines: {node: '>= 20'}
241
+ cpu: [x64]
242
+ os: [freebsd]
243
+
244
+ '@tailwindcss/oxide-linux-arm-gnueabihf@4.3.2':
245
+ resolution: {integrity: sha512-4ABn7qSbdHRwTiDiuWNegCyb5+2FJ4vKIKc3DmKrvAFw7MU1Lm11dIkTPwUaFdTzc7IsOpDbqBrlh0x6y36U/w==}
246
+ engines: {node: '>= 20'}
247
+ cpu: [arm]
248
+ os: [linux]
249
+
250
+ '@tailwindcss/oxide-linux-arm64-gnu@4.3.2':
251
+ resolution: {integrity: sha512-wDgEIGwoM8w8pufh9LVt1PahDgNdKXrLC2qfAnV3vAmococ9RWbxeAw4pxPttd/TsJfwjyLf90Dg1y9y8I6Emw==}
252
+ engines: {node: '>= 20'}
253
+ cpu: [arm64]
254
+ os: [linux]
255
+
256
+ '@tailwindcss/oxide-linux-arm64-musl@4.3.2':
257
+ resolution: {integrity: sha512-J5Nuk0uZQIiMTJj3LEx4sAA9tMFUoXQZFv1J6An+QGYe53HKRJuFDi0rpq/tuouCZeAbOBY3kQ6g8qeD4TUjtA==}
258
+ engines: {node: '>= 20'}
259
+ cpu: [arm64]
260
+ os: [linux]
261
+
262
+ '@tailwindcss/oxide-linux-x64-gnu@4.3.2':
263
+ resolution: {integrity: sha512-kqCZpSKOBEJO4mz7OqWoofBZeXTAwaVGPj0ErAj7CojmhKpWVWVOnrt9dE8odoIraZq4oj3ausM37kXi+Tow8w==}
264
+ engines: {node: '>= 20'}
265
+ cpu: [x64]
266
+ os: [linux]
267
+
268
+ '@tailwindcss/oxide-linux-x64-musl@4.3.2':
269
+ resolution: {integrity: sha512-cixpqbh2toJDmkuCRI68nXA8ZxNmdK9Y+9v5h3MC3ZQKy/0BO8AWzlkWyRM7JAFSGBlfig4YVTPsK6MVgqz1uw==}
270
+ engines: {node: '>= 20'}
271
+ cpu: [x64]
272
+ os: [linux]
273
+
274
+ '@tailwindcss/oxide-wasm32-wasi@4.3.2':
275
+ resolution: {integrity: sha512-4ec2Z/LOmRsAgU23CS4xeJfcJlmRg94A/XrbGRCF1gyU/zdDfRLYDVsS+ynSZCmGNxQ1jQriQOKMQeQxBA3Isw==}
276
+ engines: {node: '>=14.0.0'}
277
+ cpu: [wasm32]
278
+ bundledDependencies:
279
+ - '@napi-rs/wasm-runtime'
280
+ - '@emnapi/core'
281
+ - '@emnapi/runtime'
282
+ - '@tybys/wasm-util'
283
+ - '@emnapi/wasi-threads'
284
+ - tslib
285
+
286
+ '@tailwindcss/oxide-win32-arm64-msvc@4.3.2':
287
+ resolution: {integrity: sha512-Zyr/M0+XcYZu3bZrUytc7TXvrk0ftWfl8gN2MwekNDzhqhKRUucMPSeOzM0o0wH5AWOU49BsKRrfKxI2atCPMQ==}
288
+ engines: {node: '>= 20'}
289
+ cpu: [arm64]
290
+ os: [win32]
291
+
292
+ '@tailwindcss/oxide-win32-x64-msvc@4.3.2':
293
+ resolution: {integrity: sha512-QI9BO7KlNZsp2GuO0jwAAj5jCDABOKXRkCk2XuKTSaNEFSdfzqswYVTtCHBNKHLsqyjFyFkqlDiwkNbTYSssMQ==}
294
+ engines: {node: '>= 20'}
295
+ cpu: [x64]
296
+ os: [win32]
297
+
298
+ '@tailwindcss/oxide@4.3.2':
299
+ resolution: {integrity: sha512-z8ZgnzX8gdNoWLBLqBPoh/sjnxkwvf9ZuWjnO0l0yIzbLa5/9S+eC5QxGZKRobVHIC3/1BoMWjHblqWjcgFgag==}
300
+ engines: {node: '>= 20'}
301
+
302
+ '@tailwindcss/vite@4.3.2':
303
+ resolution: {integrity: sha512-eHpMeX4JXfVNJDEcsouTeCBubJBTcTLigeaw/NTUW6PB5ATKKXdyonnXgTBX2VuRbjz1hjfz6C5XAhr52ImQXA==}
304
+ peerDependencies:
305
+ vite: ^5.2.0 || ^6 || ^7 || ^8
306
+
307
+ '@tybys/wasm-util@0.10.2':
308
+ resolution: {integrity: sha512-RoBvJ2X0wuKlWFIjrwffGw1IqZHKQqzIchKaadZZfnNpsAYp2mM0h36JtPCjNDAHGgYez/15uMBpfGwchhiMgg==}
309
+
310
+ '@types/node@25.9.2':
311
+ resolution: {integrity: sha512-G05zqtJhcDLb8uslf5EjCxXg9G1KQxiV8OS0R26IC//Eoyitzqe8z37I7cqvnZlrlSfgocQRfSn/AHBZJJFyGw==}
312
+
313
+ '@types/react-dom@19.2.3':
314
+ resolution: {integrity: sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==}
315
+ peerDependencies:
316
+ '@types/react': ^19.2.0
317
+
318
+ '@types/react@19.2.17':
319
+ resolution: {integrity: sha512-MXfmqaVPEVgkBT/aY0aGCkRWWtByiYQXo3xdQ8r5RzuFrPiRn8Gar2tQdXSUQ2GKV3bkXckek89V8wQBY2Q/Aw==}
320
+
321
+ '@vitejs/plugin-react@6.0.3':
322
+ resolution: {integrity: sha512-vmFvco5/QuC2f9Oj+wTk0+9XeDFkHxSamwZKYc7MxYwKICfvUvlMhqKI0VuICPltGqh1neqBKDvO4kes1ya8vg==}
323
+ engines: {node: ^20.19.0 || >=22.12.0}
324
+ peerDependencies:
325
+ '@rolldown/plugin-babel': ^0.1.7 || ^0.2.0
326
+ babel-plugin-react-compiler: ^1.0.0
327
+ vite: ^8.0.0
328
+ peerDependenciesMeta:
329
+ '@rolldown/plugin-babel':
330
+ optional: true
331
+ babel-plugin-react-compiler:
332
+ optional: true
333
+
334
+ automation-events@7.1.19:
335
+ resolution: {integrity: sha512-cD+TLhJTI0q4AI3ktd353lrGZiVa9AchowSDzQzzGjSoYe22js4vlS32VUtWuaulghi1Yq0KYNWKk9wWuGymPA==}
336
+ engines: {node: '>=18.2.0'}
337
+
338
+ clsx@2.1.1:
339
+ resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==}
340
+ engines: {node: '>=6'}
341
+
342
+ csstype@3.2.3:
343
+ resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==}
344
+
345
+ detect-libc@2.1.2:
346
+ resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==}
347
+ engines: {node: '>=8'}
348
+
349
+ enhanced-resolve@5.21.6:
350
+ resolution: {integrity: sha512-aNnGCvbJ/RIyWo1IuhNdVjnNF+EjH9wpzpNHt+ci/m9He9LJvUN8wrCcXjp9cWsGNAuvSpVFTx/vraAFQ8qGjQ==}
351
+ engines: {node: '>=10.13.0'}
352
+
353
+ fdir@6.5.0:
354
+ resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==}
355
+ engines: {node: '>=12.0.0'}
356
+ peerDependencies:
357
+ picomatch: ^3 || ^4
358
+ peerDependenciesMeta:
359
+ picomatch:
360
+ optional: true
361
+
362
+ flatbuffers@25.9.23:
363
+ resolution: {integrity: sha512-MI1qs7Lo4Syw0EOzUl0xjs2lsoeqFku44KpngfIduHBYvzm8h2+7K8YMQh1JtVVVrUvhLpNwqVi4DERegUJhPQ==}
364
+
365
+ fsevents@2.3.2:
366
+ resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==}
367
+ engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
368
+ os: [darwin]
369
+
370
+ fsevents@2.3.3:
371
+ resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==}
372
+ engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
373
+ os: [darwin]
374
+
375
+ graceful-fs@4.2.11:
376
+ resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==}
377
+
378
+ guid-typescript@1.0.9:
379
+ resolution: {integrity: sha512-Y8T4vYhEfwJOTbouREvG+3XDsjr8E3kIr7uf+JZ0BYloFsttiHU0WfvANVsR7TxNUJa/WpCnw/Ino/p+DeBhBQ==}
380
+
381
+ jiti@2.7.0:
382
+ resolution: {integrity: sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==}
383
+ hasBin: true
384
+
385
+ lightningcss-android-arm64@1.32.0:
386
+ resolution: {integrity: sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg==}
387
+ engines: {node: '>= 12.0.0'}
388
+ cpu: [arm64]
389
+ os: [android]
390
+
391
+ lightningcss-darwin-arm64@1.32.0:
392
+ resolution: {integrity: sha512-RzeG9Ju5bag2Bv1/lwlVJvBE3q6TtXskdZLLCyfg5pt+HLz9BqlICO7LZM7VHNTTn/5PRhHFBSjk5lc4cmscPQ==}
393
+ engines: {node: '>= 12.0.0'}
394
+ cpu: [arm64]
395
+ os: [darwin]
396
+
397
+ lightningcss-darwin-x64@1.32.0:
398
+ resolution: {integrity: sha512-U+QsBp2m/s2wqpUYT/6wnlagdZbtZdndSmut/NJqlCcMLTWp5muCrID+K5UJ6jqD2BFshejCYXniPDbNh73V8w==}
399
+ engines: {node: '>= 12.0.0'}
400
+ cpu: [x64]
401
+ os: [darwin]
402
+
403
+ lightningcss-freebsd-x64@1.32.0:
404
+ resolution: {integrity: sha512-JCTigedEksZk3tHTTthnMdVfGf61Fky8Ji2E4YjUTEQX14xiy/lTzXnu1vwiZe3bYe0q+SpsSH/CTeDXK6WHig==}
405
+ engines: {node: '>= 12.0.0'}
406
+ cpu: [x64]
407
+ os: [freebsd]
408
+
409
+ lightningcss-linux-arm-gnueabihf@1.32.0:
410
+ resolution: {integrity: sha512-x6rnnpRa2GL0zQOkt6rts3YDPzduLpWvwAF6EMhXFVZXD4tPrBkEFqzGowzCsIWsPjqSK+tyNEODUBXeeVHSkw==}
411
+ engines: {node: '>= 12.0.0'}
412
+ cpu: [arm]
413
+ os: [linux]
414
+
415
+ lightningcss-linux-arm64-gnu@1.32.0:
416
+ resolution: {integrity: sha512-0nnMyoyOLRJXfbMOilaSRcLH3Jw5z9HDNGfT/gwCPgaDjnx0i8w7vBzFLFR1f6CMLKF8gVbebmkUN3fa/kQJpQ==}
417
+ engines: {node: '>= 12.0.0'}
418
+ cpu: [arm64]
419
+ os: [linux]
420
+
421
+ lightningcss-linux-arm64-musl@1.32.0:
422
+ resolution: {integrity: sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg==}
423
+ engines: {node: '>= 12.0.0'}
424
+ cpu: [arm64]
425
+ os: [linux]
426
+
427
+ lightningcss-linux-x64-gnu@1.32.0:
428
+ resolution: {integrity: sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA==}
429
+ engines: {node: '>= 12.0.0'}
430
+ cpu: [x64]
431
+ os: [linux]
432
+
433
+ lightningcss-linux-x64-musl@1.32.0:
434
+ resolution: {integrity: sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg==}
435
+ engines: {node: '>= 12.0.0'}
436
+ cpu: [x64]
437
+ os: [linux]
438
+
439
+ lightningcss-win32-arm64-msvc@1.32.0:
440
+ resolution: {integrity: sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw==}
441
+ engines: {node: '>= 12.0.0'}
442
+ cpu: [arm64]
443
+ os: [win32]
444
+
445
+ lightningcss-win32-x64-msvc@1.32.0:
446
+ resolution: {integrity: sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q==}
447
+ engines: {node: '>= 12.0.0'}
448
+ cpu: [x64]
449
+ os: [win32]
450
+
451
+ lightningcss@1.32.0:
452
+ resolution: {integrity: sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ==}
453
+ engines: {node: '>= 12.0.0'}
454
+
455
+ long@5.3.2:
456
+ resolution: {integrity: sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==}
457
+
458
+ magic-string@0.30.21:
459
+ resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==}
460
+
461
+ nanoid@3.3.12:
462
+ resolution: {integrity: sha512-ZB9RH/39qpq5Vu6Y+NmUaFhQR6pp+M2Xt76XBnEwDaGcVAqhlvxrl3B2bKS5D3NH3QR76v3aSrKaF/Kiy7lEtQ==}
463
+ engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
464
+ hasBin: true
465
+
466
+ onnxruntime-common@1.27.0:
467
+ resolution: {integrity: sha512-3KxL5wIVqa8Ex08jxSzncm9CMgw8CjOFyOQ7SxvG9o0cVLlhTNKXyIQuTbtX4tGPJEf73OER2xrjt4HJSBL4ow==}
468
+
469
+ onnxruntime-web@1.27.0:
470
+ resolution: {integrity: sha512-ogDLsqIozHZwifPuN37OproAo0byX6t43/bP8GzeZWBWD6MOGExswFAx3up4NS/vvWBOg2u2PXomDt3rMmdQSg==}
471
+
472
+ picocolors@1.1.1:
473
+ resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}
474
+
475
+ picomatch@4.0.4:
476
+ resolution: {integrity: sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==}
477
+ engines: {node: '>=12'}
478
+
479
+ platform@1.3.6:
480
+ resolution: {integrity: sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==}
481
+
482
+ playwright-core@1.61.1:
483
+ resolution: {integrity: sha512-h7Qlt6m4REp25qvIdvbDtVmD4LqVXfpRxhORv9L0jzETM05p4fuPJ3dKyuSXQxDSbXnmS79HAgi9589lGSpLkg==}
484
+ engines: {node: '>=18'}
485
+ hasBin: true
486
+
487
+ playwright@1.61.1:
488
+ resolution: {integrity: sha512-DWnY5o3YbLWK4GovuAVwpqL+1VwGNdUGrRr++8j8PtQQzvAVZUIMjKQ90fY689sEJZJBbZVw1rXaOKSTitkzPQ==}
489
+ engines: {node: '>=18'}
490
+ hasBin: true
491
+
492
+ postcss@8.5.15:
493
+ resolution: {integrity: sha512-FfR8sjd4em2T6fb3I2MwAJU7HWVMr9zba+enmQeeWFfCbm+UOC/0X4DS8XtpUTMwWMGbjKYP7xjfNekzyGmB3A==}
494
+ engines: {node: ^10 || ^12 || >=14}
495
+
496
+ protobufjs@7.6.5:
497
+ resolution: {integrity: sha512-/FPD0nUc9jH6rfFjji9IBqOz4pcSE3CsT1m7Ep6Mdb0LxSUMj8hgl6GomOvZzpNpAqqGaXA0P3VSrZLFzIhQrw==}
498
+ engines: {node: '>=12.0.0'}
499
+
500
+ react-dom@19.2.7:
501
+ resolution: {integrity: sha512-t0BRVXvbiE/o20Hfw669rLbMCDWtYZLvmJigy2f0MxsXF+71pxhR3xOkspmsO8h3ZlNzyibAmtCa3l4lYKk6gQ==}
502
+ peerDependencies:
503
+ react: ^19.2.7
504
+
505
+ react@19.2.7:
506
+ resolution: {integrity: sha512-HNe9WslTbXmFK8o8cmwgAeJFSBvt1bPdHCVKtaaV+WlAN36mpT4hcRpwbf3fY56ar2oIXzsBpOAiIRHAdY0OlQ==}
507
+ engines: {node: '>=0.10.0'}
508
+
509
+ rolldown@1.0.3:
510
+ resolution: {integrity: sha512-i00lAJ2ks1BYr7rjNjKC7BcqAS7nVfiT3QX1SI5aY+AFHblCmaUf9OE9dbdzDvW6dJxbi2ZCZiy9v3CcwOiX3g==}
511
+ engines: {node: ^20.19.0 || >=22.12.0}
512
+ hasBin: true
513
+
514
+ scheduler@0.27.0:
515
+ resolution: {integrity: sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==}
516
+
517
+ source-map-js@1.2.1:
518
+ resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
519
+ engines: {node: '>=0.10.0'}
520
+
521
+ spessasynth_core@4.3.20:
522
+ resolution: {integrity: sha512-RcYCXemGESRKIRbGEAGOwFgNSXcsuLMptjk3BmRTJJWtF6RH4KLRXKkUs6rzREUh3ooInfsJla/sRmWvwZzjhw==}
523
+
524
+ spessasynth_lib@4.3.8:
525
+ resolution: {integrity: sha512-v5D/XF9DH34FNwVSaoR51URsVxfGTuGSH577ZnmFwHOCo1mWq7b545oliIHxPFkP1OKoAjcp82oQFoqBv5i8pQ==}
526
+ deprecated: Only the latest version of spessasynth_lib is supported.
527
+
528
+ standardized-audio-context@25.3.77:
529
+ resolution: {integrity: sha512-Ki9zNz6pKcC5Pi+QPjPyVsD9GwJIJWgryji0XL9cAJXMGyn+dPOf6Qik1AHei0+UNVcc4BOCa0hWLBzlwqsW/A==}
530
+
531
+ stb-vorbis@0.0.6:
532
+ resolution: {integrity: sha512-CyvjJEGROIdnuZknwFvdOfMIO1ssUxO2OawsXCR3IlbJ8z2IMBjDe8FDxFJqBfLgf1ZOdqvoHAYx3Xk8q9rbbg==}
533
+
534
+ tailwindcss@4.3.2:
535
+ resolution: {integrity: sha512-WtctNNSH8A9jlMIqxzuYumOHU5uGZyRv0Q5svQl+oEPy5w84YpBxdb7MdqyiSPQge5jTJ6zFQLq0PFygdccSBA==}
536
+
537
+ tapable@2.3.3:
538
+ resolution: {integrity: sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==}
539
+ engines: {node: '>=6'}
540
+
541
+ tinyglobby@0.2.17:
542
+ resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==}
543
+ engines: {node: '>=12.0.0'}
544
+
545
+ tone@15.1.22:
546
+ resolution: {integrity: sha512-TCScAGD4sLsama5DjvTUXlLDXSqPealhL64nsdV1hhr6frPWve0DeSo63AKnSJwgfg55fhvxj0iPPRwPN5o0ag==}
547
+
548
+ tslib@2.8.1:
549
+ resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==}
550
+
551
+ typescript@6.0.3:
552
+ resolution: {integrity: sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==}
553
+ engines: {node: '>=14.17'}
554
+ hasBin: true
555
+
556
+ undici-types@7.24.6:
557
+ resolution: {integrity: sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==}
558
+
559
+ vite@8.0.16:
560
+ resolution: {integrity: sha512-h9bXPmJichP5fLmVQo3PyaGSDE2n3aPuomeAlVRm0JLmt4rY6zmPKd59HYI4LNW8oTK7tlTsuC7l/m7awx9Jcw==}
561
+ engines: {node: ^20.19.0 || >=22.12.0}
562
+ hasBin: true
563
+ peerDependencies:
564
+ '@types/node': ^20.19.0 || >=22.12.0
565
+ '@vitejs/devtools': ^0.1.18
566
+ esbuild: ^0.27.0 || ^0.28.0
567
+ jiti: '>=1.21.0'
568
+ less: ^4.0.0
569
+ sass: ^1.70.0
570
+ sass-embedded: ^1.70.0
571
+ stylus: '>=0.54.8'
572
+ sugarss: ^5.0.0
573
+ terser: ^5.16.0
574
+ tsx: ^4.8.1
575
+ yaml: ^2.4.2
576
+ peerDependenciesMeta:
577
+ '@types/node':
578
+ optional: true
579
+ '@vitejs/devtools':
580
+ optional: true
581
+ esbuild:
582
+ optional: true
583
+ jiti:
584
+ optional: true
585
+ less:
586
+ optional: true
587
+ sass:
588
+ optional: true
589
+ sass-embedded:
590
+ optional: true
591
+ stylus:
592
+ optional: true
593
+ sugarss:
594
+ optional: true
595
+ terser:
596
+ optional: true
597
+ tsx:
598
+ optional: true
599
+ yaml:
600
+ optional: true
601
+
602
+ snapshots:
603
+
604
+ '@babel/runtime@7.29.7': {}
605
+
606
+ '@emnapi/core@1.10.0':
607
+ dependencies:
608
+ '@emnapi/wasi-threads': 1.2.1
609
+ tslib: 2.8.1
610
+ optional: true
611
+
612
+ '@emnapi/runtime@1.10.0':
613
+ dependencies:
614
+ tslib: 2.8.1
615
+ optional: true
616
+
617
+ '@emnapi/wasi-threads@1.2.1':
618
+ dependencies:
619
+ tslib: 2.8.1
620
+ optional: true
621
+
622
+ '@jridgewell/gen-mapping@0.3.13':
623
+ dependencies:
624
+ '@jridgewell/sourcemap-codec': 1.5.5
625
+ '@jridgewell/trace-mapping': 0.3.31
626
+
627
+ '@jridgewell/remapping@2.3.5':
628
+ dependencies:
629
+ '@jridgewell/gen-mapping': 0.3.13
630
+ '@jridgewell/trace-mapping': 0.3.31
631
+
632
+ '@jridgewell/resolve-uri@3.1.2': {}
633
+
634
+ '@jridgewell/sourcemap-codec@1.5.5': {}
635
+
636
+ '@jridgewell/trace-mapping@0.3.31':
637
+ dependencies:
638
+ '@jridgewell/resolve-uri': 3.1.2
639
+ '@jridgewell/sourcemap-codec': 1.5.5
640
+
641
+ '@napi-rs/wasm-runtime@1.1.4(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)':
642
+ dependencies:
643
+ '@emnapi/core': 1.10.0
644
+ '@emnapi/runtime': 1.10.0
645
+ '@tybys/wasm-util': 0.10.2
646
+ optional: true
647
+
648
+ '@oxc-project/types@0.133.0': {}
649
+
650
+ '@protobufjs/aspromise@1.1.2': {}
651
+
652
+ '@protobufjs/base64@1.1.2': {}
653
+
654
+ '@protobufjs/codegen@2.0.5': {}
655
+
656
+ '@protobufjs/eventemitter@1.1.1': {}
657
+
658
+ '@protobufjs/fetch@1.1.1':
659
+ dependencies:
660
+ '@protobufjs/aspromise': 1.1.2
661
+
662
+ '@protobufjs/float@1.0.2': {}
663
+
664
+ '@protobufjs/path@1.1.2': {}
665
+
666
+ '@protobufjs/pool@1.1.0': {}
667
+
668
+ '@protobufjs/utf8@1.1.2': {}
669
+
670
+ '@rolldown/binding-android-arm64@1.0.3':
671
+ optional: true
672
+
673
+ '@rolldown/binding-darwin-arm64@1.0.3':
674
+ optional: true
675
+
676
+ '@rolldown/binding-darwin-x64@1.0.3':
677
+ optional: true
678
+
679
+ '@rolldown/binding-freebsd-x64@1.0.3':
680
+ optional: true
681
+
682
+ '@rolldown/binding-linux-arm-gnueabihf@1.0.3':
683
+ optional: true
684
+
685
+ '@rolldown/binding-linux-arm64-gnu@1.0.3':
686
+ optional: true
687
+
688
+ '@rolldown/binding-linux-arm64-musl@1.0.3':
689
+ optional: true
690
+
691
+ '@rolldown/binding-linux-ppc64-gnu@1.0.3':
692
+ optional: true
693
+
694
+ '@rolldown/binding-linux-s390x-gnu@1.0.3':
695
+ optional: true
696
+
697
+ '@rolldown/binding-linux-x64-gnu@1.0.3':
698
+ optional: true
699
+
700
+ '@rolldown/binding-linux-x64-musl@1.0.3':
701
+ optional: true
702
+
703
+ '@rolldown/binding-openharmony-arm64@1.0.3':
704
+ optional: true
705
+
706
+ '@rolldown/binding-wasm32-wasi@1.0.3':
707
+ dependencies:
708
+ '@emnapi/core': 1.10.0
709
+ '@emnapi/runtime': 1.10.0
710
+ '@napi-rs/wasm-runtime': 1.1.4(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)
711
+ optional: true
712
+
713
+ '@rolldown/binding-win32-arm64-msvc@1.0.3':
714
+ optional: true
715
+
716
+ '@rolldown/binding-win32-x64-msvc@1.0.3':
717
+ optional: true
718
+
719
+ '@rolldown/pluginutils@1.0.1': {}
720
+
721
+ '@tailwindcss/node@4.3.2':
722
+ dependencies:
723
+ '@jridgewell/remapping': 2.3.5
724
+ enhanced-resolve: 5.21.6
725
+ jiti: 2.7.0
726
+ lightningcss: 1.32.0
727
+ magic-string: 0.30.21
728
+ source-map-js: 1.2.1
729
+ tailwindcss: 4.3.2
730
+
731
+ '@tailwindcss/oxide-android-arm64@4.3.2':
732
+ optional: true
733
+
734
+ '@tailwindcss/oxide-darwin-arm64@4.3.2':
735
+ optional: true
736
+
737
+ '@tailwindcss/oxide-darwin-x64@4.3.2':
738
+ optional: true
739
+
740
+ '@tailwindcss/oxide-freebsd-x64@4.3.2':
741
+ optional: true
742
+
743
+ '@tailwindcss/oxide-linux-arm-gnueabihf@4.3.2':
744
+ optional: true
745
+
746
+ '@tailwindcss/oxide-linux-arm64-gnu@4.3.2':
747
+ optional: true
748
+
749
+ '@tailwindcss/oxide-linux-arm64-musl@4.3.2':
750
+ optional: true
751
+
752
+ '@tailwindcss/oxide-linux-x64-gnu@4.3.2':
753
+ optional: true
754
+
755
+ '@tailwindcss/oxide-linux-x64-musl@4.3.2':
756
+ optional: true
757
+
758
+ '@tailwindcss/oxide-wasm32-wasi@4.3.2':
759
+ optional: true
760
+
761
+ '@tailwindcss/oxide-win32-arm64-msvc@4.3.2':
762
+ optional: true
763
+
764
+ '@tailwindcss/oxide-win32-x64-msvc@4.3.2':
765
+ optional: true
766
+
767
+ '@tailwindcss/oxide@4.3.2':
768
+ optionalDependencies:
769
+ '@tailwindcss/oxide-android-arm64': 4.3.2
770
+ '@tailwindcss/oxide-darwin-arm64': 4.3.2
771
+ '@tailwindcss/oxide-darwin-x64': 4.3.2
772
+ '@tailwindcss/oxide-freebsd-x64': 4.3.2
773
+ '@tailwindcss/oxide-linux-arm-gnueabihf': 4.3.2
774
+ '@tailwindcss/oxide-linux-arm64-gnu': 4.3.2
775
+ '@tailwindcss/oxide-linux-arm64-musl': 4.3.2
776
+ '@tailwindcss/oxide-linux-x64-gnu': 4.3.2
777
+ '@tailwindcss/oxide-linux-x64-musl': 4.3.2
778
+ '@tailwindcss/oxide-wasm32-wasi': 4.3.2
779
+ '@tailwindcss/oxide-win32-arm64-msvc': 4.3.2
780
+ '@tailwindcss/oxide-win32-x64-msvc': 4.3.2
781
+
782
+ '@tailwindcss/vite@4.3.2(vite@8.0.16(@types/node@25.9.2)(jiti@2.7.0))':
783
+ dependencies:
784
+ '@tailwindcss/node': 4.3.2
785
+ '@tailwindcss/oxide': 4.3.2
786
+ tailwindcss: 4.3.2
787
+ vite: 8.0.16(@types/node@25.9.2)(jiti@2.7.0)
788
+
789
+ '@tybys/wasm-util@0.10.2':
790
+ dependencies:
791
+ tslib: 2.8.1
792
+ optional: true
793
+
794
+ '@types/node@25.9.2':
795
+ dependencies:
796
+ undici-types: 7.24.6
797
+
798
+ '@types/react-dom@19.2.3(@types/react@19.2.17)':
799
+ dependencies:
800
+ '@types/react': 19.2.17
801
+
802
+ '@types/react@19.2.17':
803
+ dependencies:
804
+ csstype: 3.2.3
805
+
806
+ '@vitejs/plugin-react@6.0.3(vite@8.0.16(@types/node@25.9.2)(jiti@2.7.0))':
807
+ dependencies:
808
+ '@rolldown/pluginutils': 1.0.1
809
+ vite: 8.0.16(@types/node@25.9.2)(jiti@2.7.0)
810
+
811
+ automation-events@7.1.19:
812
+ dependencies:
813
+ '@babel/runtime': 7.29.7
814
+ tslib: 2.8.1
815
+
816
+ clsx@2.1.1: {}
817
+
818
+ csstype@3.2.3: {}
819
+
820
+ detect-libc@2.1.2: {}
821
+
822
+ enhanced-resolve@5.21.6:
823
+ dependencies:
824
+ graceful-fs: 4.2.11
825
+ tapable: 2.3.3
826
+
827
+ fdir@6.5.0(picomatch@4.0.4):
828
+ optionalDependencies:
829
+ picomatch: 4.0.4
830
+
831
+ flatbuffers@25.9.23: {}
832
+
833
+ fsevents@2.3.2:
834
+ optional: true
835
+
836
+ fsevents@2.3.3:
837
+ optional: true
838
+
839
+ graceful-fs@4.2.11: {}
840
+
841
+ guid-typescript@1.0.9: {}
842
+
843
+ jiti@2.7.0: {}
844
+
845
+ lightningcss-android-arm64@1.32.0:
846
+ optional: true
847
+
848
+ lightningcss-darwin-arm64@1.32.0:
849
+ optional: true
850
+
851
+ lightningcss-darwin-x64@1.32.0:
852
+ optional: true
853
+
854
+ lightningcss-freebsd-x64@1.32.0:
855
+ optional: true
856
+
857
+ lightningcss-linux-arm-gnueabihf@1.32.0:
858
+ optional: true
859
+
860
+ lightningcss-linux-arm64-gnu@1.32.0:
861
+ optional: true
862
+
863
+ lightningcss-linux-arm64-musl@1.32.0:
864
+ optional: true
865
+
866
+ lightningcss-linux-x64-gnu@1.32.0:
867
+ optional: true
868
+
869
+ lightningcss-linux-x64-musl@1.32.0:
870
+ optional: true
871
+
872
+ lightningcss-win32-arm64-msvc@1.32.0:
873
+ optional: true
874
+
875
+ lightningcss-win32-x64-msvc@1.32.0:
876
+ optional: true
877
+
878
+ lightningcss@1.32.0:
879
+ dependencies:
880
+ detect-libc: 2.1.2
881
+ optionalDependencies:
882
+ lightningcss-android-arm64: 1.32.0
883
+ lightningcss-darwin-arm64: 1.32.0
884
+ lightningcss-darwin-x64: 1.32.0
885
+ lightningcss-freebsd-x64: 1.32.0
886
+ lightningcss-linux-arm-gnueabihf: 1.32.0
887
+ lightningcss-linux-arm64-gnu: 1.32.0
888
+ lightningcss-linux-arm64-musl: 1.32.0
889
+ lightningcss-linux-x64-gnu: 1.32.0
890
+ lightningcss-linux-x64-musl: 1.32.0
891
+ lightningcss-win32-arm64-msvc: 1.32.0
892
+ lightningcss-win32-x64-msvc: 1.32.0
893
+
894
+ long@5.3.2: {}
895
+
896
+ magic-string@0.30.21:
897
+ dependencies:
898
+ '@jridgewell/sourcemap-codec': 1.5.5
899
+
900
+ nanoid@3.3.12: {}
901
+
902
+ onnxruntime-common@1.27.0: {}
903
+
904
+ onnxruntime-web@1.27.0:
905
+ dependencies:
906
+ flatbuffers: 25.9.23
907
+ guid-typescript: 1.0.9
908
+ long: 5.3.2
909
+ onnxruntime-common: 1.27.0
910
+ platform: 1.3.6
911
+ protobufjs: 7.6.5
912
+
913
+ picocolors@1.1.1: {}
914
+
915
+ picomatch@4.0.4: {}
916
+
917
+ platform@1.3.6: {}
918
+
919
+ playwright-core@1.61.1: {}
920
+
921
+ playwright@1.61.1:
922
+ dependencies:
923
+ playwright-core: 1.61.1
924
+ optionalDependencies:
925
+ fsevents: 2.3.2
926
+
927
+ postcss@8.5.15:
928
+ dependencies:
929
+ nanoid: 3.3.12
930
+ picocolors: 1.1.1
931
+ source-map-js: 1.2.1
932
+
933
+ protobufjs@7.6.5:
934
+ dependencies:
935
+ '@protobufjs/aspromise': 1.1.2
936
+ '@protobufjs/base64': 1.1.2
937
+ '@protobufjs/codegen': 2.0.5
938
+ '@protobufjs/eventemitter': 1.1.1
939
+ '@protobufjs/fetch': 1.1.1
940
+ '@protobufjs/float': 1.0.2
941
+ '@protobufjs/path': 1.1.2
942
+ '@protobufjs/pool': 1.1.0
943
+ '@protobufjs/utf8': 1.1.2
944
+ '@types/node': 25.9.2
945
+ long: 5.3.2
946
+
947
+ react-dom@19.2.7(react@19.2.7):
948
+ dependencies:
949
+ react: 19.2.7
950
+ scheduler: 0.27.0
951
+
952
+ react@19.2.7: {}
953
+
954
+ rolldown@1.0.3:
955
+ dependencies:
956
+ '@oxc-project/types': 0.133.0
957
+ '@rolldown/pluginutils': 1.0.1
958
+ optionalDependencies:
959
+ '@rolldown/binding-android-arm64': 1.0.3
960
+ '@rolldown/binding-darwin-arm64': 1.0.3
961
+ '@rolldown/binding-darwin-x64': 1.0.3
962
+ '@rolldown/binding-freebsd-x64': 1.0.3
963
+ '@rolldown/binding-linux-arm-gnueabihf': 1.0.3
964
+ '@rolldown/binding-linux-arm64-gnu': 1.0.3
965
+ '@rolldown/binding-linux-arm64-musl': 1.0.3
966
+ '@rolldown/binding-linux-ppc64-gnu': 1.0.3
967
+ '@rolldown/binding-linux-s390x-gnu': 1.0.3
968
+ '@rolldown/binding-linux-x64-gnu': 1.0.3
969
+ '@rolldown/binding-linux-x64-musl': 1.0.3
970
+ '@rolldown/binding-openharmony-arm64': 1.0.3
971
+ '@rolldown/binding-wasm32-wasi': 1.0.3
972
+ '@rolldown/binding-win32-arm64-msvc': 1.0.3
973
+ '@rolldown/binding-win32-x64-msvc': 1.0.3
974
+
975
+ scheduler@0.27.0: {}
976
+
977
+ source-map-js@1.2.1: {}
978
+
979
+ spessasynth_core@4.3.20:
980
+ dependencies:
981
+ stb-vorbis: 0.0.6
982
+
983
+ spessasynth_lib@4.3.8:
984
+ dependencies:
985
+ spessasynth_core: 4.3.20
986
+
987
+ standardized-audio-context@25.3.77:
988
+ dependencies:
989
+ '@babel/runtime': 7.29.7
990
+ automation-events: 7.1.19
991
+ tslib: 2.8.1
992
+
993
+ stb-vorbis@0.0.6: {}
994
+
995
+ tailwindcss@4.3.2: {}
996
+
997
+ tapable@2.3.3: {}
998
+
999
+ tinyglobby@0.2.17:
1000
+ dependencies:
1001
+ fdir: 6.5.0(picomatch@4.0.4)
1002
+ picomatch: 4.0.4
1003
+
1004
+ tone@15.1.22:
1005
+ dependencies:
1006
+ standardized-audio-context: 25.3.77
1007
+ tslib: 2.8.1
1008
+
1009
+ tslib@2.8.1: {}
1010
+
1011
+ typescript@6.0.3: {}
1012
+
1013
+ undici-types@7.24.6: {}
1014
+
1015
+ vite@8.0.16(@types/node@25.9.2)(jiti@2.7.0):
1016
+ dependencies:
1017
+ lightningcss: 1.32.0
1018
+ picomatch: 4.0.4
1019
+ postcss: 8.5.15
1020
+ rolldown: 1.0.3
1021
+ tinyglobby: 0.2.17
1022
+ optionalDependencies:
1023
+ '@types/node': 25.9.2
1024
+ fsevents: 2.3.3
1025
+ jiti: 2.7.0
source/demo/web/public/favicon.png ADDED
source/demo/web/src/App.tsx ADDED
@@ -0,0 +1,385 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useEffect, useRef, useState } from "react";
2
+ import clsx from "clsx";
3
+ import type { PianoRoll } from "./pianoroll";
4
+ import { useAudioEngine } from "./hooks/useAudioEngine";
5
+ import { useTranscription, type AppState } from "./hooks/useTranscription";
6
+ import { Controls } from "./components/Controls";
7
+ import { OutputBar } from "./components/OutputBar";
8
+ import { PianoRollCanvas } from "./components/PianoRollCanvas";
9
+ import { InstrumentList } from "./components/InstrumentList";
10
+ import { DropOverlay } from "./components/DropOverlay";
11
+ import { Footer } from "./components/Footer";
12
+ import { WelcomeScreen } from "./components/WelcomeScreen";
13
+
14
+ /**
15
+ * A failure surfaced on the welcome screen. `server` means the backend is
16
+ * unreachable (health probe / network) and replaces the file picker entirely;
17
+ * `file` is a per-upload problem (e.g. an undecodable audio file) shown
18
+ * alongside the picker so the user can choose a different file.
19
+ */
20
+ export type AppError = { kind: "server" | "file"; message: string };
21
+ import { ProgressEstimator, formatClock } from "./progress";
22
+
23
+ type Screen = "welcome" | "transcribe";
24
+
25
+ // The song is Headache by Lost Deposit. ig: @lostdeposit
26
+ const EXAMPLE = {
27
+ url: "/headache_by_lost_deposit_1min.mp3",
28
+ filename: "Lost Deposit - Headache (example track)",
29
+ conditioning: [
30
+ "drums",
31
+ "electric_bass",
32
+ "distorted_electric_guitar",
33
+ "clean_electric_guitar",
34
+ "voice",
35
+ ],
36
+ };
37
+
38
+ export function App() {
39
+ const audio = useAudioEngine();
40
+ const rollRef = useRef<PianoRoll | null>(null);
41
+ const clockRef = useRef<HTMLSpanElement | null>(null);
42
+ // Progress estimator (stable across renders) + the DOM nodes its smoothed
43
+ // fraction/ETA are written into each frame.
44
+ const progressRef = useRef<ProgressEstimator | null>(null);
45
+ const progress = (progressRef.current ??= new ProgressEstimator());
46
+ const progressFillRef = useRef<HTMLDivElement | null>(null);
47
+ const progressLabelRef = useRef<HTMLSpanElement | null>(null);
48
+
49
+ const [screen, setScreen] = useState<Screen>("welcome");
50
+ const [selectedFile, setSelectedFile] = useState<File | null>(null);
51
+ const [appState, setAppState] = useState<AppState>("idle");
52
+ // Shown on the welcome screen: a server-down notice (set when the /health
53
+ // check fails) or a per-file error (set when a transcription is rejected).
54
+ // null = healthy and no file error.
55
+ const [error, setError] = useState<AppError | null>(null);
56
+ const [instruments, setInstruments] = useState<string[]>([]);
57
+ const [midiUrl, setMidiUrl] = useState<string | null>(null);
58
+ const [midiBlob, setMidiBlob] = useState<Blob | null>(null);
59
+ const [currentFile, setCurrentFile] = useState<File | null>(null);
60
+ const [mix, setMix] = useState(0.75);
61
+ const [stereo, setStereo] = useState(false);
62
+ const [userScrolled, setUserScrolled] = useState(false);
63
+ const [condSelected, setCondSelected] = useState<Set<string>>(() => new Set());
64
+ // True while a file is being dragged over the window. On the welcome screen
65
+ // this swaps the panel's prompt in place instead of showing the overlay.
66
+ const [dragging, setDragging] = useState(false);
67
+
68
+ const midiFilenameRef = useRef("transcription.mid");
69
+ // Mirror of the selected conditioning set, read at submit time without
70
+ // re-creating `transcribe` whenever the selection changes.
71
+ const condRef = useRef(condSelected);
72
+ condRef.current = condSelected;
73
+ // Read inside the per-frame loop (which only re-subscribes on `audio`) so the
74
+ // transcribed-so-far tint is only drawn while a transcription is running.
75
+ const appStateRef = useRef(appState);
76
+ appStateRef.current = appState;
77
+
78
+ const { transcribe, abort } = useTranscription({
79
+ audio,
80
+ rollRef,
81
+ getConditioning: () => Array.from(condRef.current),
82
+ progress,
83
+ // A failed transcription bounces back to the welcome screen with a message.
84
+ onError: (message) => {
85
+ setError({ kind: "file", message });
86
+ setScreen("welcome");
87
+ },
88
+ setAppState,
89
+ setInstruments,
90
+ setMidiUrl,
91
+ setMidiBlob,
92
+ setCurrentFile,
93
+ setUserScrolled,
94
+ midiFilenameRef,
95
+ });
96
+ // Start transcribing the file picked on the welcome screen and switch views.
97
+ // Called from a button click, so the AudioContext unlock inside `transcribe`
98
+ // still happens under a user gesture.
99
+ function startTranscription() {
100
+ if (selectedFile === null) return;
101
+ // Drop any leftover file error from a previous failed attempt.
102
+ setError(null);
103
+ setScreen("transcribe");
104
+ transcribe(selectedFile);
105
+ }
106
+
107
+ // Tear down the current transcription (in-flight or finished) and return to
108
+ // the welcome screen. The previously chosen conditioning is kept so it's easy
109
+ // to re-run with the same settings.
110
+ function resetToWelcome() {
111
+ // Stop the in-flight run right away (not just when the next one starts):
112
+ // otherwise it keeps streaming notes into the torn-down UI and keeps the
113
+ // server transcribing — and the server lock held — while the user picks
114
+ // the next file.
115
+ abort();
116
+ audio.reset();
117
+ rollRef.current?.clear();
118
+ setInstruments([]);
119
+ setMidiUrl(null);
120
+ setMidiBlob(null);
121
+ setUserScrolled(false);
122
+ setAppState("idle");
123
+ setScreen("welcome");
124
+ }
125
+
126
+ // "Transcribe another file" (also the wordmark, on the transcribe screen):
127
+ // confirm (the work is about to be discarded), then tear down and go back.
128
+ function transcribeAnother() {
129
+ if (!window.confirm("Discard this transcription and start over?")) return;
130
+ setSelectedFile(null);
131
+ resetToWelcome();
132
+ }
133
+
134
+ // Load the bundled demo track and pre-fill conditioning with a reasonable
135
+ // guess for it (a rock track). The user still reviews and hits "Transcribe".
136
+ async function useExample() {
137
+ const resp = await fetch(EXAMPLE.url);
138
+ if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
139
+ const blob = await resp.blob();
140
+ const file = new File([blob], EXAMPLE.filename, { type: "audio/mpeg" });
141
+ setCondSelected(new Set(EXAMPLE.conditioning));
142
+ setSelectedFile(file);
143
+ }
144
+
145
+ // A file dropped anywhere on the page selects it on the welcome screen, from
146
+ // either screen — dropping while a transcription is showing returns you to the
147
+ // welcome screen with the new file picked, so you can choose conditioning
148
+ // before hitting "Transcribe". It does not auto-start. Routed through a ref so
149
+ // the window-level handler (installed once) always calls the latest closure.
150
+ function onDropFile(file: File) {
151
+ // Dropping onto the transcribe screen abandons the current run — confirm
152
+ // first, then tear everything down (stop playback, clear the roll) so the
153
+ // music doesn't keep playing behind the welcome screen.
154
+ if (screen === "transcribe") {
155
+ if (!window.confirm("Discard this transcription and start over with the dropped file?"))
156
+ return;
157
+ resetToWelcome();
158
+ }
159
+ setSelectedFile(file);
160
+ }
161
+ const dropRef = useRef(onDropFile);
162
+ dropRef.current = onDropFile;
163
+
164
+ // Drive the body's data-state (it lives outside the React root) from state.
165
+ useEffect(() => {
166
+ document.body.dataset.state = appState;
167
+ }, [appState]);
168
+
169
+ // Drag & drop works anywhere on the page; a fullscreen overlay (CSS, keyed off
170
+ // `body.drag`) shows while a file is being dragged. dragenter/dragleave fire
171
+ // on every child element, so keep a depth counter to know when the drag truly
172
+ // left the window.
173
+ useEffect(() => {
174
+ let dragDepth = 0;
175
+ const onEnter = (e: DragEvent) => {
176
+ e.preventDefault();
177
+ dragDepth++;
178
+ document.body.classList.add("drag");
179
+ setDragging(true);
180
+ };
181
+ const onOver = (e: DragEvent) => e.preventDefault();
182
+ const onLeave = () => {
183
+ dragDepth = Math.max(0, dragDepth - 1);
184
+ if (dragDepth === 0) {
185
+ document.body.classList.remove("drag");
186
+ setDragging(false);
187
+ }
188
+ };
189
+ const onDrop = (e: DragEvent) => {
190
+ e.preventDefault();
191
+ dragDepth = 0;
192
+ document.body.classList.remove("drag");
193
+ setDragging(false);
194
+ const f = e.dataTransfer?.files?.[0];
195
+ if (f) dropRef.current(f);
196
+ };
197
+ window.addEventListener("dragenter", onEnter);
198
+ window.addEventListener("dragover", onOver);
199
+ window.addEventListener("dragleave", onLeave);
200
+ window.addEventListener("drop", onDrop);
201
+ return () => {
202
+ window.removeEventListener("dragenter", onEnter);
203
+ window.removeEventListener("dragover", onOver);
204
+ window.removeEventListener("dragleave", onLeave);
205
+ window.removeEventListener("drop", onDrop);
206
+ };
207
+ }, []);
208
+
209
+ // Space toggles play/pause on the transcribe screen. Ignored while focus is
210
+ // on a form control (slider, checkbox, button) so its native space behavior
211
+ // is preserved.
212
+ useEffect(() => {
213
+ if (screen !== "transcribe") return;
214
+ const onKey = (e: KeyboardEvent) => {
215
+ if (e.code !== "Space" && e.key !== " ") return;
216
+ const tag = (e.target as HTMLElement | null)?.tagName;
217
+ if (tag === "INPUT" || tag === "BUTTON" || tag === "SELECT" || tag === "TEXTAREA")
218
+ return;
219
+ e.preventDefault();
220
+ if (audio.state === "started") audio.pause();
221
+ else audio.play();
222
+ };
223
+ window.addEventListener("keydown", onKey);
224
+ return () => window.removeEventListener("keydown", onKey);
225
+ }, [screen, audio]);
226
+
227
+ // Per-frame: advance the playhead, redraw the canvas, and tick the clock.
228
+ // Kept off React state so it doesn't trigger ~60fps re-renders.
229
+ useEffect(() => {
230
+ let raf = 0;
231
+ const frame = () => {
232
+ const roll = rollRef.current;
233
+ if (roll) {
234
+ roll.setPlayhead(audio.seconds);
235
+ // Feed the chunk-completion estimate of the transcribed span (completed
236
+ // fraction × audio length). The roll combines it with the latest note
237
+ // onset and eases the frontier itself; null while not transcribing
238
+ // disables the tint (once done the whole roll is covered).
239
+ const dur = audio.duration;
240
+ roll.setDuration(dur);
241
+ roll.setTranscribedUntil(
242
+ appStateRef.current === "transcribing" && dur > 0
243
+ ? progress.completedFraction() * dur
244
+ : null,
245
+ );
246
+ roll.render();
247
+ }
248
+ if (clockRef.current) clockRef.current.textContent = `${audio.seconds.toFixed(1)}s`;
249
+ // Drive the progress bar straight to the DOM (only mounted while
250
+ // transcribing) so the smoothing doesn't re-render the app each frame.
251
+ if (progressFillRef.current) {
252
+ const now = performance.now();
253
+ const frac = progress.fraction(now);
254
+ progressFillRef.current.style.width = `${(frac * 100).toFixed(1)}%`;
255
+ // Estimated time transcribed (smoothed fraction × audio length) out of
256
+ // the file's total length, plus the ETA once a pace estimate exists.
257
+ if (progressLabelRef.current) {
258
+ const dur = audio.duration;
259
+ if (dur > 0) {
260
+ let text = `${formatClock(frac * dur)}/${formatClock(dur)}`;
261
+ const eta = progress.etaMs(now);
262
+ if (eta != null) text += ` · done in ${formatClock(eta / 1000)}`;
263
+ progressLabelRef.current.textContent = text;
264
+ } else {
265
+ progressLabelRef.current.textContent = "";
266
+ }
267
+ }
268
+ }
269
+ raf = requestAnimationFrame(frame);
270
+ };
271
+ raf = requestAnimationFrame(frame);
272
+ return () => cancelAnimationFrame(raf);
273
+ }, [audio]);
274
+
275
+ // Expose for browser-devtools debugging.
276
+ useEffect(() => {
277
+ (window as unknown as { __mu: unknown }).__mu = { audio, rollRef };
278
+ }, [audio]);
279
+
280
+ return (
281
+ <>
282
+ <div className="grain" aria-hidden="true" />
283
+
284
+ <header className="mx-auto flex max-w-7xl flex-wrap items-end justify-between gap-6 px-7 pb-6 pt-10 max-[760px]:pt-8 animate-rise">
285
+ {/* Brand: the v2 mark (transparent PNG) + the wordmark as real text. */}
286
+ <div
287
+ className={clsx(
288
+ "flex items-center gap-3 sm:gap-5",
289
+ screen === "transcribe" && "cursor-pointer",
290
+ )}
291
+ onClick={screen === "transcribe" ? transcribeAnother : undefined}
292
+ onKeyDown={
293
+ screen === "transcribe"
294
+ ? (e) => {
295
+ if (e.key === "Enter" || e.key === " ") {
296
+ e.preventDefault();
297
+ transcribeAnother();
298
+ }
299
+ }
300
+ : undefined
301
+ }
302
+ role={screen === "transcribe" ? "button" : undefined}
303
+ tabIndex={screen === "transcribe" ? 0 : undefined}
304
+ title={screen === "transcribe" ? "Transcribe another file" : undefined}
305
+ >
306
+ <img
307
+ src="/muscriptor-logo-v4-pink.svg"
308
+ alt="MuScriptor logo"
309
+ className="block h-[clamp(72px,10vw,110px)] w-auto"
310
+ draggable={false}
311
+ />
312
+ <div className="flex flex-col gap-1">
313
+ <span className="text-[clamp(2rem,8vw,3rem)] font-bold leading-none text-white">MuScriptor</span>
314
+ <span className="text-sm text-muted">
315
+ Audio to MIDI transcription
316
+ </span>
317
+ </div>
318
+ </div>
319
+ </header>
320
+
321
+ {screen === "welcome" ? (
322
+ <WelcomeScreen
323
+ selectedFile={selectedFile}
324
+ onPickFile={setSelectedFile}
325
+ onUseExample={useExample}
326
+ condSelected={condSelected}
327
+ onCondChange={setCondSelected}
328
+ onTranscribe={startTranscription}
329
+ dragging={dragging}
330
+ error={error}
331
+ setError={setError}
332
+ />
333
+ ) : (
334
+ <main className="mx-auto grid max-w-7xl grid-cols-[1fr_300px] gap-4 px-7 pb-12 pt-2 max-[760px]:grid-cols-1">
335
+ {/* Above the roll: exploring the result. */}
336
+ <Controls
337
+ audio={audio}
338
+ clockRef={clockRef}
339
+ mix={mix}
340
+ onMixChange={(v) => {
341
+ setMix(v);
342
+ audio.setMix(v);
343
+ }}
344
+ stereo={stereo}
345
+ onStereoChange={(v) => {
346
+ setStereo(v);
347
+ audio.setStereo(v);
348
+ }}
349
+ following={!userScrolled}
350
+ onToggleFollow={() => {
351
+ if (userScrolled) {
352
+ rollRef.current?.follow();
353
+ setUserScrolled(false);
354
+ } else {
355
+ rollRef.current?.unfollow();
356
+ setUserScrolled(true);
357
+ }
358
+ }}
359
+ />
360
+
361
+ <PianoRollCanvas rollRef={rollRef} audio={audio} setUserScrolled={setUserScrolled} />
362
+
363
+ <InstrumentList instruments={instruments} given={condSelected} audio={audio} rollRef={rollRef} />
364
+
365
+ {/* Below the roll: the transcription job itself — progress, export,
366
+ and starting over. */}
367
+ <OutputBar
368
+ transcribing={appState === "transcribing"}
369
+ progressFillRef={progressFillRef}
370
+ progressLabelRef={progressLabelRef}
371
+ midiUrl={midiUrl}
372
+ midiFilename={midiFilenameRef.current}
373
+ midiBlob={midiBlob}
374
+ currentFile={currentFile}
375
+ onTranscribeAnother={transcribeAnother}
376
+ />
377
+ </main>
378
+ )}
379
+
380
+ <Footer />
381
+
382
+ {screen === "transcribe" && <DropOverlay />}
383
+ </>
384
+ );
385
+ }
source/demo/web/src/audio.ts ADDED
@@ -0,0 +1,528 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as Tone from "tone";
2
+ import { WorkletSynthesizer } from "spessasynth_lib";
3
+ import workletUrl from "spessasynth_lib/dist/spessasynth_processor.min.js?url";
4
+
5
+ /**
6
+ * Playback goes through spessasynth_lib, a full SoundFont synthesizer running
7
+ * in an AudioWorklet, fed with MuseScore_General.sf3 (the vorbis-compressed
8
+ * build of the same soundfont the backend's fluidsynth /auralize uses). The
9
+ * backend serves it at /soundfonts/ from a locally-cached download — see
10
+ * muscriptor/soundfonts.py.
11
+ */
12
+ const SOUNDFONT_URL = "/soundfonts/MuseScore_General.sf3";
13
+
14
+ /** GM channel reserved for percussion. */
15
+ const DRUM_CHANNEL = 9;
16
+
17
+ /** Map a muscriptor instrument-group name to a General MIDI program number. */
18
+ const GM_PROGRAM: Record<string, number> = {
19
+ acoustic_piano: 0,
20
+ electric_piano: 4,
21
+ chromatic_percussion: 9,
22
+ organ: 19,
23
+ acoustic_guitar: 24,
24
+ clean_electric_guitar: 27,
25
+ distorted_electric_guitar: 30,
26
+ acoustic_bass: 32,
27
+ electric_bass: 33,
28
+ violin: 40,
29
+ viola: 41,
30
+ cello: 42,
31
+ contrabass: 43,
32
+ orchestral_harp: 46,
33
+ timpani: 47,
34
+ string_ensemble: 48,
35
+ synth_strings: 50,
36
+ voice: 52,
37
+ orchestra_hit: 55,
38
+ trumpet: 56,
39
+ trombone: 57,
40
+ tuba: 58,
41
+ french_horn: 60,
42
+ brass_section: 61,
43
+ soprano_and_alto_sax: 65,
44
+ tenor_sax: 66,
45
+ baritone_sax: 67,
46
+ oboe: 68,
47
+ english_horn: 69,
48
+ bassoon: 70,
49
+ clarinet: 71,
50
+ flutes: 73,
51
+ synth_lead: 80,
52
+ synth_pad: 89,
53
+ };
54
+
55
+ /** Velocity used for every synthesized note. */
56
+ const NOTE_VELOCITY = 100;
57
+
58
+ type NoteOpts = {
59
+ instrument: string;
60
+ pitch: number;
61
+ start: number;
62
+ end: number;
63
+ };
64
+
65
+ type SynthMode = "loading" | "soundfont" | "fallback";
66
+
67
+ type FallbackOscillator = "sine" | "triangle" | "sawtooth" | "square";
68
+
69
+ /**
70
+ * AudioWorklet is restricted to secure contexts, so the plain-HTTP LAN demo
71
+ * cannot use SpessaSynth. Keep that deployment useful with a lightweight
72
+ * Tone.js oscillator voice whose timbre roughly follows the predicted family.
73
+ */
74
+ function fallbackOscillator(instrument: string): FallbackOscillator {
75
+ if (instrument === "drums" || instrument === "timpani") return "square";
76
+ if (instrument.includes("guitar") || instrument.includes("bass")) return "sawtooth";
77
+ if (instrument.includes("sax") || instrument.includes("brass")) return "sawtooth";
78
+ if (instrument === "voice" || instrument.includes("flute")) return "sine";
79
+ return "triangle";
80
+ }
81
+
82
+ export class AudioEngine {
83
+ private ctx!: AudioContext;
84
+ private synth: WorkletSynthesizer | null = null;
85
+ private synthMode: SynthMode = "loading";
86
+ /** Secure-context-independent voices used when AudioWorklet is unavailable. */
87
+ private fallbackSynths = new Map<string, Tone.PolySynth>();
88
+ /** Notes scheduled while the synth / soundfont was still loading. */
89
+ private pendingNotes: NoteOpts[] = [];
90
+ /** MIDI channel assigned to each instrument group. */
91
+ private channels = new Map<string, number>();
92
+ /** Zero-gain shadow channel per instrument, used only to pre-decode samples. */
93
+ private warmChannels = new Map<string, number>();
94
+ /** `instrument:pitch` pairs already warmed (the synth caches per-pitch voices). */
95
+ private warmedNotes = new Set<string>();
96
+ private nextChannel = 0;
97
+ /** All notes ever scheduled — kept so Play-from-0 can re-schedule them. */
98
+ private allNotes: NoteOpts[] = [];
99
+ private autoStopAt: number | null = null;
100
+ /** Decoded original audio + live playback node, for the WAV/MIDI mix. */
101
+ private wavBuffer: AudioBuffer | null = null;
102
+ private wavSource: AudioBufferSourceNode | null = null;
103
+ private wavGain: GainNode;
104
+ private midiGain: GainNode;
105
+ /** Panners on each bus: centered in mix mode, hard L/R in stereo mode. */
106
+ private wavPanner: StereoPannerNode;
107
+ private midiPanner: StereoPannerNode;
108
+ private mutedInstruments = new Set<string>();
109
+ private mix = 0.75; // 0 = full WAV, 1 = full MIDI
110
+ /** When true: original audio hard-left, synthesis hard-right (mix ignored). */
111
+ private stereo = false;
112
+
113
+ constructor(options: { forceFallback?: boolean } = {}) {
114
+ // Tone.getContext() lazily creates a (suspended) AudioContext — no user
115
+ // gesture needed. The synth and soundfont can load while suspended;
116
+ // we only need to call Tone.start() to *resume* it on the play click.
117
+ this.ctx = Tone.getContext().rawContext as AudioContext;
118
+ // Each bus runs gain → panner → destination so we can both crossfade
119
+ // (gain) and place the two sources L/R (pan) independently.
120
+ this.midiPanner = this.ctx.createStereoPanner();
121
+ this.midiPanner.connect(this.ctx.destination);
122
+ this.midiGain = this.ctx.createGain();
123
+ this.midiGain.connect(this.midiPanner);
124
+ this.wavPanner = this.ctx.createStereoPanner();
125
+ this.wavPanner.connect(this.ctx.destination);
126
+ this.wavGain = this.ctx.createGain();
127
+ this.wavGain.connect(this.wavPanner);
128
+ // AudioWorkletNode is deliberately unavailable on plain-HTTP non-localhost
129
+ // pages. Those are exactly how the workstation demos are shared, so avoid
130
+ // downloading a 40 MB SoundFont that cannot be played and select the
131
+ // oscillator fallback immediately. HTTPS and localhost retain the richer
132
+ // SoundFont path.
133
+ if (!options.forceFallback && globalThis.isSecureContext && this.ctx.audioWorklet) {
134
+ this.initSynth().catch((e) => this.initFallback(e));
135
+ } else {
136
+ this.initFallback(new Error("AudioWorklet requires HTTPS or localhost"));
137
+ }
138
+ this.applyMix();
139
+ Tone.getTransport().on("start", (time) => this.startWavSource(time));
140
+ Tone.getTransport().on("stop", () => this.stopWavSource());
141
+ // Pause keeps the transport position but emits "pause", not "stop", so the
142
+ // raw WAV buffer source must be torn down here too; "start" re-creates it at
143
+ // the paused offset when playback resumes.
144
+ Tone.getTransport().on("pause", () => this.stopWavSource());
145
+ }
146
+
147
+ /** Load the worklet + soundfont, then flush notes queued in the meantime. */
148
+ private async initSynth() {
149
+ // Fetch the soundfont concurrently with the worklet setup.
150
+ const soundfont = fetch(SOUNDFONT_URL).then((res) => {
151
+ if (!res.ok) throw new Error(`${SOUNDFONT_URL}: HTTP ${res.status}`);
152
+ return res.arrayBuffer();
153
+ });
154
+ // Tone wraps its AudioContext with standardized-audio-context, so the
155
+ // worklet module and node must be created through Tone's own helpers —
156
+ // spessasynth's audioNodeCreators hook exists for exactly this.
157
+ const toneCtx = Tone.getContext();
158
+ await toneCtx.addAudioWorkletModule(workletUrl);
159
+ const synth = new WorkletSynthesizer(this.ctx, {
160
+ audioNodeCreators: {
161
+ worklet: (_ctx, name, options) =>
162
+ toneCtx.createAudioWorkletNode(name, options),
163
+ },
164
+ });
165
+ synth.connect(this.midiGain);
166
+ await synth.isReady;
167
+ await synth.soundBankManager.addSoundBank(
168
+ await soundfont,
169
+ "MuseScore_General",
170
+ );
171
+ this.synth = synth;
172
+ this.synthMode = "soundfont";
173
+ this.flushPendingNotes();
174
+ }
175
+
176
+ /** Select the basic synth used by insecure-context demo deployments. */
177
+ private initFallback(reason: unknown) {
178
+ if (this.synthMode !== "loading") return;
179
+ console.warn(
180
+ "SoundFont synthesis is unavailable; using the basic browser synth instead.",
181
+ reason,
182
+ );
183
+ this.synthMode = "fallback";
184
+ this.flushPendingNotes();
185
+ }
186
+
187
+ private flushPendingNotes() {
188
+ const queued = this.pendingNotes;
189
+ this.pendingNotes = [];
190
+ for (const n of queued) this.scheduleNoteRaw(n);
191
+ }
192
+
193
+ /** Lazily allocate one polyphonic fallback voice per instrument family. */
194
+ private fallbackSynthFor(instrument: string): Tone.PolySynth {
195
+ let voice = this.fallbackSynths.get(instrument);
196
+ if (voice) return voice;
197
+ const percussive = instrument === "drums" || instrument === "timpani";
198
+ voice = new Tone.PolySynth(Tone.Synth, {
199
+ oscillator: { type: fallbackOscillator(instrument) },
200
+ envelope: percussive
201
+ ? { attack: 0.001, decay: 0.08, sustain: 0.05, release: 0.05 }
202
+ : { attack: 0.01, decay: 0.1, sustain: 0.55, release: 0.12 },
203
+ });
204
+ voice.maxPolyphony = 32;
205
+ voice.volume.value = this.mutedInstruments.has(instrument) ? -Infinity : -10;
206
+ voice.connect(this.midiGain);
207
+ this.fallbackSynths.set(instrument, voice);
208
+ return voice;
209
+ }
210
+
211
+ private stopSynthVoices() {
212
+ this.synth?.stopAll();
213
+ for (const voice of this.fallbackSynths.values()) voice.releaseAll();
214
+ }
215
+
216
+ /** Decode `file` and remember the buffer for synced WAV playback. */
217
+ async loadWav(file: File) {
218
+ this.stopWavSource();
219
+ this.wavBuffer = null;
220
+ const bytes = await file.arrayBuffer();
221
+ try {
222
+ this.wavBuffer = await this.ctx.decodeAudioData(bytes);
223
+ } catch {
224
+ // Non-decodable input — keep MIDI-only playback.
225
+ this.wavBuffer = null;
226
+ }
227
+ // The stereo-mode WAV level depends on the buffer's channel count.
228
+ this.applyMix();
229
+ }
230
+
231
+ /** Set the MIDI/WAV crossfade. `midiAmount` in [0, 1]. */
232
+ setMix(midiAmount: number) {
233
+ this.mix = Math.max(0, Math.min(1, midiAmount));
234
+ this.applyMix();
235
+ }
236
+
237
+ /** Toggle stereo split: original → left, synthesis → right. Overrides mix. */
238
+ setStereo(enabled: boolean) {
239
+ this.stereo = enabled;
240
+ this.applyMix();
241
+ }
242
+
243
+ private applyMix() {
244
+ const t = this.ctx.currentTime;
245
+ if (this.stereo) {
246
+ // Panned hard to opposite channels. Hard-panning a stereo signal sums
247
+ // its L+R into one channel (up to +6 dB), so halve the gain of stereo
248
+ // sources to stay at roughly the level they have in mix mode. Mono
249
+ // sources pass through a hard pan at unity, so they need no trim.
250
+ const wavLevel = this.wavBuffer?.numberOfChannels === 1 ? 1 : 0.5;
251
+ this.wavGain.gain.setTargetAtTime(wavLevel, t, 0.01);
252
+ this.midiGain.gain.setTargetAtTime(0.5, t, 0.01); // synth is stereo
253
+ this.wavPanner.pan.setTargetAtTime(-1, t, 0.01);
254
+ this.midiPanner.pan.setTargetAtTime(1, t, 0.01);
255
+ } else {
256
+ // Centered crossfade between the two buses.
257
+ this.wavGain.gain.setTargetAtTime(1 - this.mix, t, 0.01);
258
+ this.midiGain.gain.setTargetAtTime(this.mix, t, 0.01);
259
+ this.wavPanner.pan.setTargetAtTime(0, t, 0.01);
260
+ this.midiPanner.pan.setTargetAtTime(0, t, 0.01);
261
+ }
262
+ }
263
+
264
+ /** Get (or assign) the MIDI channel for an instrument group. */
265
+ private channelFor(instrument: string): number {
266
+ let ch = this.channels.get(instrument);
267
+ if (ch !== undefined) return ch;
268
+ const synth = this.synth!;
269
+ if (instrument === "drums") {
270
+ ch = DRUM_CHANNEL;
271
+ } else {
272
+ ch = this.nextChannel++;
273
+ if (this.nextChannel === DRUM_CHANNEL) this.nextChannel++;
274
+ while (ch >= synth.channelCount) synth.addNewChannel();
275
+ synth.programChange(ch, GM_PROGRAM[instrument] ?? 0);
276
+ }
277
+ if (this.mutedInstruments.has(instrument)) {
278
+ synth.midiChannels[ch]?.setSystemParameter("isMuted", true);
279
+ }
280
+ this.channels.set(instrument, ch);
281
+ return ch;
282
+ }
283
+
284
+ /**
285
+ * Get (or create) the zero-gain shadow channel used to pre-warm `instrument`.
286
+ *
287
+ * The soundfont is vorbis-compressed (SF3): the worklet decodes each sample
288
+ * lazily — synchronously, on the audio thread — the first time a voice needs
289
+ * it, which audibly stutters playback (see {@link warmNote}). A shadow
290
+ * channel with the same program but channel gain 0 lets us trigger those
291
+ * decodes silently; the decoded samples and built voices land in synth-wide
292
+ * caches keyed by (preset, key, velocity), so the real channel then plays
293
+ * warm.
294
+ */
295
+ private warmChannelFor(instrument: string): number {
296
+ let ch = this.warmChannels.get(instrument);
297
+ if (ch !== undefined) return ch;
298
+ const synth = this.synth!;
299
+ ch = this.nextChannel++;
300
+ if (this.nextChannel === DRUM_CHANNEL) this.nextChannel++;
301
+ while (ch >= synth.channelCount) synth.addNewChannel();
302
+ if (instrument === "drums") {
303
+ synth.midiChannels[ch]?.setDrums(true);
304
+ } else {
305
+ synth.programChange(ch, GM_PROGRAM[instrument] ?? 0);
306
+ }
307
+ synth.midiChannels[ch]?.setSystemParameter("gain", 0);
308
+ this.warmChannels.set(instrument, ch);
309
+ return ch;
310
+ }
311
+
312
+ /**
313
+ * Pre-decode the sample(s) behind a note by playing it once, immediately and
314
+ * silently, on the instrument's shadow channel. Called as notes stream in
315
+ * during transcription so first playback doesn't stall on vorbis decodes.
316
+ * Velocity must match playback ({@link NOTE_VELOCITY}) — the synth's voice
317
+ * cache is keyed on it.
318
+ */
319
+ private warmNote(instrument: string, pitch: number) {
320
+ const key = `${instrument}:${pitch}`;
321
+ if (this.warmedNotes.has(key)) return;
322
+ this.warmedNotes.add(key);
323
+ const synth = this.synth!;
324
+ const ch = this.warmChannelFor(instrument);
325
+ synth.noteOn(ch, pitch, NOTE_VELOCITY);
326
+ synth.noteOff(ch, pitch);
327
+ }
328
+
329
+ /** Mute or unmute a single instrument on the MIDI track. Works live. */
330
+ setInstrumentMuted(instrument: string, muted: boolean) {
331
+ if (muted) this.mutedInstruments.add(instrument);
332
+ else this.mutedInstruments.delete(instrument);
333
+ const ch = this.channels.get(instrument);
334
+ if (ch !== undefined) {
335
+ this.synth?.midiChannels[ch]?.setSystemParameter("isMuted", muted);
336
+ }
337
+ const fallback = this.fallbackSynths.get(instrument);
338
+ if (fallback) fallback.volume.value = muted ? -Infinity : -10;
339
+ }
340
+
341
+ private startWavSource(at: number) {
342
+ this.stopWavSource();
343
+ if (!this.wavBuffer) return;
344
+ const offset = Tone.getTransport().seconds;
345
+ if (offset >= this.wavBuffer.duration) return;
346
+ const src = this.ctx.createBufferSource();
347
+ src.buffer = this.wavBuffer;
348
+ src.connect(this.wavGain);
349
+ src.start(at, offset);
350
+ this.wavSource = src;
351
+ }
352
+
353
+ private stopWavSource() {
354
+ if (!this.wavSource) return;
355
+ try {
356
+ this.wavSource.stop();
357
+ } catch {
358
+ // already stopped
359
+ }
360
+ this.wavSource.disconnect();
361
+ this.wavSource = null;
362
+ }
363
+
364
+ /** Schedule a note at transport time `start` for `duration` seconds. */
365
+ scheduleNote(opts: NoteOpts) {
366
+ this.allNotes.push({ ...opts });
367
+ this.scheduleNoteRaw(opts);
368
+ }
369
+
370
+ private scheduleNoteRaw(opts: NoteOpts) {
371
+ if (this.synthMode === "loading") {
372
+ this.pendingNotes.push(opts);
373
+ return;
374
+ }
375
+ const duration = Math.max(0.05, opts.end - opts.start);
376
+ if (this.synthMode === "fallback") {
377
+ const voice = this.fallbackSynthFor(opts.instrument);
378
+ Tone.getTransport().scheduleOnce((time) => {
379
+ voice.triggerAttackRelease(
380
+ Tone.Frequency(opts.pitch, "midi").toFrequency(),
381
+ duration,
382
+ time,
383
+ NOTE_VELOCITY / 127,
384
+ );
385
+ }, opts.start);
386
+ return;
387
+ }
388
+
389
+ const synth = this.synth!;
390
+ const channel = this.channelFor(opts.instrument);
391
+ this.warmNote(opts.instrument, opts.pitch);
392
+ // The callback fires slightly ahead of the audio time; passing `time`
393
+ // through lets the worklet apply both events sample-accurately. Pairing
394
+ // the noteOff with its noteOn also guarantees no stuck notes.
395
+ Tone.getTransport().scheduleOnce((time) => {
396
+ synth.noteOn(channel, opts.pitch, NOTE_VELOCITY, { time });
397
+ synth.noteOff(channel, opts.pitch, { time: time + duration });
398
+ }, opts.start);
399
+ }
400
+
401
+ /** Resume the AudioContext. Must be called from a user-gesture handler. */
402
+ async unlock() {
403
+ await Tone.start();
404
+ }
405
+
406
+ async play() {
407
+ await Tone.start();
408
+ const t = Tone.getTransport();
409
+ // If we're at the very start, every previously-fired scheduleOnce is gone;
410
+ // re-schedule every known note (and the auto-stop) from scratch.
411
+ if (t.seconds < 0.001) {
412
+ t.cancel();
413
+ for (const n of this.allNotes) this.scheduleNoteRaw(n);
414
+ if (this.autoStopAt !== null) this.scheduleStopRaw(this.autoStopAt);
415
+ }
416
+ t.start();
417
+ }
418
+
419
+ pause() {
420
+ Tone.getTransport().pause();
421
+ this.stopSynthVoices();
422
+ }
423
+
424
+ /** Jump the transport to `seconds`, re-scheduling notes from that point. */
425
+ seek(seconds: number) {
426
+ const t = Tone.getTransport();
427
+ const target = Math.max(0, seconds);
428
+ const wasPlaying = t.state === "started";
429
+ if (wasPlaying) t.pause();
430
+ this.stopSynthVoices();
431
+ // scheduleOnce events are one-shot, so a jump (especially backwards) needs
432
+ // a full re-schedule of everything that starts after the new position.
433
+ t.cancel();
434
+ t.seconds = target;
435
+ for (const n of this.allNotes) {
436
+ if (n.start >= target) this.scheduleNoteRaw(n);
437
+ }
438
+ if (this.autoStopAt !== null && this.autoStopAt > target) {
439
+ this.scheduleStopRaw(this.autoStopAt);
440
+ }
441
+ // Restarting the transport re-fires the "start" handler, which restarts
442
+ // the WAV source at the new offset.
443
+ if (wasPlaying) t.start();
444
+ }
445
+
446
+ /** Move the transport clock only — a cheap per-frame seek for live
447
+ * scrubbing. Call while paused; the one-shot note schedule is left stale,
448
+ * so follow up with a real seek() before resuming playback. */
449
+ scrubTo(seconds: number) {
450
+ Tone.getTransport().seconds = Math.max(0, seconds);
451
+ }
452
+
453
+ stop() {
454
+ const t = Tone.getTransport();
455
+ t.stop();
456
+ t.cancel();
457
+ t.seconds = 0;
458
+ this.stopSynthVoices();
459
+ }
460
+
461
+ /**
462
+ * Replace the scheduled MIDI note set in place, keeping the loaded original
463
+ * audio and the current transport position. Used by the side-by-side compare
464
+ * view to A/B between the two models' transcriptions over one shared
465
+ * transport — Tone's transport is global, so a second AudioEngine can't run
466
+ * alongside this one.
467
+ */
468
+ loadNotes(notes: NoteOpts[]) {
469
+ const t = Tone.getTransport();
470
+ const from = t.seconds;
471
+ t.cancel();
472
+ this.stopSynthVoices();
473
+ this.allNotes = notes.map((n) => ({ ...n }));
474
+ this.pendingNotes = [];
475
+ for (const n of this.allNotes) {
476
+ if (n.start >= from) this.scheduleNoteRaw(n);
477
+ }
478
+ const maxEnd = this.allNotes.reduce((m, n) => Math.max(m, n.end), 0);
479
+ this.autoStopAt = maxEnd > 0 ? maxEnd + 0.3 : null;
480
+ if (this.autoStopAt !== null && this.autoStopAt > from) {
481
+ this.scheduleStopRaw(this.autoStopAt);
482
+ }
483
+ }
484
+
485
+ /** Wipe scheduled state for a brand-new transcription. */
486
+ reset() {
487
+ this.stop();
488
+ this.allNotes = [];
489
+ this.pendingNotes = [];
490
+ this.autoStopAt = null;
491
+ this.stopWavSource();
492
+ this.wavBuffer = null;
493
+ // The instrument list is rebuilt from scratch, so unmute everything.
494
+ this.mutedInstruments.clear();
495
+ for (const ch of this.channels.values()) {
496
+ this.synth?.midiChannels[ch]?.setSystemParameter("isMuted", false);
497
+ }
498
+ for (const voice of this.fallbackSynths.values()) voice.volume.value = -10;
499
+ }
500
+
501
+ /** Remember the auto-stop time and schedule it for the current run. */
502
+ scheduleStop(t: number) {
503
+ this.autoStopAt = t;
504
+ this.scheduleStopRaw(t);
505
+ }
506
+
507
+ private scheduleStopRaw(at: number) {
508
+ Tone.getTransport().scheduleOnce(() => {
509
+ Tone.getTransport().stop();
510
+ Tone.getTransport().seconds = 0;
511
+ this.stopSynthVoices();
512
+ }, at);
513
+ }
514
+
515
+ /** Current playback position in seconds. */
516
+ get seconds(): number {
517
+ return Tone.getTransport().seconds;
518
+ }
519
+
520
+ /** Duration of the decoded source audio in seconds, or 0 if not yet loaded. */
521
+ get duration(): number {
522
+ return this.wavBuffer?.duration ?? 0;
523
+ }
524
+
525
+ get state(): "started" | "stopped" | "paused" {
526
+ return Tone.getTransport().state;
527
+ }
528
+ }
source/demo/web/src/compare.tsx ADDED
@@ -0,0 +1,779 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { createRoot } from "react-dom/client";
2
+ import { useEffect, useMemo, useRef, useState } from "react";
3
+ import clsx from "clsx";
4
+ import { AudioEngine } from "./audio";
5
+ import { label } from "./instruments";
6
+ import { PianoRoll, instrumentColor, type RollNote } from "./pianoroll";
7
+ import { streamTranscribe, TranscribeError } from "./sse";
8
+ import { IconDownload, IconPause, IconPlay } from "./components/icons";
9
+ import "./style.css";
10
+
11
+ type ModelId = "hdx" | "musc" | "yptf" | "yourmt3" | "miros";
12
+ type Status = "idle" | "queued" | "transcribing" | "done" | "error";
13
+ type Health = "checking" | "online" | "offline";
14
+
15
+ interface ModelConfig {
16
+ id: ModelId;
17
+ name: string;
18
+ eyebrow: string;
19
+ detail: string;
20
+ base: string;
21
+ accent: string;
22
+ enabled: boolean;
23
+ external: boolean;
24
+ }
25
+
26
+ interface ModelResult {
27
+ status: Status;
28
+ noteCount: number;
29
+ seconds: number | null;
30
+ instruments: string[];
31
+ progress: number;
32
+ error: string | null;
33
+ midiUrl: string | null;
34
+ }
35
+
36
+ interface Panel {
37
+ canvas: HTMLCanvasElement | null;
38
+ roll: PianoRoll | null;
39
+ open: Map<number, RollNote>;
40
+ audioNotes: RollNote[];
41
+ instruments: string[];
42
+ }
43
+
44
+ interface ExampleTrack {
45
+ id: string;
46
+ title: string;
47
+ artist: string;
48
+ genre: string;
49
+ duration: number;
50
+ license: string;
51
+ sourceUrl: string;
52
+ audioUrl: string;
53
+ }
54
+
55
+ type StreamEvent =
56
+ | { type: "start"; pitch: number; start_time: number; index: number; instrument: string }
57
+ | { type: "end"; end_time: number; start_event_index: number }
58
+ | { type: "progress"; completed: number; total: number }
59
+ | { type: "midi"; data: string };
60
+
61
+ const params = new URLSearchParams(location.search);
62
+ const host = location.hostname || "127.0.0.1";
63
+ const STORAGE_KEY = "hendrix-demo-models-v2";
64
+
65
+ const MODEL_SEED: ModelConfig[] = [
66
+ {
67
+ id: "hdx",
68
+ name: "Hendrix",
69
+ eyebrow: "Shipping system",
70
+ detail: "46M · consensus-distilled soup",
71
+ base: params.get("hdx") ?? `http://${host}:8223`,
72
+ accent: "#ff5a3d",
73
+ enabled: true,
74
+ external: false,
75
+ },
76
+ {
77
+ id: "musc",
78
+ name: "MuScriptor",
79
+ eyebrow: "Open baseline",
80
+ detail: "1.4B · Kyutai × Mirelo",
81
+ base: params.get("musc") ?? `http://${host}:8222`,
82
+ accent: "#ec3f77",
83
+ enabled: true,
84
+ external: true,
85
+ },
86
+ {
87
+ id: "yptf",
88
+ name: "YPTF-MoE",
89
+ eyebrow: "Released parent",
90
+ detail: "46M · public checkpoint",
91
+ base: params.get("yptf") ?? `http://${host}:8224`,
92
+ accent: "#8daa35",
93
+ enabled: false,
94
+ external: true,
95
+ },
96
+ {
97
+ id: "yourmt3",
98
+ name: "YourMT3+",
99
+ eyebrow: "External baseline",
100
+ detail: "multi-task MT3 family",
101
+ base: params.get("yourmt3") ?? `http://${host}:8225`,
102
+ accent: "#188fa7",
103
+ enabled: false,
104
+ external: true,
105
+ },
106
+ {
107
+ id: "miros",
108
+ name: "MIROS",
109
+ eyebrow: "External baseline",
110
+ detail: "high-precision system",
111
+ base: params.get("miros") ?? `http://${host}:8226`,
112
+ accent: "#d08a12",
113
+ enabled: false,
114
+ external: true,
115
+ },
116
+ ];
117
+
118
+ const PRESETS: { id: string; label: string; ids: ModelId[] }[] = [
119
+ { id: "hendrix", label: "Hendrix", ids: ["hdx"] },
120
+ { id: "muscriptor", label: "MuScriptor", ids: ["musc"] },
121
+ { id: "baselines", label: "All baselines", ids: ["musc", "yptf", "yourmt3", "miros"] },
122
+ { id: "full", label: "Full field", ids: MODEL_SEED.map((model) => model.id) },
123
+ ];
124
+
125
+ const EMPTY_RESULT: ModelResult = {
126
+ status: "idle",
127
+ noteCount: 0,
128
+ seconds: null,
129
+ instruments: [],
130
+ progress: 0,
131
+ error: null,
132
+ midiUrl: null,
133
+ };
134
+
135
+ function initialModels(): ModelConfig[] {
136
+ let models = MODEL_SEED;
137
+ try {
138
+ const stored = JSON.parse(localStorage.getItem(STORAGE_KEY) ?? "null") as
139
+ | Partial<ModelConfig>[]
140
+ | null;
141
+ if (Array.isArray(stored)) {
142
+ models = MODEL_SEED.map((seed) => ({
143
+ ...seed,
144
+ ...stored.find((item) => item.id === seed.id),
145
+ id: seed.id,
146
+ name: seed.name,
147
+ accent: seed.accent,
148
+ }));
149
+ }
150
+ } catch {
151
+ // A blocked or stale localStorage entry should never prevent the demo loading.
152
+ }
153
+ const selected = params.get("models")?.split(",").filter(Boolean) as ModelId[] | undefined;
154
+ return models.map((model) => ({
155
+ ...model,
156
+ base: params.get(model.id) ?? model.base,
157
+ enabled: selected ? selected.includes(model.id) : model.enabled,
158
+ }));
159
+ }
160
+
161
+ function emptyResults(models: ModelConfig[]): Record<ModelId, ModelResult> {
162
+ return Object.fromEntries(models.map((model) => [model.id, { ...EMPTY_RESULT }])) as Record<
163
+ ModelId,
164
+ ModelResult
165
+ >;
166
+ }
167
+
168
+ function formatClock(seconds: number): string {
169
+ if (!Number.isFinite(seconds) || seconds < 0) return "0:00";
170
+ const mins = Math.floor(seconds / 60);
171
+ const secs = Math.floor(seconds % 60);
172
+ return `${mins}:${secs.toString().padStart(2, "0")}`;
173
+ }
174
+
175
+ function midiObjectUrl(base64: string): string {
176
+ const bytes = Uint8Array.from(atob(base64), (char) => char.charCodeAt(0));
177
+ return URL.createObjectURL(new Blob([bytes], { type: "audio/midi" }));
178
+ }
179
+
180
+ function modelError(error: unknown, model: ModelConfig): string {
181
+ if (error instanceof TranscribeError && error.userMessage) return error.userMessage;
182
+ return `No response from ${model.name} at ${model.base}. Check the endpoint, then retry this run.`;
183
+ }
184
+
185
+ function IconTune() {
186
+ return (
187
+ <svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" strokeWidth="1.8" aria-hidden="true">
188
+ <path d="M4 7h9M17 7h3M4 17h3M11 17h9M13 4v6M7 14v6" />
189
+ </svg>
190
+ );
191
+ }
192
+
193
+ function IconUpload() {
194
+ return (
195
+ <svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" strokeWidth="1.8" aria-hidden="true">
196
+ <path d="M12 16V4m0 0L7.5 8.5M12 4l4.5 4.5M4 15v4h16v-4" />
197
+ </svg>
198
+ );
199
+ }
200
+
201
+ function IconClose() {
202
+ return (
203
+ <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.8" aria-hidden="true">
204
+ <path d="M5 5l14 14M19 5L5 19" />
205
+ </svg>
206
+ );
207
+ }
208
+
209
+ function Compare() {
210
+ const engineRef = useRef<AudioEngine | null>(null);
211
+ if (engineRef.current === null) engineRef.current = new AudioEngine();
212
+ const engine = engineRef.current;
213
+ const panels = useRef(new Map<ModelId, Panel>());
214
+ const abortRef = useRef<AbortController | null>(null);
215
+ const clockRef = useRef<HTMLSpanElement>(null);
216
+ const seekRef = useRef<HTMLInputElement>(null);
217
+ const fileInputRef = useRef<HTMLInputElement>(null);
218
+ const listenRef = useRef<ModelId>("hdx");
219
+
220
+ const [models, setModels] = useState<ModelConfig[]>(initialModels);
221
+ const [results, setResults] = useState<Record<ModelId, ModelResult>>(() => emptyResults(MODEL_SEED));
222
+ const [health, setHealth] = useState<Record<ModelId, Health>>(
223
+ () => Object.fromEntries(MODEL_SEED.map((model) => [model.id, "checking"])) as Record<ModelId, Health>,
224
+ );
225
+ const [selectedFile, setSelectedFile] = useState<File | null>(null);
226
+ const [sourceError, setSourceError] = useState<string | null>(null);
227
+ const [listen, setListen] = useState<ModelId>("hdx");
228
+ const [playing, setPlaying] = useState(false);
229
+ const [mix, setMix] = useState(0.72);
230
+ const [dragging, setDragging] = useState(false);
231
+ const [configOpen, setConfigOpen] = useState(false);
232
+ const [examples, setExamples] = useState<ExampleTrack[]>([]);
233
+ const [catalogState, setCatalogState] = useState<"loading" | "ready" | "empty" | "error">("loading");
234
+ const [loadingExample, setLoadingExample] = useState<string | null>(null);
235
+ listenRef.current = listen;
236
+
237
+ const activeModels = useMemo(() => models.filter((model) => model.enabled), [models]);
238
+ const anyRunning = activeModels.some((model) =>
239
+ ["queued", "transcribing"].includes(results[model.id].status),
240
+ );
241
+ const anyNotes = activeModels.some((model) => results[model.id].noteCount > 0);
242
+
243
+ function ensurePanel(id: ModelId): Panel {
244
+ let panel = panels.current.get(id);
245
+ if (!panel) {
246
+ panel = { canvas: null, roll: null, open: new Map(), audioNotes: [], instruments: [] };
247
+ panels.current.set(id, panel);
248
+ }
249
+ return panel;
250
+ }
251
+
252
+ function attachCanvas(id: ModelId, canvas: HTMLCanvasElement | null) {
253
+ if (!canvas) return;
254
+ const panel = ensurePanel(id);
255
+ if (panel.canvas !== canvas) {
256
+ panel.canvas = canvas;
257
+ panel.roll = new PianoRoll(canvas);
258
+ }
259
+ }
260
+
261
+ function updateResult(id: ModelId, patch: Partial<ModelResult>) {
262
+ setResults((current) => ({ ...current, [id]: { ...current[id], ...patch } }));
263
+ }
264
+
265
+ function releaseMidiUrls() {
266
+ for (const result of Object.values(results)) {
267
+ if (result.midiUrl) URL.revokeObjectURL(result.midiUrl);
268
+ }
269
+ }
270
+
271
+ function resetRun() {
272
+ engine.reset();
273
+ releaseMidiUrls();
274
+ for (const model of models) {
275
+ const panel = ensurePanel(model.id);
276
+ panel.roll?.clear();
277
+ panel.open.clear();
278
+ panel.audioNotes = [];
279
+ panel.instruments = [];
280
+ }
281
+ setResults(emptyResults(models));
282
+ setPlaying(false);
283
+ }
284
+
285
+ function selectFile(file: File) {
286
+ const looksLikeAudio = file.type.startsWith("audio/") || /\.(wav|mp3|flac|ogg|m4a)$/i.test(file.name);
287
+ if (!looksLikeAudio) {
288
+ setSourceError("That file does not look like audio. Choose a WAV, MP3, FLAC, OGG, or M4A file.");
289
+ return;
290
+ }
291
+ if (anyRunning) abortRef.current?.abort();
292
+ resetRun();
293
+ setSelectedFile(file);
294
+ setSourceError(null);
295
+ }
296
+
297
+ useEffect(() => {
298
+ try {
299
+ localStorage.setItem(
300
+ STORAGE_KEY,
301
+ JSON.stringify(models.map(({ id, base, enabled }) => ({ id, base, enabled }))),
302
+ );
303
+ } catch {
304
+ // Private browsing can deny storage; configuration still works for this tab.
305
+ }
306
+ const next = new URL(location.href);
307
+ next.searchParams.set("models", models.filter((model) => model.enabled).map((model) => model.id).join(","));
308
+ for (const model of models) next.searchParams.set(model.id, model.base);
309
+ history.replaceState(null, "", next);
310
+ }, [models]);
311
+
312
+ useEffect(() => {
313
+ const controllers = models.map((model) => {
314
+ const controller = new AbortController();
315
+ setHealth((current) => ({ ...current, [model.id]: "checking" }));
316
+ const timeout = window.setTimeout(() => controller.abort(), 3500);
317
+ fetch(`${model.base}/health`, { signal: controller.signal })
318
+ .then((response) => {
319
+ setHealth((current) => ({ ...current, [model.id]: response.ok ? "online" : "offline" }));
320
+ })
321
+ .catch(() => setHealth((current) => ({ ...current, [model.id]: "offline" })))
322
+ .finally(() => window.clearTimeout(timeout));
323
+ return controller;
324
+ });
325
+ return () => controllers.forEach((controller) => controller.abort());
326
+ }, [models.map((model) => model.base).join("|")]);
327
+
328
+ useEffect(() => {
329
+ const controller = new AbortController();
330
+ fetch("/examples/catalog.json", { signal: controller.signal })
331
+ .then(async (response) => {
332
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
333
+ return (await response.json()) as { examples?: ExampleTrack[] };
334
+ })
335
+ .then((payload) => {
336
+ const next = Array.isArray(payload.examples) ? payload.examples : [];
337
+ setExamples(next);
338
+ setCatalogState(next.length ? "ready" : "empty");
339
+ })
340
+ .catch((error) => {
341
+ if (error instanceof DOMException && error.name === "AbortError") return;
342
+ setCatalogState("error");
343
+ });
344
+ return () => controller.abort();
345
+ }, []);
346
+
347
+ useEffect(() => {
348
+ let frameId = 0;
349
+ const frame = () => {
350
+ const seconds = engine.seconds;
351
+ const duration = engine.duration;
352
+ for (const model of activeModels) {
353
+ const roll = panels.current.get(model.id)?.roll;
354
+ roll?.setPlayhead(seconds);
355
+ roll?.setDuration(duration);
356
+ roll?.render();
357
+ }
358
+ if (clockRef.current) clockRef.current.textContent = `${formatClock(seconds)} / ${formatClock(duration)}`;
359
+ if (seekRef.current && document.activeElement !== seekRef.current) {
360
+ seekRef.current.value = duration > 0 ? String((seconds / duration) * 1000) : "0";
361
+ }
362
+ if (engine.state !== "started" && playing) setPlaying(false);
363
+ frameId = requestAnimationFrame(frame);
364
+ };
365
+ frameId = requestAnimationFrame(frame);
366
+ return () => cancelAnimationFrame(frameId);
367
+ }, [activeModels, engine, playing]);
368
+
369
+ useEffect(() => {
370
+ const onKey = (event: KeyboardEvent) => {
371
+ if (event.code !== "Space" && event.key !== " ") return;
372
+ const tag = (event.target as HTMLElement | null)?.tagName;
373
+ if (["INPUT", "BUTTON", "SELECT", "TEXTAREA"].includes(tag ?? "")) return;
374
+ if (!anyNotes) return;
375
+ event.preventDefault();
376
+ togglePlay();
377
+ };
378
+ window.addEventListener("keydown", onKey);
379
+ return () => window.removeEventListener("keydown", onKey);
380
+ }, [anyNotes, engine]);
381
+
382
+ useEffect(() => {
383
+ let depth = 0;
384
+ const enter = (event: DragEvent) => {
385
+ event.preventDefault();
386
+ depth += 1;
387
+ setDragging(true);
388
+ };
389
+ const over = (event: DragEvent) => event.preventDefault();
390
+ const leave = () => {
391
+ depth = Math.max(0, depth - 1);
392
+ if (depth === 0) setDragging(false);
393
+ };
394
+ const drop = (event: DragEvent) => {
395
+ event.preventDefault();
396
+ depth = 0;
397
+ setDragging(false);
398
+ const file = event.dataTransfer?.files?.[0];
399
+ if (file) selectFile(file);
400
+ };
401
+ window.addEventListener("dragenter", enter);
402
+ window.addEventListener("dragover", over);
403
+ window.addEventListener("dragleave", leave);
404
+ window.addEventListener("drop", drop);
405
+ return () => {
406
+ window.removeEventListener("dragenter", enter);
407
+ window.removeEventListener("dragover", over);
408
+ window.removeEventListener("dragleave", leave);
409
+ window.removeEventListener("drop", drop);
410
+ };
411
+ });
412
+
413
+ useEffect(() => {
414
+ return () => {
415
+ abortRef.current?.abort();
416
+ releaseMidiUrls();
417
+ };
418
+ }, []);
419
+
420
+ async function runModel(model: ModelConfig, file: File, signal: AbortSignal) {
421
+ const panel = ensurePanel(model.id);
422
+ const started = performance.now();
423
+ updateResult(model.id, { status: "transcribing", progress: 0, error: null });
424
+ try {
425
+ for await (const raw of streamTranscribe(`${model.base}/transcribe`, file, undefined, signal)) {
426
+ if (signal.aborted) return;
427
+ const event = raw as StreamEvent;
428
+ if (event.type === "start") {
429
+ const note: RollNote = {
430
+ pitch: event.pitch,
431
+ start: event.start_time,
432
+ end: event.start_time,
433
+ instrument: event.instrument,
434
+ };
435
+ panel.roll?.addNote(note);
436
+ panel.open.set(event.index, note);
437
+ if (!panel.instruments.includes(event.instrument)) {
438
+ panel.instruments.push(event.instrument);
439
+ updateResult(model.id, { instruments: [...panel.instruments] });
440
+ }
441
+ } else if (event.type === "end") {
442
+ const note = panel.open.get(event.start_event_index);
443
+ if (!note) continue;
444
+ note.end = event.end_time;
445
+ panel.roll?.setNoteEnd(note, event.end_time);
446
+ panel.open.delete(event.start_event_index);
447
+ panel.audioNotes.push(note);
448
+ if (panel.audioNotes.length % 12 === 0) {
449
+ updateResult(model.id, { noteCount: panel.audioNotes.length });
450
+ }
451
+ if (listenRef.current === model.id) {
452
+ engine.scheduleNote({ instrument: note.instrument, pitch: note.pitch, start: note.start, end: note.end });
453
+ }
454
+ } else if (event.type === "progress") {
455
+ updateResult(model.id, {
456
+ progress: event.total > 0 ? Math.min(1, event.completed / event.total) : 0,
457
+ });
458
+ } else if (event.type === "midi") {
459
+ updateResult(model.id, { midiUrl: midiObjectUrl(event.data) });
460
+ }
461
+ }
462
+ if (signal.aborted) return;
463
+ const maxEnd = panel.audioNotes.reduce((maximum, note) => Math.max(maximum, note.end), 0);
464
+ updateResult(model.id, {
465
+ status: "done",
466
+ noteCount: panel.audioNotes.length,
467
+ seconds: (performance.now() - started) / 1000,
468
+ progress: 1,
469
+ });
470
+ if (listenRef.current === model.id && maxEnd > 0) engine.scheduleStop(maxEnd + 0.3);
471
+ } catch (error) {
472
+ if (signal.aborted) return;
473
+ updateResult(model.id, {
474
+ status: "error",
475
+ seconds: (performance.now() - started) / 1000,
476
+ error: modelError(error, model),
477
+ });
478
+ }
479
+ }
480
+
481
+ async function transcribe() {
482
+ if (!selectedFile || activeModels.length === 0) return;
483
+ abortRef.current?.abort();
484
+ resetRun();
485
+ const controller = new AbortController();
486
+ abortRef.current = controller;
487
+ setResults((current) => {
488
+ const next = { ...current };
489
+ for (const model of activeModels) next[model.id] = { ...EMPTY_RESULT, status: "queued" };
490
+ return next;
491
+ });
492
+ await engine.unlock().catch(() => undefined);
493
+ await engine.loadWav(selectedFile).catch(() => undefined);
494
+ engine.setMix(mix);
495
+ await Promise.allSettled(activeModels.map((model) => runModel(model, selectedFile, controller.signal)));
496
+ }
497
+
498
+ function togglePlay() {
499
+ if (engine.state === "started") {
500
+ engine.pause();
501
+ setPlaying(false);
502
+ } else {
503
+ engine.play();
504
+ setPlaying(true);
505
+ }
506
+ }
507
+
508
+ function chooseListen(id: ModelId) {
509
+ setListen(id);
510
+ const notes = ensurePanel(id).audioNotes;
511
+ engine.loadNotes(
512
+ notes.map((note) => ({ instrument: note.instrument, pitch: note.pitch, start: note.start, end: note.end })),
513
+ );
514
+ }
515
+
516
+ function applyPreset(ids: ModelId[]) {
517
+ setModels((current) => current.map((model) => ({ ...model, enabled: ids.includes(model.id) })));
518
+ const preferred = ids.includes(listen) ? listen : ids[0];
519
+ if (preferred) chooseListen(preferred);
520
+ }
521
+
522
+ function updateModel(id: ModelId, patch: Partial<ModelConfig>) {
523
+ setModels((current) => current.map((model) => (model.id === id ? { ...model, ...patch } : model)));
524
+ }
525
+
526
+ async function useExample(example: ExampleTrack) {
527
+ setLoadingExample(example.id);
528
+ setSourceError(null);
529
+ try {
530
+ const response = await fetch(example.audioUrl);
531
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
532
+ const blob = await response.blob();
533
+ selectFile(new File([blob], `${example.title}.wav`, { type: "audio/wav" }));
534
+ } catch {
535
+ setSourceError(`Could not load “${example.title}”. The local clip may have moved; refresh the catalog and try again.`);
536
+ } finally {
537
+ setLoadingExample(null);
538
+ }
539
+ }
540
+
541
+ return (
542
+ <div className={clsx("compare-app", dragging && "is-dragging")}>
543
+ <div className="compare-grain" aria-hidden="true" />
544
+ <header className="compare-masthead">
545
+ <a className="compare-wordmark" href="/" aria-label="Hendrix home">
546
+ <span>HENDRIX</span>
547
+ <small>LISTENING LAB / 01</small>
548
+ </a>
549
+ <div className="compare-intro">
550
+ <p className="compare-kicker">Multi-instrument transcription, exposed</p>
551
+ <h1>Hear the argument.<br /><em>See every note.</em></h1>
552
+ <p>
553
+ Route one recording through any combination of systems. Their predictions arrive live,
554
+ aligned to one transport, ready to inspect or audition.
555
+ </p>
556
+ </div>
557
+ <button className="compare-config-button" onClick={() => setConfigOpen(true)}>
558
+ <IconTune />
559
+ <span className="config-button-label">Configure models</span>
560
+ <span className="config-button-count">{activeModels.length}</span>
561
+ </button>
562
+ </header>
563
+
564
+ <main className="compare-main">
565
+ <nav className="preset-strip" aria-label="Model presets">
566
+ <span className="preset-label">Patch</span>
567
+ {PRESETS.map((preset) => {
568
+ const isActive = activeModels.length === preset.ids.length && preset.ids.every((id) => activeModels.some((model) => model.id === id));
569
+ return (
570
+ <button key={preset.id} className={clsx("preset-button", isActive && "is-active")} onClick={() => applyPreset(preset.ids)} disabled={anyRunning}>
571
+ {preset.label}
572
+ </button>
573
+ );
574
+ })}
575
+ </nav>
576
+
577
+ <section className="signal-rail" aria-label="Active model signal chain">
578
+ <div className="signal-origin">
579
+ <span>INPUT</span>
580
+ <strong>{selectedFile ? "ARMED" : "OPEN"}</strong>
581
+ </div>
582
+ <div className="signal-track" style={{ "--rail-count": Math.max(1, activeModels.length) } as React.CSSProperties}>
583
+ {activeModels.length === 0 ? (
584
+ <button className="signal-empty" onClick={() => setConfigOpen(true)}>Select at least one model to build a signal chain</button>
585
+ ) : activeModels.map((model, index) => (
586
+ <div className="signal-node" key={model.id} style={{ "--node-accent": model.accent, "--node-delay": `${index * 85}ms` } as React.CSSProperties}>
587
+ <span className={clsx("signal-light", `is-${results[model.id].status}`, health[model.id] === "offline" && "is-offline")} />
588
+ <strong>{model.name}</strong>
589
+ <small>{results[model.id].status === "transcribing" ? `${Math.round(results[model.id].progress * 100)}%` : health[model.id]}</small>
590
+ </div>
591
+ ))}
592
+ </div>
593
+ <div className="signal-output"><span>OUTPUTS</span><strong>{activeModels.length.toString().padStart(2, "0")}</strong></div>
594
+ </section>
595
+
596
+ <section className="source-console" aria-labelledby="source-heading">
597
+ <div className="source-console-head">
598
+ <div>
599
+ <span className="section-index">01 / SOURCE</span>
600
+ <h2 id="source-heading">Choose the recording</h2>
601
+ </div>
602
+ <p>Local files never leave the configured inference endpoints.</p>
603
+ </div>
604
+ <input
605
+ ref={fileInputRef}
606
+ type="file"
607
+ accept="audio/*,.wav,.mp3,.flac,.ogg,.m4a"
608
+ hidden
609
+ onChange={(event) => {
610
+ const file = event.target.files?.[0];
611
+ if (file) selectFile(file);
612
+ event.target.value = "";
613
+ }}
614
+ />
615
+ <div className="source-actions">
616
+ <button className="upload-plate" onClick={() => fileInputRef.current?.click()} disabled={anyRunning}>
617
+ <IconUpload />
618
+ <span>{selectedFile ? "Replace recording" : "Open a recording"}</span>
619
+ <small>WAV · MP3 · FLAC · OGG · M4A</small>
620
+ </button>
621
+ <div className={clsx("selected-source", selectedFile && "has-file")} aria-live="polite">
622
+ <span>{selectedFile ? "ON THE DESK" : "WAITING FOR AUDIO"}</span>
623
+ <strong title={selectedFile?.name}>{selectedFile?.name ?? "Drop a file anywhere, or pick from the crate below."}</strong>
624
+ {selectedFile && <small>{(selectedFile.size / 1_048_576).toFixed(1)} MB · ready for {activeModels.length} output{activeModels.length === 1 ? "" : "s"}</small>}
625
+ </div>
626
+ <button className="run-button" onClick={transcribe} disabled={!selectedFile || activeModels.length === 0 || anyRunning}>
627
+ <span>{anyRunning ? "Running the field" : `Run ${activeModels.length || "the"} model${activeModels.length === 1 ? "" : "s"}`}</span>
628
+ <small>{anyRunning ? "Streams stay independent" : "Start simultaneous inference"}</small>
629
+ </button>
630
+ </div>
631
+ {sourceError && <div className="source-error" role="alert"><strong>Source interrupted.</strong> {sourceError}</div>}
632
+
633
+ <div className="record-crate">
634
+ <div className="crate-heading">
635
+ <div><span>LOCAL RECORD CRATE</span><strong>{catalogState === "ready" ? `${examples.length} one-minute WAVs` : "Example WAVs"}</strong></div>
636
+ <small>Private workstation clips · source provenance retained · never included in the build</small>
637
+ </div>
638
+ {catalogState === "loading" && <div className="crate-state" aria-live="polite">Indexing the local record crate…</div>}
639
+ {catalogState === "error" && <div className="crate-state is-error">The local catalog is offline. Upload still works; restart the demo backend to restore examples.</div>}
640
+ {catalogState === "empty" && <div className="crate-state">No local WAVs found. Run <code>scripts/fetch_examples.py</code>, then refresh.</div>}
641
+ {catalogState === "ready" && (
642
+ <div className="crate-scroll">
643
+ {examples.map((example, index) => (
644
+ <button key={example.id} className={clsx("record-sleeve", loadingExample === example.id && "is-loading")} onClick={() => useExample(example)} disabled={anyRunning || loadingExample !== null}>
645
+ <span className="sleeve-number">{(index + 1).toString().padStart(2, "0")}</span>
646
+ <span className="sleeve-genre">{example.genre}</span>
647
+ <strong>{example.title}</strong>
648
+ <small>{loadingExample === example.id ? "Loading WAV…" : `${example.artist} · ${formatClock(example.duration)}`}</small>
649
+ </button>
650
+ ))}
651
+ </div>
652
+ )}
653
+ </div>
654
+ </section>
655
+
656
+ <section className="transport-console" aria-label="Shared playback transport">
657
+ <button className="transport-play" onClick={togglePlay} disabled={!anyNotes} aria-label={playing ? "Pause playback" : "Play predictions"}>
658
+ {playing ? <IconPause /> : <IconPlay />}
659
+ </button>
660
+ <span ref={clockRef} className="transport-clock">0:00 / 0:00</span>
661
+ <input
662
+ ref={seekRef}
663
+ className="transport-seek"
664
+ type="range"
665
+ min="0"
666
+ max="1000"
667
+ defaultValue="0"
668
+ aria-label="Seek through recording"
669
+ disabled={!selectedFile}
670
+ onChange={(event) => {
671
+ if (engine.duration > 0) engine.seek((Number(event.target.value) / 1000) * engine.duration);
672
+ }}
673
+ />
674
+ <label className="transport-mix">
675
+ <span>Original</span>
676
+ <input type="range" min="0" max="1" step="0.01" value={mix} aria-label="Original to synthesis mix" onChange={(event) => { const value = Number(event.target.value); setMix(value); engine.setMix(value); }} />
677
+ <span>Synthesis</span>
678
+ </label>
679
+ <div className="listen-switch" role="group" aria-label="Prediction to audition">
680
+ <span>Listen to</span>
681
+ {activeModels.map((model) => (
682
+ <button key={model.id} className={clsx(listen === model.id && "is-active")} style={{ "--model-accent": model.accent } as React.CSSProperties} onClick={() => chooseListen(model.id)} disabled={results[model.id].noteCount === 0}>
683
+ {model.name}
684
+ </button>
685
+ ))}
686
+ </div>
687
+ </section>
688
+
689
+ <section className="outputs-section" aria-labelledby="outputs-heading">
690
+ <div className="outputs-heading">
691
+ <div><span className="section-index">02 / OUTPUTS</span><h2 id="outputs-heading">The field, in parallel</h2></div>
692
+ <p>One time axis. Shared instrument colours. Independent failures.</p>
693
+ </div>
694
+ {activeModels.length === 0 ? (
695
+ <button className="outputs-empty" onClick={() => setConfigOpen(true)}>
696
+ <strong>No channels patched.</strong>
697
+ <span>Open model configuration and choose one or more systems.</span>
698
+ </button>
699
+ ) : (
700
+ <div className="model-grid">
701
+ {activeModels.map((model, index) => {
702
+ const result = results[model.id];
703
+ return (
704
+ <article className={clsx("model-panel", `status-${result.status}`)} key={model.id} style={{ "--model-accent": model.accent, "--panel-order": index } as React.CSSProperties}>
705
+ <header className="model-panel-head">
706
+ <div><span>{model.eyebrow}</span><h3>{model.name}</h3><small>{model.detail}</small></div>
707
+ <div className="model-metrics">
708
+ <span className="model-state"><i />{result.status === "idle" ? health[model.id] : result.status}</span>
709
+ <strong>{result.noteCount.toLocaleString()} <small>notes</small></strong>
710
+ <strong>{result.seconds === null ? "—" : `${result.seconds.toFixed(1)}s`} <small>runtime</small></strong>
711
+ </div>
712
+ </header>
713
+ <div className="roll-frame">
714
+ <canvas ref={(node) => attachCanvas(model.id, node)} width="920" height="390" />
715
+ {result.status === "idle" && <div className="roll-state"><span>Signal waiting</span><small>Choose a recording and run the patch.</small></div>}
716
+ {result.status === "queued" && <div className="roll-state"><span>Queued</span><small>Opening the endpoint…</small></div>}
717
+ {result.status === "error" && <div className="roll-state is-error"><span>Channel dropped</span><small>{result.error}</small><button onClick={transcribe}>Retry the run</button></div>}
718
+ {result.status === "transcribing" && <div className="panel-progress" style={{ width: `${Math.max(2, result.progress * 100)}%` }} />}
719
+ </div>
720
+ <footer className="model-panel-foot">
721
+ <div className="instrument-tape">
722
+ {result.instruments.length === 0 ? <span>Instrument families will appear here</span> : result.instruments.map((instrument) => (
723
+ <span key={instrument}><i style={{ background: instrumentColor(instrument) }} />{label(instrument)}</span>
724
+ ))}
725
+ </div>
726
+ {result.midiUrl && (
727
+ <a className="midi-download" href={result.midiUrl} download={`${selectedFile?.name.replace(/\.[^/.]+$/, "") ?? "transcription"}-${model.id}.mid`}>
728
+ <IconDownload /> MIDI
729
+ </a>
730
+ )}
731
+ </footer>
732
+ </article>
733
+ );
734
+ })}
735
+ </div>
736
+ )}
737
+ </section>
738
+ </main>
739
+
740
+ <footer className="compare-footer">
741
+ <span>HENDRIX / CONSENSUS-DISTILLED MULTI-AMT</span>
742
+ <p>Prediction playback uses a shared in-browser SoundFont. Model endpoints speak the MuScriptor SSE contract.</p>
743
+ <a href="/">Open the focused single-model view</a>
744
+ </footer>
745
+
746
+ {dragging && <div className="drop-field" aria-hidden="true"><span>DROP TO PATCH</span><strong>Release the recording anywhere.</strong></div>}
747
+
748
+ {configOpen && (
749
+ <div className="config-backdrop" role="presentation" onMouseDown={(event) => { if (event.currentTarget === event.target) setConfigOpen(false); }}>
750
+ <section className="config-drawer" role="dialog" aria-modal="true" aria-labelledby="config-title">
751
+ <header><div><span>MODEL PATCHBAY</span><h2 id="config-title">Build the comparison</h2></div><button className="config-close" onClick={() => setConfigOpen(false)} aria-label="Close model configuration"><IconClose /></button></header>
752
+ <p className="config-lede">Select any combination. Endpoints are saved in this browser and reflected in the URL, so a working setup is easy to revisit or share.</p>
753
+ <div className="config-presets">
754
+ {PRESETS.map((preset) => <button key={preset.id} onClick={() => applyPreset(preset.ids)} disabled={anyRunning}>{preset.label}</button>)}
755
+ </div>
756
+ <div className="config-models">
757
+ {models.map((model) => (
758
+ <div className={clsx("config-model", model.enabled && "is-enabled")} key={model.id} style={{ "--model-accent": model.accent } as React.CSSProperties}>
759
+ <label className="config-toggle">
760
+ <input type="checkbox" checked={model.enabled} disabled={anyRunning} onChange={(event) => updateModel(model.id, { enabled: event.target.checked })} />
761
+ <span aria-hidden="true" />
762
+ <strong>{model.name}</strong>
763
+ <small>{model.external ? "external" : "ours"}</small>
764
+ </label>
765
+ <label className="endpoint-field"><span>Endpoint</span><input type="url" value={model.base} disabled={anyRunning} onChange={(event) => updateModel(model.id, { base: event.target.value.replace(/\/$/, "") })} spellCheck="false" /></label>
766
+ <div className={clsx("endpoint-health", `is-${health[model.id]}`)}><i />{health[model.id]}</div>
767
+ </div>
768
+ ))}
769
+ </div>
770
+ <div className="config-note"><strong>Adapter contract</strong><span>Every endpoint must expose <code>GET /health</code> and MuScriptor-compatible <code>POST /transcribe</code> SSE events.</span></div>
771
+ <button className="config-done" onClick={() => setConfigOpen(false)} disabled={activeModels.length === 0}>Patch {activeModels.length} model{activeModels.length === 1 ? "" : "s"}</button>
772
+ </section>
773
+ </div>
774
+ )}
775
+ </div>
776
+ );
777
+ }
778
+
779
+ createRoot(document.getElementById("root")!).render(<Compare />);
source/demo/web/src/components/ConditioningPanel.tsx ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useEffect, useMemo, useRef, useState } from "react";
2
+ import clsx from "clsx";
3
+ import { label, scoreInstrument } from "../instruments";
4
+
5
+ /**
6
+ * Conditioning instruments: optional pre-selection that overrides the model's
7
+ * auto-detect. Names come from the backend `/instruments` endpoint; the panel
8
+ * silently renders empty if the server doesn't expose it.
9
+ *
10
+ * Selected instruments are shown as removable tags. Typing in the field offers
11
+ * a filtered list of suggestions to add.
12
+ */
13
+ export function ConditioningPanel(props: {
14
+ selected: Set<string>;
15
+ onChange: (next: Set<string>) => void;
16
+ }) {
17
+ const { selected, onChange } = props;
18
+ const [available, setAvailable] = useState<string[]>([]);
19
+ const [query, setQuery] = useState("");
20
+ const [open, setOpen] = useState(false);
21
+ const [highlight, setHighlight] = useState(0);
22
+ const rootRef = useRef<HTMLDivElement>(null);
23
+
24
+ useEffect(() => {
25
+ let cancelled = false;
26
+ (async () => {
27
+ try {
28
+ const resp = await fetch("/instruments");
29
+ if (!resp.ok) return;
30
+ const data = (await resp.json()) as { instruments: string[] };
31
+ if (!cancelled) setAvailable(data.instruments);
32
+ } catch {
33
+ /* ignore — server may not expose endpoint */
34
+ }
35
+ })();
36
+ return () => {
37
+ cancelled = true;
38
+ };
39
+ }, []);
40
+
41
+ // Close the suggestion list when clicking outside the panel.
42
+ useEffect(() => {
43
+ if (!open) return;
44
+ function onDocClick(e: MouseEvent) {
45
+ if (!rootRef.current?.contains(e.target as Node)) setOpen(false);
46
+ }
47
+ document.addEventListener("mousedown", onDocClick);
48
+ return () => document.removeEventListener("mousedown", onDocClick);
49
+ }, [open]);
50
+
51
+ const suggestions = useMemo(() => {
52
+ return (
53
+ available
54
+ .filter((n) => !selected.has(n))
55
+ .map((n, i) => ({ n, i, score: scoreInstrument(n, query) }))
56
+ .filter((c) => c.score > 0)
57
+ // Best score first; ties keep the backend ordering for stability.
58
+ .sort((a, b) => b.score - a.score || a.i - b.i)
59
+ .map((c) => c.n)
60
+ );
61
+ }, [available, selected, query]);
62
+
63
+ // Keep the highlighted index in range as the suggestion list changes.
64
+ useEffect(() => {
65
+ setHighlight((h) => Math.min(h, Math.max(0, suggestions.length - 1)));
66
+ }, [suggestions.length]);
67
+
68
+ function add(name: string) {
69
+ if (!available.includes(name) || selected.has(name)) return;
70
+ const next = new Set(selected);
71
+ next.add(name);
72
+ onChange(next);
73
+ setQuery("");
74
+ setHighlight(0);
75
+ }
76
+
77
+ function remove(name: string) {
78
+ const next = new Set(selected);
79
+ next.delete(name);
80
+ onChange(next);
81
+ }
82
+
83
+ function onKeyDown(e: React.KeyboardEvent<HTMLInputElement>) {
84
+ if (e.key === "ArrowDown") {
85
+ e.preventDefault();
86
+ setOpen(true);
87
+ setHighlight((h) => Math.min(h + 1, suggestions.length - 1));
88
+ } else if (e.key === "ArrowUp") {
89
+ e.preventDefault();
90
+ setHighlight((h) => Math.max(h - 1, 0));
91
+ } else if (e.key === "Enter") {
92
+ e.preventDefault();
93
+ if (open && suggestions[highlight]) add(suggestions[highlight]);
94
+ } else if (e.key === "Escape") {
95
+ setOpen(false);
96
+ } else if (e.key === "Backspace" && query === "" && selected.size > 0) {
97
+ // Backspace on an empty field removes the most recently added tag.
98
+ remove(Array.from(selected)[selected.size - 1]);
99
+ }
100
+ }
101
+
102
+ return (
103
+ <section className="card col-span-full px-5 pb-5 pt-4 animate-rise [animation-delay:0.24s]">
104
+ <div className="mb-3.5 flex items-start gap-3">
105
+ <div className="flex flex-col gap-2">
106
+ <h2 className="m-0 text-lg font-semibold">
107
+ What instruments are there in this track?
108
+ </h2>
109
+ <p className="text-gray">
110
+ Optional. Leave empty to let the model detect anything; listing
111
+ instruments here forbids every other instrument from appearing.
112
+ </p>
113
+ </div>
114
+ <div className="ml-auto">
115
+ <button
116
+ type="button"
117
+ className="px-3.5 py-1 text-xs"
118
+ onClick={() => onChange(new Set())}
119
+ disabled={selected.size === 0}
120
+ >
121
+ Clear
122
+ </button>
123
+ </div>
124
+ </div>
125
+
126
+ <div className="relative" ref={rootRef}>
127
+ <div
128
+ className="flex min-h-11 cursor-text flex-wrap items-center gap-2 rounded-lg border border-line-strong bg-bg px-2.5 py-2 transition-colors duration-150 ease-fluid focus-within:border-accent"
129
+ onClick={() => rootRef.current?.querySelector("input")?.focus()}
130
+ >
131
+ {Array.from(selected).map((name) => (
132
+ <span
133
+ className="inline-flex select-none items-center gap-1.5 rounded-md border border-accent-glow bg-accent-soft py-1 pl-3 pr-1.5 text-sm text-content"
134
+ key={name}
135
+ >
136
+ {label(name)}
137
+ <button
138
+ type="button"
139
+ className="grid size-4 place-content-center rounded border-none bg-transparent p-0 text-sm leading-none text-muted hover:border-none hover:bg-white/10 hover:text-content"
140
+ aria-label={`Remove ${label(name)}`}
141
+ onClick={(e) => {
142
+ e.stopPropagation();
143
+ remove(name);
144
+ }}
145
+ >
146
+ ×
147
+ </button>
148
+ </span>
149
+ ))}
150
+ <input
151
+ type="text"
152
+ className="m-0 min-w-32 flex-1 border-none bg-transparent px-0.5 py-1 font-sans text-sm text-content outline-none placeholder:text-faint"
153
+ placeholder={selected.size === 0 ? "Add an instrument…" : ""}
154
+ value={query}
155
+ autoComplete="off"
156
+ spellCheck={false}
157
+ onChange={(e) => {
158
+ setQuery(e.target.value);
159
+ setOpen(true);
160
+ }}
161
+ onFocus={() => setOpen(true)}
162
+ onKeyDown={onKeyDown}
163
+ />
164
+ </div>
165
+
166
+ {open && suggestions.length > 0 && (
167
+ <ul
168
+ className="absolute inset-x-0 top-[calc(100%+5px)] z-20 m-0 max-h-60 list-none overflow-y-auto rounded-lg border border-line-strong bg-surface-2 p-1 shadow-[0_18px_40px_-20px_rgba(0,0,0,0.9)]"
169
+ role="listbox"
170
+ >
171
+ {suggestions.map((name, i) => (
172
+ <li
173
+ key={name}
174
+ role="option"
175
+ aria-selected={i === highlight}
176
+ className={clsx(
177
+ "cursor-pointer rounded-md px-2.5 py-2 text-sm",
178
+ i === highlight ? "bg-white/[0.06] text-content" : "text-muted",
179
+ )}
180
+ onMouseEnter={() => setHighlight(i)}
181
+ onMouseDown={(e) => {
182
+ // mousedown (not click) so we add before the input blurs.
183
+ e.preventDefault();
184
+ add(name);
185
+ }}
186
+ >
187
+ {label(name)}
188
+ </li>
189
+ ))}
190
+ </ul>
191
+ )}
192
+ </div>
193
+ </section>
194
+ );
195
+ }
source/demo/web/src/components/Controls.tsx ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useEffect, useState, type RefObject } from "react";
2
+ import clsx from "clsx";
3
+ import type { AudioEngine } from "../audio";
4
+ import { IconPlay, IconPause } from "./icons";
5
+
6
+ export function Controls(props: {
7
+ audio: AudioEngine;
8
+ /** Attached to the time clock; updated imperatively by the rAF loop. */
9
+ clockRef: RefObject<HTMLSpanElement | null>;
10
+ mix: number;
11
+ onMixChange: (v: number) => void;
12
+ stereo: boolean;
13
+ onStereoChange: (v: boolean) => void;
14
+ /** Whether the roll auto-follows the playhead (toggled off by manual scrolling). */
15
+ following: boolean;
16
+ onToggleFollow: () => void;
17
+ }) {
18
+ const { audio, clockRef, mix, onMixChange, stereo, onStereoChange, following, onToggleFollow } =
19
+ props;
20
+ // The transport's state isn't React state (and it can auto-stop at the end),
21
+ // so poll it each frame to keep the toggle button's label in sync.
22
+ const [playing, setPlaying] = useState(false);
23
+ useEffect(() => {
24
+ let raf = 0;
25
+ const tick = () => {
26
+ setPlaying(audio.state === "started");
27
+ raf = requestAnimationFrame(tick);
28
+ };
29
+ raf = requestAnimationFrame(tick);
30
+ return () => cancelAnimationFrame(raf);
31
+ }, [audio]);
32
+
33
+ return (
34
+ <div className="col-span-full flex flex-wrap items-center gap-2.5 rounded-card border border-line bg-surface px-3.5 py-3 animate-rise [animation-delay:0.06s]">
35
+ <button
36
+ className={clsx(
37
+ "inline-flex items-center gap-2",
38
+ playing && "border-accent bg-accent text-white hover:border-accent hover:bg-accent",
39
+ )}
40
+ onClick={(e) => {
41
+ e.currentTarget.blur();
42
+ playing ? audio.pause() : audio.play();
43
+ }}
44
+ >
45
+ {playing ? <IconPause /> : <IconPlay />}
46
+ {playing ? "Pause" : "Play"}
47
+ </button>
48
+ <button
49
+ className={clsx("text-content", following && "border-accent hover:border-accent")}
50
+ aria-pressed={following}
51
+ title={following ? "Stop following the playhead" : "Scroll along with the playhead"}
52
+ onClick={(e) => {
53
+ e.currentTarget.blur();
54
+ onToggleFollow();
55
+ }}
56
+ >
57
+ Follow playhead
58
+ </button>
59
+ <span
60
+ className="rounded-md border border-line bg-bg px-2.5 py-1 font-mono text-sm tabular-nums text-muted"
61
+ ref={clockRef}
62
+ >
63
+ 0.0s
64
+ </span>
65
+ <label
66
+ className={clsx(
67
+ "ml-auto inline-flex items-center gap-2.5 text-sm text-muted max-[760px]:ml-0",
68
+ stereo && "opacity-40",
69
+ )}
70
+ >
71
+ <span
72
+ className={clsx(
73
+ "min-w-8 text-center transition-colors",
74
+ !stereo && "cursor-pointer hover:text-content",
75
+ )}
76
+ onClick={() => !stereo && onMixChange(0)}
77
+ >
78
+ Original
79
+ </span>
80
+ <input
81
+ className="mix-slider"
82
+ type="range"
83
+ min="0"
84
+ max="1"
85
+ step="0.01"
86
+ value={mix}
87
+ disabled={stereo}
88
+ onChange={(e) => onMixChange(parseFloat(e.target.value))}
89
+ // Drop focus once the drag ends so Space keeps toggling play/pause
90
+ // (the global handler ignores Space while an input is focused).
91
+ // Range inputs implicitly capture the pointer, so this fires even
92
+ // when the drag is released outside the slider.
93
+ onPointerUp={(e) => e.currentTarget.blur()}
94
+ // Clicks on the label's Original/MIDI spans focus the slider via a
95
+ // forwarded click with no pointer event, so blur on click too.
96
+ onClick={(e) => e.currentTarget.blur()}
97
+ />
98
+ <span
99
+ className={clsx(
100
+ "min-w-8 text-center transition-colors",
101
+ !stereo && "cursor-pointer hover:text-content",
102
+ )}
103
+ onClick={() => !stereo && onMixChange(1)}
104
+ >
105
+ MIDI
106
+ </span>
107
+ </label>
108
+ <label className="inline-flex cursor-pointer select-none items-center gap-1.5 text-sm text-muted px-3">
109
+ <input
110
+ className="cursor-pointer accent-accent"
111
+ type="checkbox"
112
+ checked={stereo}
113
+ onChange={(e) => onStereoChange(e.target.checked)}
114
+ // Same as the slider: keep Space bound to play/pause after clicking.
115
+ // click (not pointerup) also catches clicks on the wrapping label,
116
+ // which the browser forwards to the checkbox.
117
+ onClick={(e) => e.currentTarget.blur()}
118
+ />
119
+ <span>Stereo</span>
120
+ </label>
121
+ </div>
122
+ );
123
+ }
source/demo/web/src/components/DropOverlay.tsx ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /** Fullscreen overlay shown (via the `body.drag` class) while a file is dragged. */
2
+ export function DropOverlay() {
3
+ return (
4
+ <div
5
+ className="drop-overlay pointer-events-none fixed inset-0 z-[200] flex items-center justify-center bg-[rgba(11,12,16,0.78)] opacity-0 backdrop-blur-sm transition-opacity duration-150 ease-fluid"
6
+ aria-hidden="true"
7
+ >
8
+ <div className="flex flex-col items-center gap-3.5 rounded-card border-2 border-dashed border-accent bg-surface px-16 py-11 text-center shadow-[0_24px_60px_-24px_rgba(0,0,0,0.9)]">
9
+ <svg
10
+ className="h-8 w-32 fill-none stroke-accent stroke-2 [stroke-linecap:round] [stroke-linejoin:round]"
11
+ viewBox="0 0 120 32"
12
+ aria-hidden="true"
13
+ preserveAspectRatio="none"
14
+ >
15
+ <path d="M0 16 L8 16 L12 6 L18 26 L24 10 L30 22 L36 4 L42 28 L48 14 L54 18 L60 8 L66 24 L72 12 L78 20 L84 6 L90 26 L96 16 L104 16 L120 16" />
16
+ </svg>
17
+ <p className="m-0 text-base text-muted">
18
+ Drop an <strong className="font-semibold text-content">audio file</strong> to
19
+ transcribe
20
+ </p>
21
+ </div>
22
+ </div>
23
+ );
24
+ }
source/demo/web/src/components/Footer.tsx ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export function Footer() {
2
+ return (
3
+ <footer className="mx-auto mt-4 flex max-w-7xl flex-wrap items-center justify-between gap-6 border-t border-line px-7 py-10 max-[760px]:flex-col max-[760px]:items-start">
4
+ <p className="max-w-md text-muted">
5
+ MuScriptor is a multi-instrument automatic music transcription model:
6
+ it turns raw audio into per-instrument MIDI. Built by{" "}
7
+ <a
8
+ href="https://kyutai.org/"
9
+ target="_blank"
10
+ rel="noreferrer"
11
+ className="text-accent underline underline-offset-4 opacity-90 hover:opacity-100"
12
+ >
13
+ Kyutai
14
+ </a>{" "}
15
+ and{" "}
16
+ <a
17
+ href="https://www.mirelo.ai/"
18
+ target="_blank"
19
+ rel="noreferrer"
20
+ className="text-accent underline underline-offset-4 opacity-90 hover:opacity-100"
21
+ >
22
+ Mirelo
23
+ </a>
24
+ .
25
+ </p>
26
+ <div className="flex items-center gap-6">
27
+ <a
28
+ href="https://kyutai.org/"
29
+ target="_blank"
30
+ rel="noreferrer"
31
+ className="opacity-90 transition-opacity hover:opacity-100"
32
+ >
33
+ <img src="/kyutai-logo.svg" alt="Kyutai" className="h-6 w-auto" />
34
+ </a>
35
+ <a
36
+ href="https://www.mirelo.ai/"
37
+ target="_blank"
38
+ rel="noreferrer"
39
+ className="opacity-90 transition-opacity hover:opacity-100"
40
+ >
41
+ <img src="/mirelo-logo.svg" alt="Mirelo" className="h-6 w-auto mb-1" />
42
+ </a>
43
+ </div>
44
+ </footer>
45
+ );
46
+ }
source/demo/web/src/components/InstrumentList.tsx ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useEffect, useState, type RefObject } from "react";
2
+ import clsx from "clsx";
3
+ import type { AudioEngine } from "../audio";
4
+ import { instrumentColor, type PianoRoll } from "../pianoroll";
5
+ import { label } from "../instruments";
6
+ import { IconSound, IconSoundOff } from "./icons";
7
+
8
+ /** A circled "?" that reveals an explanatory tooltip on hover/focus. */
9
+ function HelpHint(props: { children: string }) {
10
+ return (
11
+ <span className="group/help relative ml-1.5 inline-flex align-middle">
12
+ <span
13
+ tabIndex={0}
14
+ className="flex size-4 cursor-help items-center justify-center rounded-full border border-line-strong text-[10px] font-semibold text-muted outline-none transition-colors duration-150 hover:border-accent hover:text-content focus-visible:border-accent focus-visible:text-content"
15
+ aria-label="What does this mean?"
16
+ >
17
+ ?
18
+ </span>
19
+ <span
20
+ role="tooltip"
21
+ className="pointer-events-none absolute right-0 top-[calc(100%+8px)] z-30 w-60 rounded-lg border border-line-strong bg-surface-2 px-3 py-2.5 text-sm font-normal leading-snug text-muted opacity-0 shadow-[0_18px_40px_-20px_rgba(0,0,0,0.9)] transition-opacity duration-150 group-hover/help:opacity-100 group-focus-within/help:opacity-100"
22
+ >
23
+ {props.children}
24
+ </span>
25
+ </span>
26
+ );
27
+ }
28
+
29
+ /** A given instrument that wasn't detected: gray, struck-through, no controls. */
30
+ function UndetectedRow(props: { name: string }) {
31
+ return (
32
+ <li className="flex items-center gap-2.5 rounded-lg px-2.5 py-2 text-muted opacity-40 [animation:rise_0.4s_var(--ease-fluid)_both]">
33
+ <span className="size-3 shrink-0 rounded-sm bg-faint" />
34
+ <span className="min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap line-through">
35
+ {label(props.name)}
36
+ </span>
37
+ <span className="shrink-0 text-xs italic text-faint">not detected</span>
38
+ </li>
39
+ );
40
+ }
41
+
42
+ /** An interactive detected instrument with mute + solo controls. */
43
+ function InstrumentRow(props: {
44
+ name: string;
45
+ muted: boolean;
46
+ soloed: boolean;
47
+ onToggleMute: () => void;
48
+ onToggleSolo: () => void;
49
+ /** Hovering the row spotlights this instrument's notes on the piano roll. */
50
+ onHover: (name: string | null) => void;
51
+ }) {
52
+ const { name, muted, soloed, onToggleMute, onToggleSolo, onHover } = props;
53
+ return (
54
+ <li
55
+ className="group flex items-center gap-2.5 rounded-lg px-2.5 py-2 text-muted transition-colors duration-150 ease-fluid hover:bg-white/[0.04] hover:text-content [animation:rise_0.4s_var(--ease-fluid)_both]"
56
+ onMouseEnter={() => onHover(name)}
57
+ onMouseLeave={() => onHover(null)}
58
+ >
59
+ <div
60
+ className={clsx(
61
+ "flex min-w-0 flex-1 items-center gap-2.5 transition-opacity duration-150 ease-fluid",
62
+ muted && "opacity-10",
63
+ )}
64
+ >
65
+ <span
66
+ className="size-3 shrink-0 rounded-sm shadow-[0_0_10px_-1px_currentColor]"
67
+ style={{ background: instrumentColor(name) }}
68
+ />
69
+ <span className="min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap">
70
+ {label(name)}
71
+ </span>
72
+ </div>
73
+ <div className="flex items-center gap-0.5">
74
+ <button
75
+ type="button"
76
+ className={clsx(
77
+ "-my-1 flex size-6 shrink-0 items-center justify-center rounded-md border-none bg-transparent p-0 text-xs font-semibold transition-[opacity,background,color] duration-150 ease-fluid hover:border-none hover:bg-white/[0.08]",
78
+ soloed
79
+ ? "text-[#ffcc44] opacity-100"
80
+ : "text-muted opacity-70 group-hover:opacity-100 hover:text-content",
81
+ )}
82
+ title={soloed ? "Unsolo" : "Solo (mute everything else)"}
83
+ aria-pressed={soloed}
84
+ onClick={onToggleSolo}
85
+ >
86
+ S
87
+ </button>
88
+ <button
89
+ type="button"
90
+ className={clsx(
91
+ "-my-1 flex size-6 shrink-0 items-center justify-center rounded-md border-none bg-transparent p-0 transition-[opacity,background,color] duration-150 ease-fluid hover:border-none hover:bg-white/[0.08]",
92
+ muted
93
+ ? "text-[#ff5577] opacity-100"
94
+ : "text-muted opacity-70 group-hover:opacity-100 hover:text-content",
95
+ )}
96
+ title={muted ? "Unmute on MIDI track" : "Mute on MIDI track"}
97
+ aria-pressed={muted}
98
+ onClick={onToggleMute}
99
+ >
100
+ {muted ? <IconSoundOff /> : <IconSound />}
101
+ </button>
102
+ </div>
103
+ </li>
104
+ );
105
+ }
106
+
107
+ export function InstrumentList(props: {
108
+ instruments: string[];
109
+ given: Set<string>;
110
+ audio: AudioEngine;
111
+ rollRef: RefObject<PianoRoll | null>;
112
+ }) {
113
+ const { instruments, given, audio, rollRef } = props;
114
+ const [muted, setMuted] = useState<Set<string>>(() => new Set());
115
+ const [soloed, setSoloed] = useState<string | null>(null);
116
+
117
+ // Keep the audio engine and piano roll in sync with the muted set.
118
+ useEffect(() => {
119
+ for (const name of instruments) {
120
+ audio.setInstrumentMuted(name, muted.has(name));
121
+ rollRef.current?.setInstrumentMuted(name, muted.has(name));
122
+ }
123
+ }, [instruments, audio, rollRef, muted]);
124
+
125
+ const toggleMute = (name: string) => {
126
+ setSoloed(null);
127
+ setMuted((prev) => {
128
+ const next = new Set(prev);
129
+ if (next.has(name)) next.delete(name);
130
+ else next.add(name);
131
+ return next;
132
+ });
133
+ };
134
+
135
+ const toggleSolo = (name: string) => {
136
+ if (soloed === name) {
137
+ setSoloed(null);
138
+ setMuted(new Set());
139
+ } else {
140
+ setSoloed(name);
141
+ setMuted(new Set(instruments.filter((other) => other !== name)));
142
+ }
143
+ };
144
+
145
+ const row = (name: string) => (
146
+ <InstrumentRow
147
+ key={name}
148
+ name={name}
149
+ muted={muted.has(name)}
150
+ soloed={soloed === name}
151
+ onToggleMute={() => toggleMute(name)}
152
+ onToggleSolo={() => toggleSolo(name)}
153
+ onHover={(n) => rollRef.current?.setHighlightedInstrument(n)}
154
+ />
155
+ );
156
+
157
+ const detectedSet = new Set(instruments);
158
+ const hasGiven = given.size > 0;
159
+ // Detected instruments that weren't in the given list.
160
+ const extra = instruments.filter((name) => !given.has(name));
161
+
162
+ return (
163
+ <aside className="card col-start-2 self-start px-4 pb-5 pt-4 max-[760px]:col-start-1 animate-rise [animation-delay:0.18s]">
164
+ {hasGiven ? (
165
+ <>
166
+ <h2 className="m-0 mb-3 flex items-center text-base font-semibold">
167
+ Given instruments
168
+ <HelpHint>
169
+ The instruments you specified. Greyed-out ones weren't detected in
170
+ the audio.
171
+ </HelpHint>
172
+ </h2>
173
+ <ul className="m-0 flex list-none flex-col gap-0.5 p-0 text-sm">
174
+ {Array.from(given).map((name) =>
175
+ detectedSet.has(name) ? (
176
+ row(name)
177
+ ) : (
178
+ <UndetectedRow key={name} name={name} />
179
+ ),
180
+ )}
181
+ </ul>
182
+
183
+ {extra.length > 0 && (
184
+ <>
185
+ <h2 className="m-0 mb-3 mt-5 text-base font-semibold">
186
+ More instruments{" "}
187
+ <HelpHint>
188
+ More instruments that the model detected in the audio, even
189
+ without them being explicitly given.
190
+ </HelpHint>
191
+ </h2>
192
+ <ul className="m-0 flex list-none flex-col gap-0.5 p-0 text-sm">
193
+ {extra.map(row)}
194
+ </ul>
195
+ </>
196
+ )}
197
+ </>
198
+ ) : (
199
+ <>
200
+ <h2 className="m-0 mb-3 text-base font-semibold">Instruments</h2>
201
+ <ul className="m-0 flex list-none flex-col gap-0.5 p-0 text-sm">
202
+ {instruments.map(row)}
203
+ </ul>
204
+ </>
205
+ )}
206
+ </aside>
207
+ );
208
+ }
source/demo/web/src/components/OutputBar.tsx ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useEffect, useRef, useState, type RefObject } from "react";
2
+ import clsx from "clsx";
3
+ import { IconChevron, IconDownload } from "./icons";
4
+
5
+ /**
6
+ * Output / "job" actions, shown below the piano roll: live transcription
7
+ * progress, exporting the result (MIDI or a stereo mix), and starting over
8
+ * with another file. Distinct from the playback bar above the roll, which is
9
+ * about exploring the result.
10
+ *
11
+ * The progress bar's fill width and "Xs / Ys" label are driven imperatively
12
+ * from App's per-frame loop (via the refs) so the smoothing never triggers
13
+ * React re-renders — same pattern as the playback clock.
14
+ */
15
+ export function OutputBar(props: {
16
+ transcribing: boolean;
17
+ progressFillRef: RefObject<HTMLDivElement | null>;
18
+ progressLabelRef: RefObject<HTMLSpanElement | null>;
19
+ midiUrl: string | null;
20
+ midiFilename: string;
21
+ /** Raw MIDI blob + source audio, re-uploaded to /auralize for the mix. */
22
+ midiBlob: Blob | null;
23
+ currentFile: File | null;
24
+ onTranscribeAnother: () => void;
25
+ }) {
26
+ const {
27
+ transcribing,
28
+ progressFillRef,
29
+ progressLabelRef,
30
+ midiUrl,
31
+ midiFilename,
32
+ midiBlob,
33
+ currentFile,
34
+ onTranscribeAnother,
35
+ } = props;
36
+ const [synthesizing, setSynthesizing] = useState(false);
37
+ const [menuOpen, setMenuOpen] = useState(false);
38
+ const menuRef = useRef<HTMLDivElement>(null);
39
+ const ready = midiUrl !== null;
40
+
41
+ // Dismiss the download menu on outside click / Escape.
42
+ useEffect(() => {
43
+ if (!menuOpen) return;
44
+ const onDown = (e: MouseEvent) => {
45
+ if (menuRef.current && !menuRef.current.contains(e.target as Node)) setMenuOpen(false);
46
+ };
47
+ const onKey = (e: KeyboardEvent) => {
48
+ if (e.key === "Escape") setMenuOpen(false);
49
+ };
50
+ document.addEventListener("mousedown", onDown);
51
+ document.addEventListener("keydown", onKey);
52
+ return () => {
53
+ document.removeEventListener("mousedown", onDown);
54
+ document.removeEventListener("keydown", onKey);
55
+ };
56
+ }, [menuOpen]);
57
+
58
+ function download() {
59
+ if (midiUrl === null) return;
60
+ const a = document.createElement("a");
61
+ a.href = midiUrl;
62
+ a.download = midiFilename;
63
+ a.click();
64
+ }
65
+
66
+ // Renders the transcription server-side with FluidSynth. "synth" downloads
67
+ // just the synthesized MIDI (mono); "mix" blends it with the original audio
68
+ // (L = original, R = synthesis) for easy A/B comparison.
69
+ async function downloadWav(mode: "synth" | "mix") {
70
+ if (midiBlob === null || currentFile === null) return;
71
+ setSynthesizing(true);
72
+ try {
73
+ const form = new FormData();
74
+ form.append("mode", mode);
75
+ form.append("midi", midiBlob, "transcription.mid");
76
+ if (mode === "mix") form.append("audio", currentFile);
77
+ const resp = await fetch("/auralize", { method: "POST", body: form });
78
+ if (!resp.ok) {
79
+ const text = await resp.text();
80
+ let detail = text;
81
+ try {
82
+ detail = JSON.parse(text).detail ?? text;
83
+ } catch {
84
+ // not JSON — keep the raw body
85
+ }
86
+ throw new Error(detail);
87
+ }
88
+ const wavBlob = await resp.blob();
89
+ const url = URL.createObjectURL(wavBlob);
90
+ const a = document.createElement("a");
91
+ a.href = url;
92
+ const stem = currentFile.name.replace(/\.[^.]+$/, "") || "transcription";
93
+ a.download = stem + (mode === "mix" ? "_mix.wav" : "_transcription.wav");
94
+ a.click();
95
+ URL.revokeObjectURL(url);
96
+ } catch (e) {
97
+ alert("Couldn't create the audio file: " + (e as Error).message);
98
+ } finally {
99
+ setSynthesizing(false);
100
+ }
101
+ }
102
+
103
+ const menuItem =
104
+ "block w-full rounded-none border-0 bg-transparent px-3 py-2 text-left text-[13px] font-normal text-content hover:bg-[#20212b]";
105
+
106
+ return (
107
+ <div className="col-span-full flex flex-wrap items-center gap-3 rounded-card border border-line bg-surface px-3.5 py-3">
108
+ {transcribing && (
109
+ <div className="flex min-w-48 flex-1 items-center gap-3">
110
+ <div className="h-1 flex-1 overflow-hidden rounded-full bg-bg">
111
+ <div
112
+ ref={progressFillRef}
113
+ className="h-full rounded-full bg-accent"
114
+ style={{ width: "0%" }}
115
+ />
116
+ </div>
117
+ <span
118
+ ref={progressLabelRef}
119
+ className="shrink-0 whitespace-nowrap font-mono text-xs tabular-nums text-faint"
120
+ >
121
+ estimating…
122
+ </span>
123
+ </div>
124
+ )}
125
+
126
+ <div className="ml-auto flex items-center gap-2.5">
127
+ <div className="relative" ref={menuRef}>
128
+ <button
129
+ className={clsx("inline-flex items-center gap-2", ready && "btn-primary")}
130
+ disabled={!ready || synthesizing}
131
+ onClick={() => setMenuOpen((o) => !o)}
132
+ aria-haspopup="menu"
133
+ aria-expanded={menuOpen}
134
+ >
135
+ <IconDownload />
136
+ {synthesizing ? "Synthesizing…" : "Download"}
137
+ <IconChevron
138
+ className={clsx("transition-transform", menuOpen && "rotate-180")}
139
+ />
140
+ </button>
141
+ {menuOpen && (
142
+ <div
143
+ role="menu"
144
+ className="absolute left-0 z-20 mt-1.5 min-w-48 overflow-hidden rounded-md border border-line-strong bg-surface-2 py-1 shadow-[0_18px_40px_-20px_rgba(0,0,0,0.9)]"
145
+ >
146
+ <button
147
+ role="menuitem"
148
+ className={menuItem}
149
+ onClick={() => {
150
+ setMenuOpen(false);
151
+ download();
152
+ }}
153
+ >
154
+ MIDI file
155
+ </button>
156
+ <button
157
+ role="menuitem"
158
+ className={menuItem}
159
+ title="Just the transcribed notes, played with a SoundFont (mono)"
160
+ onClick={() => {
161
+ setMenuOpen(false);
162
+ downloadWav("synth");
163
+ }}
164
+ >
165
+ WAV - transcription only
166
+ </button>
167
+ <button
168
+ role="menuitem"
169
+ className={menuItem}
170
+ title="Original audio (L) + transcribed notes played with a SoundFont (R)"
171
+ onClick={() => {
172
+ setMenuOpen(false);
173
+ downloadWav("mix");
174
+ }}
175
+ >
176
+ WAV - stereo with original
177
+ </button>
178
+ </div>
179
+ )}
180
+ </div>
181
+ <button
182
+ onClick={(e) => {
183
+ e.currentTarget.blur();
184
+ onTranscribeAnother();
185
+ }}
186
+ >
187
+ Transcribe another file
188
+ </button>
189
+ </div>
190
+ </div>
191
+ );
192
+ }
source/demo/web/src/components/PianoRollCanvas.tsx ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useEffect, useRef, type Dispatch, type RefObject, type SetStateAction } from "react";
2
+ import type { AudioEngine } from "../audio";
3
+ import { PianoRoll, KEY_WIDTH } from "../pianoroll";
4
+
5
+ export function PianoRollCanvas(props: {
6
+ rollRef: RefObject<PianoRoll | null>;
7
+ audio: AudioEngine;
8
+ setUserScrolled: Dispatch<SetStateAction<boolean>>;
9
+ }) {
10
+ const { rollRef, audio, setUserScrolled } = props;
11
+ const canvasRef = useRef<HTMLCanvasElement>(null);
12
+
13
+ useEffect(() => {
14
+ const canvas = canvasRef.current!;
15
+ const roll = new PianoRoll(canvas);
16
+ rollRef.current = roll;
17
+
18
+ // Wheel bindings follow the DAW convention (Ableton / FL / Reaper):
19
+ // ctrl/cmd + scroll → zoom the time axis (also what a macOS trackpad
20
+ // pinch fires, so pinch zooms the timeline);
21
+ // alt/option + scroll → zoom the pitch axis;
22
+ // shift + scroll → pan the time axis;
23
+ // plain scroll → vertical wheel pans the pitch axis, horizontal wheel
24
+ // (trackpad) pans time.
25
+ // (Pitch zoom via the key strip is the click-drag gesture below.)
26
+ const onWheel = (e: WheelEvent) => {
27
+ e.preventDefault();
28
+ const rect = canvas.getBoundingClientRect();
29
+ const factor = Math.exp(-e.deltaY * 0.01);
30
+ if (e.altKey) {
31
+ roll.zoomPitch(factor, e.clientY - rect.top);
32
+ setUserScrolled(true);
33
+ return;
34
+ }
35
+ if (e.ctrlKey || e.metaKey) {
36
+ roll.zoomTime(factor, e.clientX - rect.left);
37
+ setUserScrolled(true);
38
+ return;
39
+ }
40
+ if (e.shiftKey) {
41
+ const d = e.deltaX !== 0 ? e.deltaX : e.deltaY;
42
+ if (d !== 0) roll.scrollBy(d / roll.pxPerSec);
43
+ } else {
44
+ if (e.deltaX !== 0) roll.scrollBy(e.deltaX / roll.pxPerSec);
45
+ if (e.deltaY !== 0) roll.scrollPitchBy(-e.deltaY);
46
+ }
47
+ setUserScrolled(true);
48
+ };
49
+
50
+ // Scrubbing: press-and-drag in the note area moves the playhead live under
51
+ // the cursor (with follow mode on, the view scrolls along). Playback pauses
52
+ // for the duration of the drag and resumes from the release point. The
53
+ // move/up handlers live on the window so the scrub survives the pointer
54
+ // leaving the canvas — dragging out past the left edge clamps to the start.
55
+ // A plain click is just a zero-length scrub, so click-to-seek still works.
56
+ let scrub: { wasPlaying: boolean } | null = null;
57
+ const scrubTo = (clientX: number) => {
58
+ const rect = canvas.getBoundingClientRect();
59
+ // Leaving the canvas on the left means "to the start" — a stationary
60
+ // cursor gets no more mousemove events, so it could never out-scroll
61
+ // the view to reach 0 otherwise.
62
+ const t =
63
+ clientX < rect.left ? 0 : Math.max(0, roll.xToSeconds(clientX - rect.left));
64
+ // Clock-only seek per move (a full seek() re-schedules every note); the
65
+ // rAF loop reads it back into the roll's playhead each frame.
66
+ audio.scrubTo(t);
67
+ roll.setPlayhead(t);
68
+ };
69
+
70
+ // Ableton-style key-strip gesture: click-drag on the keyboard zooms the
71
+ // pitch axis horizontally (drag right = zoom in) and pans it vertically
72
+ // (grab-style). Anchored on the cursor's pitch.
73
+ let keyDrag: { x: number; y: number } | null = null;
74
+ const onMouseDown = (e: MouseEvent) => {
75
+ const rect = canvas.getBoundingClientRect();
76
+ const x = e.clientX - rect.left;
77
+ if (x >= KEY_WIDTH) {
78
+ scrub = { wasPlaying: audio.state === "started" };
79
+ if (scrub.wasPlaying) audio.pause();
80
+ scrubTo(e.clientX);
81
+ } else {
82
+ keyDrag = { x, y: e.clientY - rect.top };
83
+ }
84
+ e.preventDefault();
85
+ };
86
+ const onMouseMove = (e: MouseEvent) => {
87
+ if (scrub) {
88
+ scrubTo(e.clientX);
89
+ return;
90
+ }
91
+ const rect = canvas.getBoundingClientRect();
92
+ if (keyDrag) {
93
+ const x = e.clientX - rect.left;
94
+ const y = e.clientY - rect.top;
95
+ const dx = x - keyDrag.x;
96
+ const dy = y - keyDrag.y;
97
+ if (dx !== 0) roll.zoomPitch(Math.exp(dx * 0.01), y);
98
+ if (dy !== 0) roll.scrollPitchBy(dy);
99
+ keyDrag = { x, y };
100
+ setUserScrolled(true);
101
+ return;
102
+ }
103
+ // Hint the gesture with a resize cursor while hovering the key strip.
104
+ canvas.style.cursor =
105
+ e.clientX - rect.left < KEY_WIDTH ? "ew-resize" : "default";
106
+ };
107
+ const onMouseUp = () => {
108
+ if (scrub) {
109
+ // One real seek to rebuild the (one-shot) note schedule from the
110
+ // release point, then resume if the drag interrupted playback.
111
+ audio.seek(audio.seconds);
112
+ if (scrub.wasPlaying) audio.play();
113
+ scrub = null;
114
+ }
115
+ keyDrag = null;
116
+ };
117
+
118
+ // Touch: one finger drags the view (left/right scrolls time, up/down pans
119
+ // the pitch axis when zoomed); two fingers pinch to zoom — horizontal
120
+ // spread zooms time, vertical spread zooms the pitch axis.
121
+ let pan: { x: number; y: number } | null = null;
122
+ let pinch: { dx: number; dy: number } | null = null;
123
+ const pinchSpan = (t: TouchList) => ({
124
+ dx: Math.abs(t[0].clientX - t[1].clientX),
125
+ dy: Math.abs(t[0].clientY - t[1].clientY),
126
+ });
127
+
128
+ const onTouchStart = (e: TouchEvent) => {
129
+ if (e.touches.length === 2) {
130
+ pinch = pinchSpan(e.touches);
131
+ pan = null;
132
+ e.preventDefault();
133
+ } else if (e.touches.length === 1) {
134
+ pan = { x: e.touches[0].clientX, y: e.touches[0].clientY };
135
+ }
136
+ };
137
+
138
+ const onTouchMove = (e: TouchEvent) => {
139
+ const rect = canvas.getBoundingClientRect();
140
+ if (pinch && e.touches.length === 2) {
141
+ e.preventDefault();
142
+ const span = pinchSpan(e.touches);
143
+ const cx = (e.touches[0].clientX + e.touches[1].clientX) / 2 - rect.left;
144
+ const cy = (e.touches[0].clientY + e.touches[1].clientY) / 2 - rect.top;
145
+ const MIN = 12; // ignore tiny spans where the ratio gets noisy
146
+ if (pinch.dx > MIN && span.dx > MIN) roll.zoomTime(span.dx / pinch.dx, cx);
147
+ if (pinch.dy > MIN && span.dy > MIN) roll.zoomPitch(span.dy / pinch.dy, cy);
148
+ pinch = span;
149
+ setUserScrolled(true);
150
+ } else if (pan && e.touches.length === 1) {
151
+ e.preventDefault();
152
+ const t = e.touches[0];
153
+ roll.scrollBy(-(t.clientX - pan.x) / roll.pxPerSec);
154
+ roll.scrollPitchBy(t.clientY - pan.y);
155
+ pan = { x: t.clientX, y: t.clientY };
156
+ setUserScrolled(true);
157
+ }
158
+ };
159
+
160
+ const onTouchEnd = (e: TouchEvent) => {
161
+ if (e.touches.length < 2) pinch = null;
162
+ if (e.touches.length === 0) pan = null;
163
+ };
164
+
165
+ canvas.addEventListener("wheel", onWheel, { passive: false });
166
+ canvas.addEventListener("touchstart", onTouchStart, { passive: false });
167
+ canvas.addEventListener("touchmove", onTouchMove, { passive: false });
168
+ canvas.addEventListener("touchend", onTouchEnd, { passive: false });
169
+ canvas.addEventListener("mousedown", onMouseDown);
170
+ window.addEventListener("mousemove", onMouseMove);
171
+ window.addEventListener("mouseup", onMouseUp);
172
+ return () => {
173
+ canvas.removeEventListener("wheel", onWheel);
174
+ canvas.removeEventListener("touchstart", onTouchStart);
175
+ canvas.removeEventListener("touchmove", onTouchMove);
176
+ canvas.removeEventListener("touchend", onTouchEnd);
177
+ canvas.removeEventListener("mousedown", onMouseDown);
178
+ window.removeEventListener("mousemove", onMouseMove);
179
+ window.removeEventListener("mouseup", onMouseUp);
180
+ };
181
+ }, [audio, rollRef, setUserScrolled]);
182
+
183
+ return (
184
+ <section className="relative col-start-1 overflow-hidden rounded-card border border-line bg-[linear-gradient(180deg,rgba(255,255,255,0.02),transparent_60px),#0a0b0e] p-0 shadow-[0_1px_0_rgba(255,255,255,0.04)_inset,0_18px_40px_-28px_rgba(0,0,0,0.9)] animate-rise [animation-delay:0.12s]">
185
+ <canvas className="block h-[420px] w-full" width={1200} height={400} ref={canvasRef} />
186
+ </section>
187
+ );
188
+ }
source/demo/web/src/components/WelcomeScreen.tsx ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {
2
+ useEffect,
3
+ useRef,
4
+ useState,
5
+ type Dispatch,
6
+ type SetStateAction,
7
+ } from "react";
8
+ import clsx from "clsx";
9
+ import { ConditioningPanel } from "./ConditioningPanel";
10
+ import type { AppError } from "../App";
11
+
12
+ const SERVER_DOWN = "The muscriptor server is temporarily unavailable.";
13
+
14
+ /**
15
+ * First screen of the two-step flow: pick an audio file, then optionally choose
16
+ * conditioning instruments, then hit "Transcribe" to hand off to the main view.
17
+ * Transcription doesn't start until the button is clicked.
18
+ */
19
+ export function WelcomeScreen(props: {
20
+ selectedFile: File | null;
21
+ onPickFile: (file: File) => void;
22
+ /** Loads the bundled demo track + its suggested conditioning. */
23
+ onUseExample: () => Promise<void>;
24
+ condSelected: Set<string>;
25
+ onCondChange: (next: Set<string>) => void;
26
+ onTranscribe: () => void;
27
+ /** True while a file is dragged over the window; swaps the prompt in place. */
28
+ dragging: boolean;
29
+ /** A server-down notice replaces the picker; a file error sits beside it. */
30
+ error: AppError | null;
31
+ setError: Dispatch<SetStateAction<AppError | null>>;
32
+ }) {
33
+ const {
34
+ selectedFile,
35
+ onPickFile,
36
+ onUseExample,
37
+ condSelected,
38
+ onCondChange,
39
+ onTranscribe,
40
+ dragging,
41
+ error,
42
+ setError,
43
+ } = props;
44
+ const fileInputRef = useRef<HTMLInputElement>(null);
45
+ const [loadingExample, setLoadingExample] = useState(false);
46
+
47
+ // Probe the server on mount. A failure swaps the file picker for a
48
+ // server-down notice; success clears a stale server-down notice so the user
49
+ // can try again once the server recovers. A file error (e.g. an undecodable
50
+ // upload) is left alone — the server being up doesn't make a bad file good.
51
+ useEffect(() => {
52
+ let cancelled = false;
53
+ const clearServerError = () =>
54
+ setError((prev) => (prev?.kind === "server" ? null : prev));
55
+ fetch("/health")
56
+ .then((r) => {
57
+ if (cancelled) return;
58
+ if (r.ok) clearServerError();
59
+ else setError({ kind: "server", message: SERVER_DOWN });
60
+ })
61
+ .catch(() => {
62
+ if (!cancelled) setError({ kind: "server", message: SERVER_DOWN });
63
+ });
64
+ return () => {
65
+ cancelled = true;
66
+ };
67
+ }, [setError]);
68
+
69
+ async function handleExample() {
70
+ setLoadingExample(true);
71
+ try {
72
+ await onUseExample();
73
+ } catch (e) {
74
+ alert("Couldn't load the example file: " + (e as Error).message);
75
+ } finally {
76
+ setLoadingExample(false);
77
+ }
78
+ }
79
+
80
+ return (
81
+ <main className="mx-auto flex max-w-3xl flex-col gap-4 px-7 pb-12 pt-2 animate-rise [animation-delay:0.06s]">
82
+ <p className="text-base leading-relaxed text-muted">
83
+ MuScriptor is the best open model for multi-instrument transcription to
84
+ date. Give it a recording: pop, classical, metal, jazz, whatever, and
85
+ it transcribes the notes played by every instrument into
86
+ MIDI, for you to download or explore interactively.
87
+ </p>
88
+ <input
89
+ type="file"
90
+ accept="audio/*"
91
+ hidden
92
+ ref={fileInputRef}
93
+ onChange={(e) => {
94
+ const f = e.target.files?.[0];
95
+ if (f) onPickFile(f);
96
+ // Allow re-picking the same file (onChange won't fire otherwise).
97
+ e.target.value = "";
98
+ }}
99
+ />
100
+
101
+ <section className={clsx("card p-0", dragging && "animate-drag-glow")}>
102
+ {error?.kind === "server" ? (
103
+ <div className="flex flex-col items-center gap-3 px-8 py-16 text-center">
104
+ <p className="m-0 font-serif text-5xl leading-none text-content">
105
+ unavailable
106
+ </p>
107
+ <p className="m-0 max-w-md text-base text-muted">{error.message}</p>
108
+ </div>
109
+ ) : selectedFile === null ? (
110
+ <div className="flex flex-col items-center gap-4 px-8 py-16 text-center">
111
+ <div
112
+ className="h-16 w-32 bg-accent"
113
+ style={{
114
+ maskImage: "url(/muscriptor-wave.svg)",
115
+ WebkitMaskImage: "url(/muscriptor-wave.svg)",
116
+ maskSize: "contain",
117
+ WebkitMaskSize: "contain",
118
+ maskRepeat: "no-repeat",
119
+ WebkitMaskRepeat: "no-repeat",
120
+ maskPosition: "center",
121
+ WebkitMaskPosition: "center",
122
+ }}
123
+ aria-hidden="true"
124
+ />
125
+ <p className="m-0 text-base text-muted">
126
+ {dragging ? (
127
+ <span className="font-semibold text-content">Drop anywhere</span>
128
+ ) : (
129
+ <>
130
+ Drop an{" "}
131
+ <strong className="font-semibold text-content">audio file</strong> here,
132
+ or
133
+ </>
134
+ )}
135
+ </p>
136
+ <button
137
+ className="rounded-xl border-transparent bg-content px-7 py-3 text-base font-semibold text-[#15151b] hover:border-transparent hover:bg-white"
138
+ onClick={() => fileInputRef.current?.click()}
139
+ >
140
+ Select an audio file
141
+ </button>
142
+ <button
143
+ className="border-none bg-transparent px-1 py-0.5 text-sm text-muted underline underline-offset-4 hover:border-none hover:bg-transparent enabled:hover:text-content"
144
+ onClick={handleExample}
145
+ disabled={loadingExample}
146
+ >
147
+ {loadingExample ? "Loading example…" : "or try an example track"}
148
+ </button>
149
+ </div>
150
+ ) : (
151
+ <div className="flex flex-col items-start gap-2.5 px-8 py-7">
152
+ <p
153
+ className="m-0 max-w-full overflow-hidden text-ellipsis whitespace-nowrap text-2xl leading-[1.1] text-content"
154
+ title={selectedFile.name}
155
+ >
156
+ {selectedFile.name}
157
+ </p>
158
+ <button onClick={() => fileInputRef.current?.click()}>
159
+ Choose a different file
160
+ </button>
161
+ </div>
162
+ )}
163
+ </section>
164
+
165
+ {error?.kind === "file" && (
166
+ <p className="m-0 rounded-xl border border-red-500/40 bg-red-500/10 px-4 py-3 text-sm text-red-300">
167
+ {error.message}
168
+ </p>
169
+ )}
170
+
171
+ {error?.kind !== "server" && selectedFile !== null && (
172
+ <>
173
+ <ConditioningPanel selected={condSelected} onChange={onCondChange} />
174
+ <div className="flex justify-end">
175
+ <button
176
+ className="btn-primary rounded-xl px-9 py-3 text-base"
177
+ onClick={onTranscribe}
178
+ >
179
+ Transcribe
180
+ </button>
181
+ </div>
182
+ </>
183
+ )}
184
+ </main>
185
+ );
186
+ }
source/demo/web/src/components/icons.tsx ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Feather-style inline icons. Shared stroke styling; each path comes from the
2
+ // original main.ts icon strings.
3
+ const stroke = {
4
+ viewBox: "0 0 24 24",
5
+ width: 15,
6
+ height: 15,
7
+ fill: "none",
8
+ stroke: "currentColor",
9
+ strokeWidth: 2,
10
+ strokeLinecap: "round" as const,
11
+ strokeLinejoin: "round" as const,
12
+ "aria-hidden": true,
13
+ };
14
+
15
+ export function IconSound() {
16
+ return (
17
+ <svg {...stroke}>
18
+ <polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5" />
19
+ <path d="M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07" />
20
+ </svg>
21
+ );
22
+ }
23
+
24
+ export function IconSoundOff() {
25
+ return (
26
+ <svg {...stroke}>
27
+ <polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5" />
28
+ <line x1="23" y1="9" x2="17" y2="15" />
29
+ <line x1="17" y1="9" x2="23" y2="15" />
30
+ </svg>
31
+ );
32
+ }
33
+
34
+ export function IconPlay() {
35
+ return (
36
+ <svg {...stroke} fill="currentColor">
37
+ <polygon points="5 3 19 12 5 21 5 3" />
38
+ </svg>
39
+ );
40
+ }
41
+
42
+ export function IconPause() {
43
+ return (
44
+ <svg {...stroke} fill="currentColor">
45
+ <rect x="6" y="4" width="4" height="16" rx="1" />
46
+ <rect x="14" y="4" width="4" height="16" rx="1" />
47
+ </svg>
48
+ );
49
+ }
50
+
51
+ export function IconChevron({ className }: { className?: string }) {
52
+ return (
53
+ <svg
54
+ viewBox="0 0 24 24"
55
+ width={14}
56
+ height={14}
57
+ fill="none"
58
+ stroke="currentColor"
59
+ strokeWidth={2}
60
+ strokeLinecap="round"
61
+ strokeLinejoin="round"
62
+ aria-hidden="true"
63
+ className={className}
64
+ >
65
+ <polyline points="6 9 12 15 18 9" />
66
+ </svg>
67
+ );
68
+ }
69
+
70
+ export function IconDownload() {
71
+ return (
72
+ <svg
73
+ viewBox="0 0 16 16"
74
+ aria-hidden="true"
75
+ className="h-3.5 w-3.5 fill-none stroke-current [stroke-linecap:round] [stroke-linejoin:round] [stroke-width:1.5]"
76
+ >
77
+ <path d="M8 1v8m0 0L4.5 5.5M8 9l3.5-3.5M2 11v2.5A1.5 1.5 0 0 0 3.5 15h9a1.5 1.5 0 0 0 1.5-1.5V11" />
78
+ </svg>
79
+ );
80
+ }
source/demo/web/src/hooks/useAudioEngine.ts ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useRef } from "react";
2
+ import { AudioEngine } from "../audio";
3
+
4
+ /**
5
+ * Lazily construct a single {@link AudioEngine} for the app's lifetime.
6
+ *
7
+ * The engine wraps Tone's *global* transport + AudioContext and registers
8
+ * transport listeners in its constructor, so it must exist exactly once. The
9
+ * ref guard guarantees that even if React re-renders the owning component. (We
10
+ * deliberately don't wrap the app in <StrictMode>, whose simulated double-mount
11
+ * would otherwise create two engines competing over the one global transport.)
12
+ */
13
+ export function useAudioEngine(): AudioEngine {
14
+ const ref = useRef<AudioEngine | null>(null);
15
+ if (ref.current === null) ref.current = new AudioEngine();
16
+ return ref.current;
17
+ }
source/demo/web/src/hooks/useTranscription.ts ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useRef, type Dispatch, type RefObject, type SetStateAction } from "react";
2
+ import { streamTranscribe, TranscribeError } from "../sse";
3
+ import type { AudioEngine } from "../audio";
4
+ import type { ProgressEstimator } from "../progress";
5
+ import { PianoRoll, type RollNote } from "../pianoroll";
6
+
7
+ type StartEvent = {
8
+ type: "start";
9
+ pitch: number;
10
+ start_time: number;
11
+ index: number;
12
+ instrument: string;
13
+ };
14
+ type EndEvent = {
15
+ type: "end";
16
+ end_time: number;
17
+ start_event_index: number;
18
+ };
19
+ type MidiEvent = {
20
+ type: "midi";
21
+ data: string; // base64-encoded .mid file
22
+ };
23
+ type ProgressMsg = {
24
+ type: "progress";
25
+ completed: number; // chunks transcribed so far
26
+ total: number; // total chunks
27
+ };
28
+ type StreamedEvent = StartEvent | EndEvent | MidiEvent | ProgressMsg;
29
+
30
+ export type AppState = "idle" | "transcribing" | "done" | "error";
31
+
32
+ export interface TranscriptionDeps {
33
+ audio: AudioEngine;
34
+ /** Holds the PianoRoll once the canvas has mounted (may be null very early). */
35
+ rollRef: RefObject<PianoRoll | null>;
36
+ /** Conditioning instruments selected in the UI, read at submit time. */
37
+ getConditioning: () => string[];
38
+ /** Smooths chunk-completion anchors into a live progress fraction + ETA. */
39
+ progress: ProgressEstimator;
40
+ /** Called when a (non-superseded) transcription fails, so the UI can recover.
41
+ * `message` is a user-facing explanation (server-sent when available). */
42
+ onError: (message: string) => void;
43
+ setAppState: (s: AppState) => void;
44
+ /** Detected-instrument names, in first-seen order. */
45
+ setInstruments: Dispatch<SetStateAction<string[]>>;
46
+ /** Object URL of the assembled MIDI file, or null to disable download. */
47
+ setMidiUrl: (url: string | null) => void;
48
+ /** Raw MIDI blob, re-uploaded to /auralize for the mix download. */
49
+ setMidiBlob: (blob: Blob | null) => void;
50
+ /** Source audio file, re-uploaded to /auralize alongside the MIDI. */
51
+ setCurrentFile: (file: File | null) => void;
52
+ setUserScrolled: (v: boolean) => void;
53
+ /** Mutated so the download anchor can name the saved file. */
54
+ midiFilenameRef: RefObject<string>;
55
+ }
56
+
57
+ /**
58
+ * Returns a `transcribe(file)` function that streams the `/transcribe` SSE feed
59
+ * into the piano roll + audio engine. Ported from the original imperative
60
+ * `main.ts`; React state is touched only for low-frequency UI (status, detected
61
+ * instruments, download URL) — notes themselves stay inside the two classes.
62
+ */
63
+ export function useTranscription(deps: TranscriptionDeps) {
64
+ const {
65
+ audio,
66
+ rollRef,
67
+ getConditioning,
68
+ progress,
69
+ onError,
70
+ setAppState,
71
+ setInstruments,
72
+ setMidiUrl,
73
+ setMidiBlob,
74
+ setCurrentFile,
75
+ setUserScrolled,
76
+ midiFilenameRef,
77
+ } = deps;
78
+
79
+ // Names already surfaced in the instrument list this run.
80
+ const knownRef = useRef(new Set<string>());
81
+ // Provisional notes awaiting their matching `end` event, keyed by start index.
82
+ const openNotesRef = useRef(new Map<number, { startNote: RollNote }>());
83
+ // Current MIDI object URL, kept so we can revoke it before creating a new one.
84
+ const midiUrlRef = useRef<string | null>(null);
85
+ // The in-flight transcription, if any. Starting a new one aborts this so its
86
+ // (now stale) SSE stream stops feeding notes into the freshly-reset UI/audio.
87
+ const activeRef = useRef<AbortController | null>(null);
88
+
89
+ function addInstrument(name: string) {
90
+ if (knownRef.current.has(name)) return;
91
+ knownRef.current.add(name);
92
+ setInstruments((prev) => [...prev, name]);
93
+ }
94
+
95
+ function reset() {
96
+ rollRef.current?.clear();
97
+ knownRef.current.clear();
98
+ setInstruments([]);
99
+ openNotesRef.current.clear();
100
+ audio.reset();
101
+ setUserScrolled(false);
102
+ }
103
+
104
+ function clearMidi() {
105
+ if (midiUrlRef.current !== null) {
106
+ URL.revokeObjectURL(midiUrlRef.current);
107
+ midiUrlRef.current = null;
108
+ }
109
+ setMidiUrl(null);
110
+ setMidiBlob(null);
111
+ }
112
+
113
+ function setMidi(base64: string) {
114
+ const bytes = Uint8Array.from(atob(base64), (c) => c.charCodeAt(0));
115
+ const blob = new Blob([bytes], { type: "audio/midi" });
116
+ if (midiUrlRef.current !== null) URL.revokeObjectURL(midiUrlRef.current);
117
+ const url = URL.createObjectURL(blob);
118
+ midiUrlRef.current = url;
119
+ setMidiUrl(url);
120
+ setMidiBlob(blob);
121
+ }
122
+
123
+ function onEvent(ev: StartEvent | EndEvent) {
124
+ const roll = rollRef.current;
125
+ if (ev.type === "start") {
126
+ addInstrument(ev.instrument);
127
+ // Provisional end = start (will be patched on the matching end event).
128
+ const note: RollNote = {
129
+ pitch: ev.pitch,
130
+ start: ev.start_time,
131
+ end: ev.start_time,
132
+ instrument: ev.instrument,
133
+ };
134
+ roll?.addNote(note);
135
+ openNotesRef.current.set(ev.index, { startNote: note });
136
+ } else {
137
+ const open = openNotesRef.current.get(ev.start_event_index);
138
+ if (!open) return;
139
+ open.startNote.end = ev.end_time;
140
+ // Finalize geometry in the roll too — it stamps the reveal time and
141
+ // restacks any overlapping same-pitch notes. (The line above keeps `end`
142
+ // correct for audio scheduling even if the canvas hasn't mounted yet.)
143
+ roll?.setNoteEnd(open.startNote, ev.end_time);
144
+ openNotesRef.current.delete(ev.start_event_index);
145
+ audio.scheduleNote({
146
+ instrument: open.startNote.instrument,
147
+ pitch: open.startNote.pitch,
148
+ start: open.startNote.start,
149
+ end: open.startNote.end,
150
+ });
151
+ }
152
+ }
153
+
154
+ async function transcribe(file: File) {
155
+ // Remember the source audio so the mix download can re-upload it.
156
+ setCurrentFile(file);
157
+ // Cancel any previous run before resetting state for this one.
158
+ activeRef.current?.abort();
159
+ const controller = new AbortController();
160
+ activeRef.current = controller;
161
+ // True once a *newer* transcription has superseded this one.
162
+ const isStale = () => activeRef.current !== controller;
163
+
164
+ reset();
165
+ clearMidi();
166
+ progress.reset();
167
+ midiFilenameRef.current = file.name.replace(/\.[^/.]+$/, "") + ".mid";
168
+ setAppState("transcribing");
169
+ // Resume the AudioContext now, while we still have the user-gesture
170
+ // activation from the drop / file-pick. Without this, calling play()
171
+ // later — even from a click — sometimes can't unlock the context.
172
+ audio.unlock().catch(() => {});
173
+ // Decode the WAV in parallel with the transcription so it's ready by the
174
+ // time the user hits play.
175
+ audio.loadWav(file).catch(() => {});
176
+ let maxEnd = 0;
177
+ try {
178
+ const cond = getConditioning();
179
+ const extra = cond.length > 0 ? { instruments: cond } : undefined;
180
+ for await (const raw of streamTranscribe(
181
+ "/transcribe",
182
+ file,
183
+ extra,
184
+ controller.signal,
185
+ )) {
186
+ // A newer upload took over while we were awaiting — drop this event so
187
+ // it can't repopulate the piano roll / re-schedule old notes.
188
+ if (isStale()) return;
189
+ const ev = raw as StreamedEvent;
190
+ if (ev.type === "midi") {
191
+ // Final event: the assembled MIDI file. Enables the download button.
192
+ setMidi(ev.data);
193
+ continue;
194
+ }
195
+ if (ev.type === "progress") {
196
+ // Coarse chunk anchor — the estimator smooths it into the live bar.
197
+ progress.onAnchor(ev.completed, ev.total, performance.now());
198
+ continue;
199
+ }
200
+ onEvent(ev);
201
+ if (ev.type === "end" && ev.end_time > maxEnd) maxEnd = ev.end_time;
202
+ }
203
+ if (isStale()) return;
204
+ // Stop the transport ~0.3 s after the last note ends.
205
+ if (maxEnd > 0) audio.scheduleStop(maxEnd + 0.3);
206
+ setAppState("done");
207
+ } catch (e) {
208
+ // An abort (from being superseded) surfaces here as an error — ignore it
209
+ // so it can't clobber the newer run.
210
+ if (isStale() || controller.signal.aborted) return;
211
+ setAppState("error");
212
+ // Prefer the server's explanation (e.g. an undecodable file) over a
213
+ // generic message; fall back when the failure was a network error or
214
+ // the server gave no detail.
215
+ const message =
216
+ e instanceof TranscribeError && e.userMessage
217
+ ? e.userMessage
218
+ : "The muscriptor server is temporarily unavailable. Please try again later.";
219
+ onError(message);
220
+ } finally {
221
+ if (activeRef.current === controller) activeRef.current = null;
222
+ }
223
+ }
224
+
225
+ /** Abort the in-flight transcription (if any) without starting a new one.
226
+ * Call when the user leaves the transcribe screen, so the stale stream
227
+ * stops feeding notes into the audio engine — and so the server hears the
228
+ * disconnect while the user is still picking the next file. */
229
+ function abort() {
230
+ activeRef.current?.abort();
231
+ activeRef.current = null;
232
+ }
233
+
234
+ return { transcribe, abort };
235
+ }
source/demo/web/src/instruments.ts ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Fuzzy matching for the conditioning instrument picker.
3
+ *
4
+ * The backend instrument ids (e.g. `french_horn`) are terse and don't cover the
5
+ * many ways a musician might search — by family ("brass"), by colloquial name
6
+ * ("rhodes", "fiddle"), or with a typo. `ALIASES` maps each id to extra search
7
+ * terms, and `scoreInstrument` ranks a candidate against a query using those
8
+ * terms plus a subsequence fallback for typos.
9
+ */
10
+
11
+ /**
12
+ * Family / category keywords, each expanded to the instrument ids it covers.
13
+ * Kept separate from per-instrument aliases so a family can be edited in one
14
+ * place; both are folded into the per-instrument alias lists below.
15
+ */
16
+ const FAMILIES: Record<string, string[]> = {
17
+ keys: ["acoustic_piano", "electric_piano", "organ"],
18
+ keyboard: ["acoustic_piano", "electric_piano", "organ"],
19
+ piano: ["acoustic_piano", "electric_piano"],
20
+ guitar: [
21
+ "acoustic_guitar",
22
+ "clean_electric_guitar",
23
+ "distorted_electric_guitar",
24
+ ],
25
+ bass: ["acoustic_bass", "electric_bass", "contrabass"],
26
+ strings: [
27
+ "violin",
28
+ "viola",
29
+ "cello",
30
+ "contrabass",
31
+ "orchestral_harp",
32
+ "string_ensemble",
33
+ "synth_strings",
34
+ ],
35
+ orchestra: [
36
+ "violin",
37
+ "viola",
38
+ "cello",
39
+ "contrabass",
40
+ "orchestral_harp",
41
+ "timpani",
42
+ "string_ensemble",
43
+ "french_horn",
44
+ "trumpet",
45
+ "trombone",
46
+ "tuba",
47
+ "oboe",
48
+ "english_horn",
49
+ "bassoon",
50
+ "clarinet",
51
+ "flutes",
52
+ ],
53
+ brass: ["trumpet", "trombone", "tuba", "french_horn", "brass_section"],
54
+ horns: ["trumpet", "trombone", "tuba", "french_horn", "brass_section"],
55
+ woodwind: [
56
+ "oboe",
57
+ "english_horn",
58
+ "bassoon",
59
+ "clarinet",
60
+ "flutes",
61
+ "soprano_and_alto_sax",
62
+ "tenor_sax",
63
+ "baritone_sax",
64
+ ],
65
+ woodwinds: [
66
+ "oboe",
67
+ "english_horn",
68
+ "bassoon",
69
+ "clarinet",
70
+ "flutes",
71
+ "soprano_and_alto_sax",
72
+ "tenor_sax",
73
+ "baritone_sax",
74
+ ],
75
+ reed: ["oboe", "english_horn", "bassoon", "clarinet"],
76
+ sax: ["soprano_and_alto_sax", "tenor_sax", "baritone_sax"],
77
+ saxophone: ["soprano_and_alto_sax", "tenor_sax", "baritone_sax"],
78
+ wind: [
79
+ "trumpet",
80
+ "trombone",
81
+ "tuba",
82
+ "french_horn",
83
+ "brass_section",
84
+ "oboe",
85
+ "english_horn",
86
+ "bassoon",
87
+ "clarinet",
88
+ "flutes",
89
+ "soprano_and_alto_sax",
90
+ "tenor_sax",
91
+ "baritone_sax",
92
+ ],
93
+ percussion: ["drums", "timpani", "chromatic_percussion"],
94
+ synth: ["synth_strings", "synth_lead", "synth_pad"],
95
+ vocals: ["voice"],
96
+ vocal: ["voice"],
97
+ };
98
+
99
+ /** Per-instrument colloquial names and common spellings. */
100
+ const SPECIFIC: Record<string, string[]> = {
101
+ acoustic_piano: ["grand piano", "grand", "upright piano"],
102
+ electric_piano: ["rhodes", "wurlitzer", "wurli", "ep", "e-piano"],
103
+ chromatic_percussion: [
104
+ "vibraphone",
105
+ "vibes",
106
+ "marimba",
107
+ "xylophone",
108
+ "glockenspiel",
109
+ "bells",
110
+ "celesta",
111
+ ],
112
+ organ: ["hammond", "pipe organ", "b3"],
113
+ acoustic_guitar: ["nylon", "steel string", "acoustic"],
114
+ clean_electric_guitar: ["electric guitar", "clean guitar"],
115
+ distorted_electric_guitar: [
116
+ "electric guitar",
117
+ "distortion",
118
+ "overdrive",
119
+ "distorted guitar",
120
+ ],
121
+ acoustic_bass: ["upright bass", "double bass", "stand-up bass"],
122
+ electric_bass: ["bass guitar", "e-bass", "electric bass"],
123
+ violin: ["fiddle"],
124
+ cello: ["violoncello"],
125
+ contrabass: ["double bass", "upright bass"],
126
+ orchestral_harp: ["harp"],
127
+ timpani: ["kettle drum", "kettledrums"],
128
+ string_ensemble: ["string section", "strings"],
129
+ synth_strings: ["synth strings", "string pad"],
130
+ voice: ["vocals", "vocal", "singer", "choir", "vox"],
131
+ orchestra_hit: ["orch hit", "stab", "hit"],
132
+ french_horn: ["horn"],
133
+ brass_section: ["brass", "horn section", "horns"],
134
+ soprano_and_alto_sax: ["alto sax", "soprano sax", "alto", "soprano"],
135
+ tenor_sax: ["tenor"],
136
+ baritone_sax: ["bari sax", "baritone", "bari"],
137
+ english_horn: ["cor anglais"],
138
+ flutes: ["flute", "piccolo", "recorder"],
139
+ synth_lead: ["lead"],
140
+ synth_pad: ["pad"],
141
+ drums: ["drum kit", "drumkit", "kit", "beat", "percussion"],
142
+ };
143
+
144
+ /** Final id -> alias-terms map, merging families and per-instrument names. */
145
+ const ALIASES: Record<string, string[]> = (() => {
146
+ const out: Record<string, Set<string>> = {};
147
+ for (const [term, ids] of Object.entries(FAMILIES)) {
148
+ for (const id of ids) (out[id] ??= new Set()).add(term);
149
+ }
150
+ for (const [id, terms] of Object.entries(SPECIFIC)) {
151
+ for (const t of terms) (out[id] ??= new Set()).add(t);
152
+ }
153
+ return Object.fromEntries(
154
+ Object.entries(out).map(([id, set]) => [id, [...set]]),
155
+ );
156
+ })();
157
+
158
+ /** Display form of an instrument id ("electric_bass" -> "electric bass"). */
159
+ export function label(name: string): string {
160
+ return name.replace(/_/g, " ");
161
+ }
162
+
163
+ /** True if every char of `q` appears in `text` in order (typo-tolerant). */
164
+ function isSubsequence(q: string, text: string): boolean {
165
+ let i = 0;
166
+ for (let j = 0; j < text.length && i < q.length; j++) {
167
+ if (text[j] === q[i]) i++;
168
+ }
169
+ return i === q.length;
170
+ }
171
+
172
+ /**
173
+ * Score `name` against `query` for ranking; 0 means no match. Higher is a
174
+ * tighter match: exact label > label prefix > label substring > alias hits >
175
+ * subsequence (typo) fallback.
176
+ */
177
+ export function scoreInstrument(name: string, query: string): number {
178
+ const q = query.trim().toLowerCase();
179
+ if (q === "") return 1;
180
+
181
+ const text = label(name).toLowerCase();
182
+ if (text === q) return 100;
183
+ if (text.startsWith(q)) return 80;
184
+ if (text.includes(q)) return 60;
185
+
186
+ let best = 0;
187
+ for (const alias of ALIASES[name] ?? []) {
188
+ if (alias === q) best = Math.max(best, 55);
189
+ else if (alias.startsWith(q)) best = Math.max(best, 45);
190
+ else if (alias.includes(q)) best = Math.max(best, 40);
191
+ }
192
+ if (best > 0) return best;
193
+
194
+ // Typo tolerance — only for queries long enough to be meaningful.
195
+ if (q.length >= 3) {
196
+ if (isSubsequence(q, text)) return 20;
197
+ for (const alias of ALIASES[name] ?? []) {
198
+ if (isSubsequence(q, alias)) return 15;
199
+ }
200
+ }
201
+ return 0;
202
+ }
source/demo/web/src/local.tsx ADDED
@@ -0,0 +1,329 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useEffect, useRef, useState } from "react";
2
+ import { createRoot } from "react-dom/client";
3
+ import "./style.css";
4
+ import "./local/local.css";
5
+ import { AudioEngine } from "./audio";
6
+ import { PianoRollCanvas } from "./components/PianoRollCanvas";
7
+ import type { PianoRoll, RollNote } from "./pianoroll";
8
+ import { decodeTrackTokens, instrumentName, type HendrixNote } from "./local/codec";
9
+ import { decodeAudio, sliceAudio, spectrogram, TARGET_SAMPLE_RATE } from "./local/dsp";
10
+ import { notesToMidi } from "./local/midi";
11
+ import { LocalHendrixModel, probeLocalCapability, type LocalBackend, type LocalCapability } from "./local/model";
12
+
13
+ type RunState = "idle" | "loading" | "running" | "done" | "error";
14
+ const isSpace = import.meta.env.VITE_HENDRIX_SPACE === "1";
15
+ const precisionQuery = new URLSearchParams(window.location.search).get("precision");
16
+ const precisionOverride = precisionQuery === "fp32" || precisionQuery === "fp16" ? precisionQuery : undefined;
17
+ const cacheQuery = new URLSearchParams(window.location.search).get("cache");
18
+ const gpuResidentOutputs = cacheQuery !== "cpu";
19
+ const backendQuery = new URLSearchParams(window.location.search).get("backend");
20
+ const preferredBackend: LocalBackend | undefined = backendQuery === "wasm" || backendQuery === "webgpu"
21
+ ? backendQuery
22
+ : undefined;
23
+
24
+ function LocalApp() {
25
+ const audioRef = useRef<AudioEngine | null>(null);
26
+ const audio = (audioRef.current ??= new AudioEngine({ forceFallback: true }));
27
+ const rollRef = useRef<PianoRoll | null>(null);
28
+ const modelRef = useRef<LocalHendrixModel | null>(null);
29
+ const abortRef = useRef<AbortController | null>(null);
30
+ const recorderRef = useRef<{ recorder: MediaRecorder; stream: MediaStream; chunks: Blob[] } | null>(null);
31
+ const [capability, setCapability] = useState<LocalCapability | null>(null);
32
+ const [file, setFile] = useState<File | null>(null);
33
+ const [runState, setRunState] = useState<RunState>("idle");
34
+ const [status, setStatus] = useState("Choose a recording or make one here.");
35
+ const [progress, setProgress] = useState(0);
36
+ const [notes, setNotes] = useState<HendrixNote[]>([]);
37
+ const [midiUrl, setMidiUrl] = useState<string | null>(null);
38
+ const [limitSeconds, setLimitSeconds] = useState(2.05);
39
+ const [recording, setRecording] = useState(false);
40
+ const [inputPending, setInputPending] = useState(false);
41
+ const [diagnostics, setDiagnostics] = useState("");
42
+ const [, setUserScrolled] = useState(false);
43
+
44
+ useEffect(() => {
45
+ probeLocalCapability(preferredBackend).then(setCapability).catch((error) => setCapability({
46
+ supported: false,
47
+ adapter: "",
48
+ shaderF16: false,
49
+ backend: "wasm",
50
+ reason: String(error),
51
+ }));
52
+ }, []);
53
+
54
+ useEffect(() => {
55
+ let frame = 0;
56
+ const render = () => {
57
+ rollRef.current?.setPlayhead(audio.seconds);
58
+ rollRef.current?.render();
59
+ frame = requestAnimationFrame(render);
60
+ };
61
+ frame = requestAnimationFrame(render);
62
+ return () => cancelAnimationFrame(frame);
63
+ }, [audio]);
64
+
65
+ useEffect(() => () => {
66
+ abortRef.current?.abort();
67
+ recorderRef.current?.stream.getTracks().forEach((track) => track.stop());
68
+ }, []);
69
+
70
+ useEffect(() => () => {
71
+ if (midiUrl) URL.revokeObjectURL(midiUrl);
72
+ }, [midiUrl]);
73
+
74
+ function chooseFile(selected: File) {
75
+ abortRef.current?.abort();
76
+ audio.reset();
77
+ rollRef.current?.clear();
78
+ setFile(selected);
79
+ setNotes([]);
80
+ setProgress(0);
81
+ setRunState("idle");
82
+ setDiagnostics("");
83
+ setStatus(`${selected.name} stays on this device.`);
84
+ setMidiUrl(null);
85
+ }
86
+
87
+ async function startRecording() {
88
+ if (!navigator.mediaDevices?.getUserMedia || typeof MediaRecorder === "undefined") {
89
+ throw new Error("Recording is unavailable in this browser. Choose an audio file instead.");
90
+ }
91
+ const stream = await navigator.mediaDevices.getUserMedia({
92
+ audio: { channelCount: 1, echoCancellation: false, noiseSuppression: false },
93
+ });
94
+ let recorder: MediaRecorder;
95
+ try {
96
+ recorder = new MediaRecorder(stream);
97
+ } catch (error) {
98
+ stream.getTracks().forEach((track) => track.stop());
99
+ throw error;
100
+ }
101
+ const state = { recorder, stream, chunks: [] as Blob[] };
102
+ recorderRef.current = state;
103
+ recorder.ondataavailable = (event) => { if (event.data.size) state.chunks.push(event.data); };
104
+ recorder.onstop = () => {
105
+ const blob = new Blob(state.chunks, { type: recorder.mimeType || "audio/mp4" });
106
+ stream.getTracks().forEach((track) => track.stop());
107
+ chooseFile(new File([blob], `hendrix-recording-${Date.now()}.${blob.type.includes("webm") ? "webm" : blob.type.includes("ogg") ? "ogg" : "m4a"}`, { type: blob.type }));
108
+ recorderRef.current = null;
109
+ setRecording(false);
110
+ };
111
+ try {
112
+ recorder.start(250);
113
+ } catch (error) {
114
+ stream.getTracks().forEach((track) => track.stop());
115
+ recorderRef.current = null;
116
+ throw error;
117
+ }
118
+ setRecording(true);
119
+ setStatus("Recording locally… tap Stop when you have enough audio.");
120
+ }
121
+
122
+ function stopRecording() {
123
+ recorderRef.current?.recorder.stop();
124
+ }
125
+
126
+ async function loadDiagnosticClip() {
127
+ setStatus("Loading the known two-second check clip…");
128
+ const response = await fetch("/diagnostic.wav", { cache: "no-cache" });
129
+ if (!response.ok) throw new Error(`Diagnostic clip: HTTP ${response.status}`);
130
+ chooseFile(new File([await response.blob()], "hendrix-known-check.wav", { type: "audio/wav" }));
131
+ setLimitSeconds(2.05);
132
+ }
133
+
134
+ async function prepareInput(action: () => Promise<void>) {
135
+ setInputPending(true);
136
+ try {
137
+ await action();
138
+ } catch (error) {
139
+ setRunState("error");
140
+ setStatus(error instanceof Error ? error.message : String(error));
141
+ } finally {
142
+ setInputPending(false);
143
+ }
144
+ }
145
+
146
+ async function transcribe() {
147
+ if (!file || !capability?.supported) return;
148
+ const controller = new AbortController();
149
+ abortRef.current?.abort();
150
+ abortRef.current = controller;
151
+ setRunState("loading");
152
+ setProgress(0);
153
+ setDiagnostics("");
154
+ setNotes([]);
155
+ setMidiUrl(null);
156
+ audio.reset();
157
+ rollRef.current?.clear();
158
+ await audio.unlock().catch(() => {});
159
+ // Await playback decoding too, so it cannot mutate the next run after cancel.
160
+ const playbackReady = audio.loadWav(file).catch(() => {});
161
+ const started = performance.now();
162
+ try {
163
+ setStatus("Decoding and resampling audio on this device…");
164
+ const [decoded] = await Promise.all([decodeAudio(file, limitSeconds), playbackReady]);
165
+ controller.signal.throwIfAborted();
166
+ const kept = decoded.subarray(0, Math.min(decoded.length, Math.round(limitSeconds * TARGET_SAMPLE_RATE)));
167
+ const duration = kept.length / TARGET_SAMPLE_RATE;
168
+ const windows = sliceAudio(kept);
169
+ if (!modelRef.current) {
170
+ modelRef.current = await LocalHendrixModel.create(
171
+ "/models",
172
+ (message) => { if (!controller.signal.aborted) setStatus(message); },
173
+ precisionOverride,
174
+ gpuResidentOutputs,
175
+ capability.backend,
176
+ );
177
+ }
178
+ controller.signal.throwIfAborted();
179
+ const model = modelRef.current;
180
+ setRunState("running");
181
+ const tokenWindows: number[][][] = [];
182
+ const runDiagnostics: string[] = [];
183
+ for (let index = 0; index < windows.length; index++) {
184
+ if (controller.signal.aborted) throw new DOMException("Cancelled", "AbortError");
185
+ setStatus(`Transcribing window ${index + 1} of ${windows.length} on ${model.adapter}…`);
186
+ setProgress(index / windows.length);
187
+ const features = spectrogram(windows[index]);
188
+ const result = await model.transcribeSegment(features, controller.signal);
189
+ controller.signal.throwIfAborted();
190
+ tokenWindows.push(result.channels);
191
+ const detail = result.diagnostics;
192
+ runDiagnostics.push(
193
+ `w${index + 1} ${detail.precision}/${detail.logitsArray} backend=${detail.backend} cache=${detail.cacheLocation} steps=${detail.steps} eos=${detail.endedChannels}/13 encoder=${detail.encoderMs.toFixed(0)}ms cross=${detail.crossCacheMs.toFixed(0)}ms decoder=${detail.decoderMs.toFixed(0)}ms finite=${detail.finiteLogits}/${detail.totalLogits} first=${detail.firstTokens.join(",")} ch0=${detail.channelPreviews[0].join(",")}`,
194
+ );
195
+ setProgress((index + 1) / windows.length);
196
+ }
197
+ setStatus("Turning tokens into notes…");
198
+ const decodedNotes = decodeTrackTokens(
199
+ tokenWindows,
200
+ model.manifest.runtime_contract.segment_seconds,
201
+ duration,
202
+ );
203
+ setNotes(decodedNotes);
204
+ rollRef.current?.setDuration(duration);
205
+ for (const note of decodedNotes) {
206
+ const rollNote: RollNote = {
207
+ pitch: note.pitch,
208
+ start: note.onset,
209
+ end: note.offset,
210
+ instrument: instrumentName(note),
211
+ };
212
+ rollRef.current?.addNote(rollNote);
213
+ rollRef.current?.setNoteEnd(rollNote, note.offset);
214
+ audio.scheduleNote({
215
+ instrument: rollNote.instrument,
216
+ pitch: rollNote.pitch,
217
+ start: rollNote.start,
218
+ end: rollNote.end,
219
+ });
220
+ }
221
+ if (duration > 0) audio.scheduleStop(duration + 0.3);
222
+ const midi = notesToMidi(decodedNotes);
223
+ setMidiUrl(URL.createObjectURL(midi));
224
+ const elapsed = (performance.now() - started) / 1000;
225
+ setDiagnostics(runDiagnostics.join(" | "));
226
+ setStatus(`${decodedNotes.length} notes from ${duration.toFixed(1)} s of audio in ${elapsed.toFixed(1)} s. Audio never left this device.`);
227
+ setRunState("done");
228
+ } catch (error) {
229
+ if (controller.signal.aborted) {
230
+ setRunState("idle");
231
+ setStatus("Cancelled.");
232
+ } else {
233
+ console.error(error);
234
+ setRunState("error");
235
+ setStatus(error instanceof Error ? error.message : String(error));
236
+ }
237
+ } finally {
238
+ if (abortRef.current === controller) abortRef.current = null;
239
+ }
240
+ }
241
+
242
+ function cancel() {
243
+ abortRef.current?.abort();
244
+ setStatus("Cancelling… waiting for the current browser operation to finish.");
245
+ }
246
+
247
+ const families = Array.from(new Set(notes.map(instrumentName))).sort();
248
+ const busy = runState === "loading" || runState === "running";
249
+ const inputLocked = busy || recording || inputPending;
250
+
251
+ return (
252
+ <main className="local-shell">
253
+ <header className="local-hero">
254
+ <a href="/" className="local-kicker">{isSpace ? "HENDRIX / AUDIO TO MIDI" : "HENDRIX / LOCAL LAB"}</a>
255
+ <h1>{isSpace ? <>Audio to MIDI.<br />On your device.</> : <>46M parameters.<br />No server.</>}</h1>
256
+ <p><strong>29× fewer learned parameters than MuScriptor-large.</strong> The D26 research checkpoint runs here with WebGPU or a CPU fallback. Pick a file or record here; the page turns it into notes without an upload.</p>
257
+ </header>
258
+
259
+ <section className="local-card capability-card">
260
+ <span className={capability?.supported ? "status-dot ready" : "status-dot"} />
261
+ {capability === null ? "Checking this browser…" : capability.supported
262
+ ? `${capability.adapter} · ${precisionOverride === "fp16" ? "FP16 diagnostic · 100.1 MB" : "FP32 verified · 195.3 MB"}`
263
+ : capability.reason}
264
+ </section>
265
+
266
+ <section className="local-card input-card">
267
+ <div className="file-row">
268
+ <label className="primary-button">
269
+ Choose audio
270
+ <input type="file" accept="audio/*" disabled={inputLocked} hidden onChange={(event) => {
271
+ const selected = event.target.files?.[0];
272
+ if (selected) chooseFile(selected);
273
+ }} />
274
+ </label>
275
+ <button className="secondary-button" disabled={inputLocked} onClick={() => prepareInput(loadDiagnosticClip)}>{isSpace ? "Try Bach example" : "Known check clip"}</button>
276
+ {!recording ? (
277
+ <button className="secondary-button" onClick={() => prepareInput(startRecording)} disabled={!capability?.supported || inputLocked}>Record here</button>
278
+ ) : (
279
+ <button className="record-button" onClick={stopRecording}>Stop recording</button>
280
+ )}
281
+ <label className="limit-label">Use first
282
+ <select disabled={inputLocked} value={limitSeconds} onChange={(event) => setLimitSeconds(Number(event.target.value))}>
283
+ <option value={2.05}>2 seconds</option>
284
+ <option value={6}>6 seconds</option>
285
+ <option value={10}>10 seconds</option>
286
+ <option value={30}>30 seconds</option>
287
+ <option value={60}>60 seconds</option>
288
+ </select>
289
+ </label>
290
+ </div>
291
+ <div className="chosen-file">{file ? file.name : "No recording chosen"}</div>
292
+ <div className="action-row">
293
+ <button className="primary-button" onClick={transcribe} disabled={!file || !capability?.supported || inputLocked}>Run on this device</button>
294
+ {busy && <button className="secondary-button" onClick={cancel}>Cancel</button>}
295
+ </div>
296
+ <p className="run-hint">Start with two seconds. The first run downloads a 195.3 MB model and prepares it; speed varies by device.</p>
297
+ <div className="progress-track" role="progressbar" aria-label="Transcription progress" aria-valuemin={0} aria-valuemax={100} aria-valuenow={Math.round(progress * 100)}><div style={{ width: `${progress * 100}%` }} /></div>
298
+ <p role="status" aria-live="polite" className={runState === "error" ? "run-status error" : "run-status"}>{status}</p>
299
+ {diagnostics && <details className="run-diagnostics"><summary>Run details</summary><p className="diagnostic-output">{diagnostics}</p></details>}
300
+ </section>
301
+
302
+ {notes.length > 0 && (
303
+ <section className="result-bar">
304
+ <div><strong>{notes.length}</strong><span>notes</span></div>
305
+ <div><strong>{families.length}</strong><span>families</span></div>
306
+ <button onClick={() => audio.state === "started" ? audio.pause() : audio.play()} className="secondary-button">Play / pause</button>
307
+ {midiUrl && <a className="primary-button" href={midiUrl} download={`${file?.name.replace(/\.[^/.]+$/, "") ?? "hendrix"}.mid`}>Download MIDI</a>}
308
+ </section>
309
+ )}
310
+
311
+ <div className="roll-stage">
312
+ <PianoRollCanvas rollRef={rollRef} audio={audio} setUserScrolled={setUserScrolled} />
313
+ {notes.length === 0 && <div className="roll-empty">Your notes will appear here</div>}
314
+ </div>
315
+
316
+ <footer className="local-footer">
317
+ <p>The D26 research build uses the 195.3 MB FP32 graph. WebGPU is preferred; WebAssembly runs the same graph on the CPU when no GPU is available. Later visits use the browser cache.</p>
318
+ <nav aria-label="Other demo modes" className="local-footer-links">
319
+ {isSpace ? <a href="https://github.com/jackboyla/hendrix">Source and research</a> : <a href="/compare.html">Compare systems</a>}
320
+ <a href="/local.html?backend=wasm">Force CPU WebAssembly</a>
321
+ {!isSpace && <a href="/local.html?cache=cpu">CPU-cache timing control</a>}
322
+ {!isSpace && <a href="/local.html?precision=fp16&amp;v=diagnostic-5">FP16 diagnostic</a>}
323
+ </nav>
324
+ </footer>
325
+ </main>
326
+ );
327
+ }
328
+
329
+ createRoot(document.getElementById("root")!).render(<LocalApp />);
source/demo/web/src/local/codec.ts ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export interface HendrixNote {
2
+ onset: number;
3
+ offset: number;
4
+ pitch: number;
5
+ program: number;
6
+ isDrum: boolean;
7
+ velocity: number;
8
+ }
9
+
10
+ interface Event {
11
+ type: "PAD" | "EOS" | "UNK" | "shift" | "pitch" | "velocity" | "tie" | "program" | "drum";
12
+ value: number;
13
+ }
14
+
15
+ interface NoteEvent {
16
+ isDrum: boolean;
17
+ program: number;
18
+ time: number | null;
19
+ velocity: number;
20
+ pitch: number;
21
+ }
22
+
23
+ interface DecodedWindow {
24
+ notes: NoteEvent[];
25
+ ties: NoteEvent[];
26
+ lastActivity: Array<[number, number]>;
27
+ start: number;
28
+ }
29
+
30
+ const PROGRAM_GROUPS: Array<[string, number[]]> = [
31
+ ["acoustic_piano", [0, 1, 3, 6, 7]],
32
+ ["electric_piano", [2, 4, 5]],
33
+ ["chromatic_percussion", range(8, 16)],
34
+ ["organ", range(16, 24)],
35
+ ["acoustic_guitar", [24, 25]],
36
+ ["clean_electric_guitar", [26, 27, 28]],
37
+ ["distorted_electric_guitar", [29, 30, 31]],
38
+ ["acoustic_bass", [32, 35]],
39
+ ["electric_bass", [33, 34, 36, 37, 38, 39]],
40
+ ["violin", [40]], ["viola", [41]], ["cello", [42]], ["contrabass", [43]],
41
+ ["orchestral_harp", [46]], ["timpani", [47]],
42
+ ["string_ensemble", [48, 49, 44, 45]], ["synth_strings", [50, 51]],
43
+ ["voice", [52, 53, 54, 100, 101]], ["orchestra_hit", [55]],
44
+ ["trumpet", [56, 59]], ["trombone", [57]], ["tuba", [58]],
45
+ ["french_horn", [60]], ["brass_section", [61, 62, 63]],
46
+ ["soprano_and_alto_sax", [64, 65]], ["tenor_sax", [66]],
47
+ ["baritone_sax", [67]], ["oboe", [68]], ["english_horn", [69]],
48
+ ["bassoon", [70]], ["clarinet", [71]], ["flutes", range(72, 80)],
49
+ ["synth_lead", range(80, 88)], ["synth_pad", range(88, 96)],
50
+ ];
51
+
52
+ function range(start: number, end: number): number[] {
53
+ return Array.from({ length: end - start }, (_, index) => start + index);
54
+ }
55
+
56
+ const programNames = new Map<number, string>();
57
+ for (const [name, programs] of PROGRAM_GROUPS) {
58
+ for (const program of programs) programNames.set(program, name);
59
+ }
60
+
61
+ export function instrumentName(note: HendrixNote): string {
62
+ if (note.isDrum) return "drums";
63
+ return programNames.get(note.program) ?? `program_${note.program}`;
64
+ }
65
+
66
+ function decodeToken(token: number): Event {
67
+ if (token === 0) return { type: "PAD", value: 0 };
68
+ if (token === 1) return { type: "EOS", value: 0 };
69
+ if (token === 2) return { type: "UNK", value: 0 };
70
+ if (token <= 208) return { type: "shift", value: token - 3 };
71
+ if (token <= 336) return { type: "pitch", value: token - 209 };
72
+ if (token <= 338) return { type: "velocity", value: token - 337 };
73
+ if (token === 339) return { type: "tie", value: 0 };
74
+ if (token <= 467) return { type: "program", value: token - 340 };
75
+ if (token <= 595) return { type: "drum", value: token - 468 };
76
+ throw new Error(`unknown token ${token}`);
77
+ }
78
+
79
+ function decodeWindow(tokens: number[], start: number): DecodedWindow {
80
+ const events = tokens.map(decodeToken);
81
+ let program: number | null = null;
82
+ const ties: NoteEvent[] = [];
83
+ const lastActivity: Array<[number, number]> = [];
84
+ let tieIndex = -1;
85
+ for (let i = 0; i < events.length; i++) {
86
+ const event = events[i];
87
+ if (event.type === "tie") {
88
+ tieIndex = i;
89
+ break;
90
+ }
91
+ if (event.type === "shift") break;
92
+ if (event.type === "program") program = event.value;
93
+ if (event.type === "pitch" && program !== null) {
94
+ ties.push({ isDrum: false, program, time: null, velocity: 1, pitch: event.value });
95
+ lastActivity.push([program, event.value]);
96
+ }
97
+ }
98
+ if (tieIndex < 0) return { notes: [], ties: [], lastActivity: [], start };
99
+
100
+ const notes: NoteEvent[] = [];
101
+ const startTick = Math.round(start * 100);
102
+ let tick = startTick;
103
+ let velocity: number | null = null;
104
+ for (const event of events.slice(tieIndex + 1)) {
105
+ if (event.type === "shift") {
106
+ if (event.value > 0) tick = startTick + event.value;
107
+ } else if (event.type === "drum") {
108
+ notes.push({ isDrum: true, program: 128, time: tick / 100, velocity: 1, pitch: event.value });
109
+ } else if (event.type === "program") {
110
+ program = event.value;
111
+ } else if (event.type === "velocity") {
112
+ velocity = event.value;
113
+ } else if (event.type === "pitch" && program !== null && velocity !== null) {
114
+ const key = `${program}:${event.value}`;
115
+ if (velocity > 0) {
116
+ lastActivity.push([program, event.value]);
117
+ } else {
118
+ const index = lastActivity.findIndex(([p, pitch]) => `${p}:${pitch}` === key);
119
+ if (index < 0) continue;
120
+ lastActivity.splice(index, 1);
121
+ }
122
+ notes.push({ isDrum: false, program, time: tick / 100, velocity, pitch: event.value });
123
+ } else if (event.type === "EOS") {
124
+ break;
125
+ }
126
+ }
127
+ notes.sort((a, b) => (a.time ?? 0) - (b.time ?? 0) || Number(a.isDrum) - Number(b.isDrum) || a.program - b.program || a.velocity - b.velocity || a.pitch - b.pitch);
128
+ ties.sort((a, b) => Number(a.isDrum) - Number(b.isDrum) || a.program - b.program || a.pitch - b.pitch);
129
+ return { notes, ties, lastActivity, start };
130
+ }
131
+
132
+ function notesFromEvents(events: NoteEvent[]): HendrixNote[] {
133
+ const active = new Map<string, NoteEvent>();
134
+ const notes: HendrixNote[] = [];
135
+ events.sort((a, b) => (a.time ?? 0) - (b.time ?? 0) || Number(a.isDrum) - Number(b.isDrum) || a.pitch - b.pitch || a.velocity - b.velocity || a.program - b.program);
136
+ for (const event of events) {
137
+ if (event.time === null) continue;
138
+ if (event.isDrum) {
139
+ notes.push({ onset: event.time, offset: event.time + 0.01, pitch: event.pitch, program: 128, isDrum: true, velocity: 1 });
140
+ continue;
141
+ }
142
+ const key = `${event.pitch}:${event.program}`;
143
+ if (event.velocity === 1) {
144
+ const previous = active.get(key);
145
+ if (previous !== undefined && previous.time !== null) {
146
+ notes.push({ onset: previous.time, offset: event.time, pitch: event.pitch, program: event.program, isDrum: false, velocity: previous.velocity });
147
+ }
148
+ active.set(key, event);
149
+ } else {
150
+ const previous = active.get(key);
151
+ active.delete(key);
152
+ if (previous !== undefined && previous.time !== null) {
153
+ notes.push({ onset: previous.time, offset: event.time, pitch: event.pitch, program: event.program, isDrum: false, velocity: previous.velocity });
154
+ }
155
+ }
156
+ }
157
+ for (const event of active.values()) {
158
+ if (event.time !== null) notes.push({ onset: event.time, offset: event.time + 0.01, pitch: event.pitch, program: event.program, isDrum: false, velocity: 1 });
159
+ }
160
+ return notes;
161
+ }
162
+
163
+ function trimOverlaps(notes: HendrixNote[]): HendrixNote[] {
164
+ const groups = new Map<string, HendrixNote[]>();
165
+ for (const note of notes) {
166
+ const key = `${note.pitch}:${note.program}:${Number(note.isDrum)}`;
167
+ const group = groups.get(key) ?? [];
168
+ group.push(note);
169
+ groups.set(key, group);
170
+ }
171
+ const result: HendrixNote[] = [];
172
+ for (const group of groups.values()) {
173
+ group.sort((a, b) => a.onset - b.onset);
174
+ for (let i = 1; i < group.length; i++) {
175
+ if (group[i - 1].offset > group[i].onset) group[i - 1].offset = group[i].onset;
176
+ }
177
+ result.push(...group.filter((note) => note.onset < note.offset));
178
+ }
179
+ return result.sort((a, b) => a.onset - b.onset || Number(a.isDrum) - Number(b.isDrum) || a.program - b.program || a.velocity - b.velocity || a.pitch - b.pitch);
180
+ }
181
+
182
+ /** Decode [window][channel][token] output with the upstream tie merge rules. */
183
+ export function decodeTrackTokens(
184
+ windows: number[][][],
185
+ segmentSeconds: number,
186
+ duration: number,
187
+ ): HendrixNote[] {
188
+ const channelNotes: HendrixNote[][] = [];
189
+ for (let channel = 0; channel < 13; channel++) {
190
+ const decoded = windows.map((window, index) => decodeWindow(window[channel], index * segmentSeconds));
191
+ const merged: NoteEvent[] = [];
192
+ let previousActivity: Array<[number, number]> | null = null;
193
+ for (const current of decoded) {
194
+ if (previousActivity !== null) {
195
+ const ties = new Set(current.ties.map((event) => `${event.program}:${event.pitch}`));
196
+ for (const [program, pitch] of previousActivity) {
197
+ if (!ties.has(`${program}:${pitch}`)) {
198
+ merged.push({ isDrum: false, program, time: current.start, velocity: 0, pitch });
199
+ }
200
+ }
201
+ }
202
+ merged.push(...current.notes);
203
+ previousActivity = current.lastActivity;
204
+ }
205
+ channelNotes.push(notesFromEvents(merged));
206
+ }
207
+ return trimOverlaps(channelNotes.flat())
208
+ .filter((note) => note.onset < duration)
209
+ .map((note) => ({ ...note, offset: Math.min(duration, Math.max(note.offset, note.onset + 0.01)) }));
210
+ }
source/demo/web/src/local/dsp.ts ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export const TARGET_SAMPLE_RATE = 16_000;
2
+ export const INPUT_FRAMES = 32_767;
3
+ export const FFT_SIZE = 2_048;
4
+ export const HOP_LENGTH = 300;
5
+ export const SPECTROGRAM_FRAMES = 110;
6
+ export const SPECTROGRAM_BINS = 1_024;
7
+
8
+ /** Decode, downmix, and resample an audio file in the browser. */
9
+ export async function decodeAudio(file: Blob, maxSeconds?: number): Promise<Float32Array> {
10
+ const context = new AudioContext();
11
+ try {
12
+ const decoded = await context.decodeAudioData(await file.arrayBuffer());
13
+ const duration = maxSeconds === undefined ? decoded.duration : Math.min(decoded.duration, maxSeconds);
14
+ const length = Math.max(1, Math.ceil(duration * TARGET_SAMPLE_RATE));
15
+ const offline = new OfflineAudioContext(1, length, TARGET_SAMPLE_RATE);
16
+ const mono = offline.createBuffer(1, decoded.length, decoded.sampleRate);
17
+ const target = mono.getChannelData(0);
18
+ for (let channel = 0; channel < decoded.numberOfChannels; channel++) {
19
+ const source = decoded.getChannelData(channel);
20
+ const scale = 1 / decoded.numberOfChannels;
21
+ for (let i = 0; i < source.length; i++) target[i] += source[i] * scale;
22
+ }
23
+ const node = offline.createBufferSource();
24
+ node.buffer = mono;
25
+ node.connect(offline.destination);
26
+ node.start();
27
+ return new Float32Array((await offline.startRendering()).getChannelData(0));
28
+ } finally {
29
+ await context.close();
30
+ }
31
+ }
32
+
33
+ /** Split mono 16 kHz audio into the exact zero-padded windows used upstream. */
34
+ export function sliceAudio(audio: Float32Array): Float32Array[] {
35
+ const count = Math.max(1, Math.ceil(audio.length / INPUT_FRAMES));
36
+ const windows: Float32Array[] = [];
37
+ for (let index = 0; index < count; index++) {
38
+ const window = new Float32Array(INPUT_FRAMES);
39
+ window.set(audio.subarray(index * INPUT_FRAMES, (index + 1) * INPUT_FRAMES));
40
+ windows.push(window);
41
+ }
42
+ return windows;
43
+ }
44
+
45
+ class Radix2Fft {
46
+ private readonly reversed = new Uint16Array(FFT_SIZE);
47
+ // Keep butterfly state in f64. A long f32 butterfly chain raises the noise
48
+ // floor in near-silent bins; the following log scale then makes that error
49
+ // large enough to change encoder input values.
50
+ private readonly real = new Float64Array(FFT_SIZE);
51
+ private readonly imaginary = new Float64Array(FFT_SIZE);
52
+
53
+ constructor() {
54
+ const bits = Math.log2(FFT_SIZE);
55
+ for (let value = 0; value < FFT_SIZE; value++) {
56
+ let source = value;
57
+ let target = 0;
58
+ for (let bit = 0; bit < bits; bit++) {
59
+ target = (target << 1) | (source & 1);
60
+ source >>= 1;
61
+ }
62
+ this.reversed[value] = target;
63
+ }
64
+ }
65
+
66
+ magnitude(input: Float32Array, output: Float32Array, outputOffset: number) {
67
+ for (let i = 0; i < FFT_SIZE; i++) {
68
+ this.real[this.reversed[i]] = input[i];
69
+ this.imaginary[this.reversed[i]] = 0;
70
+ }
71
+ for (let width = 2; width <= FFT_SIZE; width *= 2) {
72
+ const half = width / 2;
73
+ const angle = (-2 * Math.PI) / width;
74
+ for (let start = 0; start < FFT_SIZE; start += width) {
75
+ for (let offset = 0; offset < half; offset++) {
76
+ const cos = Math.cos(angle * offset);
77
+ const sin = Math.sin(angle * offset);
78
+ const even = start + offset;
79
+ const odd = even + half;
80
+ const oddReal = this.real[odd] * cos - this.imaginary[odd] * sin;
81
+ const oddImaginary = this.real[odd] * sin + this.imaginary[odd] * cos;
82
+ const evenReal = this.real[even];
83
+ const evenImaginary = this.imaginary[even];
84
+ this.real[even] = evenReal + oddReal;
85
+ this.imaginary[even] = evenImaginary + oddImaginary;
86
+ this.real[odd] = evenReal - oddReal;
87
+ this.imaginary[odd] = evenImaginary - oddImaginary;
88
+ }
89
+ }
90
+ }
91
+ // Bin zero is the DC term and the checkpoint drops it.
92
+ for (let bin = 1; bin <= SPECTROGRAM_BINS; bin++) {
93
+ output[outputOffset + bin - 1] = Math.hypot(
94
+ this.real[bin],
95
+ this.imaginary[bin],
96
+ );
97
+ }
98
+ }
99
+ }
100
+
101
+ const fft = new Radix2Fft();
102
+ const hann = Float32Array.from(
103
+ { length: FFT_SIZE },
104
+ (_, i) => 0.5 - 0.5 * Math.cos((2 * Math.PI * i) / FFT_SIZE),
105
+ );
106
+
107
+ function reflectIndex(index: number, length: number): number {
108
+ let reflected = index;
109
+ while (reflected < 0 || reflected >= length) {
110
+ reflected = reflected < 0 ? -reflected : 2 * length - 2 - reflected;
111
+ }
112
+ return reflected;
113
+ }
114
+
115
+ /**
116
+ * Match the checkpoint's centered Hann magnitude STFT and log min-max scale.
117
+ * The returned row-major array has shape [1, 110, 1024].
118
+ */
119
+ export function spectrogram(audio: Float32Array): Float32Array {
120
+ if (audio.length !== INPUT_FRAMES) {
121
+ throw new Error(`expected ${INPUT_FRAMES} samples, got ${audio.length}`);
122
+ }
123
+ const frame = new Float32Array(FFT_SIZE);
124
+ const result = new Float32Array(SPECTROGRAM_FRAMES * SPECTROGRAM_BINS);
125
+ const centerPad = FFT_SIZE / 2;
126
+ for (let time = 0; time < SPECTROGRAM_FRAMES; time++) {
127
+ const start = time * HOP_LENGTH - centerPad;
128
+ for (let i = 0; i < FFT_SIZE; i++) {
129
+ frame[i] = audio[reflectIndex(start + i, audio.length)] * hann[i];
130
+ }
131
+ fft.magnitude(frame, result, time * SPECTROGRAM_BINS);
132
+ }
133
+
134
+ let minimum = Number.POSITIVE_INFINITY;
135
+ let maximum = Number.NEGATIVE_INFINITY;
136
+ for (let i = 0; i < result.length; i++) {
137
+ const value = Math.log(result[i] + 1e-5);
138
+ result[i] = Number.isFinite(value) ? value : 0;
139
+ minimum = Math.min(minimum, result[i]);
140
+ maximum = Math.max(maximum, result[i]);
141
+ }
142
+ const denominator = maximum - minimum + 0.008;
143
+ for (let i = 0; i < result.length; i++) {
144
+ result[i] = (result[i] - minimum) / denominator;
145
+ }
146
+ return result;
147
+ }
source/demo/web/src/local/float16.ts ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Read one float16 value returned by ONNX Runtime Web.
3
+ *
4
+ * Browsers without Float16Array expose raw IEEE-754 bits in a Uint16Array.
5
+ * Safari exposes numeric values through Float16Array instead. Treating those
6
+ * numeric values as bit patterns corrupts decoder argmax results.
7
+ */
8
+ export function readFloat16(data: ArrayLike<number>, index: number): number {
9
+ const value = data[index];
10
+ if (!(data instanceof Uint16Array)) return Number(value);
11
+ const sign = value & 0x8000 ? -1 : 1;
12
+ const exponent = (value >> 10) & 0x1f;
13
+ const fraction = value & 0x3ff;
14
+ if (exponent === 0) return sign * 2 ** -14 * (fraction / 1024);
15
+ if (exponent === 31) return fraction ? Number.NaN : sign * Number.POSITIVE_INFINITY;
16
+ return sign * 2 ** (exponent - 15) * (1 + fraction / 1024);
17
+ }
source/demo/web/src/local/local.css ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ :root { color-scheme: dark; }
2
+ body { margin: 0; background: #090a0d; color: #f2f0e9; }
3
+ .local-shell { width: min(1120px, calc(100% - 28px)); margin: 0 auto; padding: max(24px, env(safe-area-inset-top)) 0 56px; display: grid; gap: 18px; font-family: Inter, ui-sans-serif, system-ui, sans-serif; }
4
+ .local-hero { padding: clamp(24px, 6vw, 72px) 4px 20px; border-bottom: 1px solid #30323a; }
5
+ .local-kicker { color: #ff627d; letter-spacing: .18em; font-size: 12px; font-weight: 800; text-decoration: none; }
6
+ .local-hero h1 { margin: 14px 0; max-width: 850px; font-family: Georgia, serif; font-size: clamp(54px, 11vw, 124px); font-weight: 500; letter-spacing: -.06em; line-height: .82; }
7
+ .local-hero p { max-width: 700px; margin: 26px 0 0; color: #b7bac4; font-size: clamp(16px, 2vw, 21px); line-height: 1.5; }
8
+ .local-card { border: 1px solid #2d3038; border-radius: 16px; background: #111319; box-shadow: inset 0 1px rgba(255,255,255,.04); }
9
+ .capability-card { display: flex; align-items: center; gap: 10px; padding: 14px 18px; color: #c7cad2; font-size: 13px; }
10
+ .status-dot { width: 9px; height: 9px; border-radius: 50%; background: #ff627d; box-shadow: 0 0 14px #ff627d88; }
11
+ .status-dot.ready { background: #70e09b; box-shadow: 0 0 14px #70e09b88; }
12
+ .input-card { padding: clamp(18px, 4vw, 34px); }
13
+ .file-row, .action-row, .result-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
14
+ .primary-button, .secondary-button, .record-button { appearance: none; border-radius: 999px; border: 1px solid transparent; padding: 12px 18px; font: inherit; font-weight: 750; text-decoration: none; cursor: pointer; }
15
+ .primary-button { color: #090a0d; background: #f2f0e9; }
16
+ .secondary-button { color: #f2f0e9; background: #1b1e25; border-color: #3a3e48; }
17
+ .record-button { color: white; background: #d83455; animation: pulse-record 1.3s infinite; }
18
+ button:disabled, .primary-button:has(input:disabled) { cursor: not-allowed; opacity: .38; }
19
+ .limit-label { display: flex; gap: 8px; align-items: center; margin-left: auto; color: #9da1ac; font-size: 13px; }
20
+ .limit-label select { border: 1px solid #3a3e48; border-radius: 8px; background: #171920; color: white; padding: 8px; }
21
+ .chosen-file { margin: 22px 0; overflow: hidden; color: #f2f0e9; font-family: ui-monospace, monospace; text-overflow: ellipsis; white-space: nowrap; }
22
+ .progress-track { height: 5px; margin-top: 22px; overflow: hidden; border-radius: 9px; background: #262933; }
23
+ .progress-track > div { height: 100%; background: linear-gradient(90deg, #ff5577, #f3b65c); transition: width .2s ease; }
24
+ .run-status { min-height: 1.5em; margin: 12px 0 0; color: #aeb1bb; font-size: 14px; }
25
+ .run-status.error { color: #ff8ca0; }
26
+ .diagnostic-output { overflow-wrap: anywhere; margin: 10px 0 0; color: #858994; font: 11px/1.5 ui-monospace, monospace; }
27
+ .result-bar { padding: 16px 18px; border: 1px solid #2d3038; border-radius: 16px; background: #111319; }
28
+ .result-bar > div { min-width: 80px; }
29
+ .result-bar strong { display: block; font-family: Georgia, serif; font-size: 30px; font-weight: 500; }
30
+ .result-bar span { color: #8f939e; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
31
+ .result-bar button { margin-left: auto; }
32
+ .roll-stage { position: relative; }
33
+ .roll-empty { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: max-content; max-width: 80%; padding: 11px 16px; border: 1px solid #3a3e48; border-radius: 999px; background: #111319e8; color: #b7bac4; font-size: 13px; pointer-events: none; }
34
+ .local-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 16px 36px; padding: 8px 4px 0; color: #858994; font-size: 12px; line-height: 1.5; }
35
+ .local-footer p { max-width: 650px; margin: 0; }
36
+ .local-footer-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px 16px; max-width: 380px; }
37
+ .local-footer a { color: #d9dce5; text-decoration-color: #626670; text-underline-offset: 3px; }
38
+ @keyframes pulse-record { 50% { box-shadow: 0 0 0 7px #d8345522; } }
39
+ @media (max-width: 640px) {
40
+ .local-shell { width: min(100% - 20px, 1120px); }
41
+ .local-hero h1 { font-size: 58px; }
42
+ .limit-label { width: 100%; margin: 8px 0 0; }
43
+ .result-bar button { margin-left: 0; }
44
+ .local-footer { grid-template-columns: 1fr; }
45
+ .local-footer-links { justify-content: flex-start; }
46
+ }
47
+
48
+ .run-hint { color: #aeb1bb; font-size: 13px; line-height: 1.5; margin: 16px 0 0; }
49
+ .run-diagnostics { color: #aeb1bb; font-size: 12px; margin-top: 12px; }
50
+ .run-diagnostics summary { cursor: pointer; }
51
+ .primary-button:focus-within, button:focus-visible, a:focus-visible, select:focus-visible { outline: 2px solid #ff627d; outline-offset: 4px; }
source/demo/web/src/local/midi.ts ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { HendrixNote } from "./codec";
2
+
3
+ function variableLength(value: number): number[] {
4
+ let buffer = value & 0x7f;
5
+ const bytes: number[] = [];
6
+ while ((value >>= 7) > 0) buffer = (buffer << 8) | ((value & 0x7f) | 0x80);
7
+ while (true) {
8
+ bytes.push(buffer & 0xff);
9
+ if (buffer & 0x80) buffer >>= 8;
10
+ else break;
11
+ }
12
+ return bytes;
13
+ }
14
+
15
+ function u16(value: number): number[] { return [(value >> 8) & 0xff, value & 0xff]; }
16
+ function u32(value: number): number[] { return [(value >> 24) & 0xff, (value >> 16) & 0xff, (value >> 8) & 0xff, value & 0xff]; }
17
+ function chunk(name: string, data: number[]): number[] {
18
+ return [...Array.from(name).map((c) => c.charCodeAt(0)), ...u32(data.length), ...data];
19
+ }
20
+
21
+ export function notesToMidi(notes: HendrixNote[]): Blob {
22
+ const byProgram = new Map<string, HendrixNote[]>();
23
+ for (const note of notes) {
24
+ const key = note.isDrum ? "drums" : String(note.program);
25
+ const track = byProgram.get(key) ?? [];
26
+ track.push(note);
27
+ byProgram.set(key, track);
28
+ }
29
+ const tracks: number[][] = [];
30
+ tracks.push(chunk("MTrk", [0, 0xff, 0x51, 3, 0x07, 0xa1, 0x20, 0, 0xff, 0x2f, 0]));
31
+ let nextChannel = 0;
32
+ for (const [key, trackNotes] of byProgram) {
33
+ const isDrum = key === "drums";
34
+ while (nextChannel === 9) nextChannel++;
35
+ const channel = isDrum ? 9 : nextChannel++ % 16;
36
+ const program = isDrum ? 0 : Number(key);
37
+ const events: Array<{ tick: number; order: number; bytes: number[] }> = [];
38
+ if (!isDrum) events.push({ tick: 0, order: 0, bytes: [0xc0 | channel, program & 0x7f] });
39
+ for (const note of trackNotes) {
40
+ const start = Math.max(0, Math.round(note.onset * 960));
41
+ const end = Math.max(start + 1, Math.round(note.offset * 960));
42
+ events.push({ tick: start, order: 1, bytes: [0x90 | channel, note.pitch & 0x7f, 100] });
43
+ events.push({ tick: end, order: 0, bytes: [0x80 | channel, note.pitch & 0x7f, 0] });
44
+ }
45
+ events.sort((a, b) => a.tick - b.tick || a.order - b.order);
46
+ const data: number[] = [];
47
+ let lastTick = 0;
48
+ for (const event of events) {
49
+ data.push(...variableLength(event.tick - lastTick), ...event.bytes);
50
+ lastTick = event.tick;
51
+ }
52
+ data.push(0, 0xff, 0x2f, 0);
53
+ tracks.push(chunk("MTrk", data));
54
+ }
55
+ const header = chunk("MThd", [...u16(1), ...u16(tracks.length), ...u16(480)]);
56
+ return new Blob([new Uint8Array([...header, ...tracks.flat()])], { type: "audio/midi" });
57
+ }
source/demo/web/src/local/model.ts ADDED
@@ -0,0 +1,359 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as ort from "onnxruntime-web/webgpu";
2
+ import { SPECTROGRAM_BINS, SPECTROGRAM_FRAMES } from "./dsp";
3
+ import { readFloat16 } from "./float16";
4
+
5
+ export interface LocalCapability {
6
+ supported: boolean;
7
+ adapter: string;
8
+ shaderF16: boolean;
9
+ backend: "webgpu" | "wasm";
10
+ reason?: string;
11
+ }
12
+
13
+ export type LocalBackend = "webgpu" | "wasm";
14
+
15
+ interface Manifest {
16
+ precision: "fp16" | "fp32";
17
+ runtime_contract: {
18
+ sample_rate: number;
19
+ input_frames: number;
20
+ segment_seconds: number;
21
+ channels: number;
22
+ max_tokens: number;
23
+ };
24
+ }
25
+
26
+ type Progress = (message: string) => void;
27
+
28
+ export interface SegmentDiagnostics {
29
+ precision: "fp16" | "fp32";
30
+ backend: LocalBackend;
31
+ cacheLocation: "gpu" | "cpu";
32
+ logitsArray: string;
33
+ steps: number;
34
+ endedChannels: number;
35
+ finiteLogits: number;
36
+ totalLogits: number;
37
+ firstTokens: number[];
38
+ channelPreviews: number[][];
39
+ encoderMs: number;
40
+ crossCacheMs: number;
41
+ decoderMs: number;
42
+ }
43
+
44
+ export interface SegmentResult {
45
+ channels: number[][];
46
+ diagnostics: SegmentDiagnostics;
47
+ }
48
+
49
+ function adapterLabel(adapter: GPUAdapter): string {
50
+ const info = adapter.info;
51
+ return [info.vendor, info.architecture, info.device, info.description]
52
+ .filter(Boolean)
53
+ .join(" · ") || "WebGPU adapter";
54
+ }
55
+
56
+ function wasmThreads(): number {
57
+ // The HF page may embed us without cross-origin isolation. ORT can still
58
+ // run there, but SharedArrayBuffer and multi-threaded WASM need isolation.
59
+ if (!globalThis.crossOriginIsolated) return 1;
60
+ const logicalCores = navigator.hardwareConcurrency || 1;
61
+ return Math.min(4, Math.ceil(logicalCores / 2));
62
+ }
63
+
64
+ function wasmLabel(): string {
65
+ const threads = wasmThreads();
66
+ return `WebAssembly CPU · ${threads} ${threads === 1 ? "thread" : "threads"}`;
67
+ }
68
+
69
+ export async function probeLocalCapability(preferred?: LocalBackend): Promise<LocalCapability> {
70
+ if (preferred === "wasm") {
71
+ return { supported: true, adapter: wasmLabel(), shaderF16: false, backend: "wasm" };
72
+ }
73
+ if (!globalThis.isSecureContext || !navigator.gpu) {
74
+ return { supported: true, adapter: wasmLabel(), shaderF16: false, backend: "wasm" };
75
+ }
76
+ const adapter = await navigator.gpu.requestAdapter({ powerPreference: "high-performance" });
77
+ if (!adapter) {
78
+ return { supported: true, adapter: wasmLabel(), shaderF16: false, backend: "wasm" };
79
+ }
80
+ return {
81
+ supported: true,
82
+ adapter: adapterLabel(adapter),
83
+ shaderF16: adapter.features.has("shader-f16"),
84
+ backend: "webgpu",
85
+ };
86
+ }
87
+
88
+ const floatView = new Float32Array(1);
89
+ const integerView = new Uint32Array(floatView.buffer);
90
+
91
+ function floatToHalf(value: number): number {
92
+ floatView[0] = value;
93
+ const bits = integerView[0];
94
+ const sign = (bits >> 16) & 0x8000;
95
+ let exponent = ((bits >> 23) & 0xff) - 127 + 15;
96
+ let mantissa = bits & 0x7fffff;
97
+ if (exponent <= 0) {
98
+ if (exponent < -10) return sign;
99
+ mantissa = (mantissa | 0x800000) >> (1 - exponent);
100
+ return sign | ((mantissa + 0x1000) >> 13);
101
+ }
102
+ if (exponent >= 31) return sign | (mantissa ? 0x7e00 : 0x7c00);
103
+ mantissa += 0x1000;
104
+ if (mantissa & 0x800000) {
105
+ mantissa = 0;
106
+ exponent += 1;
107
+ if (exponent >= 31) return sign | 0x7c00;
108
+ }
109
+ return sign | (exponent << 10) | (mantissa >> 13);
110
+ }
111
+
112
+ function floatData(values: Float32Array, precision: "fp16" | "fp32") {
113
+ if (precision === "fp32") return values;
114
+ const result = new Uint16Array(values.length);
115
+ for (let i = 0; i < values.length; i++) result[i] = floatToHalf(values[i]);
116
+ return result;
117
+ }
118
+
119
+ function int64(values: number[], dims: readonly number[]): ort.Tensor {
120
+ return new ort.Tensor("int64", BigInt64Array.from(values, BigInt), dims);
121
+ }
122
+
123
+ function argmaxChannels(logits: ort.Tensor, precision: "fp16" | "fp32") {
124
+ const data = logits.data as ArrayLike<number>;
125
+ const vocabulary = 596;
126
+ const tokens: number[] = [];
127
+ let finiteValues = 0;
128
+ for (let channel = 0; channel < 13; channel++) {
129
+ let bestIndex = 0;
130
+ let bestValue = Number.NEGATIVE_INFINITY;
131
+ const start = channel * vocabulary;
132
+ for (let token = 0; token < vocabulary; token++) {
133
+ const value = precision === "fp16" ? readFloat16(data, start + token) : Number(data[start + token]);
134
+ if (Number.isFinite(value)) finiteValues += 1;
135
+ if (value > bestValue) {
136
+ bestValue = value;
137
+ bestIndex = token;
138
+ }
139
+ }
140
+ tokens.push(bestIndex);
141
+ }
142
+ const constructor = (data as { constructor?: { name?: string } }).constructor;
143
+ return {
144
+ tokens,
145
+ arrayType: constructor?.name || "unknown",
146
+ finiteValues,
147
+ totalValues: data.length,
148
+ };
149
+ }
150
+
151
+ export class LocalHendrixModel {
152
+ readonly manifest: Manifest;
153
+ readonly precision: "fp16" | "fp32";
154
+ readonly adapter: string;
155
+ readonly backend: LocalBackend;
156
+ private constructor(
157
+ manifest: Manifest,
158
+ adapter: string,
159
+ backend: LocalBackend,
160
+ private readonly cacheLocation: "gpu" | "cpu",
161
+ private readonly encoder: ort.InferenceSession,
162
+ private readonly crossCache: ort.InferenceSession,
163
+ private readonly decoder: ort.InferenceSession,
164
+ ) {
165
+ this.manifest = manifest;
166
+ this.precision = manifest.precision;
167
+ this.adapter = adapter;
168
+ this.backend = backend;
169
+ }
170
+
171
+ static async create(
172
+ modelBase = "/models",
173
+ progress: Progress = () => {},
174
+ precisionOverride?: "fp16" | "fp32",
175
+ gpuResidentOutputs = true,
176
+ backend: LocalBackend = "webgpu",
177
+ ): Promise<LocalHendrixModel> {
178
+ ort.env.logLevel = "error";
179
+ ort.env.wasm.wasmPaths = "/ort/";
180
+ let adapterName: string;
181
+ if (backend === "webgpu") {
182
+ if (!globalThis.isSecureContext || !navigator.gpu) {
183
+ throw new Error("WebGPU needs Safari or Chrome over HTTPS (localhost also works). ");
184
+ }
185
+ progress("Checking WebGPU…");
186
+ const adapter = await navigator.gpu.requestAdapter({ powerPreference: "high-performance" });
187
+ if (!adapter) throw new Error("No WebGPU adapter is available.");
188
+ ort.env.webgpu.adapter = adapter;
189
+ adapterName = adapterLabel(adapter);
190
+ } else {
191
+ progress("Starting the local CPU runtime…");
192
+ ort.env.wasm.numThreads = wasmThreads();
193
+ adapterName = wasmLabel();
194
+ gpuResidentOutputs = false;
195
+ }
196
+ // Safari's WebGPU FP16 path currently returns a finite but collapsed token-0
197
+ // stream for this graph. Keep FP16 available for explicit diagnostics, but
198
+ // use the verified FP32 graph by default on the two Apple demo targets.
199
+ const precision = precisionOverride ?? "fp32";
200
+ if (backend === "wasm" && precision === "fp16") {
201
+ throw new Error("The CPU browser path uses the verified FP32 model.");
202
+ }
203
+ if (backend === "webgpu" && precision === "fp16") {
204
+ const adapter = ort.env.webgpu.adapter;
205
+ if (!adapter?.features.has("shader-f16")) {
206
+ throw new Error("This WebGPU adapter cannot run the FP16 model.");
207
+ }
208
+ }
209
+ const root = `${modelBase}/${precision}`;
210
+ progress(`Loading the ${precision.toUpperCase()} model…`);
211
+ const response = await fetch(`${root}/manifest.json`, { cache: "no-cache" });
212
+ if (!response.ok) throw new Error(`${precision.toUpperCase()} model manifest: HTTP ${response.status}`);
213
+ const manifest = (await response.json()) as Manifest;
214
+ if (manifest.precision !== precision) throw new Error("Model precision does not match this GPU.");
215
+ const baseOptions: ort.InferenceSession.SessionOptions = {
216
+ executionProviders: [backend],
217
+ graphOptimizationLevel: "all",
218
+ logSeverityLevel: 3,
219
+ };
220
+ progress("Compiling the encoder…");
221
+ const encoder = await ort.InferenceSession.create(`${root}/encoder.onnx`, {
222
+ ...baseOptions,
223
+ // The encoder state immediately feeds the cache graph. Leaving it on the
224
+ // GPU avoids a download followed by an upload between the two sessions.
225
+ ...(gpuResidentOutputs ? { preferredOutputLocation: "gpu-buffer" as const } : {}),
226
+ });
227
+ progress("Compiling the attention cache…");
228
+ const crossCache = await ort.InferenceSession.create(`${root}/cross_cache.onnx`, {
229
+ ...baseOptions,
230
+ // Cross-attention K/V tensors are reused at every token step.
231
+ ...(gpuResidentOutputs ? { preferredOutputLocation: "gpu-buffer" as const } : {}),
232
+ });
233
+ progress("Compiling the note decoder…");
234
+ const decoderOutputs: Record<string, ort.Tensor.DataLocation> = { logits: "cpu" };
235
+ for (let layer = 0; layer < 8; layer++) {
236
+ decoderOutputs[`layer_${layer}_present_self_key`] = "gpu-buffer";
237
+ decoderOutputs[`layer_${layer}_present_self_value`] = "gpu-buffer";
238
+ }
239
+ const decoder = await ort.InferenceSession.create(`${root}/decoder_step.onnx`, {
240
+ ...baseOptions,
241
+ // Only logits need to reach JavaScript for argmax. Growing self-attention
242
+ // caches remain GPU-resident and feed the next decoder step directly.
243
+ ...(gpuResidentOutputs ? { preferredOutputLocation: decoderOutputs } : {}),
244
+ });
245
+ return new LocalHendrixModel(
246
+ manifest,
247
+ adapterName,
248
+ backend,
249
+ gpuResidentOutputs ? "gpu" : "cpu",
250
+ encoder,
251
+ crossCache,
252
+ decoder,
253
+ );
254
+ }
255
+
256
+ async transcribeSegment(input: Float32Array, signal?: AbortSignal): Promise<SegmentResult> {
257
+ if (signal?.aborted) throw new DOMException("Cancelled", "AbortError");
258
+ const type = this.precision === "fp16" ? "float16" : "float32";
259
+ const encoderInput = new ort.Tensor(
260
+ type,
261
+ floatData(input, this.precision),
262
+ [1, SPECTROGRAM_FRAMES, SPECTROGRAM_BINS],
263
+ );
264
+ const encoderStarted = performance.now();
265
+ const encoderOutput = await this.encoder.run({ spectrogram: encoderInput });
266
+ const encoderMs = performance.now() - encoderStarted;
267
+ encoderInput.dispose();
268
+ const encoded = encoderOutput.encoder_hidden_states;
269
+ const crossStarted = performance.now();
270
+ const crossOutput = await this.crossCache.run({ encoder_hidden_states: encoded });
271
+ const crossCacheMs = performance.now() - crossStarted;
272
+ encoded.dispose();
273
+ const cross = this.crossCache.outputNames.map((name) => crossOutput[name]);
274
+
275
+ let selfCache: ort.Tensor[] = Array.from({ length: 16 }, () => new ort.Tensor(
276
+ type,
277
+ this.precision === "fp16" ? new Uint16Array(0) : new Float32Array(0),
278
+ [13, 6, 0, 64],
279
+ ));
280
+ let next = Array(13).fill(0) as number[];
281
+ const unfinished = Array(13).fill(true) as boolean[];
282
+ const channels = Array.from({ length: 13 }, () => [] as number[]);
283
+ let logitsArray = "unknown";
284
+ let finiteLogits = 0;
285
+ let totalLogits = 0;
286
+ let firstTokens: number[] = [];
287
+ let steps = 0;
288
+ let decoderMs = 0;
289
+
290
+ try {
291
+ for (let position = 0; position < this.manifest.runtime_contract.max_tokens; position++) {
292
+ if (signal?.aborted) throw new DOMException("Cancelled", "AbortError");
293
+ const tokenIds = int64(next, [1, 13, 1]);
294
+ const positionIds = int64([position], [1]);
295
+ const feeds: Record<string, ort.Tensor> = { token_ids: tokenIds, position_ids: positionIds };
296
+ for (let layer = 0; layer < 8; layer++) {
297
+ feeds[`layer_${layer}_self_key`] = selfCache[layer * 2];
298
+ feeds[`layer_${layer}_self_value`] = selfCache[layer * 2 + 1];
299
+ feeds[`layer_${layer}_cross_key`] = cross[layer * 2];
300
+ feeds[`layer_${layer}_cross_value`] = cross[layer * 2 + 1];
301
+ }
302
+ const decoderStarted = performance.now();
303
+ const output = await this.decoder.run(feeds);
304
+ decoderMs += performance.now() - decoderStarted;
305
+ tokenIds.dispose();
306
+ positionIds.dispose();
307
+ const argmax = argmaxChannels(output.logits, this.precision);
308
+ const raw = argmax.tokens;
309
+ if (position === 0) {
310
+ logitsArray = argmax.arrayType;
311
+ finiteLogits = argmax.finiteValues;
312
+ totalLogits = argmax.totalValues;
313
+ firstTokens = raw.slice();
314
+ }
315
+ steps = position + 1;
316
+ output.logits.dispose();
317
+ const nextCache = this.decoder.outputNames.slice(1).map((name) => output[name]);
318
+ for (const tensor of selfCache) tensor.dispose();
319
+ selfCache = nextCache;
320
+ next = raw;
321
+ for (let channel = 0; channel < 13; channel++) {
322
+ const token = unfinished[channel] ? raw[channel] : 0;
323
+ channels[channel].push(token);
324
+ if (token === 1) unfinished[channel] = false;
325
+ }
326
+ if (unfinished.every((value) => !value)) break;
327
+ // Let Safari paint progress and handle a Cancel tap between token steps.
328
+ if (position % 8 === 7) {
329
+ await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));
330
+ }
331
+ }
332
+ return {
333
+ channels,
334
+ diagnostics: {
335
+ precision: this.precision,
336
+ backend: this.backend,
337
+ cacheLocation: this.cacheLocation,
338
+ logitsArray,
339
+ steps,
340
+ endedChannels: unfinished.filter((value) => !value).length,
341
+ finiteLogits,
342
+ totalLogits,
343
+ firstTokens,
344
+ channelPreviews: channels.slice(0, 3).map((tokens) => tokens.slice(0, 12)),
345
+ encoderMs,
346
+ crossCacheMs,
347
+ decoderMs,
348
+ },
349
+ };
350
+ } finally {
351
+ for (const tensor of selfCache) tensor.dispose();
352
+ for (const tensor of cross) tensor.dispose();
353
+ }
354
+ }
355
+
356
+ async dispose() {
357
+ await Promise.all([this.encoder.release(), this.crossCache.release(), this.decoder.release()]);
358
+ }
359
+ }
source/demo/web/src/main.tsx ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ import { createRoot } from "react-dom/client";
2
+ import { App } from "./App";
3
+ import "./style.css";
4
+
5
+ // No <StrictMode>: the app is built around Tone's single global transport /
6
+ // AudioContext (see useAudioEngine), and StrictMode's simulated double-mount
7
+ // would create a second engine and double-trigger audio in dev.
8
+ createRoot(document.getElementById("root")!).render(<App />);
source/demo/web/src/pianoroll.ts ADDED
@@ -0,0 +1,501 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export interface RollNote {
2
+ pitch: number;
3
+ start: number;
4
+ end: number;
5
+ instrument: string;
6
+ /**
7
+ * `performance.now()` at which this note's geometry was finalized (its `end`
8
+ * event arrived), driving the left-to-right reveal. Unset notes are drawn
9
+ * with no reveal (full width), e.g. when loading a finished MIDI.
10
+ */
11
+ spawn?: number;
12
+ /**
13
+ * Number of same-pitch notes drawn in front of this one that overlap it in
14
+ * time. The note is nudged up by this many steps so it peeks out from behind
15
+ * them. Maintained in {@link PianoRoll.setNoteEnd}.
16
+ */
17
+ stackOffset?: number;
18
+ }
19
+
20
+ /** Reveal duration in ms — how long a note takes to grow to full width. */
21
+ const REVEAL_MS = 280;
22
+
23
+ /** Shave this off each note's drawn width so adjacent notes keep a visible gap. */
24
+ const NOTE_GAP_PX = 1.5;
25
+
26
+ /** Upward nudge per overlapping same-pitch note drawn in front, so it peeks out. */
27
+ const NOTE_STACK_PX = 1.5;
28
+
29
+ /** Ease-out cubic: fast start, slowing as it reaches the end. */
30
+ function easeOut(t: number): number {
31
+ const u = 1 - t;
32
+ return 1 - u * u * u;
33
+ }
34
+
35
+ const PX_PER_SEC = 80;
36
+ const MIN_PX_PER_SEC = 10;
37
+ const MAX_PX_PER_SEC = 2000;
38
+ const MAX_PX_PER_PITCH = 160;
39
+ const PITCH_MIN = 21; // A0
40
+ const PITCH_MAX = 108; // C8
41
+ /** Top of the auto-fit view; higher pitches are reachable only by zooming. */
42
+ const DEFAULT_PITCH_TOP = 84; // C6
43
+ const DEFAULT_PITCH_RANGE = DEFAULT_PITCH_TOP - PITCH_MIN + 1; // 64
44
+
45
+ /** Width in px of the piano-key strip on the left edge. */
46
+ export const KEY_WIDTH = 56;
47
+
48
+ /** Black keys within an octave (C=0): C#, D#, F#, G#, A#. */
49
+ function isBlackKey(pitch: number): boolean {
50
+ const n = ((pitch % 12) + 12) % 12;
51
+ return n === 1 || n === 3 || n === 6 || n === 8 || n === 10;
52
+ }
53
+
54
+ /**
55
+ * Golden-angle hue step (≈137.5°). Stepping the hue by this each time keeps any
56
+ * prefix of the generated sequence as evenly spaced around the wheel as
57
+ * possible, so the palette stays well-separated however many instruments appear.
58
+ */
59
+ const GOLDEN_ANGLE = 137.508;
60
+
61
+ /**
62
+ * Color index per instrument, assigned in first-seen order and remembered for
63
+ * the lifetime of the page. Persisting it keeps a given instrument on the same
64
+ * color across transcriptions even as the set of instruments changes.
65
+ */
66
+ const instrumentIndex = new Map<string, number>();
67
+
68
+ export function instrumentColor(name: string): string {
69
+ let idx = instrumentIndex.get(name);
70
+ if (idx === undefined) {
71
+ idx = instrumentIndex.size;
72
+ instrumentIndex.set(name, idx);
73
+ }
74
+ const hue = (idx * GOLDEN_ANGLE) % 360;
75
+ return `hsl(${hue}, 70%, 55%)`;
76
+ }
77
+
78
+ export class PianoRoll {
79
+ private canvas: HTMLCanvasElement;
80
+ private ctx: CanvasRenderingContext2D;
81
+ private notes: RollNote[] = [];
82
+ private hiddenInstruments = new Set<string>();
83
+ private mutedInstruments = new Set<string>();
84
+ /** Instrument hovered in the instrument list; all others draw faded. */
85
+ private highlightedInstrument: string | null = null;
86
+ private playhead = 0;
87
+ /**
88
+ * Chunk-completion estimate of how far transcription has reached (seconds), or
89
+ * null when not transcribing. Combined with `latestNoteStart` into the tinted
90
+ * [0, t) frontier; the chunk estimate is what advances the frontier across
91
+ * silent spans where no notes arrive.
92
+ */
93
+ private chunkFrontier: number | null = null;
94
+ /** Start time of the latest note seen — a precise lower bound on the frontier. */
95
+ private latestNoteStart = 0;
96
+ /** Frontier actually drawn; eases toward the target each frame for a smooth glide. */
97
+ private transcribedSmooth = 0;
98
+ /** Seconds-from-start of the left edge when the user has taken over scrolling. */
99
+ private userOffset: number | null = null;
100
+ /** Last offset we rendered with — handy so external code knows what's visible. */
101
+ private lastOffset = 0;
102
+ /** Time-axis zoom, in pixels per second. */
103
+ private _pxPerSec = PX_PER_SEC;
104
+ /** Row height in px when the user has zoomed the pitch axis; null = auto-fit all 88 keys. */
105
+ private pxPerPitch: number | null = null;
106
+ /** Pitch value at the top edge, used only while pitch-zoomed. */
107
+ private pitchTop = DEFAULT_PITCH_TOP;
108
+ /** Loaded audio length in seconds; caps how far the time axis can scroll. */
109
+ private contentDuration = 0;
110
+
111
+ get pxPerSec(): number {
112
+ return this._pxPerSec;
113
+ }
114
+
115
+ constructor(canvas: HTMLCanvasElement) {
116
+ this.canvas = canvas;
117
+ this.ctx = canvas.getContext("2d")!;
118
+ this.resize();
119
+ window.addEventListener("resize", () => this.resize());
120
+ }
121
+
122
+ private resize() {
123
+ const dpr = window.devicePixelRatio || 1;
124
+ const rect = this.canvas.getBoundingClientRect();
125
+ this.canvas.width = rect.width * dpr;
126
+ this.canvas.height = rect.height * dpr;
127
+ this.ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
128
+ }
129
+
130
+ addNote(n: RollNote) {
131
+ this.notes.push(n);
132
+ // The transcribed frontier never lags behind the most recent note's onset.
133
+ if (n.start > this.latestNoteStart) this.latestNoteStart = n.start;
134
+ }
135
+
136
+ /**
137
+ * Record a note's final end time (its `end` event arrived). Beyond driving the
138
+ * left-to-right reveal, this restacks same-pitch notes that overlap `n` in
139
+ * time: whichever of an overlapping pair is drawn behind gets one more upward
140
+ * step ({@link NOTE_STACK_PX}) so it peeks out above the note in front.
141
+ *
142
+ * Iteration order matches draw order (insertion order), so notes seen before
143
+ * `n` are behind it and notes seen after are in front. Each overlapping pair
144
+ * is settled exactly once — when the later of the two to arrive finalizes —
145
+ * since only already-finalized notes (`spawn` set) take part.
146
+ */
147
+ setNoteEnd(n: RollNote, end: number) {
148
+ n.end = end;
149
+ n.spawn = performance.now();
150
+ let behindN = true;
151
+ for (const e of this.notes) {
152
+ if (e === n) {
153
+ behindN = false;
154
+ continue;
155
+ }
156
+ if (e.spawn === undefined || e.pitch !== n.pitch) continue;
157
+ // Half-open overlap test on the final time ranges.
158
+ if (e.start < n.end && n.start < e.end) {
159
+ if (behindN) e.stackOffset = (e.stackOffset ?? 0) + 1;
160
+ else n.stackOffset = (n.stackOffset ?? 0) + 1;
161
+ }
162
+ }
163
+ }
164
+
165
+ /** Spotlight `name`'s notes (fading all other instruments); null clears it. */
166
+ setHighlightedInstrument(name: string | null) {
167
+ this.highlightedInstrument = name;
168
+ }
169
+
170
+ setPlayhead(seconds: number) {
171
+ this.playhead = seconds;
172
+ }
173
+
174
+ /** Tell the roll the loaded audio length, which bounds the time-axis scroll. */
175
+ setDuration(seconds: number) {
176
+ this.contentDuration = seconds;
177
+ }
178
+
179
+ /**
180
+ * Feed the chunk-completion estimate of the transcribed span, or null when not
181
+ * transcribing (which disables the tint). The drawn frontier is the max of this
182
+ * and the latest note onset, eased over a few frames.
183
+ */
184
+ setTranscribedUntil(seconds: number | null) {
185
+ this.chunkFrontier = seconds;
186
+ }
187
+
188
+ /** Show or hide every note belonging to `instrument`. */
189
+ setInstrumentVisible(instrument: string, visible: boolean) {
190
+ if (visible) this.hiddenInstruments.delete(instrument);
191
+ else this.hiddenInstruments.add(instrument);
192
+ }
193
+
194
+ /** Dim every note belonging to `instrument` (drawn at 10% alpha) when muted. */
195
+ setInstrumentMuted(instrument: string, muted: boolean) {
196
+ if (muted) this.mutedInstruments.add(instrument);
197
+ else this.mutedInstruments.delete(instrument);
198
+ }
199
+
200
+ clear() {
201
+ this.notes = [];
202
+ this.hiddenInstruments.clear();
203
+ // Unmounting the instrument list mid-hover fires no mouseleave, so drop
204
+ // any stale spotlight here.
205
+ this.highlightedInstrument = null;
206
+ this.playhead = 0;
207
+ this.chunkFrontier = null;
208
+ this.latestNoteStart = 0;
209
+ this.transcribedSmooth = 0;
210
+ this.userOffset = null;
211
+ this.lastOffset = 0;
212
+ this._pxPerSec = PX_PER_SEC;
213
+ this.pxPerPitch = null;
214
+ this.pitchTop = DEFAULT_PITCH_TOP;
215
+ this.contentDuration = 0;
216
+ }
217
+
218
+ /** Add `deltaSeconds` to the left-edge offset, taking the view out of follow mode. */
219
+ scrollBy(deltaSeconds: number) {
220
+ const base = this.userOffset ?? this.lastOffset;
221
+ this.userOffset = this.clampOffset(base + deltaSeconds, this._pxPerSec);
222
+ }
223
+
224
+ /** Pan the pitch axis by `deltaPx` pixels. */
225
+ scrollPitchBy(deltaPx: number) {
226
+ const H = this.canvas.getBoundingClientRect().height;
227
+ if (this.pxPerPitch === null) {
228
+ // Auto-fit hides everything above C6; entering a panned window at the
229
+ // same row height lets the user scroll up to it without zooming first.
230
+ this.pxPerPitch = H / DEFAULT_PITCH_RANGE;
231
+ this.pitchTop = DEFAULT_PITCH_TOP;
232
+ }
233
+ this.pitchTop = this.clampPitchTop(
234
+ this.pitchTop + deltaPx / this.pxPerPitch,
235
+ this.pxPerPitch,
236
+ H,
237
+ );
238
+ }
239
+
240
+ /**
241
+ * Zoom the time axis by `factor`, keeping the second under `anchorX` fixed.
242
+ * `anchorX` is canvas-relative (including the key strip); the gutter is
243
+ * subtracted here so the content area starts at zero seconds-from-offset.
244
+ */
245
+ zoomTime(factor: number, anchorX: number) {
246
+ const old = this._pxPerSec;
247
+ const next = Math.min(MAX_PX_PER_SEC, Math.max(MIN_PX_PER_SEC, old * factor));
248
+ if (next === old) return;
249
+ const ax = anchorX - KEY_WIDTH;
250
+ const base = this.userOffset ?? this.lastOffset;
251
+ const anchorSec = base + ax / old;
252
+ this._pxPerSec = next;
253
+ this.userOffset = this.clampOffset(anchorSec - ax / next, next);
254
+ }
255
+
256
+ /** Zoom the pitch axis by `factor`, keeping the pitch under `anchorY` (px) fixed. */
257
+ zoomPitch(factor: number, anchorY: number) {
258
+ const H = this.canvas.getBoundingClientRect().height;
259
+ const fit = H / DEFAULT_PITCH_RANGE;
260
+ const oldRowH = this.pxPerPitch ?? fit;
261
+ const oldTop = this.pxPerPitch === null ? DEFAULT_PITCH_TOP : this.pitchTop;
262
+ const next = Math.min(MAX_PX_PER_PITCH, oldRowH * factor);
263
+ if (next <= fit) {
264
+ // Zoomed back out to where all 88 keys fit — return to auto-fit mode.
265
+ this.pxPerPitch = null;
266
+ return;
267
+ }
268
+ const anchorPitch = oldTop - anchorY / oldRowH;
269
+ this.pxPerPitch = next;
270
+ this.pitchTop = this.clampPitchTop(anchorPitch + anchorY / next, next, H);
271
+ }
272
+
273
+ /** Keep the zoomed pitch window inside [A0, C8]. */
274
+ private clampPitchTop(top: number, rowH: number, H: number): number {
275
+ const visible = H / rowH;
276
+ const min = Math.min(PITCH_MIN + visible, PITCH_MAX);
277
+ return Math.min(PITCH_MAX, Math.max(min, top));
278
+ }
279
+
280
+ /** Resume auto-following the playhead. */
281
+ follow() {
282
+ this.userOffset = null;
283
+ }
284
+
285
+ /** Take over scrolling: freeze the view at its current offset. */
286
+ unfollow() {
287
+ this.userOffset = this.lastOffset;
288
+ }
289
+
290
+ get isFollowing(): boolean {
291
+ return this.userOffset === null;
292
+ }
293
+
294
+ /** Translate a canvas-relative x pixel coordinate to a transport-time in seconds. */
295
+ xToSeconds(x: number): number {
296
+ return Math.max(0, this.lastOffset + (x - KEY_WIDTH) / this._pxPerSec);
297
+ }
298
+
299
+ /** Latest note end across all notes — drives x-axis scroll. */
300
+ private maxEnd(): number {
301
+ let m = 0;
302
+ for (const n of this.notes) if (n.end > m) m = n.end;
303
+ return m;
304
+ }
305
+
306
+ /** End of the scrollable content: the further of the audio length and last note. */
307
+ private contentEnd(): number {
308
+ return Math.max(this.contentDuration, this.maxEnd());
309
+ }
310
+
311
+ /**
312
+ * Clamp a left-edge offset (seconds) to [0, contentEnd - viewSec] so the view
313
+ * can't scroll past the start or beyond the end of the audio. `pxPerSec` is
314
+ * passed in because callers (zoomTime) may be mid-change to it.
315
+ */
316
+ private clampOffset(offsetSec: number, pxPerSec: number): number {
317
+ const contentW = this.canvas.getBoundingClientRect().width - KEY_WIDTH;
318
+ const viewSec = contentW / pxPerSec;
319
+ const max = Math.max(0, this.contentEnd() - viewSec);
320
+ return Math.max(0, Math.min(offsetSec, max));
321
+ }
322
+
323
+ render() {
324
+ const ctx = this.ctx;
325
+ const rect = this.canvas.getBoundingClientRect();
326
+ const W = rect.width;
327
+ const H = rect.height;
328
+ ctx.clearRect(0, 0, W, H);
329
+
330
+ // Auto-scroll: keep the view still while the playhead is inside it; only
331
+ // scroll once the playhead reaches the right third (or leaves the view to
332
+ // the left, e.g. on stop). Manual scrolling (userOffset !== null) wins.
333
+ // The note area starts after the key strip; only that width shows time.
334
+ const contentW = W - KEY_WIDTH;
335
+ const maxT = Math.max(this.maxEnd(), this.playhead + 1);
336
+ const viewSec = contentW / this._pxPerSec;
337
+ let offsetSec: number;
338
+ if (this.userOffset !== null) {
339
+ // Re-clamp each frame so a window resize or newly-streamed notes can't
340
+ // leave the frozen view stranded past the content end.
341
+ offsetSec = Math.max(0, Math.min(this.userOffset, Math.max(0, this.contentEnd() - viewSec)));
342
+ } else {
343
+ offsetSec = this.lastOffset;
344
+ if (this.playhead > offsetSec + viewSec * 0.66) {
345
+ offsetSec = this.playhead - viewSec * 0.66;
346
+ } else if (this.playhead < offsetSec) {
347
+ offsetSec = this.playhead;
348
+ }
349
+ offsetSec = Math.max(0, Math.min(offsetSec, Math.max(0, maxT - viewSec)));
350
+ }
351
+ this.lastOffset = offsetSec;
352
+ const pxPerSec = this._pxPerSec;
353
+
354
+ // Pitch axis: auto-fit all 88 keys, or use the zoomed window if the user
355
+ // has pinched vertically.
356
+ const rowH = this.pxPerPitch ?? H / DEFAULT_PITCH_RANGE;
357
+ const pitchTop = this.pxPerPitch === null ? DEFAULT_PITCH_TOP : this.pitchTop;
358
+
359
+ // Everything time-indexed lives in the content area to the right of the
360
+ // key strip; clip so notes/grid can't bleed under the keyboard.
361
+ ctx.save();
362
+ ctx.beginPath();
363
+ ctx.rect(KEY_WIDTH, 0, contentW, H);
364
+ ctx.clip();
365
+
366
+ // Pitch grid: faint horizontal stripes for C notes
367
+ ctx.fillStyle = "#16161c";
368
+ for (let p = PITCH_MIN; p <= PITCH_MAX; p++) {
369
+ if (p % 12 === 0) {
370
+ const y = (pitchTop - p) * rowH;
371
+ ctx.fillRect(KEY_WIDTH, y, contentW, rowH);
372
+ }
373
+ }
374
+
375
+ // Time grid: vertical lines every second.
376
+ ctx.strokeStyle = "#22222a";
377
+ ctx.lineWidth = 1;
378
+ const startSec = Math.floor(offsetSec);
379
+ const endSec = Math.ceil(offsetSec + viewSec);
380
+ for (let s = startSec; s <= endSec; s++) {
381
+ const x = KEY_WIDTH + (s - offsetSec) * pxPerSec;
382
+ ctx.beginPath();
383
+ ctx.moveTo(x + 0.5, 0);
384
+ ctx.lineTo(x + 0.5, H);
385
+ ctx.stroke();
386
+ }
387
+
388
+ // Transcribed-so-far overlay: a faint light wash over the [0, t) time span
389
+ // the backend has already processed. The frontier is the furthest of the
390
+ // chunk-completion estimate (which advances across silent spans) and the
391
+ // latest note onset (precise where notes exist), eased toward each frame so
392
+ // it glides instead of snapping when an anchor lands or a note starts. Drawn
393
+ // over the grid but under the notes so they stay crisp; clipped to content.
394
+ if (this.chunkFrontier !== null) {
395
+ const target = Math.max(this.chunkFrontier, this.latestNoteStart);
396
+ // ~12%/frame ≈ a 150 ms ease at 60 fps; snap once effectively there.
397
+ this.transcribedSmooth += (target - this.transcribedSmooth) * 0.12;
398
+ if (Math.abs(target - this.transcribedSmooth) < 0.01) {
399
+ this.transcribedSmooth = target;
400
+ }
401
+ const x0 = KEY_WIDTH + (0 - offsetSec) * pxPerSec;
402
+ const x1 = KEY_WIDTH + (this.transcribedSmooth - offsetSec) * pxPerSec;
403
+ ctx.fillStyle = "rgba(255, 255, 255, 0.05)";
404
+ ctx.fillRect(x0, 0, x1 - x0, H);
405
+ } else {
406
+ this.transcribedSmooth = 0; // tint off once transcription finishes
407
+ }
408
+
409
+ // Notes
410
+ const now = performance.now();
411
+ // Sliver of background between adjacent semitones, so notes on
412
+ // consecutive pitches read as separate bars at any zoom level.
413
+ const rowGap = Math.max(0.5, Math.min(4, rowH * 0.1));
414
+ // Stack-shift budget for overlapping same-pitch notes: at most 3px, and
415
+ // never past the row gap (minus a 1px border) — so a shifted note can't
416
+ // collide with a note one semitone up. At the unzoomed row height this
417
+ // rounds to no shift at all.
418
+ const maxShift = Math.min(3, Math.max(0, rowGap - 1));
419
+ for (const n of this.notes) {
420
+ if (n.pitch < PITCH_MIN || n.pitch > PITCH_MAX) continue;
421
+ if (this.hiddenInstruments.has(n.instrument)) continue;
422
+ const x = KEY_WIDTH + (n.start - offsetSec) * pxPerSec;
423
+ const full = Math.max(2, (n.end - n.start) * pxPerSec - NOTE_GAP_PX);
424
+ // Left-to-right reveal: grow from the note's onset to its full width,
425
+ // easing out over REVEAL_MS. Unstamped notes draw at full width.
426
+ const reveal =
427
+ n.spawn === undefined ? 1 : easeOut(Math.min(1, (now - n.spawn) / REVEAL_MS));
428
+ const w = full * reveal;
429
+ if (x + w < KEY_WIDTH || x > W) continue;
430
+ // Nudge up so notes hidden behind an overlapping same-pitch note peek
431
+ // out. stackOffset counts overlapping notes, so it can grow large (a
432
+ // sustained note under a run of staccato hits collects +1 per hit) —
433
+ // cap the TOTAL shift at the budget above.
434
+ const shift = Math.min((n.stackOffset ?? 0) * NOTE_STACK_PX, maxShift);
435
+ const y = (pitchTop - n.pitch) * rowH - shift;
436
+ if (y + rowH < 0 || y > H) continue;
437
+ // Muting dims a track; while an instrument is highlighted (hovered in
438
+ // the instrument list), every other track fades even further back.
439
+ let alpha = this.mutedInstruments.has(n.instrument) ? 0.2 : 1;
440
+ if (this.highlightedInstrument !== null && n.instrument !== this.highlightedInstrument) {
441
+ alpha = Math.min(alpha, 0.15);
442
+ }
443
+ ctx.globalAlpha = alpha;
444
+ ctx.fillStyle = instrumentColor(n.instrument);
445
+ ctx.fillRect(x, y, w, Math.max(2, rowH - rowGap));
446
+ }
447
+ ctx.globalAlpha = 1;
448
+
449
+ // Playhead
450
+ const px = KEY_WIDTH + (this.playhead - offsetSec) * pxPerSec;
451
+ ctx.strokeStyle = "#ff5577";
452
+ ctx.lineWidth = 2;
453
+ ctx.beginPath();
454
+ ctx.moveTo(px, 0);
455
+ ctx.lineTo(px, H);
456
+ ctx.stroke();
457
+
458
+ ctx.restore();
459
+
460
+ this.drawKeyboard(ctx, H, rowH, pitchTop);
461
+ }
462
+
463
+ /** Draw the piano-key strip down the left edge, aligned to the pitch axis. */
464
+ private drawKeyboard(
465
+ ctx: CanvasRenderingContext2D,
466
+ H: number,
467
+ rowH: number,
468
+ pitchTop: number,
469
+ ) {
470
+ const showLabels = rowH >= 8;
471
+ if (showLabels) {
472
+ ctx.font = "10px sans-serif";
473
+ ctx.textBaseline = "middle";
474
+ }
475
+ for (let p = PITCH_MIN; p <= PITCH_MAX; p++) {
476
+ const y = (pitchTop - p) * rowH;
477
+ if (y + rowH < 0 || y > H) continue;
478
+ ctx.fillStyle = isBlackKey(p) ? "#23232b" : "#cfd2dc";
479
+ ctx.fillRect(0, y, KEY_WIDTH, rowH);
480
+ // Thin separator between adjacent keys.
481
+ ctx.strokeStyle = "#16161c";
482
+ ctx.lineWidth = 1;
483
+ ctx.beginPath();
484
+ ctx.moveTo(0, y + 0.5);
485
+ ctx.lineTo(KEY_WIDTH, y + 0.5);
486
+ ctx.stroke();
487
+ // Octave label on each C (MIDI 60 = C4).
488
+ if (showLabels && p % 12 === 0) {
489
+ ctx.fillStyle = "#16161c";
490
+ ctx.fillText(`C${p / 12 - 1}`, 4, y + rowH / 2);
491
+ }
492
+ }
493
+ // Boundary between keyboard and note area.
494
+ ctx.strokeStyle = "#000";
495
+ ctx.lineWidth = 1;
496
+ ctx.beginPath();
497
+ ctx.moveTo(KEY_WIDTH + 0.5, 0);
498
+ ctx.lineTo(KEY_WIDTH + 0.5, H);
499
+ ctx.stroke();
500
+ }
501
+ }