@viji-dev/core 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/artist-dts-p5.js +1 -1
- package/dist/artist-dts.js +1 -1
- package/dist/artist-global-p5.d.ts +1 -1
- package/dist/artist-global.d.ts +1 -1
- package/dist/assets/{viji.worker-Clz2HjaH.js → viji.worker-ByIbGiBL.js} +14 -14
- package/dist/docs-api.js +8 -8
- package/dist/{essentia-wasm.web-7iahj_bF.js → essentia-wasm.web-0tQ5KtU1.js} +1 -1
- package/dist/{index-BcsAA44l.js → index-BYp7SdOD.js} +250 -428
- package/dist/index.d.ts +24 -701
- package/dist/index.js +5 -7
- package/dist/param-inference.d.ts +14 -0
- package/dist/param-inference.js +3235 -0
- package/dist/scene-analysis-CEQRlNUL.js +186 -0
- package/dist/scene-analysis.d.ts +127 -0
- package/dist/scene-analysis.js +4 -0
- package/package.json +11 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { S as eB } from "./scene-analysis-CEQRlNUL.js";
|
|
2
|
+
const uI = [
|
|
2
3
|
"audio",
|
|
3
4
|
"video",
|
|
4
5
|
"mouse",
|
|
@@ -7,7 +8,7 @@ const mI = [
|
|
|
7
8
|
"touch",
|
|
8
9
|
"sensors",
|
|
9
10
|
"devices"
|
|
10
|
-
],
|
|
11
|
+
], rI = [
|
|
11
12
|
"faceDetection",
|
|
12
13
|
"faceMesh",
|
|
13
14
|
"emotion",
|
|
@@ -20,7 +21,7 @@ class d extends Error {
|
|
|
20
21
|
super(A), this.code = B, this.context = I, this.name = "VijiCoreError";
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
|
-
const yB = '"use strict";(()=>{function I(e){switch(e.type){case"init":{let t=e,n=[];return t.data?.canvas&&n.push(t.data.canvas),t.data?.controlPort&&n.push(t.data.controlPort),n}case"video-canvas-setup":{let t=e;return t.data?.offscreenCanvas?[t.data.offscreenCanvas]:[]}case"video-frame-update":{let t=e;return t.data?.imageBitmap?[t.data.imageBitmap]:[]}case"video-frame-direct":{let t=e;return t.data?.imageBitmap?[t.data.imageBitmap]:[]}case"parameter-update":return e.data?.transferList??[];case"parameter-batch-update":return e.data?.transferList??[];case"audio-analysis-update":{let t=e,n=[];return t.data?.frequencyData?.buffer&&n.push(t.data.frequencyData.buffer),t.data?.waveformData?.buffer&&n.push(t.data.waveformData.buffer),n}case"capture-frame-result":case"auto-capture-result":{let t=e.data;return t?.bitmap?[t.bitmap]:[]}case"cv-results-update":{let t=e.data;return t?.analysedFrame?[t.analysedFrame]:[]}default:return[]}}var l=null,g=null,r=null,v=null,a=null,L=!1,H=!1;function S(){return document.readyState==="loading"?new Promise(e=>{document.addEventListener("DOMContentLoaded",()=>e(),{once:!0})}):Promise.resolve()}async function A(){await S();let e={type:"iframe-ready",protocolVersion:1,environment:{crossOriginIsolated:window.crossOriginIsolated,isSecureContext:window.isSecureContext,origin:self.origin}};window.parent.postMessage(e,"*")}function F(){window.addEventListener("message",e=>{if(e.source===window.parent){if(l===null)l=e.origin,g=window.parent;else if(e.origin!==l)return;X(e.data).catch(t=>{m(t)})}})}function y(e,t=[]){if(l===null||g===null)return;let n=l==="null"?"*":l;g.postMessage(e,n,t)}function m(e){let t=e,n=t?.stack?{type:"iframe-error",message:t.message??String(e),stack:t.stack}:{type:"iframe-error",message:t?.message??String(e)};j(n)}function Y(e){let t={type:"iframe-error",message:e.message?`Worker error: ${e.message}`:"Worker error: (no detail \\u2014 likely cross-origin opacity)",...e.error&&e.error.stack?{stack:e.error.stack}:{},...e.filename?{filename:e.filename}:{},...e.lineno?{lineno:e.lineno}:{},...e.colno?{colno:e.colno}:{}};j(t)}function j(e){if(l&&g){let t=l==="null"?"*":l;g.postMessage(e,t)}else window.parent.postMessage(e,"*")}async function X(e){switch(e.type){case"viji-bootstrap":await K(e);return;case"viji-host-message":V(e.payload);return;case"viji-resize":U(e.width,e.height);return;case"viji-enable-sensors":W(e.enabled);return;case"viji-enable-interaction":T(e.enabled);return;case"viji-terminate":$();return}}async function K(e){if(r)return;a=document.createElement("canvas"),a.id="viji-canvas",a.width=e.init.canvasWidth,a.height=e.init.canvasHeight,a.style.width="100%",a.style.height="100%",a.style.display="block",a.tabIndex=0,a.style.outline="none",document.body.appendChild(a);let t=a.transferControlToOffscreen();v=URL.createObjectURL(new Blob([e.workerCode],{type:"application/javascript"})),r=new Worker(v,{type:"classic"}),r.onerror=s=>{Y(s)},r.onmessage=s=>{G(s.data)};let n=`init_${Date.now()}`,i={type:"init",id:n,timestamp:Date.now(),data:{canvas:t,isHeadless:e.init.isHeadless,sc:e.init.sc,rh:e.init.rh,controlPort:e.controlPort,reporterConfig:e.init.reporterConfig}},f=z(s=>s&&s.type==="init-response"&&s.id===n);r.postMessage(i,[t,e.controlPort]),await f,e.init.allowInteraction&&!e.init.isHeadless&&T(!0),e.init.allowSensors&&!e.init.isHeadless&&W(!0),a&&a.addEventListener("contextmenu",s=>s.preventDefault()),y({type:"viji-ready"})}function z(e){return new Promise((t,n)=>{if(!r){n(new Error("worker not spawned"));return}let i=r,f=s=>{e(s.data)&&(i.removeEventListener("message",f),t(s.data))};i.addEventListener("message",f)})}function V(e){if(!(!r||!e))try{let t=I(e);r.postMessage(e,t)}catch(t){m(t)}}function G(e){if(e)try{let t=I(e);y({type:"worker-message",payload:e},t)}catch(t){m(t)}}function U(e,t){r&&r.postMessage({type:"resolution-update",id:`resize_${Date.now()}`,timestamp:Date.now(),data:{effectiveWidth:e,effectiveHeight:t,displayScale:1}})}var b=!1;function T(e){e!==L&&a&&(e?(a.addEventListener("mousedown",u,{passive:!1}),a.addEventListener("mousemove",u,{passive:!1}),a.addEventListener("mouseup",u,{passive:!1}),a.addEventListener("mouseenter",x,{passive:!1}),a.addEventListener("mouseleave",R,{passive:!1}),a.addEventListener("wheel",C,{passive:!1}),a.addEventListener("touchstart",d,{passive:!1}),a.addEventListener("touchmove",d,{passive:!1}),a.addEventListener("touchend",d,{passive:!1}),a.addEventListener("touchcancel",d,{passive:!1}),document.addEventListener("keydown",M,{passive:!1}),document.addEventListener("keyup",M,{passive:!1}),a.addEventListener("mousedown",h),a.addEventListener("touchstart",h),L=!0):(a.removeEventListener("mousedown",u),a.removeEventListener("mousemove",u),a.removeEventListener("mouseup",u),a.removeEventListener("mouseenter",x),a.removeEventListener("mouseleave",R),a.removeEventListener("wheel",C),a.removeEventListener("touchstart",d),a.removeEventListener("touchmove",d),a.removeEventListener("touchend",d),a.removeEventListener("touchcancel",d),document.removeEventListener("keydown",M),document.removeEventListener("keyup",M),a.removeEventListener("mousedown",h),a.removeEventListener("touchstart",h),L=!1))}function h(){a&&a.focus()}function w(e,t){r&&r.postMessage({type:e,id:`${e}_${Date.now()}`,timestamp:Date.now(),data:t}),y({type:"interaction-event",kind:e,data:t})}function u(e){if(!a)return;e.preventDefault();let t=a.getBoundingClientRect(),n=(e.clientX-t.left)*(a.width/t.width),i=(e.clientY-t.top)*(a.height/t.height);w("mouse-update",{x:n,y:i,buttons:e.buttons,deltaX:e.movementX||0,deltaY:e.movementY||0,wheelDeltaX:0,wheelDeltaY:0,isInCanvas:b,timestamp:performance.now()})}function x(e){b=!0,u(e)}function R(e){b=!1,u(e)}function C(e){if(!a)return;e.preventDefault();let t=a.getBoundingClientRect(),n=(e.clientX-t.left)*(a.width/t.width),i=(e.clientY-t.top)*(a.height/t.height);w("mouse-update",{x:n,y:i,buttons:e.buttons,deltaX:0,deltaY:0,wheelDeltaX:e.deltaX,wheelDeltaY:e.deltaY,isInCanvas:b,timestamp:performance.now()})}var _=new Set(["Tab","F1","F2","F3","F4","F5","F11","F12"]);function M(e){_.has(e.key)||e.preventDefault(),w("keyboard-update",{type:e.type,key:e.key,code:e.code,keyCode:e.keyCode,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,timestamp:performance.now()})}function d(e){if(!a)return;e.preventDefault();let t=a.getBoundingClientRect(),n=a.width/t.width,i=a.height/t.height,f=a.width,s=a.height,D=o=>{let c=(o.clientX-t.left)*n,p=(o.clientY-t.top)*i;return{identifier:o.identifier,clientX:c,clientY:p,radiusX:o.radiusX??0,radiusY:o.radiusY??0,rotationAngle:o.rotationAngle??0,force:o.force??0,isInCanvas:c>=0&&c<=f&&p>=0&&p<=s}},E=new Map;for(let o=0;o<e.changedTouches.length;o++){let c=e.changedTouches[o];E.set(c.identifier,D(c))}let k=Array.from(e.touches).map(o=>E.get(o.identifier)??D(o));if(e.type==="touchend"||e.type==="touchcancel"){let o=new Set(k.map(c=>c.identifier));for(let[c,p]of E)o.has(c)||k.push({...p,ended:!0})}w("touch-update",{type:e.type,touches:k,timestamp:performance.now()})}function W(e){e!==H&&(e?(window.addEventListener("devicemotion",O),window.addEventListener("deviceorientation",P),H=!0):(window.removeEventListener("devicemotion",O),window.removeEventListener("deviceorientation",P),H=!1))}function O(e){let t=e.acceleration===null||e.acceleration.x===null&&e.acceleration.y===null&&e.acceleration.z===null,n=e.accelerationIncludingGravity===null||e.accelerationIncludingGravity.x===null&&e.accelerationIncludingGravity.y===null&&e.accelerationIncludingGravity.z===null,i=e.rotationRate===null||e.rotationRate.alpha===null&&e.rotationRate.beta===null&&e.rotationRate.gamma===null;t&&n&&i||y({type:"sensor-event",kind:"motion",data:{acceleration:t?null:{x:e.acceleration.x,y:e.acceleration.y,z:e.acceleration.z},accelerationIncludingGravity:n?null:{x:e.accelerationIncludingGravity.x,y:e.accelerationIncludingGravity.y,z:e.accelerationIncludingGravity.z},rotationRate:i?null:{alpha:e.rotationRate.alpha,beta:e.rotationRate.beta,gamma:e.rotationRate.gamma},interval:e.interval||16}})}function P(e){e.alpha===null&&e.beta===null&&e.gamma===null||y({type:"sensor-event",kind:"orientation",data:{alpha:e.alpha,beta:e.beta,gamma:e.gamma,absolute:e.absolute||!1}})}function $(){T(!1),W(!1),r&&(r.terminate(),r=null),v&&(URL.revokeObjectURL(v),v=null)}F();A().catch(e=>m(e));window.addEventListener("error",e=>{m(e.error??new Error(e.message))});window.addEventListener("unhandledrejection",e=>{m(e.reason??new Error("Unhandled promise rejection"))});})();\n', kB = "accelerometer; gyroscope; magnetometer; camera; microphone",
|
|
24
|
+
const yB = '"use strict";(()=>{function I(e){switch(e.type){case"init":{let t=e,n=[];return t.data?.canvas&&n.push(t.data.canvas),t.data?.controlPort&&n.push(t.data.controlPort),n}case"video-canvas-setup":{let t=e;return t.data?.offscreenCanvas?[t.data.offscreenCanvas]:[]}case"video-frame-update":{let t=e;return t.data?.imageBitmap?[t.data.imageBitmap]:[]}case"video-frame-direct":{let t=e;return t.data?.imageBitmap?[t.data.imageBitmap]:[]}case"parameter-update":return e.data?.transferList??[];case"parameter-batch-update":return e.data?.transferList??[];case"audio-analysis-update":{let t=e,n=[];return t.data?.frequencyData?.buffer&&n.push(t.data.frequencyData.buffer),t.data?.waveformData?.buffer&&n.push(t.data.waveformData.buffer),n}case"capture-frame-result":case"auto-capture-result":{let t=e.data;return t?.bitmap?[t.bitmap]:[]}case"cv-results-update":{let t=e.data;return t?.analysedFrame?[t.analysedFrame]:[]}default:return[]}}var l=null,g=null,r=null,v=null,a=null,L=!1,H=!1;function S(){return document.readyState==="loading"?new Promise(e=>{document.addEventListener("DOMContentLoaded",()=>e(),{once:!0})}):Promise.resolve()}async function A(){await S();let e={type:"iframe-ready",protocolVersion:1,environment:{crossOriginIsolated:window.crossOriginIsolated,isSecureContext:window.isSecureContext,origin:self.origin}};window.parent.postMessage(e,"*")}function F(){window.addEventListener("message",e=>{if(e.source===window.parent){if(l===null)l=e.origin,g=window.parent;else if(e.origin!==l)return;X(e.data).catch(t=>{m(t)})}})}function y(e,t=[]){if(l===null||g===null)return;let n=l==="null"?"*":l;g.postMessage(e,n,t)}function m(e){let t=e,n=t?.stack?{type:"iframe-error",message:t.message??String(e),stack:t.stack}:{type:"iframe-error",message:t?.message??String(e)};j(n)}function Y(e){let t={type:"iframe-error",message:e.message?`Worker error: ${e.message}`:"Worker error: (no detail \\u2014 likely cross-origin opacity)",...e.error&&e.error.stack?{stack:e.error.stack}:{},...e.filename?{filename:e.filename}:{},...e.lineno?{lineno:e.lineno}:{},...e.colno?{colno:e.colno}:{}};j(t)}function j(e){if(l&&g){let t=l==="null"?"*":l;g.postMessage(e,t)}else window.parent.postMessage(e,"*")}async function X(e){switch(e.type){case"viji-bootstrap":await K(e);return;case"viji-host-message":V(e.payload);return;case"viji-resize":U(e.width,e.height);return;case"viji-enable-sensors":W(e.enabled);return;case"viji-enable-interaction":T(e.enabled);return;case"viji-terminate":$();return}}async function K(e){if(r)return;a=document.createElement("canvas"),a.id="viji-canvas",a.width=e.init.canvasWidth,a.height=e.init.canvasHeight,a.style.width="100%",a.style.height="100%",a.style.display="block",a.tabIndex=0,a.style.outline="none",document.body.appendChild(a);let t=a.transferControlToOffscreen();v=URL.createObjectURL(new Blob([e.workerCode],{type:"application/javascript"})),r=new Worker(v,{type:"classic"}),r.onerror=s=>{Y(s)},r.onmessage=s=>{G(s.data)};let n=`init_${Date.now()}`,i={type:"init",id:n,timestamp:Date.now(),data:{canvas:t,isHeadless:e.init.isHeadless,sc:e.init.sc,rh:e.init.rh,controlPort:e.controlPort,reporterConfig:e.init.reporterConfig}},f=z(s=>s&&s.type==="init-response"&&s.id===n);r.postMessage(i,[t,e.controlPort]),await f,e.init.allowInteraction&&!e.init.isHeadless&&T(!0),e.init.allowSensors&&!e.init.isHeadless&&W(!0),a&&a.addEventListener("contextmenu",s=>s.preventDefault()),y({type:"viji-ready"})}function z(e){return new Promise((t,n)=>{if(!r){n(new Error("worker not spawned"));return}let i=r,f=s=>{e(s.data)&&(i.removeEventListener("message",f),t(s.data))};i.addEventListener("message",f)})}function V(e){if(!(!r||!e))try{let t=I(e);r.postMessage(e,t)}catch(t){m(t)}}function G(e){if(e)try{let t=I(e);y({type:"worker-message",payload:e},t)}catch(t){m(t)}}function U(e,t){r&&r.postMessage({type:"resolution-update",id:`resize_${Date.now()}`,timestamp:Date.now(),data:{effectiveWidth:e,effectiveHeight:t,displayScale:1}})}var b=!1;function T(e){e!==L&&a&&(e?(a.addEventListener("mousedown",u,{passive:!1}),a.addEventListener("mousemove",u,{passive:!1}),a.addEventListener("mouseup",u,{passive:!1}),a.addEventListener("mouseenter",x,{passive:!1}),a.addEventListener("mouseleave",R,{passive:!1}),a.addEventListener("wheel",C,{passive:!1}),a.addEventListener("touchstart",d,{passive:!1}),a.addEventListener("touchmove",d,{passive:!1}),a.addEventListener("touchend",d,{passive:!1}),a.addEventListener("touchcancel",d,{passive:!1}),document.addEventListener("keydown",M,{passive:!1}),document.addEventListener("keyup",M,{passive:!1}),a.addEventListener("mousedown",h),a.addEventListener("touchstart",h),L=!0):(a.removeEventListener("mousedown",u),a.removeEventListener("mousemove",u),a.removeEventListener("mouseup",u),a.removeEventListener("mouseenter",x),a.removeEventListener("mouseleave",R),a.removeEventListener("wheel",C),a.removeEventListener("touchstart",d),a.removeEventListener("touchmove",d),a.removeEventListener("touchend",d),a.removeEventListener("touchcancel",d),document.removeEventListener("keydown",M),document.removeEventListener("keyup",M),a.removeEventListener("mousedown",h),a.removeEventListener("touchstart",h),L=!1))}function h(){a&&a.focus()}function w(e,t){r&&r.postMessage({type:e,id:`${e}_${Date.now()}`,timestamp:Date.now(),data:t}),y({type:"interaction-event",kind:e,data:t})}function u(e){if(!a)return;e.preventDefault();let t=a.getBoundingClientRect(),n=(e.clientX-t.left)*(a.width/t.width),i=(e.clientY-t.top)*(a.height/t.height);w("mouse-update",{x:n,y:i,buttons:e.buttons,deltaX:e.movementX||0,deltaY:e.movementY||0,wheelDeltaX:0,wheelDeltaY:0,isInCanvas:b,timestamp:performance.now()})}function x(e){b=!0,u(e)}function R(e){b=!1,u(e)}function C(e){if(!a)return;e.preventDefault();let t=a.getBoundingClientRect(),n=(e.clientX-t.left)*(a.width/t.width),i=(e.clientY-t.top)*(a.height/t.height);w("mouse-update",{x:n,y:i,buttons:e.buttons,deltaX:0,deltaY:0,wheelDeltaX:e.deltaX,wheelDeltaY:e.deltaY,isInCanvas:b,timestamp:performance.now()})}var _=new Set(["Tab","F1","F2","F3","F4","F5","F11","F12"]);function M(e){_.has(e.key)||e.preventDefault(),w("keyboard-update",{type:e.type,key:e.key,code:e.code,keyCode:e.keyCode,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,timestamp:performance.now()})}function d(e){if(!a)return;e.preventDefault();let t=a.getBoundingClientRect(),n=a.width/t.width,i=a.height/t.height,f=a.width,s=a.height,D=o=>{let c=(o.clientX-t.left)*n,p=(o.clientY-t.top)*i;return{identifier:o.identifier,clientX:c,clientY:p,radiusX:o.radiusX??0,radiusY:o.radiusY??0,rotationAngle:o.rotationAngle??0,force:o.force??0,isInCanvas:c>=0&&c<=f&&p>=0&&p<=s}},E=new Map;for(let o=0;o<e.changedTouches.length;o++){let c=e.changedTouches[o];E.set(c.identifier,D(c))}let k=Array.from(e.touches).map(o=>E.get(o.identifier)??D(o));if(e.type==="touchend"||e.type==="touchcancel"){let o=new Set(k.map(c=>c.identifier));for(let[c,p]of E)o.has(c)||k.push({...p,ended:!0})}w("touch-update",{type:e.type,touches:k,timestamp:performance.now()})}function W(e){e!==H&&(e?(window.addEventListener("devicemotion",O),window.addEventListener("deviceorientation",P),H=!0):(window.removeEventListener("devicemotion",O),window.removeEventListener("deviceorientation",P),H=!1))}function O(e){let t=e.acceleration===null||e.acceleration.x===null&&e.acceleration.y===null&&e.acceleration.z===null,n=e.accelerationIncludingGravity===null||e.accelerationIncludingGravity.x===null&&e.accelerationIncludingGravity.y===null&&e.accelerationIncludingGravity.z===null,i=e.rotationRate===null||e.rotationRate.alpha===null&&e.rotationRate.beta===null&&e.rotationRate.gamma===null;t&&n&&i||y({type:"sensor-event",kind:"motion",data:{acceleration:t?null:{x:e.acceleration.x,y:e.acceleration.y,z:e.acceleration.z},accelerationIncludingGravity:n?null:{x:e.accelerationIncludingGravity.x,y:e.accelerationIncludingGravity.y,z:e.accelerationIncludingGravity.z},rotationRate:i?null:{alpha:e.rotationRate.alpha,beta:e.rotationRate.beta,gamma:e.rotationRate.gamma},interval:e.interval||16}})}function P(e){e.alpha===null&&e.beta===null&&e.gamma===null||y({type:"sensor-event",kind:"orientation",data:{alpha:e.alpha,beta:e.beta,gamma:e.gamma,absolute:e.absolute||!1}})}function $(){T(!1),W(!1),r&&(r.terminate(),r=null),v&&(URL.revokeObjectURL(v),v=null)}F();A().catch(e=>m(e));window.addEventListener("error",e=>{m(e.error??new Error(e.message))});window.addEventListener("unhandledrejection",e=>{m(e.reason??new Error("Unhandled promise rejection"))});})();\n', kB = "accelerometer; gyroscope; magnetometer; camera; microphone", pA = "null";
|
|
24
25
|
function MB(D) {
|
|
25
26
|
switch (D.type) {
|
|
26
27
|
case "init": {
|
|
@@ -270,14 +271,14 @@ class nB {
|
|
|
270
271
|
// ========================================
|
|
271
272
|
installHostMessageListener(A) {
|
|
272
273
|
this.hostMessageListener && window.removeEventListener("message", this.hostMessageListener), this.hostMessageListener = (B) => {
|
|
273
|
-
B.source === A.contentWindow && B.origin ===
|
|
274
|
+
B.source === A.contentWindow && B.origin === pA && this.handleIframeMessage(B.data);
|
|
274
275
|
}, window.addEventListener("message", this.hostMessageListener);
|
|
275
276
|
}
|
|
276
277
|
handleIframeMessage(A) {
|
|
277
278
|
if (!(!A || typeof A != "object" || typeof A.type != "string"))
|
|
278
279
|
switch (A.type) {
|
|
279
280
|
case "iframe-ready": {
|
|
280
|
-
if (this.lockedOrigin =
|
|
281
|
+
if (this.lockedOrigin = pA, this.iframeReadyTimeoutId !== null && (clearTimeout(this.iframeReadyTimeoutId), this.iframeReadyTimeoutId = null), this.iframeReadyResolver) {
|
|
281
282
|
const B = this.iframeReadyResolver;
|
|
282
283
|
this.iframeReadyResolver = null, this.iframeReadyRejecter = null, B();
|
|
283
284
|
}
|
|
@@ -547,7 +548,7 @@ class nB {
|
|
|
547
548
|
}
|
|
548
549
|
}
|
|
549
550
|
}
|
|
550
|
-
const dB = "" + new URL("assets/viji.worker-
|
|
551
|
+
const dB = "" + new URL("assets/viji.worker-ByIbGiBL.js", import.meta.url).href;
|
|
551
552
|
class JB {
|
|
552
553
|
constructor(A, B, I) {
|
|
553
554
|
this.iframeManager = A, this.sceneCode = B, this.init = I;
|
|
@@ -834,10 +835,10 @@ class JB {
|
|
|
834
835
|
}, this.iframeManager.onWorkerMessage(this.onWorkerMessageBound);
|
|
835
836
|
}
|
|
836
837
|
}
|
|
837
|
-
const YB = 5e3,
|
|
838
|
+
const YB = 5e3, zA = 15e3;
|
|
838
839
|
async function UB(D) {
|
|
839
840
|
try {
|
|
840
|
-
const A = await fetch(D, { signal: AbortSignal.timeout(
|
|
841
|
+
const A = await fetch(D, { signal: AbortSignal.timeout(zA) });
|
|
841
842
|
if (!A.ok)
|
|
842
843
|
throw new d(
|
|
843
844
|
`Failed to fetch ${D}: ${A.status} ${A.statusText}`,
|
|
@@ -846,7 +847,7 @@ async function UB(D) {
|
|
|
846
847
|
return await A.arrayBuffer();
|
|
847
848
|
} catch (A) {
|
|
848
849
|
throw A instanceof DOMException && A.name === "TimeoutError" ? new d(
|
|
849
|
-
`Timed out fetching ${D} after ${
|
|
850
|
+
`Timed out fetching ${D} after ${zA}ms`,
|
|
850
851
|
"WORKER_ASSET_FETCH_ERROR"
|
|
851
852
|
) : A;
|
|
852
853
|
}
|
|
@@ -1016,7 +1017,7 @@ class NB {
|
|
|
1016
1017
|
this.activeTouches.clear(), this.activeKeys.clear(), this.pressedThisFrame.clear(), this.releasedThisFrame.clear();
|
|
1017
1018
|
}
|
|
1018
1019
|
}
|
|
1019
|
-
class
|
|
1020
|
+
class b {
|
|
1020
1021
|
value = 0;
|
|
1021
1022
|
attackCoeff;
|
|
1022
1023
|
releaseCoeff;
|
|
@@ -1072,11 +1073,11 @@ class H {
|
|
|
1072
1073
|
*/
|
|
1073
1074
|
static createPresets(A = 60) {
|
|
1074
1075
|
return {
|
|
1075
|
-
fast: new
|
|
1076
|
+
fast: new b(0, 300, A),
|
|
1076
1077
|
// Instant attack, 300ms decay
|
|
1077
|
-
sustained: new
|
|
1078
|
+
sustained: new b(5, 500, A),
|
|
1078
1079
|
// 5ms attack, 500ms decay
|
|
1079
|
-
slow: new
|
|
1080
|
+
slow: new b(20, 800, A)
|
|
1080
1081
|
// 20ms attack, 800ms decay
|
|
1081
1082
|
};
|
|
1082
1083
|
}
|
|
@@ -1139,8 +1140,8 @@ const NA = {
|
|
|
1139
1140
|
debounceMs: 125
|
|
1140
1141
|
// Exact 16th-note timing at 120 BPM
|
|
1141
1142
|
}
|
|
1142
|
-
},
|
|
1143
|
-
class
|
|
1143
|
+
}, HB = 5e3, AA = ["low", "lowMid", "mid", "highMid", "high"];
|
|
1144
|
+
class bB {
|
|
1144
1145
|
/** Per-band state */
|
|
1145
1146
|
bandStates = /* @__PURE__ */ new Map();
|
|
1146
1147
|
/** Per-instance configs (do not mutate shared defaults) */
|
|
@@ -1225,13 +1226,13 @@ class HB {
|
|
|
1225
1226
|
const N = Math.min(0.08, Math.max(5e-3, 0.02 * w));
|
|
1226
1227
|
h.minEnergy = h.minEnergy + (o - h.minEnergy) * N;
|
|
1227
1228
|
}
|
|
1228
|
-
const
|
|
1229
|
-
h.fluxHistory || (h.fluxHistory = []), h.fluxHistory.push(
|
|
1230
|
-
let e =
|
|
1229
|
+
const t = Math.min(h.prevEnergy, h.minEnergy), c = Math.max(0, o - h.prevEnergy), F = Math.max(0, o - t, c);
|
|
1230
|
+
h.fluxHistory || (h.fluxHistory = []), h.fluxHistory.push(F), h.fluxHistory.length > 3 && h.fluxHistory.shift();
|
|
1231
|
+
let e = F;
|
|
1231
1232
|
h.fluxHistory.length >= 2 && (e += h.fluxHistory[h.fluxHistory.length - 2] * 0.5), h.fluxHistory.length >= 3 && (e += h.fluxHistory[h.fluxHistory.length - 3] * 0.25), e /= 1.75, h.lastFlux = e, h.lastEnergy = o;
|
|
1232
1233
|
const y = o - h.prevEnergy * 0.95, M = Math.max(e, e + y * 0.2), n = M / Math.max(1e-3, Q), k = Math.min(1, n / 0.08), J = this.recentEnergies.get(G), l = this.recentFluxes.get(G);
|
|
1233
1234
|
J.push(o), l.push(e), J.length > this.STATS_WINDOW_SIZE && J.shift(), l.length > this.STATS_WINDOW_SIZE && l.shift();
|
|
1234
|
-
const Y = 6e4 / this.currentBPM, U = Math.max(150, Math.min(350, Y * 0.45)), Z = Y / 4,
|
|
1235
|
+
const Y = 6e4 / this.currentBPM, U = Math.max(150, Math.min(350, Y * 0.45)), Z = Y / 4, H = G === "high" || G === "highMid" ? Z * 0.45 : Z * 0.9, r = Math.max(G === "high" || G === "highMid" ? 60 : 80, Math.min(G === "high" || G === "highMid" ? 150 : 250, H)), p = G === "low" ? U : r, P = G === "high" ? 0.85 : 1, X = h.cutoff * P, x = e > R.minFlux, T = o > X, u = o > R.minThreshold, _ = I - h.lastOnsetTime > p, K = x && T && u && _;
|
|
1235
1236
|
if (G === "low" || this.debugMode && G === "high") {
|
|
1236
1237
|
const N = G === "low" ? "low" : "high";
|
|
1237
1238
|
if (K) {
|
|
@@ -1252,7 +1253,7 @@ class HB {
|
|
|
1252
1253
|
}
|
|
1253
1254
|
}
|
|
1254
1255
|
K && (h.cutoff = o * R.cutoffMultiplier, h.lastOnsetTime = I, h.onsetHistory.push(I), E = !0), h.cutoff *= Math.pow(R.decayRate, w), h.cutoff = Math.max(h.cutoff, R.minThreshold), h.cutoff = Math.max(h.cutoff, h.minEnergy * 1.02), h.prevEnergy2 = h.prevEnergy, h.prevEnergy = o;
|
|
1255
|
-
const z = I -
|
|
1256
|
+
const z = I - HB;
|
|
1256
1257
|
h.onsetHistory = h.onsetHistory.filter((N) => N > z), h.primaryOnsetHistory = h.primaryOnsetHistory.filter((N) => N > z);
|
|
1257
1258
|
const f = K ? Math.min(1, e * 5 + o * 0.5) : 0;
|
|
1258
1259
|
C = Math.max(C, f), g[G] = {
|
|
@@ -1281,18 +1282,18 @@ class HB {
|
|
|
1281
1282
|
this.debugMode && console.log(`🎯 [Coherence] NEW CLUSTER: [${G.join(", ")}] marked as PRIMARY`);
|
|
1282
1283
|
} else {
|
|
1283
1284
|
const o = I - this.currentCluster.startTime, h = [], R = [], w = this.currentCluster.primaryBands.has("low") || this.currentCluster.primaryBands.has("lowMid");
|
|
1284
|
-
for (const
|
|
1285
|
-
if (this.currentCluster.primaryBands.has(
|
|
1286
|
-
g[
|
|
1285
|
+
for (const t of G)
|
|
1286
|
+
if (this.currentCluster.primaryBands.has(t))
|
|
1287
|
+
g[t].isPrimary = !0;
|
|
1287
1288
|
else {
|
|
1288
|
-
const c = g[
|
|
1289
|
-
if (
|
|
1290
|
-
if (g[
|
|
1289
|
+
const c = g[t].strength, F = t === "mid" || t === "highMid", e = t === "high";
|
|
1290
|
+
if (F && c > 0.75 || e && c > 0.7) {
|
|
1291
|
+
if (g[t].isPrimary = !0, R.push(t), this.currentCluster.primaryBands.add(t), this.debugMode) {
|
|
1291
1292
|
const y = o < 8 ? "simultaneous" : w ? "layered-event" : "independent";
|
|
1292
|
-
console.log(` ✅ [Pattern] REAL HIT at +${o.toFixed(0)}ms: [${
|
|
1293
|
+
console.log(` ✅ [Pattern] REAL HIT at +${o.toFixed(0)}ms: [${t}] ALLOWED (${y}, strength=${c.toFixed(2)})`);
|
|
1293
1294
|
}
|
|
1294
1295
|
} else
|
|
1295
|
-
g[
|
|
1296
|
+
g[t].isPrimary = !1, g[t].strength *= 0.3, h.push(t);
|
|
1296
1297
|
}
|
|
1297
1298
|
this.debugMode && (R.length > 0 && console.log(` ✅ [Pattern] REAL HITS at +${o.toFixed(0)}ms: [${R.join(", ")}] ALLOWED`), h.length > 0 && console.log(` 🔇 [Pattern] WEAK RESONANCE at +${o.toFixed(0)}ms: [${h.join(", ")}] SUPPRESSED`));
|
|
1298
1299
|
}
|
|
@@ -1565,7 +1566,7 @@ class LB {
|
|
|
1565
1566
|
if (!this.isInitialized)
|
|
1566
1567
|
return this.initPromise ? this.initPromise : (this.initPromise = (async () => {
|
|
1567
1568
|
try {
|
|
1568
|
-
const A = await import("./essentia.js-core.es-CC_3Ap1i.js"), B = await import("./essentia-wasm.web-
|
|
1569
|
+
const A = await import("./essentia.js-core.es-CC_3Ap1i.js"), B = await import("./essentia-wasm.web-0tQ5KtU1.js").then((g) => g.e), I = A.Essentia || A.default?.Essentia || A.default;
|
|
1569
1570
|
let Q = B.default || B.EssentiaWASM || B.default?.EssentiaWASM;
|
|
1570
1571
|
if (!Q)
|
|
1571
1572
|
throw new Error("WASM module not found - check essentia-wasm.web.js export");
|
|
@@ -1661,14 +1662,14 @@ class LB {
|
|
|
1661
1662
|
I
|
|
1662
1663
|
), h = s.onsetDetection || 0, R = G.onsetDetection || 0, w = o.onsetDetection || 0;
|
|
1663
1664
|
this.detectionHistory.complex.push(h), this.detectionHistory.hfc.push(R), this.detectionHistory.flux.push(w);
|
|
1664
|
-
const
|
|
1665
|
-
this.detectionHistory.complex.length >
|
|
1665
|
+
const t = this.ADAPTIVE_WINDOW * 2;
|
|
1666
|
+
this.detectionHistory.complex.length > t && (this.detectionHistory.complex.shift(), this.detectionHistory.hfc.shift(), this.detectionHistory.flux.shift());
|
|
1666
1667
|
const c = this.calculateAdaptiveThreshold(
|
|
1667
1668
|
this.detectionHistory.complex,
|
|
1668
1669
|
this.adaptiveLambda.kick,
|
|
1669
1670
|
// 1.8 - conservative (avoid bass bleed)
|
|
1670
1671
|
"kick"
|
|
1671
|
-
),
|
|
1672
|
+
), F = this.calculateAdaptiveThreshold(
|
|
1672
1673
|
this.detectionHistory.hfc,
|
|
1673
1674
|
this.adaptiveLambda.hat,
|
|
1674
1675
|
// 1.5 - use percentile-based threshold
|
|
@@ -1679,7 +1680,7 @@ class LB {
|
|
|
1679
1680
|
this.adaptiveLambda.snare,
|
|
1680
1681
|
// 1.4 - balanced
|
|
1681
1682
|
"snare"
|
|
1682
|
-
), y = this.detectionHistory.complex.slice(-3), M = this.detectionHistory.hfc.slice(-3), n = this.detectionHistory.flux.slice(-3), k = this.temporalIntegration(y, "kick"), J = this.temporalIntegration(M, "hat"), l = this.temporalIntegration(n, "snare"), Y = Math.min(5, Math.max(0, k)), U = Math.max(0, J), Z = Math.min(5, Math.max(0, l)),
|
|
1683
|
+
), y = this.detectionHistory.complex.slice(-3), M = this.detectionHistory.hfc.slice(-3), n = this.detectionHistory.flux.slice(-3), k = this.temporalIntegration(y, "kick"), J = this.temporalIntegration(M, "hat"), l = this.temporalIntegration(n, "snare"), Y = Math.min(5, Math.max(0, k)), U = Math.max(0, J), Z = Math.min(5, Math.max(0, l)), H = this.calculateSharpness(k, y), m = this.calculateSharpness(l, n), q = this.calculateSharpness(J, M), r = i - this.lastOnsetTime.kick, p = i - this.lastOnsetTime.snare, P = i - this.lastOnsetTime.hat, X = r >= this.minOnsetInterval.kick, x = p >= this.minOnsetInterval.snare, T = P >= this.minOnsetInterval.hat, u = X && Y > c && Q.low > this.bandThresholds.low, _ = T && U > F && (Q.high > this.bandThresholds.high || Q.highMid > this.bandThresholds.highMid), K = x && Z > e && Q.mid > this.bandThresholds.mid, z = Q.high + Q.highMid > 5e-4, f = Q.mid > 5e-4, N = _ && Q.high + Q.highMid > Q.mid * 2 + 1e-9, L = K && f && !N, V = _ && z, S = u || L || V;
|
|
1683
1684
|
u && (this.lastOnsetTime.kick = i), L && (this.lastOnsetTime.snare = i), V && (this.lastOnsetTime.hat = i), S && (this.lastOnsetTime.global = i), S && this.debugFrameCount++;
|
|
1684
1685
|
const W = Math.max(0, Math.min(1, Math.max(k, J, l)));
|
|
1685
1686
|
return {
|
|
@@ -1690,13 +1691,13 @@ class LB {
|
|
|
1690
1691
|
onset: u,
|
|
1691
1692
|
strength: Y,
|
|
1692
1693
|
energy: Q.low,
|
|
1693
|
-
sharpness:
|
|
1694
|
+
sharpness: H
|
|
1694
1695
|
},
|
|
1695
1696
|
lowMid: {
|
|
1696
1697
|
onset: u,
|
|
1697
1698
|
strength: Y,
|
|
1698
1699
|
energy: Q.lowMid,
|
|
1699
|
-
sharpness:
|
|
1700
|
+
sharpness: H
|
|
1700
1701
|
},
|
|
1701
1702
|
mid: {
|
|
1702
1703
|
onset: L,
|
|
@@ -1960,7 +1961,7 @@ class LB {
|
|
|
1960
1961
|
}
|
|
1961
1962
|
}
|
|
1962
1963
|
}
|
|
1963
|
-
const IA = 60, O = 200, WB = 85, mB = 180, uB = 200,
|
|
1964
|
+
const IA = 60, O = 200, WB = 85, mB = 180, uB = 200, VA = 4, aA = 10, rB = ["low", "lowMid", "mid", "highMid", "high"];
|
|
1964
1965
|
class qB {
|
|
1965
1966
|
// Autocorrelation state
|
|
1966
1967
|
onsetEnvelope = [];
|
|
@@ -2128,9 +2129,9 @@ class qB {
|
|
|
2128
2129
|
const M = g[y], n = g[y - o];
|
|
2129
2130
|
h += M * n, R += M * M, w += n * n;
|
|
2130
2131
|
}
|
|
2131
|
-
const
|
|
2132
|
-
let c = h /
|
|
2133
|
-
const
|
|
2132
|
+
const t = Math.sqrt(R * w) + 1e-8;
|
|
2133
|
+
let c = h / t;
|
|
2134
|
+
const F = this.fpsEstimate * 60 / o, e = Math.round(o / 2);
|
|
2134
2135
|
if (e >= E && e < g.length) {
|
|
2135
2136
|
let y = 0, M = 0, n = 0;
|
|
2136
2137
|
for (let J = e; J < g.length; J++) {
|
|
@@ -2140,7 +2141,7 @@ class qB {
|
|
|
2140
2141
|
const k = y / (Math.sqrt(M * n) + 1e-8);
|
|
2141
2142
|
k > 0.4 && Math.abs(k - c) < 0.15 && (c *= 0.85);
|
|
2142
2143
|
}
|
|
2143
|
-
|
|
2144
|
+
F >= WB && F <= mB && (c *= 1.03), c > a && (a = c, i = o);
|
|
2144
2145
|
}
|
|
2145
2146
|
let s = this.fpsEstimate * 60 / i;
|
|
2146
2147
|
if (s > 150 && a > 0.5) {
|
|
@@ -2155,10 +2156,10 @@ class qB {
|
|
|
2155
2156
|
for (const { factor: h, name: R } of o) {
|
|
2156
2157
|
const w = Math.round(i / h);
|
|
2157
2158
|
if (w >= E && w <= C && w < g.length) {
|
|
2158
|
-
let
|
|
2159
|
+
let t = 0, c = 0, F = 0;
|
|
2159
2160
|
for (let y = w; y < g.length; y++)
|
|
2160
|
-
|
|
2161
|
-
const e =
|
|
2161
|
+
t += g[y] * g[y - w], c += g[y] * g[y], F += g[y - w] * g[y - w];
|
|
2162
|
+
const e = t / (Math.sqrt(c * F) + 1e-8);
|
|
2162
2163
|
if (e > a * 0.8) {
|
|
2163
2164
|
s = this.fpsEstimate * 60 / w, a = e, i = w;
|
|
2164
2165
|
break;
|
|
@@ -2178,7 +2179,7 @@ class qB {
|
|
|
2178
2179
|
const B = /* @__PURE__ */ new Map(), I = [];
|
|
2179
2180
|
for (const G of rB) {
|
|
2180
2181
|
const o = A.getBandHistory(G), h = this.analyzeBandRhythm(o);
|
|
2181
|
-
if (B.set(G, h), h.sampleCount >=
|
|
2182
|
+
if (B.set(G, h), h.sampleCount >= VA && h.dominantInterval > 0) {
|
|
2182
2183
|
let R = 6e4 / h.dominantInterval;
|
|
2183
2184
|
for (; R > O; ) R /= 2;
|
|
2184
2185
|
for (; R < IA; ) R *= 2;
|
|
@@ -2208,18 +2209,18 @@ class qB {
|
|
|
2208
2209
|
if (!h) {
|
|
2209
2210
|
const w = G.bpm * 0.5;
|
|
2210
2211
|
if (w >= IA && w <= O) {
|
|
2211
|
-
const
|
|
2212
|
+
const t = I.find(
|
|
2212
2213
|
(c) => (c.band === "low" || c.band === "lowMid") && Math.abs(c.bpm - w) / w < 0.08
|
|
2213
2214
|
// Within 8%
|
|
2214
2215
|
);
|
|
2215
|
-
if (
|
|
2216
|
-
const c =
|
|
2217
|
-
(G.bpm > 200 || c > 1.5) && (G.bpm =
|
|
2216
|
+
if (t && t.confidence > o) {
|
|
2217
|
+
const c = t.confidence / o;
|
|
2218
|
+
(G.bpm > 200 || c > 1.5) && (G.bpm = t.bpm, G.confidence = o * 1.2, h = !0);
|
|
2218
2219
|
}
|
|
2219
2220
|
}
|
|
2220
2221
|
}
|
|
2221
2222
|
h || (I.some(
|
|
2222
|
-
(
|
|
2223
|
+
(t) => (t.band === "low" || t.band === "lowMid") && Math.abs(t.bpm - G.bpm) / G.bpm < 0.1
|
|
2223
2224
|
) ? G.confidence *= 1.5 : G.confidence *= 1.2);
|
|
2224
2225
|
} else
|
|
2225
2226
|
G.confidence *= 1.2;
|
|
@@ -2232,9 +2233,9 @@ class qB {
|
|
|
2232
2233
|
const h = [G.band];
|
|
2233
2234
|
for (const w of I) {
|
|
2234
2235
|
if (w.band === G.band) continue;
|
|
2235
|
-
const
|
|
2236
|
-
for (const
|
|
2237
|
-
if (Math.abs(
|
|
2236
|
+
const t = w.bpm / G.bpm, c = [0.25, 0.5, 1, 2, 4];
|
|
2237
|
+
for (const F of c)
|
|
2238
|
+
if (Math.abs(t - F) < F * 0.1) {
|
|
2238
2239
|
o += w.confidence * 0.7, h.push(w.band);
|
|
2239
2240
|
break;
|
|
2240
2241
|
}
|
|
@@ -2274,7 +2275,7 @@ class qB {
|
|
|
2274
2275
|
* Analyze rhythm pattern for a single band
|
|
2275
2276
|
*/
|
|
2276
2277
|
analyzeBandRhythm(A) {
|
|
2277
|
-
if (A.length <
|
|
2278
|
+
if (A.length < VA)
|
|
2278
2279
|
return { dominantInterval: 500, consistency: 0, sampleCount: 0 };
|
|
2279
2280
|
const B = [...A].sort((s, G) => s - G), I = [];
|
|
2280
2281
|
for (let s = 1; s < B.length; s++) {
|
|
@@ -2313,11 +2314,11 @@ class qB {
|
|
|
2313
2314
|
crossValidate(A, B) {
|
|
2314
2315
|
const I = performance.now();
|
|
2315
2316
|
if (this.gridLockBPM !== null) {
|
|
2316
|
-
const c = I - this.gridLockTime,
|
|
2317
|
+
const c = I - this.gridLockTime, F = this.scoreGridAlignment(this.gridLockBPM, this.getRecentOnsets(), I);
|
|
2317
2318
|
this.syncopationLevel = this.calculateSyncopation();
|
|
2318
2319
|
const e = this.syncopationLevel > 0.6 ? 0.55 : 0.65;
|
|
2319
|
-
if (
|
|
2320
|
-
this.gridLockTime = I, this.gridLockScore =
|
|
2320
|
+
if (F > e && c < 5e3) {
|
|
2321
|
+
this.gridLockTime = I, this.gridLockScore = F, this.applyFinalBPM(this.gridLockBPM, 0.9, "combined", B.anchorBand, I), this.updateHypotheses(this.gridLockBPM, 0.9, I), this.updateDriftRate(this.gridLockBPM, I), this.detectTransition();
|
|
2321
2322
|
return;
|
|
2322
2323
|
}
|
|
2323
2324
|
const y = [A.bpm, B.bpm];
|
|
@@ -2333,7 +2334,7 @@ class qB {
|
|
|
2333
2334
|
this.gridLockMemoryBPM = this.gridLockBPM, this.gridLockMemoryTime = I, this.gridLockBPM = null;
|
|
2334
2335
|
else if (c > this.GRID_LOCK_DURATION_MS) {
|
|
2335
2336
|
const n = this.syncopationLevel > 0.6 ? 0.4 : 0.5;
|
|
2336
|
-
|
|
2337
|
+
F < n && (this.gridLockMemoryBPM = this.gridLockBPM, this.gridLockMemoryTime = I, this.gridLockBPM = null);
|
|
2337
2338
|
} else if (c > 7e3)
|
|
2338
2339
|
this.gridLockMemoryBPM = this.gridLockBPM, this.gridLockMemoryTime = I, this.gridLockBPM = null;
|
|
2339
2340
|
else {
|
|
@@ -2343,25 +2344,25 @@ class qB {
|
|
|
2343
2344
|
}
|
|
2344
2345
|
}
|
|
2345
2346
|
if (I - (this.lastUpdateTime - this.bpmHistory.length * 200) < this.KICK_FIRST_WINDOW_MS && B.anchorBand === "low" && B.confidence > 0.4) {
|
|
2346
|
-
const c = B.bpm,
|
|
2347
|
-
this.methodAgreement = 0.8, this.applyFinalBPM(c,
|
|
2347
|
+
const c = B.bpm, F = Math.min(1, B.confidence * 1.2), e = "ioi";
|
|
2348
|
+
this.methodAgreement = 0.8, this.applyFinalBPM(c, F, e, B.anchorBand, I);
|
|
2348
2349
|
return;
|
|
2349
2350
|
}
|
|
2350
2351
|
if (A.bpm === 0 && B.bpm === 0)
|
|
2351
2352
|
return;
|
|
2352
2353
|
if (A.bpm === 0) {
|
|
2353
|
-
const c = B.bpm,
|
|
2354
|
-
this.methodAgreement = 0.7, this.applyFinalBPM(c,
|
|
2354
|
+
const c = B.bpm, F = B.confidence * 0.9, e = "ioi";
|
|
2355
|
+
this.methodAgreement = 0.7, this.applyFinalBPM(c, F, e, B.anchorBand, I);
|
|
2355
2356
|
return;
|
|
2356
2357
|
} else if (B.bpm === 0) {
|
|
2357
|
-
const c = A.bpm,
|
|
2358
|
-
this.methodAgreement = 0.7, this.applyFinalBPM(c,
|
|
2358
|
+
const c = A.bpm, F = A.confidence * 0.9, e = "autocorr";
|
|
2359
|
+
this.methodAgreement = 0.7, this.applyFinalBPM(c, F, e, null, I);
|
|
2359
2360
|
return;
|
|
2360
2361
|
}
|
|
2361
2362
|
const E = Math.abs(A.bpm - B.bpm) / Math.max(A.bpm, B.bpm), C = Math.abs(A.bpm - B.bpm * 2) / A.bpm < 0.08 || Math.abs(A.bpm * 2 - B.bpm) / B.bpm < 0.08;
|
|
2362
2363
|
let i, a, s, G = !1;
|
|
2363
2364
|
if (E < 0.05) {
|
|
2364
|
-
const c = (A.bpm * A.confidence + B.bpm * B.confidence) / (A.confidence + B.confidence + 1e-3),
|
|
2365
|
+
const c = (A.bpm * A.confidence + B.bpm * B.confidence) / (A.confidence + B.confidence + 1e-3), F = [
|
|
2365
2366
|
c,
|
|
2366
2367
|
// Current agreed BPM
|
|
2367
2368
|
c * 1.5,
|
|
@@ -2379,7 +2380,7 @@ class qB {
|
|
|
2379
2380
|
l < this.GRID_LOCK_MEMORY_DURATION_MS ? Math.abs(c - this.gridLockMemoryBPM) / this.gridLockMemoryBPM < 0.05 && (n = 0.2 * (1 - l / this.GRID_LOCK_MEMORY_DURATION_MS)) : this.gridLockMemoryBPM = null;
|
|
2380
2381
|
}
|
|
2381
2382
|
let k = y + M + n;
|
|
2382
|
-
for (const l of
|
|
2383
|
+
for (const l of F) {
|
|
2383
2384
|
if (l < IA || l > O || Math.abs(l - c) < 5) continue;
|
|
2384
2385
|
const Y = this.scoreGridAlignment(l, this.getRecentOnsets(), I), U = l / O * 0.5;
|
|
2385
2386
|
let Z = 0;
|
|
@@ -2387,8 +2388,8 @@ class qB {
|
|
|
2387
2388
|
const m = I - this.gridLockMemoryTime;
|
|
2388
2389
|
m < this.GRID_LOCK_MEMORY_DURATION_MS ? Math.abs(l - this.gridLockMemoryBPM) / this.gridLockMemoryBPM < 0.05 && (Z = 0.2 * (1 - m / this.GRID_LOCK_MEMORY_DURATION_MS)) : this.gridLockMemoryBPM = null;
|
|
2389
2390
|
}
|
|
2390
|
-
const
|
|
2391
|
-
|
|
2391
|
+
const H = Y + U + Z;
|
|
2392
|
+
H > k + 0.15 ? (k = H, e = l, G = !0) : H > k + 0.05 && (k = H, e = l);
|
|
2392
2393
|
}
|
|
2393
2394
|
i = e, s = "combined", a = Math.min(1, (A.confidence + B.confidence) / 2 * 1.3), this.methodAgreement = 1 - E;
|
|
2394
2395
|
let J = !1;
|
|
@@ -2414,15 +2415,15 @@ class qB {
|
|
|
2414
2415
|
e + 10
|
|
2415
2416
|
];
|
|
2416
2417
|
let Y = e, U = k;
|
|
2417
|
-
for (const
|
|
2418
|
-
if (
|
|
2419
|
-
const m = this.scoreGridAlignment(
|
|
2420
|
-
r > U && (Y =
|
|
2418
|
+
for (const H of l) {
|
|
2419
|
+
if (H < IA || H > O) continue;
|
|
2420
|
+
const m = this.scoreGridAlignment(H, this.getRecentOnsets(), I), q = H / O * 0.5, r = m + q;
|
|
2421
|
+
r > U && (Y = H, U = r);
|
|
2421
2422
|
}
|
|
2422
2423
|
let Z = !0;
|
|
2423
2424
|
if (Y > 140 && B.bpm >= 80 && B.bpm <= 150 && B.confidence > 0.5) {
|
|
2424
|
-
const
|
|
2425
|
-
if (
|
|
2425
|
+
const H = Y / B.bpm, m = Math.abs(Y - B.bpm);
|
|
2426
|
+
if (H >= 1.25 && H <= 3.5 || m > 30) {
|
|
2426
2427
|
const q = this.scoreGridAlignment(B.bpm, this.getRecentOnsets(), I), r = this.scoreGridAlignment(Y, this.getRecentOnsets(), I);
|
|
2427
2428
|
q > r * 0.8 && (Y = B.bpm, i = B.bpm, s = "ioi", a = B.confidence, Z = !1);
|
|
2428
2429
|
}
|
|
@@ -2442,7 +2443,7 @@ class qB {
|
|
|
2442
2443
|
B.bpm * 1.5,
|
|
2443
2444
|
B.bpm * 2
|
|
2444
2445
|
];
|
|
2445
|
-
let
|
|
2446
|
+
let F = A.bpm, e = -1;
|
|
2446
2447
|
for (const y of c) {
|
|
2447
2448
|
if (y < IA || y > O) continue;
|
|
2448
2449
|
const M = this.scoreGridAlignment(y, this.getRecentOnsets(), I), n = y === A.bpm || Math.abs(y - A.bpm) < 5 ? 0.1 : 0, k = M + n, J = y / O * 0.5;
|
|
@@ -2452,25 +2453,25 @@ class qB {
|
|
|
2452
2453
|
U < this.GRID_LOCK_MEMORY_DURATION_MS ? Math.abs(y - this.gridLockMemoryBPM) / this.gridLockMemoryBPM < 0.05 && (l = 0.2 * (1 - U / this.GRID_LOCK_MEMORY_DURATION_MS)) : this.gridLockMemoryBPM = null;
|
|
2453
2454
|
}
|
|
2454
2455
|
const Y = k + J + l;
|
|
2455
|
-
Y > e && (e = Y,
|
|
2456
|
+
Y > e && (e = Y, F = y);
|
|
2456
2457
|
}
|
|
2457
2458
|
if (e > 0.4) {
|
|
2458
|
-
if (i =
|
|
2459
|
+
if (i = F, a = Math.max(A.confidence, B.confidence) * 0.8, s = "combined", this.methodAgreement = 0.6, e > 0.7) {
|
|
2459
2460
|
G = !0;
|
|
2460
2461
|
const y = [
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2462
|
+
F - 10,
|
|
2463
|
+
F - 8,
|
|
2464
|
+
F - 6,
|
|
2465
|
+
F - 4,
|
|
2466
|
+
F - 2,
|
|
2467
|
+
F,
|
|
2468
|
+
F + 2,
|
|
2469
|
+
F + 4,
|
|
2470
|
+
F + 6,
|
|
2471
|
+
F + 8,
|
|
2472
|
+
F + 10
|
|
2472
2473
|
];
|
|
2473
|
-
let M =
|
|
2474
|
+
let M = F, n = e;
|
|
2474
2475
|
for (const J of y) {
|
|
2475
2476
|
if (J < IA || J > O) continue;
|
|
2476
2477
|
const l = this.scoreGridAlignment(J, this.getRecentOnsets(), I), Y = J / O * 0.5, U = l + Y;
|
|
@@ -2499,17 +2500,17 @@ class qB {
|
|
|
2499
2500
|
Math.abs(i - c) < Math.abs(this.currentBPM - c) || (a *= 0.3);
|
|
2500
2501
|
}
|
|
2501
2502
|
this.bpmHistory.push(i), this.bpmHistory.length > this.bpmHistoryMaxSize && this.bpmHistory.shift();
|
|
2502
|
-
const R = [...this.bpmHistory].sort((c,
|
|
2503
|
-
let
|
|
2503
|
+
const R = [...this.bpmHistory].sort((c, F) => c - F), w = R[Math.floor(R.length / 2)];
|
|
2504
|
+
let t;
|
|
2504
2505
|
if (G)
|
|
2505
|
-
|
|
2506
|
+
t = w;
|
|
2506
2507
|
else {
|
|
2507
2508
|
const c = Math.max(0.1, Math.min(0.4, a));
|
|
2508
|
-
|
|
2509
|
-
const
|
|
2510
|
-
this.methodAgreement > 0.6 && (this.bpmHistory.length < 5 ||
|
|
2509
|
+
t = this.currentBPM * (1 - c) + w * c, h > 0.15 && (t = this.currentBPM * 0.85 + t * 0.15);
|
|
2510
|
+
const F = this.hypotheses.length > 0 && this.hypotheses[0].likelihood > 0.7;
|
|
2511
|
+
this.methodAgreement > 0.6 && (this.bpmHistory.length < 5 || F) && (t = w);
|
|
2511
2512
|
}
|
|
2512
|
-
this.applyFinalBPM(
|
|
2513
|
+
this.applyFinalBPM(t, a, s, B.anchorBand, I), this.updateHypotheses(i, a, I), this.updateDriftRate(i, I), this.detectTransition();
|
|
2513
2514
|
}
|
|
2514
2515
|
/**
|
|
2515
2516
|
* Apply final BPM and update state
|
|
@@ -2659,7 +2660,7 @@ class qB {
|
|
|
2659
2660
|
const R = h[0].time, w = [];
|
|
2660
2661
|
for (let y = R; y <= I + E; y += E)
|
|
2661
2662
|
w.push(y);
|
|
2662
|
-
let
|
|
2663
|
+
let t = 0, c = 0;
|
|
2663
2664
|
for (const y of h) {
|
|
2664
2665
|
let M = 1 / 0;
|
|
2665
2666
|
for (const J of w) {
|
|
@@ -2667,10 +2668,10 @@ class qB {
|
|
|
2667
2668
|
l < M && (M = l);
|
|
2668
2669
|
}
|
|
2669
2670
|
const n = Math.min(0.5, M / E), k = Math.sqrt(y.strength / 1e3);
|
|
2670
|
-
|
|
2671
|
+
t += n * k, c += k;
|
|
2671
2672
|
}
|
|
2672
|
-
const
|
|
2673
|
-
return 1 - Math.min(1,
|
|
2673
|
+
const F = t / (c + 1e-3);
|
|
2674
|
+
return 1 - Math.min(1, F * 2);
|
|
2674
2675
|
}
|
|
2675
2676
|
/**
|
|
2676
2677
|
* Get current tempo result
|
|
@@ -2817,7 +2818,7 @@ class qB {
|
|
|
2817
2818
|
};
|
|
2818
2819
|
}
|
|
2819
2820
|
}
|
|
2820
|
-
const
|
|
2821
|
+
const XA = 0.3, pB = 0.1, zB = 0.5, VB = 0.15, XB = 0.08, xB = 3e4, xA = 1e4, KB = 0.3;
|
|
2821
2822
|
class OB {
|
|
2822
2823
|
/** Current phase (0-1) */
|
|
2823
2824
|
phase = 0;
|
|
@@ -2844,7 +2845,7 @@ class OB {
|
|
|
2844
2845
|
/** Whether in a tempo transition */
|
|
2845
2846
|
inTransition = !1;
|
|
2846
2847
|
/** Adaptive PLL gain (calculated each frame) */
|
|
2847
|
-
currentGain =
|
|
2848
|
+
currentGain = XA;
|
|
2848
2849
|
/** ========== PHASE 4: DUAL-GATE BAR ADVANCEMENT STATE ========== */
|
|
2849
2850
|
/** Last time a bar was advanced (for debounce) */
|
|
2850
2851
|
lastBarAdvanceTime = 0;
|
|
@@ -2914,7 +2915,7 @@ class OB {
|
|
|
2914
2915
|
(Math.abs(s - G) / G < 0.1 || g > 0.9 || this.inTransition) && (this.trackedBPM = this.trackedBPM * (1 - C) + I * C, this.periodMs = 6e4 / this.trackedBPM, this.bpmHistory.push({ time: Q, bpm: I }));
|
|
2915
2916
|
}
|
|
2916
2917
|
this.bpmHistory = this.bpmHistory.filter(
|
|
2917
|
-
(s) => Q - s.time <
|
|
2918
|
+
(s) => Q - s.time < xA
|
|
2918
2919
|
), this.detectDrift(Q);
|
|
2919
2920
|
const i = this.phase, a = Q - this.lastBeatTime;
|
|
2920
2921
|
if (this.phase = a / this.periodMs % 1, A ? (this.lastOnsetTime = Q, this.inBreakdown = !1) : Q - this.lastOnsetTime > 2e3 && (this.inBreakdown = !0), A) {
|
|
@@ -2931,11 +2932,11 @@ class OB {
|
|
|
2931
2932
|
this.lastBeatTime = Q, this.phase = 0, this.lastHardSyncTime = Q, this.consecutiveAlignedKicks = 0, this.detectPhaseWrap(i, Q), this.tryAdvanceBar(Q, B);
|
|
2932
2933
|
return;
|
|
2933
2934
|
}
|
|
2934
|
-
const
|
|
2935
|
+
const t = this.inTransition ? XB : VB;
|
|
2935
2936
|
if (G < 0.05) {
|
|
2936
2937
|
const c = s * this.periodMs * (this.currentGain * 0.5);
|
|
2937
2938
|
this.lastBeatTime += c, this.phase = (Q - this.lastBeatTime) / this.periodMs % 1, this.detectPhaseWrap(i, Q), this.tryAdvanceBar(Q, B);
|
|
2938
|
-
} else if (G <
|
|
2939
|
+
} else if (G < t)
|
|
2939
2940
|
this.lastBeatTime = Q, this.phase = 0, this.detectPhaseWrap(i, Q), this.tryAdvanceBar(Q, B);
|
|
2940
2941
|
else if (G < 0.4) {
|
|
2941
2942
|
const c = s * this.periodMs * this.currentGain;
|
|
@@ -3003,7 +3004,7 @@ class OB {
|
|
|
3003
3004
|
this.driftRate = 0;
|
|
3004
3005
|
return;
|
|
3005
3006
|
}
|
|
3006
|
-
const B = this.bpmHistory.filter((E) => A - E.time <
|
|
3007
|
+
const B = this.bpmHistory.filter((E) => A - E.time < xA).filter((E) => E.bpm > 0);
|
|
3007
3008
|
if (B.length < 3) {
|
|
3008
3009
|
this.driftRate = 0;
|
|
3009
3010
|
return;
|
|
@@ -3167,7 +3168,7 @@ class OB {
|
|
|
3167
3168
|
* Reset all state
|
|
3168
3169
|
*/
|
|
3169
3170
|
reset() {
|
|
3170
|
-
this.phase = 0, this.lastBeatTime = 0, this.periodMs = 500, this.trackedBPM = 120, this.beatCounter = 0, this.lastOnsetTime = 0, this.bpmHistory = [], this.driftRate = 0, this.inBreakdown = !1, this.tempoConfidence = 0.5, this.inTransition = !1, this.currentGain =
|
|
3171
|
+
this.phase = 0, this.lastBeatTime = 0, this.periodMs = 500, this.trackedBPM = 120, this.beatCounter = 0, this.lastOnsetTime = 0, this.bpmHistory = [], this.driftRate = 0, this.inBreakdown = !1, this.tempoConfidence = 0.5, this.inTransition = !1, this.currentGain = XA, this.lastBarAdvanceTime = 0, this.pendingBarAdvance = !1, this.lastPhaseWrapTime = 0, this.consecutiveAlignedKicks = 0, this.lastHardSyncTime = 0, this.trackingStartTime = 0, this.kickPhaseHistory = [], this.phaseOffsetCalibrated = 0, this.lastCalibrationTime = 0;
|
|
3171
3172
|
}
|
|
3172
3173
|
// ─────────────────────────────────────────────────────────────────────────
|
|
3173
3174
|
// State serialization (for VijiCore.exportFullState same-process transfer)
|
|
@@ -3218,7 +3219,7 @@ class OB {
|
|
|
3218
3219
|
function gA(D, A) {
|
|
3219
3220
|
return D > 0 ? D + A : 0;
|
|
3220
3221
|
}
|
|
3221
|
-
const fB = 2e3, vB = 1e4,
|
|
3222
|
+
const fB = 2e3, vB = 1e4, EB = 25e3, jB = EB, PB = 0.3, KA = 0.6, HA = 2e3, bA = 3e4, OA = 0.25, EA = 60;
|
|
3222
3223
|
class TB {
|
|
3223
3224
|
// State machine
|
|
3224
3225
|
state = "TRACKING";
|
|
@@ -3248,14 +3249,14 @@ class TB {
|
|
|
3248
3249
|
// Running average of onset strength
|
|
3249
3250
|
// Envelope followers for beat energy curves
|
|
3250
3251
|
envelopes = {
|
|
3251
|
-
kick: new
|
|
3252
|
-
snare: new
|
|
3253
|
-
hat: new
|
|
3254
|
-
any: new
|
|
3255
|
-
kickSmoothed: new
|
|
3256
|
-
snareSmoothed: new
|
|
3257
|
-
hatSmoothed: new
|
|
3258
|
-
anySmoothed: new
|
|
3252
|
+
kick: new b(0, 300, EA),
|
|
3253
|
+
snare: new b(0, 300, EA),
|
|
3254
|
+
hat: new b(0, 300, EA),
|
|
3255
|
+
any: new b(0, 300, EA),
|
|
3256
|
+
kickSmoothed: new b(5, 500, EA),
|
|
3257
|
+
snareSmoothed: new b(5, 500, EA),
|
|
3258
|
+
hatSmoothed: new b(5, 500, EA),
|
|
3259
|
+
anySmoothed: new b(5, 500, EA)
|
|
3259
3260
|
};
|
|
3260
3261
|
// Confidence factors
|
|
3261
3262
|
tempoMethodAgreement = 0;
|
|
@@ -3350,7 +3351,7 @@ class TB {
|
|
|
3350
3351
|
*/
|
|
3351
3352
|
getEffectiveWindowSize() {
|
|
3352
3353
|
const A = this.consistencyScore;
|
|
3353
|
-
return A > 0.7 ?
|
|
3354
|
+
return A > 0.7 ? EB : A < 0.3 ? fB : vB;
|
|
3354
3355
|
}
|
|
3355
3356
|
/**
|
|
3356
3357
|
* Filter samples to effective window based on current stability
|
|
@@ -3454,8 +3455,8 @@ class TB {
|
|
|
3454
3455
|
};
|
|
3455
3456
|
k?.confidence !== void 0 && (Y.confidence = k.confidence), this.eventBuffer.push({ event: Y, expiresAt: i }), this.lastEventTime.kick = g, this.eventTimestamps.kick.push(g);
|
|
3456
3457
|
}
|
|
3457
|
-
const
|
|
3458
|
-
if (C.snare && !
|
|
3458
|
+
const t = a.snare || this.eventBuffer.some((k) => k.event.type === "snare" && Math.abs(k.event.time - g) < 30);
|
|
3459
|
+
if (C.snare && !t) {
|
|
3459
3460
|
a.snare = !0, this.debugSnareCount++;
|
|
3460
3461
|
const k = G.find((U) => U.type === "snare"), J = k && "bands" in k ? k.bands : h, l = k?.strength || A.bands.mid.strength, Y = {
|
|
3461
3462
|
type: "snare",
|
|
@@ -3486,8 +3487,8 @@ class TB {
|
|
|
3486
3487
|
};
|
|
3487
3488
|
k?.confidence !== void 0 && (Y.confidence = k.confidence), this.eventBuffer.push({ event: Y, expiresAt: i }), this.lastEventTime.hat = g, this.eventTimestamps.hat.push(g);
|
|
3488
3489
|
} else C.hat;
|
|
3489
|
-
const
|
|
3490
|
-
this.debugMode &&
|
|
3490
|
+
const F = this.eventBuffer.map((k) => k.event);
|
|
3491
|
+
this.debugMode && F.length > 0 && g - (this.lastBufferLogTime || 0) > 2e3 && (this.lastBufferLogTime = g), this.updateEnvelopes(C, A, Q);
|
|
3491
3492
|
const e = this.calculateConfidence(), y = this.calculateTrackingConfidence(B), M = this.state === "LOCKED" || this.state === "BREAKDOWN", n = this.createDebugInfo(B, I, g, y);
|
|
3492
3493
|
return {
|
|
3493
3494
|
kick: this.envelopes.kick.getValue(),
|
|
@@ -3498,7 +3499,7 @@ class TB {
|
|
|
3498
3499
|
snareSmoothed: this.envelopes.snareSmoothed.getValue(),
|
|
3499
3500
|
hatSmoothed: this.envelopes.hatSmoothed.getValue(),
|
|
3500
3501
|
anySmoothed: this.envelopes.anySmoothed.getValue(),
|
|
3501
|
-
events:
|
|
3502
|
+
events: F,
|
|
3502
3503
|
// Buffered events (persisted for 20ms, reliable for async access)
|
|
3503
3504
|
bpm: I.getBPM(),
|
|
3504
3505
|
phase: I.getPhase(),
|
|
@@ -3561,13 +3562,13 @@ class TB {
|
|
|
3561
3562
|
const Q = I - this.lastOnsetTime, g = this.calculateConfidence();
|
|
3562
3563
|
switch (this.state) {
|
|
3563
3564
|
case "TRACKING":
|
|
3564
|
-
g >=
|
|
3565
|
+
g >= KA ? (this.transitionTo("LOCKED", I), this.lockedBPM = B.getBPM()) : Q > HA && this.transitionTo("BREAKDOWN", I);
|
|
3565
3566
|
break;
|
|
3566
3567
|
case "LOCKED":
|
|
3567
|
-
Q >
|
|
3568
|
+
Q > HA ? this.transitionTo("BREAKDOWN", I) : g < PB && this.transitionTo("TRACKING", I);
|
|
3568
3569
|
break;
|
|
3569
3570
|
case "BREAKDOWN":
|
|
3570
|
-
Q <
|
|
3571
|
+
Q < HA ? g >= KA ? this.transitionTo("LOCKED", I) : this.transitionTo("TRACKING", I) : (Q > bA || B.isExtrapolationLimitReached()) && this.transitionTo("LOST", I);
|
|
3571
3572
|
break;
|
|
3572
3573
|
case "LOST":
|
|
3573
3574
|
Q < 500 && this.transitionTo("TRACKING", I);
|
|
@@ -3588,10 +3589,10 @@ class TB {
|
|
|
3588
3589
|
detectTrackChange(A, B) {
|
|
3589
3590
|
const I = performance.now(), Q = I - this.stateEnteredTime, g = I - this.lastOnsetTime;
|
|
3590
3591
|
if (this.state === "LOCKED" && Q < 1e4)
|
|
3591
|
-
return this.gridScore <
|
|
3592
|
+
return this.gridScore < OA && this.recentGridScores.length >= 15 && this.recentGridScores.reduce((E, C) => E + C, 0) / this.recentGridScores.length, !1;
|
|
3592
3593
|
if (this.state === "LOCKED" && g > 3e3)
|
|
3593
3594
|
return !1;
|
|
3594
|
-
if ((this.state === "LOCKED" || this.state === "BREAKDOWN") && this.gridScore <
|
|
3595
|
+
if ((this.state === "LOCKED" || this.state === "BREAKDOWN") && this.gridScore < OA && this.recentGridScores.length >= 15 && this.recentGridScores.reduce((C, i) => C + i, 0) / this.recentGridScores.length < 0.15)
|
|
3595
3596
|
return !0;
|
|
3596
3597
|
if (this.state === "LOCKED") {
|
|
3597
3598
|
const E = Math.abs(B.bpm - this.lockedBPM), C = this.lockedBPM >= 60 && this.lockedBPM <= 200, i = B.bpm >= 60 && B.bpm <= 200;
|
|
@@ -3716,14 +3717,14 @@ class TB {
|
|
|
3716
3717
|
if (this.adaptiveProfiles.hatIndependent.samples.length >= 2) {
|
|
3717
3718
|
const B = this.filterToEffectiveWindow(this.adaptiveProfiles.hatIndependent.samples, A);
|
|
3718
3719
|
if (B.length >= 2) {
|
|
3719
|
-
const I = B.map((w) => w.strength), Q = B.map((w) => w.trebleRatio), g = B.map((w) => w.sharpness), E = [...I].sort((w,
|
|
3720
|
+
const I = B.map((w) => w.strength), Q = B.map((w) => w.trebleRatio), g = B.map((w) => w.sharpness), E = [...I].sort((w, t) => w - t), i = 0.1 + this.consistencyScore * 0.2, a = E[Math.floor(E.length * i)], s = [...Q].sort((w, t) => w - t), G = s[Math.floor(s.length * 0.8)], o = [...g].sort((w, t) => w - t), h = o[Math.floor(o.length * 0.1)], R = this.consistencyScore < 0.5 ? 2e3 : 1 / 0;
|
|
3720
3721
|
this.adaptiveThresholds.hatIndependent.minStrength = Math.min(R, a * 0.8), this.adaptiveThresholds.hatIndependent.minTrebleRatio = Math.max(0.12, G * 0.85), this.adaptiveThresholds.hatIndependent.minSharpness = Math.max(0.3, h * 0.8);
|
|
3721
3722
|
}
|
|
3722
3723
|
}
|
|
3723
3724
|
if (this.adaptiveProfiles.hatLayered.samples.length >= 2) {
|
|
3724
3725
|
const B = this.filterToEffectiveWindow(this.adaptiveProfiles.hatLayered.samples, A);
|
|
3725
3726
|
if (B.length >= 2) {
|
|
3726
|
-
const I = B.map((w) => w.strength), Q = B.map((w) => w.trebleRatio), g = B.map((w) => w.sharpness), E = [...I].sort((w,
|
|
3727
|
+
const I = B.map((w) => w.strength), Q = B.map((w) => w.trebleRatio), g = B.map((w) => w.sharpness), E = [...I].sort((w, t) => w - t), i = 0.1 + this.consistencyScore * 0.2, a = E[Math.floor(E.length * i)], s = [...Q].sort((w, t) => w - t), G = s[Math.floor(s.length * 0.7)], o = [...g].sort((w, t) => w - t), h = o[Math.floor(o.length * 0.1)], R = this.consistencyScore < 0.5 ? 2e3 : 1 / 0;
|
|
3727
3728
|
this.adaptiveThresholds.hatLayered.minStrength = Math.min(R, a * 0.8), this.adaptiveThresholds.hatLayered.minTrebleRatio = Math.max(0.08, G * 0.8), this.adaptiveThresholds.hatLayered.minSharpness = Math.max(0.3, h * 0.8);
|
|
3728
3729
|
}
|
|
3729
3730
|
}
|
|
@@ -3766,7 +3767,7 @@ class TB {
|
|
|
3766
3767
|
const B = this.bandEnergyHistory[A];
|
|
3767
3768
|
if (B.length < 5)
|
|
3768
3769
|
return 1e-4;
|
|
3769
|
-
const I = B.map((w) => w.value), Q = this.calculateMedian(I), g = this.calculateMAD(I, Q), E = Q + this.bandNoiseMadK * g, C = [...I].sort((w,
|
|
3770
|
+
const I = B.map((w) => w.value), Q = this.calculateMedian(I), g = this.calculateMAD(I, Q), E = Q + this.bandNoiseMadK * g, C = [...I].sort((w, t) => w - t), i = Math.floor(C.length * 0.1), s = C[Math.min(i, C.length - 1)] * 0.8, G = Math.min(E, s), o = Math.max(...I), h = Math.min(G, o * 0.3);
|
|
3770
3771
|
return Math.max(1e-5, h);
|
|
3771
3772
|
}
|
|
3772
3773
|
/**
|
|
@@ -3780,12 +3781,12 @@ class TB {
|
|
|
3780
3781
|
const R = Math.max(I.high.strength, I.highMid.strength), w = Math.min(1, R / 3e3);
|
|
3781
3782
|
if (R > 800 && (E > 1e-4 || I.highMid.energy > a * 0.4) ? o = !0 : w < 0.05 && E < a * 1.5 && (o = !1), !s && !G && !o)
|
|
3782
3783
|
return { kick: !1, snare: !1, hat: !1, any: !1 };
|
|
3783
|
-
const
|
|
3784
|
-
(E > 1e-6 ? g / E : 1) > 0.6 &&
|
|
3784
|
+
const t = A.ratios.bass, c = A.ratios.mid, F = A.ratios.treble;
|
|
3785
|
+
(E > 1e-6 ? g / E : 1) > 0.6 && F < 0.55 && w < 0.45 && (o = !1);
|
|
3785
3786
|
const y = performance.now(), M = y - this.lastKickTime, n = M > 30 && M < 251;
|
|
3786
3787
|
let J = I.low.onset && I.low.strength > 0.12 && // Strong complex phase onset
|
|
3787
|
-
|
|
3788
|
-
!n || I.low.onset && (I.low.isPrimary ?? !0) &&
|
|
3788
|
+
t > 0.35 && // Still bass-dominant
|
|
3789
|
+
!n || I.low.onset && (I.low.isPrimary ?? !0) && t > 0.4 && !n && s && Q > C * 1.02;
|
|
3789
3790
|
if (J && this.lastKickTime > 0) {
|
|
3790
3791
|
const S = B.getState(), W = this.validateKickInterval(
|
|
3791
3792
|
M,
|
|
@@ -3808,11 +3809,11 @@ class TB {
|
|
|
3808
3809
|
const l = J;
|
|
3809
3810
|
if (I.low.onset && !l) {
|
|
3810
3811
|
const S = [];
|
|
3811
|
-
n && S.push("tail"),
|
|
3812
|
+
n && S.push("tail"), t <= 0.4 && S.push("ratio"), Q <= C * 1.02 && S.push("floor"), s || S.push("noEnergy"), this.lastRejections.push({
|
|
3812
3813
|
type: "K",
|
|
3813
3814
|
reason: S.join(","),
|
|
3814
3815
|
values: {
|
|
3815
|
-
bassRatio:
|
|
3816
|
+
bassRatio: t,
|
|
3816
3817
|
lowEnergy: Q,
|
|
3817
3818
|
lowFloor: C,
|
|
3818
3819
|
timeSinceLast: M
|
|
@@ -3822,15 +3823,15 @@ class TB {
|
|
|
3822
3823
|
if (l) {
|
|
3823
3824
|
const S = y - this.lastKickTime;
|
|
3824
3825
|
this.lastKickTime > 0 && (this.kickIntervals.push(Math.round(S)), this.kickIntervals.length > this.MAX_KICK_INTERVALS && this.kickIntervals.shift()), this.lastKickTime = y;
|
|
3825
|
-
const W =
|
|
3826
|
+
const W = t > 0 ? c / t : 0;
|
|
3826
3827
|
this.adaptiveProfiles.kick.samples.push({
|
|
3827
3828
|
midRatio: c,
|
|
3828
3829
|
midToBass: W,
|
|
3829
3830
|
time: y
|
|
3830
3831
|
}), this.adaptiveProfiles.kick.samples.length >= 2 && this.calculateAdaptiveThresholds();
|
|
3831
3832
|
}
|
|
3832
|
-
const Y = M > 200, U = I.mid.onset, Z = I.mid.sharpness ?? 1,
|
|
3833
|
-
|
|
3833
|
+
const Y = M > 200, U = I.mid.onset, Z = I.mid.sharpness ?? 1, H = Y ? this.adaptiveThresholds.snareIndependent.minSharpness : this.adaptiveThresholds.snareLayered.minSharpness, m = l && c < 0.12 && // Mid ratio way too low for a real snare
|
|
3834
|
+
t > 0.7, q = U && I.mid.strength >= 0.18 && I.mid.energy >= 2e-5 && Z > H * 0.6 && !m, r = U && I.mid.strength >= Math.max(0.18, this.adaptiveThresholds.snareIndependent.minStrength * 0.7) && c >= this.adaptiveThresholds.snareIndependent.minMidRatio * 0.7 && Z > H * 0.8 && !m, p = U && G && g > i * 1.05 && Z > H * 0.8 && // Slightly relaxed to reduce misses
|
|
3834
3835
|
!m && // Block kick harmonics
|
|
3835
3836
|
// Mode 0: TRUST ESSENTIA when flux is clear even if ratios are low (prevents midRatio misses)
|
|
3836
3837
|
(q || r || // Mode 1: INDEPENDENT snare (no kick present)
|
|
@@ -3839,7 +3840,7 @@ class TB {
|
|
|
3839
3840
|
(I.mid.strength >= this.adaptiveThresholds.snareIndependent.minStrength && c >= this.adaptiveThresholds.snareIndependent.minMidRatio * 0.9 || // Fallback: strong flux alone (trust Essentia)
|
|
3840
3841
|
I.mid.strength > 0.55) || // Mode 2: LAYERED K+S+H detection
|
|
3841
3842
|
// Use thresholds learned from layered snares (WITH kick context)
|
|
3842
|
-
l && U && I.mid.strength >= this.adaptiveThresholds.snareLayered.minStrength && I.mid.energy >= this.adaptiveThresholds.snareLayered.minEnergy &&
|
|
3843
|
+
l && U && I.mid.strength >= this.adaptiveThresholds.snareLayered.minStrength && I.mid.energy >= this.adaptiveThresholds.snareLayered.minEnergy && t > 0.55);
|
|
3843
3844
|
if (p) {
|
|
3844
3845
|
const S = M <= 80, W = I.mid.sharpness ?? 1;
|
|
3845
3846
|
W > 0.25 && I.mid.strength > 0.3 && c > 0.1 && (S ? this.adaptiveProfiles.snareLayered.samples.push({
|
|
@@ -3851,7 +3852,7 @@ class TB {
|
|
|
3851
3852
|
}) : this.adaptiveProfiles.snareIndependent.samples.push({
|
|
3852
3853
|
strength: I.mid.strength,
|
|
3853
3854
|
midRatio: c,
|
|
3854
|
-
trebleRatio:
|
|
3855
|
+
trebleRatio: F,
|
|
3855
3856
|
sharpness: W,
|
|
3856
3857
|
time: y
|
|
3857
3858
|
}), (this.adaptiveProfiles.snareIndependent.samples.length >= 2 || this.adaptiveProfiles.snareLayered.samples.length >= 2) && this.calculateAdaptiveThresholds());
|
|
@@ -3915,12 +3916,12 @@ class TB {
|
|
|
3915
3916
|
this.recentOnsetStrengths.push(C), this.recentOnsetStrengths.length > this.STRENGTH_HISTORY_SIZE && this.recentOnsetStrengths.shift(), this.recentOnsetStrengths.length > 5 && (this.averageOnsetStrength = this.recentOnsetStrengths.reduce((G, o) => G + o, 0) / this.recentOnsetStrengths.length);
|
|
3916
3917
|
const i = B.low.energy + B.lowMid.energy + B.mid.energy + B.highMid.energy + B.high.energy, a = Math.max(0.01, this.averageOnsetStrength * 0.3);
|
|
3917
3918
|
if (i > a) {
|
|
3918
|
-
const G = (B.low.energy + B.lowMid.energy * 0.5) / i, o = (B.lowMid.energy * 0.5 + B.mid.energy + B.highMid.energy * 0.3) / i, h = (B.highMid.energy * 0.7 + B.high.energy) / i, R = this.profileSimilarity(G, o, h, this.kickProfile), w = this.profileSimilarity(G, o, h, this.snareProfile),
|
|
3919
|
-
B.low.onset && R >
|
|
3919
|
+
const G = (B.low.energy + B.lowMid.energy * 0.5) / i, o = (B.lowMid.energy * 0.5 + B.mid.energy + B.highMid.energy * 0.3) / i, h = (B.highMid.energy * 0.7 + B.high.energy) / i, R = this.profileSimilarity(G, o, h, this.kickProfile), w = this.profileSimilarity(G, o, h, this.snareProfile), t = this.profileSimilarity(G, o, h, this.hatProfile), c = Math.max(0.7, Math.min(1.3, C / Math.max(0.1, this.averageOnsetStrength))), F = 0.35 / c, e = 0.3 / c, y = 0.25 / c;
|
|
3920
|
+
B.low.onset && R > F && G > 0.25 && (Q = !0, this.lastKickTime = performance.now());
|
|
3920
3921
|
const M = performance.now() - this.lastKickTime, n = M < 20, k = !Q && B.mid.onset && !B.low.onset, J = M < 20, l = n && (Q && Math.abs(o - this.kickProfile.midRatio) < 0.15 || // Simultaneous with profile match
|
|
3921
3922
|
k && J || // Very close (<20ms) - always suppress
|
|
3922
3923
|
k && G < 0.3);
|
|
3923
|
-
(B.mid.onset || B.low.onset && B.mid.onset) && w > e && o > 0.18 && (l || (g = !0)), (B.high.onset || B.highMid.onset) &&
|
|
3924
|
+
(B.mid.onset || B.low.onset && B.mid.onset) && w > e && o > 0.18 && (l || (g = !0)), (B.high.onset || B.highMid.onset) && t > y && h > 0.15 && !Q && !g && (E = !0), Q && g && (B.low.strength > B.mid.strength * 2.5 ? (this.debugMode, g = !1) : B.mid.strength > B.low.strength * 2.5 && (this.debugMode, Q = !1)), Q && E && B.low.strength > B.high.strength * 3 && (this.debugMode, E = !1), !B.low.isPrimary && Q && (this.debugMode, Q = !1), !B.mid.isPrimary && g && (this.debugMode, g = !1), !B.high.isPrimary && !B.highMid.isPrimary && E && (this.debugMode, E = !1);
|
|
3924
3925
|
}
|
|
3925
3926
|
const s = Q || g || E;
|
|
3926
3927
|
return (Q || g || E) && this.debugMode && (I.filter((G) => B[G]?.isPrimary), I.filter((G) => !B[G]?.isPrimary), I.map((G) => `${G}=${(B[G]?.sharpness ?? 0).toFixed(2)}`).join(", ")), { kick: Q, snare: g, hat: E, any: s };
|
|
@@ -3981,7 +3982,7 @@ class TB {
|
|
|
3981
3982
|
return 0;
|
|
3982
3983
|
let B = 0;
|
|
3983
3984
|
if (B += this.tempoMethodAgreement * 0.3, B += this.gridScore * 0.3, B += this.consistencyScore * 0.2, B += this.anchorClarity * 0.2, this.state === "BREAKDOWN") {
|
|
3984
|
-
const I = performance.now() - this.stateEnteredTime, Q = Math.max(0.3, 1 - I /
|
|
3985
|
+
const I = performance.now() - this.stateEnteredTime, Q = Math.max(0.3, 1 - I / bA);
|
|
3985
3986
|
B *= Q;
|
|
3986
3987
|
}
|
|
3987
3988
|
return Math.min(1, B);
|
|
@@ -4003,7 +4004,7 @@ class TB {
|
|
|
4003
4004
|
B += 0.2 * (1 - I);
|
|
4004
4005
|
}
|
|
4005
4006
|
if (B += this.gridScore * 0.1, this.state === "BREAKDOWN") {
|
|
4006
|
-
const I = performance.now() - this.stateEnteredTime, Q = Math.max(0.3, 1 - I /
|
|
4007
|
+
const I = performance.now() - this.stateEnteredTime, Q = Math.max(0.3, 1 - I / bA);
|
|
4007
4008
|
B *= Q;
|
|
4008
4009
|
}
|
|
4009
4010
|
return this.state === "LOCKED" ? B = Math.max(B, 0.7) : this.state === "TRACKING" && A.confidence > 0.6 && (B = Math.max(B, 0.5)), Math.min(1, B);
|
|
@@ -4300,15 +4301,15 @@ class _B {
|
|
|
4300
4301
|
B.kick && (c += "K"), B.snare && (c += "S"), B.hat && (c += "H"), R.d = c;
|
|
4301
4302
|
}
|
|
4302
4303
|
G && Q.length > 0 && (R.x = Q.map((c) => {
|
|
4303
|
-
const
|
|
4304
|
-
return `${c.type}:${c.reason}${
|
|
4304
|
+
const F = Object.entries(c.values).filter(([e, y]) => !e.includes("time")).map(([e, y]) => `${e.slice(0, 3)}=${y.toFixed(2)}`).join(",");
|
|
4305
|
+
return `${c.type}:${c.reason}${F ? `(${F})` : ""}`;
|
|
4305
4306
|
}).join(";"));
|
|
4306
|
-
const
|
|
4307
|
-
if (h &&
|
|
4307
|
+
const t = [];
|
|
4308
|
+
if (h && t.push(`bar:${this.lastBar}→${B.bar}:JUMP`), o && t.push(`bpm:${this.lastBPM.toFixed(0)}→${B.bpm.toFixed(0)}`), t.length > 0 && (R.ch = t.join(";")), g && (s || G || o || h)) {
|
|
4308
4309
|
if (g.pllGain !== void 0 && Math.abs(g.pllGain - this.lastPllGain) > 0.1 && (R.pllG = parseFloat(g.pllGain.toFixed(2)), this.lastPllGain = g.pllGain), g.tempoConf !== void 0 && Math.abs(g.tempoConf - this.lastTempoConf) > 0.1 && (R.tConf = parseFloat(g.tempoConf.toFixed(2)), this.lastTempoConf = g.tempoConf), g.trackingConf !== void 0 && Math.abs(g.trackingConf - this.lastTrackingConf) > 0.1 && (R.trConf = parseFloat(g.trackingConf.toFixed(2)), this.lastTrackingConf = g.trackingConf), g.timeSinceKick !== void 0 && (B.kick || Q?.some((c) => c.type === "K")) && (R.kickΔ = Math.round(g.timeSinceKick), R.expΔ = Math.round(6e4 / B.bpm)), g.phaseError !== void 0 && (h || Math.abs(g.phaseError) > 0.15) && (R.pErr = parseFloat(g.phaseError.toFixed(2))), g.adaptiveFloors) {
|
|
4309
4310
|
const c = {};
|
|
4310
|
-
let
|
|
4311
|
-
g.adaptiveFloors.low !== void 0 && Math.abs(g.adaptiveFloors.low - this.lastLowFloor) / Math.max(this.lastLowFloor, 1e-6) > 0.5 && (c.l = g.adaptiveFloors.low, this.lastLowFloor = g.adaptiveFloors.low,
|
|
4311
|
+
let F = !1;
|
|
4312
|
+
g.adaptiveFloors.low !== void 0 && Math.abs(g.adaptiveFloors.low - this.lastLowFloor) / Math.max(this.lastLowFloor, 1e-6) > 0.5 && (c.l = g.adaptiveFloors.low, this.lastLowFloor = g.adaptiveFloors.low, F = !0), g.adaptiveFloors.mid !== void 0 && Math.abs(g.adaptiveFloors.mid - this.lastMidFloor) / Math.max(this.lastMidFloor, 1e-6) > 0.5 && (c.m = g.adaptiveFloors.mid, this.lastMidFloor = g.adaptiveFloors.mid, F = !0), g.adaptiveFloors.high !== void 0 && Math.abs(g.adaptiveFloors.high - this.lastHighFloor) / Math.max(this.lastHighFloor, 1e-6) > 0.5 && (c.h = g.adaptiveFloors.high, this.lastHighFloor = g.adaptiveFloors.high, F = !0), F && (R.fl = c);
|
|
4312
4313
|
}
|
|
4313
4314
|
g.kickPattern && (B.kick || Q?.some((c) => c.type === "K")) && (R.kPat = g.kickPattern), g.kickPhase !== void 0 && B.kick && (R.kφ = parseFloat(g.kickPhase.toFixed(2))), g.compressed && (R.cmp = !0), g.bpmVariance !== void 0 && (o || g.bpmVariance > 5) && (R.bVar = parseFloat(g.bpmVariance.toFixed(1)));
|
|
4314
4315
|
}
|
|
@@ -4430,7 +4431,7 @@ Rejection rate: ${(I / A * 60).toFixed(1)} per minute
|
|
|
4430
4431
|
return this.events.length;
|
|
4431
4432
|
}
|
|
4432
4433
|
}
|
|
4433
|
-
const wA = ["kick", "snare", "hat"],
|
|
4434
|
+
const wA = ["kick", "snare", "hat"], fA = 60, vA = 5e3, $B = 500, AI = 8, cA = 0.18, oA = 3, BI = 3e3, II = 100, QI = 64, gI = 0.05, EI = 0.15, DA = 1;
|
|
4434
4435
|
function ZA() {
|
|
4435
4436
|
return {
|
|
4436
4437
|
mode: "auto",
|
|
@@ -4444,14 +4445,14 @@ function ZA() {
|
|
|
4444
4445
|
replayLastEventTime: 0,
|
|
4445
4446
|
replayIndex: 0,
|
|
4446
4447
|
pendingTapEvents: [],
|
|
4447
|
-
envelope: new
|
|
4448
|
-
envelopeSmoothed: new
|
|
4448
|
+
envelope: new b(0, 300, fA),
|
|
4449
|
+
envelopeSmoothed: new b(5, 500, fA),
|
|
4449
4450
|
sessionActive: !1,
|
|
4450
4451
|
sessionEndTimer: null,
|
|
4451
4452
|
tapTimeoutTimer: null
|
|
4452
4453
|
};
|
|
4453
4454
|
}
|
|
4454
|
-
class
|
|
4455
|
+
class CB {
|
|
4455
4456
|
state = {
|
|
4456
4457
|
kick: ZA(),
|
|
4457
4458
|
snare: ZA(),
|
|
@@ -4657,7 +4658,7 @@ class iB {
|
|
|
4657
4658
|
continue;
|
|
4658
4659
|
}
|
|
4659
4660
|
if (Q.events = Q.events.filter((o) => o.type !== i), a.mode === "tapping") {
|
|
4660
|
-
if (B - a.lastTapTime >
|
|
4661
|
+
if (B - a.lastTapTime > vA) {
|
|
4661
4662
|
a.tapIOIs = [], a.pendingTapEvents = [], a.pattern ? (this.setMode(i, "pattern"), a.replayLastEventTime = B, a.replayIndex = 0) : this.setMode(i, "auto");
|
|
4662
4663
|
continue;
|
|
4663
4664
|
}
|
|
@@ -4739,7 +4740,7 @@ class iB {
|
|
|
4739
4740
|
*/
|
|
4740
4741
|
scheduleSessionTimers(A) {
|
|
4741
4742
|
const B = this.state[A];
|
|
4742
|
-
this.cancelSessionTimers(B), B.sessionEndTimer = setTimeout(() => this.onSessionEndTimer(A), $B), B.tapTimeoutTimer = setTimeout(() => this.onTapTimeoutTimer(A),
|
|
4743
|
+
this.cancelSessionTimers(B), B.sessionEndTimer = setTimeout(() => this.onSessionEndTimer(A), $B), B.tapTimeoutTimer = setTimeout(() => this.onTapTimeoutTimer(A), vA);
|
|
4743
4744
|
}
|
|
4744
4745
|
cancelSessionTimers(A) {
|
|
4745
4746
|
A.sessionEndTimer !== null && (clearTimeout(A.sessionEndTimer), A.sessionEndTimer = null), A.tapTimeoutTimer !== null && (clearTimeout(A.tapTimeoutTimer), A.tapTimeoutTimer = null);
|
|
@@ -5057,8 +5058,8 @@ j.prototype._transform4 = function() {
|
|
|
5057
5058
|
var G = g >>> 2;
|
|
5058
5059
|
for (E = 0; E < B; E += g)
|
|
5059
5060
|
for (var o = E + G, h = E, R = 0; h < o; h += 2, R += Q) {
|
|
5060
|
-
const w = h,
|
|
5061
|
-
A[w] = $, A[w + 1] = RA, A[
|
|
5061
|
+
const w = h, t = w + G, c = t + G, F = c + G, e = A[w], y = A[w + 1], M = A[t], n = A[t + 1], k = A[c], J = A[c + 1], l = A[F], Y = A[F + 1], U = e, Z = y, H = s[R], m = a * s[R + 1], q = M * H - n * m, r = M * m + n * H, p = s[2 * R], P = a * s[2 * R + 1], X = k * p - J * P, x = k * P + J * p, T = s[3 * R], u = a * s[3 * R + 1], _ = l * T - Y * u, K = l * u + Y * T, z = U + X, f = Z + x, N = U - X, L = Z - x, V = q + _, S = r + K, W = a * (q - _), v = a * (r - K), $ = z + V, RA = f + S, lA = z - V, nA = f - S, dA = N + v, JA = L - W, YA = N - v, UA = L + W;
|
|
5062
|
+
A[w] = $, A[w + 1] = RA, A[t] = dA, A[t + 1] = JA, A[c] = lA, A[c + 1] = nA, A[F] = YA, A[F + 1] = UA;
|
|
5062
5063
|
}
|
|
5063
5064
|
}
|
|
5064
5065
|
};
|
|
@@ -5067,8 +5068,8 @@ j.prototype._singleTransform2 = function(A, B, I) {
|
|
|
5067
5068
|
Q[A] = s, Q[A + 1] = G, Q[A + 2] = o, Q[A + 3] = h;
|
|
5068
5069
|
};
|
|
5069
5070
|
j.prototype._singleTransform4 = function(A, B, I) {
|
|
5070
|
-
const Q = this._out, g = this._data, E = this._inv ? -1 : 1, C = I * 2, i = I * 3, a = g[B], s = g[B + 1], G = g[B + I], o = g[B + I + 1], h = g[B + C], R = g[B + C + 1], w = g[B + i],
|
|
5071
|
-
Q[A] = l, Q[A + 1] = Y, Q[A + 2] = U, Q[A + 3] = Z, Q[A + 4] =
|
|
5071
|
+
const Q = this._out, g = this._data, E = this._inv ? -1 : 1, C = I * 2, i = I * 3, a = g[B], s = g[B + 1], G = g[B + I], o = g[B + I + 1], h = g[B + C], R = g[B + C + 1], w = g[B + i], t = g[B + i + 1], c = a + h, F = s + R, e = a - h, y = s - R, M = G + w, n = o + t, k = E * (G - w), J = E * (o - t), l = c + M, Y = F + n, U = e + J, Z = y - k, H = c - M, m = F - n, q = e - J, r = y + k;
|
|
5072
|
+
Q[A] = l, Q[A + 1] = Y, Q[A + 2] = U, Q[A + 3] = Z, Q[A + 4] = H, Q[A + 5] = m, Q[A + 6] = q, Q[A + 7] = r;
|
|
5072
5073
|
};
|
|
5073
5074
|
j.prototype._realTransform4 = function() {
|
|
5074
5075
|
var A = this._out, B = this._csize, I = this._width, Q = 1 << I, g = B / Q << 1, E, C, i = this._bitrev;
|
|
@@ -5088,15 +5089,15 @@ j.prototype._realTransform4 = function() {
|
|
|
5088
5089
|
var G = g >>> 1, o = G >>> 1, h = o >>> 1;
|
|
5089
5090
|
for (E = 0; E < B; E += g)
|
|
5090
5091
|
for (var R = 0, w = 0; R <= h; R += 2, w += Q) {
|
|
5091
|
-
var
|
|
5092
|
-
if (A[
|
|
5092
|
+
var t = E + R, c = t + o, F = c + o, e = F + o, y = A[t], M = A[t + 1], n = A[c], k = A[c + 1], J = A[F], l = A[F + 1], Y = A[e], U = A[e + 1], Z = y, H = M, m = s[w], q = a * s[w + 1], r = n * m - k * q, p = n * q + k * m, P = s[2 * w], X = a * s[2 * w + 1], x = J * P - l * X, T = J * X + l * P, u = s[3 * w], _ = a * s[3 * w + 1], K = Y * u - U * _, z = Y * _ + U * u, f = Z + x, N = H + T, L = Z - x, V = H - T, S = r + K, W = p + z, v = a * (r - K), $ = a * (p - z), RA = f + S, lA = N + W, nA = L + $, dA = V - v;
|
|
5093
|
+
if (A[t] = RA, A[t + 1] = lA, A[c] = nA, A[c + 1] = dA, R === 0) {
|
|
5093
5094
|
var JA = f - S, YA = N - W;
|
|
5094
|
-
A[
|
|
5095
|
+
A[F] = JA, A[F + 1] = YA;
|
|
5095
5096
|
continue;
|
|
5096
5097
|
}
|
|
5097
5098
|
if (R !== h) {
|
|
5098
|
-
var UA = L,
|
|
5099
|
-
A[
|
|
5099
|
+
var UA = L, GB = -V, aB = f, oB = -N, DB = -a * $, hB = -a * v, sB = -a * W, RB = -a * S, wB = UA + DB, cB = GB + hB, FB = aB + RB, tB = oB - sB, rA = E + o - R, qA = E + G - R;
|
|
5100
|
+
A[rA] = wB, A[rA + 1] = cB, A[qA] = FB, A[qA + 1] = tB;
|
|
5100
5101
|
}
|
|
5101
5102
|
}
|
|
5102
5103
|
}
|
|
@@ -5106,8 +5107,8 @@ j.prototype._singleRealTransform2 = function(A, B, I) {
|
|
|
5106
5107
|
Q[A] = i, Q[A + 1] = 0, Q[A + 2] = a, Q[A + 3] = 0;
|
|
5107
5108
|
};
|
|
5108
5109
|
j.prototype._singleRealTransform4 = function(A, B, I) {
|
|
5109
|
-
const Q = this._out, g = this._data, E = this._inv ? -1 : 1, C = I * 2, i = I * 3, a = g[B], s = g[B + I], G = g[B + C], o = g[B + i], h = a + G, R = a - G, w = s + o,
|
|
5110
|
-
Q[A] = c, Q[A + 1] = 0, Q[A + 2] =
|
|
5110
|
+
const Q = this._out, g = this._data, E = this._inv ? -1 : 1, C = I * 2, i = I * 3, a = g[B], s = g[B + I], G = g[B + C], o = g[B + i], h = a + G, R = a - G, w = s + o, t = E * (s - o), c = h + w, F = R, e = -t, y = h - w, M = R, n = t;
|
|
5111
|
+
Q[A] = c, Q[A + 1] = 0, Q[A + 2] = F, Q[A + 3] = e, Q[A + 4] = y, Q[A + 5] = 0, Q[A + 6] = M, Q[A + 7] = n;
|
|
5111
5112
|
};
|
|
5112
5113
|
const GI = /* @__PURE__ */ CI(iI);
|
|
5113
5114
|
class CA {
|
|
@@ -5186,12 +5187,12 @@ class CA {
|
|
|
5186
5187
|
};
|
|
5187
5188
|
const I = 60;
|
|
5188
5189
|
this.envelopeFollowers = {
|
|
5189
|
-
volumeSmoothed: new
|
|
5190
|
-
lowSmoothed: new
|
|
5191
|
-
lowMidSmoothed: new
|
|
5192
|
-
midSmoothed: new
|
|
5193
|
-
highMidSmoothed: new
|
|
5194
|
-
highSmoothed: new
|
|
5190
|
+
volumeSmoothed: new b(50, 200, I),
|
|
5191
|
+
lowSmoothed: new b(20, 150, I),
|
|
5192
|
+
lowMidSmoothed: new b(20, 150, I),
|
|
5193
|
+
midSmoothed: new b(20, 150, I),
|
|
5194
|
+
highMidSmoothed: new b(20, 150, I),
|
|
5195
|
+
highSmoothed: new b(20, 150, I)
|
|
5195
5196
|
}, this.refreshFFTResources();
|
|
5196
5197
|
}
|
|
5197
5198
|
static create(A, B = 2048) {
|
|
@@ -5222,7 +5223,7 @@ class CA {
|
|
|
5222
5223
|
this.disconnectNodes(), this.frequencyData = null, this.timeDomainData = null, this.fftMagnitude = null, this.fftMagnitudeDb = null, this.fftPhase = null, this.fftEngine = null, this.fftInput = null, this.fftOutput = null, this.hannWindow = null, this.lastWaveformFrame = null, this.currentStream = null, this.isAnalysisRunning = !1, this.audioState.isConnected = !1, this.resetValues();
|
|
5223
5224
|
}
|
|
5224
5225
|
}
|
|
5225
|
-
class
|
|
5226
|
+
class tA {
|
|
5226
5227
|
// Shared AudioContext (one for all channels)
|
|
5227
5228
|
audioContext = null;
|
|
5228
5229
|
workletRegistered = !1;
|
|
@@ -5392,12 +5393,12 @@ class FA {
|
|
|
5392
5393
|
timeSinceKick: this.stateManager.getTimeSinceLastKick(),
|
|
5393
5394
|
phaseError: this.pll.getLastPhaseError(),
|
|
5394
5395
|
adaptiveFloors: this.stateManager.getAdaptiveFloors()
|
|
5395
|
-
},
|
|
5396
|
-
|
|
5396
|
+
}, t = this.stateManager.getKickPattern();
|
|
5397
|
+
t !== void 0 && (w.kickPattern = t);
|
|
5397
5398
|
const c = this.stateManager.getBPMVariance();
|
|
5398
5399
|
c !== void 0 && (w.bpmVariance = c);
|
|
5399
|
-
const
|
|
5400
|
-
|
|
5400
|
+
const F = this.stateManager.isCompressed();
|
|
5401
|
+
F && (w.compressed = F), C.events.some((e) => e.type === "kick") && (w.kickPhase = h.phase), C.debug?.pllGain !== void 0 && (w.pllGain = C.debug.pllGain), C.debug?.tempoConfidence !== void 0 && (w.tempoConf = C.debug.tempoConfidence), C.debug?.trackingConfidence !== void 0 && (w.trackingConf = C.debug.trackingConfidence), this.diagnosticLogger.logFrame(
|
|
5401
5402
|
I,
|
|
5402
5403
|
{
|
|
5403
5404
|
bpm: C.bpm,
|
|
@@ -5494,11 +5495,11 @@ class FA {
|
|
|
5494
5495
|
let R = 0, w = 0;
|
|
5495
5496
|
for (let n = o; n <= h; n++)
|
|
5496
5497
|
R += B[n], w++;
|
|
5497
|
-
const
|
|
5498
|
+
const t = w > 0 ? R / w : 0, c = Q > 0 ? Math.min(1, t / Q) : 0;
|
|
5498
5499
|
a[s] = c;
|
|
5499
|
-
const e = (A.bandNoiseFloor[s] ?? 1e-4) * 0.995 +
|
|
5500
|
+
const e = (A.bandNoiseFloor[s] ?? 1e-4) * 0.995 + t * 5e-3;
|
|
5500
5501
|
A.bandNoiseFloor[s] = e;
|
|
5501
|
-
const y = Math.max(0,
|
|
5502
|
+
const y = Math.max(0, t - e * 1.5), M = Q > 0 ? Math.min(1, y / Q) : 0;
|
|
5502
5503
|
i[s] = M;
|
|
5503
5504
|
}
|
|
5504
5505
|
return A.audioState.bands = {
|
|
@@ -5545,17 +5546,17 @@ class FA {
|
|
|
5545
5546
|
let g;
|
|
5546
5547
|
const E = (this.essentiaOnsetDetection?.isReady() || !1) && !!this.mainChannel.fftMagnitudeDb && !!this.mainChannel.fftPhase, C = !!(this.mainChannel.fftMagnitudeDb && this.mainChannel.fftPhase);
|
|
5547
5548
|
if (E && C) {
|
|
5548
|
-
const
|
|
5549
|
+
const F = this.essentiaOnsetDetection.detectFromSpectrum(
|
|
5549
5550
|
this.mainChannel.fftMagnitudeDb,
|
|
5550
5551
|
this.mainChannel.fftPhase,
|
|
5551
5552
|
Q
|
|
5552
5553
|
// DO NOT pass normalized bands - causes false snare detections on kicks
|
|
5553
5554
|
// Essentia should compute its own bands from spectrum for accurate ratios
|
|
5554
|
-
), e = Math.max(0, Math.min(1,
|
|
5555
|
-
this.updateEssentiaBandHistories(
|
|
5556
|
-
global: { onset:
|
|
5557
|
-
bands:
|
|
5558
|
-
ratios:
|
|
5555
|
+
), e = Math.max(0, Math.min(1, F.strength));
|
|
5556
|
+
this.updateEssentiaBandHistories(F, I), g = {
|
|
5557
|
+
global: { onset: F.onset, strength: e },
|
|
5558
|
+
bands: F.bands,
|
|
5559
|
+
ratios: F.ratios,
|
|
5559
5560
|
// 🔥 Pass Essentia's pre-computed ratios from raw spectrum
|
|
5560
5561
|
getBandHistory: (y) => this.getEssentiaBandHistory(y),
|
|
5561
5562
|
getAllHistories: () => this.getEssentiaAllHistories()
|
|
@@ -5568,22 +5569,22 @@ class FA {
|
|
|
5568
5569
|
this.pll.update(s, G, i.bpm, I, a, i.inTransition);
|
|
5569
5570
|
const o = this.stateManager.update(g, i, this.pll, B);
|
|
5570
5571
|
if (this.debugMode && g.global.onset) {
|
|
5571
|
-
const
|
|
5572
|
+
const F = this.pll.getState(), e = [];
|
|
5572
5573
|
g.bands.low.onset && e.push("L"), g.bands.lowMid.onset && e.push("LM"), g.bands.mid.onset && e.push("M"), g.bands.highMid.onset && e.push("HM"), g.bands.high.onset && e.push("H");
|
|
5573
5574
|
const y = [];
|
|
5574
5575
|
o.events.some((M) => M.type === "kick" && Math.abs(M.time - I) < 50) && y.push("K"), o.events.some((M) => M.type === "snare" && Math.abs(M.time - I) < 50) && y.push("S"), o.events.some((M) => M.type === "hat" && Math.abs(M.time - I) < 50) && y.push("H"), this.onsetLogBuffer.push({
|
|
5575
5576
|
time: I,
|
|
5576
5577
|
type: y.join("+") || "onset",
|
|
5577
|
-
phase:
|
|
5578
|
-
bar:
|
|
5578
|
+
phase: F.phase,
|
|
5579
|
+
bar: F.bar,
|
|
5579
5580
|
bands: e,
|
|
5580
5581
|
strength: g.global.strength
|
|
5581
5582
|
}), this.onsetLogBuffer.length > 20 && this.onsetLogBuffer.shift();
|
|
5582
5583
|
}
|
|
5583
5584
|
if (this.debugMode && I - this.lastPhaseLogTime > 2e3) {
|
|
5584
|
-
const
|
|
5585
|
+
const F = this.pll.getState(), e = this.stateManager.getState();
|
|
5585
5586
|
console.log(`
|
|
5586
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`), console.log(`🎯 [TEMPO/PHASE/BAR] t=${(I / 1e3).toFixed(1)}s`), console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"), console.log("📊 BPM Status:"), console.log(` Final: ${o.bpm.toFixed(1)} BPM (source: ${this.lastBpmSource})`), console.log(` PLL: ${
|
|
5587
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`), console.log(`🎯 [TEMPO/PHASE/BAR] t=${(I / 1e3).toFixed(1)}s`), console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"), console.log("📊 BPM Status:"), console.log(` Final: ${o.bpm.toFixed(1)} BPM (source: ${this.lastBpmSource})`), console.log(` PLL: ${F.bpm.toFixed(1)} BPM`), console.log(` Tempo: ${i.bpm.toFixed(1)} BPM (conf=${i.confidence.toFixed(2)}, method=${i.method})`), console.log(` Agree: ${i.methodAgreement.toFixed(2)} | Anchor: ${i.anchorBand || "none"}`), console.log("📍 Phase & Bar:"), console.log(` Phase: ${F.phase.toFixed(3)} (${(F.phase * 100).toFixed(0)}% through beat)`), console.log(` Bar: ${F.bar + 1}/4`), console.log(` Drift: ${F.driftRate.toFixed(3)}`), console.log("🎚️ State:"), console.log(` State: ${e}`), console.log(` Locked: ${o.isLocked}`), console.log(` Conf: ${o.confidence.toFixed(2)}`), this.onsetLogBuffer.length > 0 ? (console.log(`🎵 Recent Onsets (last ${Math.min(10, this.onsetLogBuffer.length)}):`), this.onsetLogBuffer.slice(-10).forEach((M, n) => {
|
|
5587
5588
|
const k = ((M.time - I) / 1e3).toFixed(2), J = `φ=${M.phase.toFixed(2)}`, l = `bar=${M.bar + 1}`;
|
|
5588
5589
|
console.log(` ${n + 1}. t=${k}s | ${M.type.padEnd(5)} | ${J} | ${l} | [${M.bands.join(",")}] | str=${M.strength.toFixed(2)}`);
|
|
5589
5590
|
})) : console.log("🎵 Recent Onsets: none detected"), console.log(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
@@ -5594,10 +5595,10 @@ class FA {
|
|
|
5594
5595
|
{ value: i.bpm, source: "tempo" },
|
|
5595
5596
|
{ value: this.lastNonZeroBpm, source: "carry" },
|
|
5596
5597
|
{ value: 120, source: "default" }
|
|
5597
|
-
].find((
|
|
5598
|
-
this.lastNonZeroBpm = w, this.lastBpmSource = R.source, this.debugMode &&
|
|
5598
|
+
].find((F) => Number.isFinite(F.value) && F.value > 0) ?? { value: 120, source: "default" }, w = R.value, t = this.lastBpmSource;
|
|
5599
|
+
this.lastNonZeroBpm = w, this.lastBpmSource = R.source, this.debugMode && t !== this.lastBpmSource && console.log(`[AudioSystem][bpm] Source changed: ${t} -> ${this.lastBpmSource} (resolved=${w.toFixed(2)}, pll=${o.bpm?.toFixed?.(2) ?? o.bpm}, tempo=${i.bpm?.toFixed?.(2) ?? i.bpm})`);
|
|
5599
5600
|
const c = o.bpm === w ? o : { ...o, bpm: w };
|
|
5600
|
-
return this.lastKickDetected = c.events.some((
|
|
5601
|
+
return this.lastKickDetected = c.events.some((F) => F.type === "kick") || G, c;
|
|
5601
5602
|
}
|
|
5602
5603
|
/**
|
|
5603
5604
|
* Debug logging helper
|
|
@@ -5636,17 +5637,17 @@ class FA {
|
|
|
5636
5637
|
// recorded on addStream and replayed before the cached analysis on attach.
|
|
5637
5638
|
channelMeta = /* @__PURE__ */ new Map();
|
|
5638
5639
|
constructor(A) {
|
|
5639
|
-
this.handleAudioStreamUpdate = this.handleAudioStreamUpdate.bind(this), this.performAnalysis = this.performAnalysis.bind(this), A && this.analysisSinks.set("__constructor", A), this.mainChannel = CA.create(0, this.fftSize), this.onsetDetection = new
|
|
5640
|
+
this.handleAudioStreamUpdate = this.handleAudioStreamUpdate.bind(this), this.performAnalysis = this.performAnalysis.bind(this), A && this.analysisSinks.set("__constructor", A), this.mainChannel = CA.create(0, this.fftSize), this.onsetDetection = new bB(), this.essentiaOnsetDetection = new LB(), this.initializeEssentia(), this.tempoInduction = new qB(), this.pll = new OB(), this.stateManager = new TB(), this.onsetTapManager = new CB();
|
|
5640
5641
|
const B = 60;
|
|
5641
5642
|
this.beatEnvelopeFollowers = {
|
|
5642
|
-
kick: new
|
|
5643
|
-
snare: new
|
|
5644
|
-
hat: new
|
|
5645
|
-
any: new
|
|
5646
|
-
kickSmoothed: new
|
|
5647
|
-
snareSmoothed: new
|
|
5648
|
-
hatSmoothed: new
|
|
5649
|
-
anySmoothed: new
|
|
5643
|
+
kick: new b(0, 300, B),
|
|
5644
|
+
snare: new b(0, 300, B),
|
|
5645
|
+
hat: new b(0, 300, B),
|
|
5646
|
+
any: new b(0, 300, B),
|
|
5647
|
+
kickSmoothed: new b(5, 500, B),
|
|
5648
|
+
snareSmoothed: new b(5, 500, B),
|
|
5649
|
+
hatSmoothed: new b(5, 500, B),
|
|
5650
|
+
anySmoothed: new b(5, 500, B)
|
|
5650
5651
|
}, this.resetEssentiaBandHistories(), this.tickIdle = this.tickIdle.bind(this), this.startIdleTicker();
|
|
5651
5652
|
}
|
|
5652
5653
|
/**
|
|
@@ -5853,9 +5854,9 @@ class FA {
|
|
|
5853
5854
|
startStalenessTimer() {
|
|
5854
5855
|
this.stalenessTimer === null && (this.stalenessTimer = setInterval(() => {
|
|
5855
5856
|
const A = performance.now();
|
|
5856
|
-
this.mainChannel.audioState.isConnected && this.mainChannel.lastFrameTime > 0 && A - this.mainChannel.lastFrameTime >
|
|
5857
|
+
this.mainChannel.audioState.isConnected && this.mainChannel.lastFrameTime > 0 && A - this.mainChannel.lastFrameTime > tA.STALENESS_THRESHOLD_MS && (this.resetAudioValues(), this.sendChannelResults(this.mainChannel, !0));
|
|
5857
5858
|
for (const B of this.additionalChannels.values())
|
|
5858
|
-
B.audioState.isConnected && B.lastFrameTime > 0 && A - B.lastFrameTime >
|
|
5859
|
+
B.audioState.isConnected && B.lastFrameTime > 0 && A - B.lastFrameTime > tA.STALENESS_THRESHOLD_MS && (B.resetValues(), this.sourceFedIndices.has(B.streamIndex) && (B.audioState.isConnected = !1), this.sendChannelResults(B, !1));
|
|
5859
5860
|
}, 250));
|
|
5860
5861
|
}
|
|
5861
5862
|
stopStalenessTimer() {
|
|
@@ -6568,7 +6569,7 @@ class aI {
|
|
|
6568
6569
|
this.debugMode && console.log(`[StreamCapture] ${A}`, ...B);
|
|
6569
6570
|
}
|
|
6570
6571
|
}
|
|
6571
|
-
const oI = 0,
|
|
6572
|
+
const oI = 0, jA = 1, eA = 100, yA = 200, PA = 1, TA = 100;
|
|
6572
6573
|
class kA {
|
|
6573
6574
|
constructor(A = null) {
|
|
6574
6575
|
this.cvHooks = A;
|
|
@@ -6621,7 +6622,7 @@ class kA {
|
|
|
6621
6622
|
"STREAM_LIMIT_REACHED"
|
|
6622
6623
|
);
|
|
6623
6624
|
this.additionalStreams.push(A);
|
|
6624
|
-
const I = this.additionalStreams.length - 1, Q = this.makeCapture(
|
|
6625
|
+
const I = this.additionalStreams.length - 1, Q = this.makeCapture(jA + I, {});
|
|
6625
6626
|
return this.additionalCaptures.push(Q), Q.setStream(A), I;
|
|
6626
6627
|
}
|
|
6627
6628
|
removeAdditionalStream(A) {
|
|
@@ -6631,7 +6632,7 @@ class kA {
|
|
|
6631
6632
|
for (const B of this.additionalCaptures) B.destroy();
|
|
6632
6633
|
this.additionalCaptures = [];
|
|
6633
6634
|
for (let B = 0; B < this.additionalStreams.length; B++) {
|
|
6634
|
-
const I = this.makeCapture(
|
|
6635
|
+
const I = this.makeCapture(jA + B, {});
|
|
6635
6636
|
this.additionalCaptures.push(I), I.setStream(this.additionalStreams[B]);
|
|
6636
6637
|
}
|
|
6637
6638
|
}
|
|
@@ -8537,14 +8538,14 @@ function cI() {
|
|
|
8537
8538
|
segmentation: { active: !1, meaningful: !1 }
|
|
8538
8539
|
};
|
|
8539
8540
|
}
|
|
8540
|
-
const
|
|
8541
|
+
const _A = new URL("assets/wasm/vision_wasm_internal.js", import.meta.url).href, $A = new URL("assets/wasm/vision_wasm_internal.wasm", import.meta.url).href, AB = new URL("assets/wasm/vision_wasm_nosimd_internal.js", import.meta.url).href, BB = new URL("assets/wasm/vision_wasm_nosimd_internal.wasm", import.meta.url).href, FA = {
|
|
8541
8542
|
faceDetection: { enable: (D) => D.enableFaceDetection(), disable: (D) => D.disableFaceDetection() },
|
|
8542
8543
|
faceMesh: { enable: (D) => D.enableFaceMesh(), disable: (D) => D.disableFaceMesh() },
|
|
8543
8544
|
emotionDetection: { enable: (D) => D.enableEmotionDetection(), disable: (D) => D.disableEmotionDetection() },
|
|
8544
8545
|
handTracking: { enable: (D) => D.enableHandTracking(), disable: (D) => D.disableHandTracking() },
|
|
8545
8546
|
poseDetection: { enable: (D) => D.enablePoseDetection(), disable: (D) => D.disablePoseDetection() },
|
|
8546
8547
|
bodySegmentation: { enable: (D) => D.enableBodySegmentation(), disable: (D) => D.disableBodySegmentation() }
|
|
8547
|
-
},
|
|
8548
|
+
}, FI = new Set(Object.keys(FA)), tI = 199, IB = 16;
|
|
8548
8549
|
class eI {
|
|
8549
8550
|
streams = /* @__PURE__ */ new Map();
|
|
8550
8551
|
sinks = /* @__PURE__ */ new Map();
|
|
@@ -8579,12 +8580,12 @@ class eI {
|
|
|
8579
8580
|
*/
|
|
8580
8581
|
handleFeatureRequest(A, B, I) {
|
|
8581
8582
|
if (this.disposed) return;
|
|
8582
|
-
if (!Number.isInteger(B) || B < 0 || B >
|
|
8583
|
+
if (!Number.isInteger(B) || B < 0 || B > tI || !Array.isArray(I)) {
|
|
8583
8584
|
this.debugLog(`cv-feature-request rejected (out of bounds): stream ${B}`);
|
|
8584
8585
|
return;
|
|
8585
8586
|
}
|
|
8586
|
-
if (I = I.filter((g) =>
|
|
8587
|
-
this.debugLog(`cv-feature-request rejected (stream cap ${
|
|
8587
|
+
if (I = I.filter((g) => FI.has(g)), !this.streams.has(B) && this.streams.size >= IB) {
|
|
8588
|
+
this.debugLog(`cv-feature-request rejected (stream cap ${IB} reached): stream ${B}`);
|
|
8588
8589
|
return;
|
|
8589
8590
|
}
|
|
8590
8591
|
const Q = this.ensureStream(B);
|
|
@@ -8670,13 +8671,13 @@ class eI {
|
|
|
8670
8671
|
applyWasmAssets(A, B = null) {
|
|
8671
8672
|
this.memoryMode && B ? A.setCVWasmAssets(
|
|
8672
8673
|
{
|
|
8673
|
-
simdLoaderJs:
|
|
8674
|
-
nosimdLoaderJs:
|
|
8674
|
+
simdLoaderJs: _A,
|
|
8675
|
+
nosimdLoaderJs: AB,
|
|
8675
8676
|
simdBinary: "viji-cv-wasm:simd",
|
|
8676
8677
|
nosimdBinary: "viji-cv-wasm:nosimd"
|
|
8677
8678
|
},
|
|
8678
8679
|
B
|
|
8679
|
-
) : A.setCVWasmAssets({ simdLoaderJs:
|
|
8680
|
+
) : A.setCVWasmAssets({ simdLoaderJs: _A, simdBinary: $A, nosimdLoaderJs: AB, nosimdBinary: BB }, null);
|
|
8680
8681
|
}
|
|
8681
8682
|
fetchBinaries() {
|
|
8682
8683
|
if (!this.binariesPromise) {
|
|
@@ -8685,7 +8686,7 @@ class eI {
|
|
|
8685
8686
|
if (!I.ok) throw new Error(`WASM fetch failed: ${I.status} ${B}`);
|
|
8686
8687
|
return I.arrayBuffer();
|
|
8687
8688
|
};
|
|
8688
|
-
this.binariesPromise = Promise.all([A(
|
|
8689
|
+
this.binariesPromise = Promise.all([A($A), A(BB)]).then(([B, I]) => ({ simdBinary: B, nosimdBinary: I }));
|
|
8689
8690
|
}
|
|
8690
8691
|
return this.binariesPromise;
|
|
8691
8692
|
}
|
|
@@ -8706,13 +8707,13 @@ class eI {
|
|
|
8706
8707
|
const Q = [...I].filter((E) => !B.applied.has(E)), g = [...B.applied].filter((E) => !I.has(E));
|
|
8707
8708
|
for (const E of g)
|
|
8708
8709
|
try {
|
|
8709
|
-
await
|
|
8710
|
+
await FA[E].disable(B.cv), B.applied.delete(E);
|
|
8710
8711
|
} catch (C) {
|
|
8711
8712
|
this.debugLog(`CV disable ${E} failed:`, C), B.applied.delete(E);
|
|
8712
8713
|
}
|
|
8713
8714
|
for (const E of Q)
|
|
8714
8715
|
try {
|
|
8715
|
-
await
|
|
8716
|
+
await FA[E].enable(B.cv), B.applied.add(E);
|
|
8716
8717
|
} catch (C) {
|
|
8717
8718
|
if (this.memoryMode)
|
|
8718
8719
|
this.debugLog(`CV enable ${E} failed:`, C);
|
|
@@ -8721,7 +8722,7 @@ class eI {
|
|
|
8721
8722
|
try {
|
|
8722
8723
|
this.memoryMode = !0;
|
|
8723
8724
|
const i = await this.fetchBinaries();
|
|
8724
|
-
this.applyWasmAssets(B.cv, i), await
|
|
8725
|
+
this.applyWasmAssets(B.cv, i), await FA[E].enable(B.cv), B.applied.add(E);
|
|
8725
8726
|
continue;
|
|
8726
8727
|
} catch (i) {
|
|
8727
8728
|
this.debugLog(`CV enable ${E} failed in memory mode too:`, i);
|
|
@@ -8994,7 +8995,7 @@ class hA {
|
|
|
8994
8995
|
if (this._destroyed)
|
|
8995
8996
|
throw new d("Media engine group has been disposed", "INSTANCE_DESTROYED");
|
|
8996
8997
|
if (!this.audioSystem) {
|
|
8997
|
-
this.audioSystem = new
|
|
8998
|
+
this.audioSystem = new tA();
|
|
8998
8999
|
for (const A of this.sinks.values())
|
|
8999
9000
|
this.audioSystem.addSink(A.id, (B) => A.post(B.type, B.data));
|
|
9000
9001
|
}
|
|
@@ -9149,7 +9150,7 @@ class hA {
|
|
|
9149
9150
|
...this.deviceAudioStreamIndices.values(),
|
|
9150
9151
|
...this.deviceRemoteAudioIndices.values()
|
|
9151
9152
|
]);
|
|
9152
|
-
for (I =
|
|
9153
|
+
for (I = TA; Q.has(I); ) I++;
|
|
9153
9154
|
this.deviceRemoteAudioIndices.set(A, I), this.ensureAudio().addDeviceAnalysisChannel(I, A);
|
|
9154
9155
|
} finally {
|
|
9155
9156
|
this.endConnectivityEdge();
|
|
@@ -9234,7 +9235,7 @@ class hA {
|
|
|
9234
9235
|
this.beginConnectivityEdge();
|
|
9235
9236
|
try {
|
|
9236
9237
|
this.additionalAudioStreams.push(A);
|
|
9237
|
-
const I = this.additionalAudioStreams.length - 1, Q =
|
|
9238
|
+
const I = this.additionalAudioStreams.length - 1, Q = PA + I;
|
|
9238
9239
|
return await this.ensureAudio().addStream(Q, A, { streamType: "additional" }), I;
|
|
9239
9240
|
} finally {
|
|
9240
9241
|
this.endConnectivityEdge();
|
|
@@ -9247,7 +9248,7 @@ class hA {
|
|
|
9247
9248
|
try {
|
|
9248
9249
|
this.additionalAudioStreams[A].getTracks().forEach((B) => B.stop()), this.additionalAudioStreams.splice(A, 1), this.audioSystem && await this.audioSystem.reinitializeAdditionalChannels(
|
|
9249
9250
|
this.additionalAudioStreams,
|
|
9250
|
-
|
|
9251
|
+
PA
|
|
9251
9252
|
);
|
|
9252
9253
|
} finally {
|
|
9253
9254
|
this.endConnectivityEdge();
|
|
@@ -9261,7 +9262,7 @@ class hA {
|
|
|
9261
9262
|
try {
|
|
9262
9263
|
this.clearDeviceAudio(A);
|
|
9263
9264
|
const I = new Set(this.deviceAudioStreamIndices.values());
|
|
9264
|
-
let Q =
|
|
9265
|
+
let Q = TA;
|
|
9265
9266
|
for (; I.has(Q); )
|
|
9266
9267
|
Q++;
|
|
9267
9268
|
return this.deviceAudioStreamIndices.set(A, Q), await this.ensureAudio().addStream(Q, B, { streamType: "device", deviceId: A }), Q;
|
|
@@ -9386,183 +9387,6 @@ class kI {
|
|
|
9386
9387
|
this.internalDevice = { motion: null, orientation: null };
|
|
9387
9388
|
}
|
|
9388
9389
|
}
|
|
9389
|
-
class uA {
|
|
9390
|
-
/**
|
|
9391
|
-
* Detects the renderer type from scene code comments
|
|
9392
|
-
*
|
|
9393
|
-
* Looks for:
|
|
9394
|
-
* - // @renderer shader
|
|
9395
|
-
* - /* @renderer shader *\/
|
|
9396
|
-
* - // @renderer p5
|
|
9397
|
-
* - /* @renderer p5 *\/
|
|
9398
|
-
*
|
|
9399
|
-
* @param sceneCode - The artist's scene code to analyze
|
|
9400
|
-
* @returns The detected renderer type ('shader', 'p5', or 'native')
|
|
9401
|
-
*/
|
|
9402
|
-
static detectRendererType(A) {
|
|
9403
|
-
return /\/\/\s*@renderer\s+shader|\/\*\s*@renderer\s+shader\s*\*\//.test(A) ? "shader" : /\/\/\s*@renderer\s+p5|\/\*\s*@renderer\s+p5\s*\*\//.test(A) ? "p5" : "native";
|
|
9404
|
-
}
|
|
9405
|
-
/**
|
|
9406
|
-
* P5 main-canvas mode from the renderer directive (only meaningful when
|
|
9407
|
-
* {@link detectRendererType} is `'p5'`).
|
|
9408
|
-
*
|
|
9409
|
-
* - `// @renderer p5` → 2D (default)
|
|
9410
|
-
* - `// @renderer p5 webgl` → WEBGL
|
|
9411
|
-
*/
|
|
9412
|
-
static detectP5CanvasMode(A) {
|
|
9413
|
-
return /\/\/\s*@renderer\s+p5\s+webgl\b|\/\*\s*@renderer\s+p5\s+webgl\s*\*\//i.test(
|
|
9414
|
-
A
|
|
9415
|
-
) ? "webgl" : "2d";
|
|
9416
|
-
}
|
|
9417
|
-
/**
|
|
9418
|
-
* Detects which engine capabilities the scene's code declares it uses.
|
|
9419
|
-
*
|
|
9420
|
-
* Static analysis only — the scene is never executed. Comments and string
|
|
9421
|
-
* literals are stripped first (so capabilities cannot be spoofed via
|
|
9422
|
-
* commented-out code), then capability tokens are matched. Detection is
|
|
9423
|
-
* **inclusive-biased**: a capability the scene actually uses is never
|
|
9424
|
-
* hidden, but a rarely-ambiguous case may report an extra one (a false
|
|
9425
|
-
* "show" is harmless; a false "hide" would break a working scene).
|
|
9426
|
-
*
|
|
9427
|
-
* - Shader scenes: matched against built-in `u_*` uniform usage (exact).
|
|
9428
|
-
* - Native / p5 scenes: matched against `viji.*` usage tokens.
|
|
9429
|
-
*
|
|
9430
|
-
* @param sceneCode - The artist's scene code to analyze
|
|
9431
|
-
* @param renderer - The renderer type (from {@link detectRendererType})
|
|
9432
|
-
* @returns The set of capabilities the scene declares it uses
|
|
9433
|
-
*/
|
|
9434
|
-
static detectCapabilities(A, B) {
|
|
9435
|
-
const I = this.stripCommentsAndStrings(A), Q = {
|
|
9436
|
-
audio: !1,
|
|
9437
|
-
video: !1,
|
|
9438
|
-
mouse: !1,
|
|
9439
|
-
keyboard: !1,
|
|
9440
|
-
pointer: !1,
|
|
9441
|
-
touch: !1,
|
|
9442
|
-
parameters: !1,
|
|
9443
|
-
sensors: !1,
|
|
9444
|
-
devices: !1,
|
|
9445
|
-
cv: {
|
|
9446
|
-
faceDetection: !1,
|
|
9447
|
-
faceMesh: !1,
|
|
9448
|
-
emotion: !1,
|
|
9449
|
-
handTracking: !1,
|
|
9450
|
-
poseDetection: !1,
|
|
9451
|
-
segmentation: !1
|
|
9452
|
-
}
|
|
9453
|
-
};
|
|
9454
|
-
return B === "shader" ? this.detectShaderCapabilities(I, Q) : this.detectScriptCapabilities(I, Q), Q;
|
|
9455
|
-
}
|
|
9456
|
-
/**
|
|
9457
|
-
* Replaces comment spans and string/template literals with whitespace via a
|
|
9458
|
-
* single forward scan. Robust against the regex-ordering pitfalls of
|
|
9459
|
-
* stripping comments and strings independently (a `//` inside a string, or a
|
|
9460
|
-
* quote inside a comment). Over-stripping is acceptable for capability
|
|
9461
|
-
* detection; under-detection is not.
|
|
9462
|
-
*/
|
|
9463
|
-
static stripCommentsAndStrings(A) {
|
|
9464
|
-
let B = "";
|
|
9465
|
-
const I = A.length;
|
|
9466
|
-
let Q = 0;
|
|
9467
|
-
for (; Q < I; ) {
|
|
9468
|
-
const g = A[Q], E = Q + 1 < I ? A[Q + 1] : "";
|
|
9469
|
-
if (g === "/" && E === "/") {
|
|
9470
|
-
for (Q += 2; Q < I && A[Q] !== `
|
|
9471
|
-
`; ) Q++;
|
|
9472
|
-
continue;
|
|
9473
|
-
}
|
|
9474
|
-
if (g === "/" && E === "*") {
|
|
9475
|
-
for (Q += 2; Q < I && !(A[Q] === "*" && A[Q + 1] === "/"); ) Q++;
|
|
9476
|
-
Q += 2, B += " ";
|
|
9477
|
-
continue;
|
|
9478
|
-
}
|
|
9479
|
-
if (g === '"' || g === "'" || g === "`") {
|
|
9480
|
-
const C = g;
|
|
9481
|
-
for (Q++; Q < I; ) {
|
|
9482
|
-
if (A[Q] === "\\") {
|
|
9483
|
-
Q += 2;
|
|
9484
|
-
continue;
|
|
9485
|
-
}
|
|
9486
|
-
if (A[Q] === C) {
|
|
9487
|
-
Q++;
|
|
9488
|
-
break;
|
|
9489
|
-
}
|
|
9490
|
-
Q++;
|
|
9491
|
-
}
|
|
9492
|
-
B += " ";
|
|
9493
|
-
continue;
|
|
9494
|
-
}
|
|
9495
|
-
B += g, Q++;
|
|
9496
|
-
}
|
|
9497
|
-
return B;
|
|
9498
|
-
}
|
|
9499
|
-
/**
|
|
9500
|
-
* Shader (GLSL) capability detection from built-in `u_*` uniform usage.
|
|
9501
|
-
* The uniform-name SOT is `ShaderWorkerAdapter.getBuiltInUniforms()`.
|
|
9502
|
-
* The `u_device*` family is suffix-aware: camera uniforms
|
|
9503
|
-
* (`u_device0`, `u_device0Resolution/Connected`) map to video+devices,
|
|
9504
|
-
* sensor uniforms (`u_device0Acceleration`, …) map to sensors+devices, and
|
|
9505
|
-
* the internal-device sensors (`u_deviceAcceleration`, …) map to sensors.
|
|
9506
|
-
*/
|
|
9507
|
-
static detectShaderCapabilities(A, B) {
|
|
9508
|
-
/\bu_audio\w*/.test(A) && (B.audio = !0), /\bu_video\w*/.test(A) && (B.video = !0), /\bu_mouse\w*/.test(A) && (B.mouse = !0), /\bu_key\w*/.test(A) && (B.keyboard = !0), /\bu_touch\w*/.test(A) && (B.touch = !0), /\bu_pointer\w*/.test(A) && (B.pointer = !0), /\bu_device(Acceleration|AccelerationGravity|RotationRate|OrientationAbsolute|Orientation)\b/.test(A) && (B.sensors = !0), /\bu_device[0-7](AccelerationGravity|Acceleration|RotationRate|Orientation)\b/.test(A) && (B.sensors = !0, B.devices = !0), /\bu_externalDeviceCount\b/.test(A) && (B.devices = !0, B.sensors = !0), (/\bu_deviceCount\b/.test(A) || /\bu_device[0-7](Resolution|Connected)?\b/.test(A)) && (B.video = !0, B.devices = !0), /\bu_face\w*/.test(A) && (B.cv.faceDetection = !0), /\bu_face0(Neutral|Happy|Sad|Angry|Surprised|Disgusted|Fearful)\b/.test(A) && (B.cv.emotion = !0), (/\bu_face0HeadPose\b/.test(A) || /\bu_videoAnalysed\w*/.test(A) || /\bu_face0(Brow|Cheek|Eye|Jaw|Mouth|Nose|Tongue)\w*/.test(A)) && (B.cv.faceMesh = !0), (/\bu_handCount\b/.test(A) || /\bu_(left|right)Hand\w*/.test(A)) && (B.cv.handTracking = !0), (/\bu_pose\w*/.test(A) || /\bu_(nose|leftShoulder|rightShoulder|leftElbow|rightElbow|leftWrist|rightWrist|leftHip|rightHip|leftKnee|rightKnee|leftAnkle|rightAnkle)Position\b/.test(A)) && (B.cv.poseDetection = !0), /\bu_segmentation\w*/.test(A) && (B.cv.segmentation = !0);
|
|
9509
|
-
}
|
|
9510
|
-
/**
|
|
9511
|
-
* Native / p5 capability detection from `viji.*` usage tokens. CV features
|
|
9512
|
-
* are keyed on their canonical `enable*` method names (the canonical
|
|
9513
|
-
* signal — a scene must enable a feature to receive its data).
|
|
9514
|
-
*/
|
|
9515
|
-
static detectScriptCapabilities(A, B) {
|
|
9516
|
-
/\bviji\.audio/.test(A) && (B.audio = !0), /\bviji\.video/.test(A) && (B.video = !0), /\bviji\.mouse/.test(A) && (B.mouse = !0), /\bviji\.keyboard/.test(A) && (B.keyboard = !0), /\bviji\.touches/.test(A) && (B.touch = !0), /\bviji\.pointer/.test(A) && (B.pointer = !0), /\bviji\.device\b/.test(A) && (B.sensors = !0), /\bviji\.devices/.test(A) && (B.devices = !0), /\bviji\.(slider|color|toggle|select|text|number|image|button|coordinate)\s*\(/.test(A) && (B.parameters = !0), /\benableFaceDetection\b/.test(A) && (B.cv.faceDetection = !0), /\benableFaceMesh\b/.test(A) && (B.cv.faceMesh = !0), /\benableEmotionDetection\b/.test(A) && (B.cv.emotion = !0), /\benableHandTracking\b/.test(A) && (B.cv.handTracking = !0), /\benablePoseDetection\b/.test(A) && (B.cv.poseDetection = !0), /\benableBodySegmentation\b/.test(A) && (B.cv.segmentation = !0);
|
|
9517
|
-
}
|
|
9518
|
-
/**
|
|
9519
|
-
* Detects which specific interaction inputs a scene reads (positions and
|
|
9520
|
-
* mouse buttons), for the worker's consumed-meaningfully evaluation. Renderer-
|
|
9521
|
-
* aware: shader scenes are read from built-in uniform usage, native/p5 from
|
|
9522
|
-
* `mouse.*` / `pointer.*` / `touches.*` member access. Comments/strings are
|
|
9523
|
-
* stripped first. Inclusive-biased like {@link detectCapabilities}.
|
|
9524
|
-
*
|
|
9525
|
-
* @param sceneCode - The artist's scene code to analyze
|
|
9526
|
-
* @param renderer - The renderer type (from {@link detectRendererType})
|
|
9527
|
-
* @returns The interaction-input usage mask
|
|
9528
|
-
*/
|
|
9529
|
-
/**
|
|
9530
|
-
* Whether the scene statically consumes the CV analysed frame. Gates
|
|
9531
|
-
* per-sink `analysedFrame` bitmap delivery from the shared CV engine to
|
|
9532
|
-
* zero for non-consumers.
|
|
9533
|
-
*
|
|
9534
|
-
* Three arms, inclusive-biased (over-detection is safe — the sink merely
|
|
9535
|
-
* receives bitmaps it ignores; under-detection breaks consumers SILENTLY):
|
|
9536
|
-
* - `analysedFrame` / `getAnalysedFrameData` — the JS surface
|
|
9537
|
-
* (native / p5 scenes, any stream).
|
|
9538
|
-
* - `u_videoAnalysed*` — the SHADER arm: GLSL scenes consume the
|
|
9539
|
-
* analysed frame as a texture bound by ShaderWorkerAdapter and never
|
|
9540
|
-
* contain the JS names; without this arm they would be classified as
|
|
9541
|
-
* non-consumers and permanently sample the 1×1 black fallback.
|
|
9542
|
-
* (Same source pattern as the capability mapping above, which routes
|
|
9543
|
-
* `u_videoAnalysed*` to `cv.faceMesh` — this is a separate consumer
|
|
9544
|
-
* flag, NOT a capability: it must not move cohort keys.)
|
|
9545
|
-
*
|
|
9546
|
-
* @param sceneCode - The artist's scene code to analyze
|
|
9547
|
-
* @returns true when the scene reads the analysed frame
|
|
9548
|
-
*/
|
|
9549
|
-
static detectAnalysedFrameUse(A) {
|
|
9550
|
-
const B = this.stripCommentsAndStrings(A);
|
|
9551
|
-
return /\b(analysedFrame|getAnalysedFrameData)\b/.test(B) || /\bu_videoAnalysed\w*/.test(B);
|
|
9552
|
-
}
|
|
9553
|
-
static detectUsage(A, B) {
|
|
9554
|
-
const I = this.stripCommentsAndStrings(A), Q = {
|
|
9555
|
-
mouse: { position: !1, left: !1, right: !1, middle: !1 },
|
|
9556
|
-
pointer: { position: !1, down: !1 },
|
|
9557
|
-
touch: !1
|
|
9558
|
-
};
|
|
9559
|
-
return B === "shader" ? (Q.mouse.position = /\bu_mouse(\b|InCanvas|Delta|Wheel)/.test(I), Q.mouse.left = /\bu_mouse(Left|Pressed|WasPressed|WasReleased)\b/.test(I), Q.mouse.right = /\bu_mouseRight\b/.test(I), Q.mouse.middle = /\bu_mouseMiddle\b/.test(I), Q.pointer.position = /\bu_pointer(\b|Delta|InCanvas)/.test(I), Q.pointer.down = /\bu_pointer(Down|WasPressed|WasReleased)\b/.test(I), Q.touch = /\bu_touch/.test(I)) : (Q.mouse.position = /\bmouse\.(x|y|deltaX|deltaY|wheelDelta|wheelX|wheelY|wasMoved)\b/.test(I), Q.mouse.left = /\bmouse\.(leftButton|isPressed|wasPressed|wasReleased)\b/.test(I), Q.mouse.right = /\bmouse\.rightButton\b/.test(I), Q.mouse.middle = /\bmouse\.middleButton\b/.test(I), Q.pointer.position = /\bpointer\.(x|y|deltaX|deltaY)\b/.test(I), Q.pointer.down = /\bpointer\.(isDown|wasPressed|wasReleased)\b/.test(I), Q.touch = /\btouches\./.test(I)), Q;
|
|
9560
|
-
}
|
|
9561
|
-
}
|
|
9562
|
-
function rI(D) {
|
|
9563
|
-
const A = uA.detectRendererType(D);
|
|
9564
|
-
return uA.detectCapabilities(D, A);
|
|
9565
|
-
}
|
|
9566
9390
|
function MI(D) {
|
|
9567
9391
|
if (typeof D == "string")
|
|
9568
9392
|
return lI(D);
|
|
@@ -9582,7 +9406,7 @@ function sA(D, A, B) {
|
|
|
9582
9406
|
const I = LA(D, "r"), Q = LA(A, "g"), g = LA(B, "b");
|
|
9583
9407
|
return "#" + WA(I) + WA(Q) + WA(g);
|
|
9584
9408
|
}
|
|
9585
|
-
function
|
|
9409
|
+
function iB(D, A, B) {
|
|
9586
9410
|
if (typeof D != "number" || typeof A != "number" || typeof B != "number" || !isFinite(D) || !isFinite(A) || !isFinite(B))
|
|
9587
9411
|
throw new Error(`Invalid HSB: h=${D}, s=${A}, b=${B}`);
|
|
9588
9412
|
if (A < 0 || A > 100)
|
|
@@ -9641,15 +9465,15 @@ function JI(D) {
|
|
|
9641
9465
|
const A = MA(D);
|
|
9642
9466
|
if (A.length !== 3)
|
|
9643
9467
|
throw new Error(`hsl() requires 3 arguments, got ${A.length}: hsl(${D})`);
|
|
9644
|
-
const B = BA(A[0], "h"), I =
|
|
9645
|
-
return
|
|
9468
|
+
const B = BA(A[0], "h"), I = QB(A[1], "s"), Q = QB(A[2], "l");
|
|
9469
|
+
return HI(B, I, Q);
|
|
9646
9470
|
}
|
|
9647
9471
|
function YI(D) {
|
|
9648
9472
|
const A = MA(D);
|
|
9649
9473
|
if (A.length !== 3)
|
|
9650
9474
|
throw new Error(`hsb() requires 3 arguments, got ${A.length}: hsb(${D})`);
|
|
9651
9475
|
const B = BA(A[0], "h"), I = BA(A[1], "s"), Q = BA(A[2], "b");
|
|
9652
|
-
return
|
|
9476
|
+
return iB(B, I, Q);
|
|
9653
9477
|
}
|
|
9654
9478
|
function UI(D) {
|
|
9655
9479
|
const A = MA(D);
|
|
@@ -9670,9 +9494,9 @@ function SI(D) {
|
|
|
9670
9494
|
}
|
|
9671
9495
|
function NI(D) {
|
|
9672
9496
|
const A = GA(D.h, "h"), B = GA(D.s, "s"), I = GA(D.b, "b");
|
|
9673
|
-
return
|
|
9497
|
+
return iB(A, B, I);
|
|
9674
9498
|
}
|
|
9675
|
-
function
|
|
9499
|
+
function HI(D, A, B) {
|
|
9676
9500
|
if (A < 0 || A > 100)
|
|
9677
9501
|
throw new Error(`HSL saturation must be 0..100%, got: ${A}%`);
|
|
9678
9502
|
if (B < 0 || B > 100)
|
|
@@ -9696,7 +9520,7 @@ function BA(D, A) {
|
|
|
9696
9520
|
throw new Error(`Invalid number for '${A}': '${D}'`);
|
|
9697
9521
|
return B;
|
|
9698
9522
|
}
|
|
9699
|
-
function
|
|
9523
|
+
function QB(D, A) {
|
|
9700
9524
|
if (!D.endsWith("%"))
|
|
9701
9525
|
throw new Error(`Field '${A}' must use percent notation (e.g., 50%), got: '${D}'`);
|
|
9702
9526
|
return BA(D.slice(0, -1), A);
|
|
@@ -9716,7 +9540,7 @@ function LA(D, A) {
|
|
|
9716
9540
|
function WA(D) {
|
|
9717
9541
|
return D.toString(16).padStart(2, "0");
|
|
9718
9542
|
}
|
|
9719
|
-
function
|
|
9543
|
+
function bI() {
|
|
9720
9544
|
const D = () => ({ trueCount: 0, falseCount: 0 });
|
|
9721
9545
|
return {
|
|
9722
9546
|
audio: D(),
|
|
@@ -9745,10 +9569,10 @@ function ZI(D) {
|
|
|
9745
9569
|
function LI(D) {
|
|
9746
9570
|
return (D.renderer === "native" || D.renderer === "p5" || D.renderer === "shader") && typeof D.consumesAnalysedFrame == "boolean" && typeof D.capabilities == "object" && D.capabilities !== null && typeof D.capabilities.cv == "object" && D.capabilities.cv !== null && (D.p5CanvasMode === void 0 || D.p5CanvasMode === "2d" || D.p5CanvasMode === "webgl");
|
|
9747
9571
|
}
|
|
9748
|
-
function
|
|
9572
|
+
function gB(D, A) {
|
|
9749
9573
|
return D && A && typeof D == "object" && typeof A == "object" && "x" in D && "x" in A && "y" in D && "y" in A ? D.x === A.x && D.y === A.y : !1;
|
|
9750
9574
|
}
|
|
9751
|
-
class
|
|
9575
|
+
class uA {
|
|
9752
9576
|
iframeManager = null;
|
|
9753
9577
|
workerManager = null;
|
|
9754
9578
|
interactionManager = null;
|
|
@@ -9814,7 +9638,7 @@ class rA {
|
|
|
9814
9638
|
sceneRenderer = "native";
|
|
9815
9639
|
// Pre-ready placeholder: the empty capability mask, derived through the
|
|
9816
9640
|
// analyzer itself so the shape can never drift from SceneCapabilities.
|
|
9817
|
-
sceneCapabilities =
|
|
9641
|
+
sceneCapabilities = eB.detectCapabilities("", "native");
|
|
9818
9642
|
sceneP5CanvasMode;
|
|
9819
9643
|
sceneConsumesAnalysedFrame = !1;
|
|
9820
9644
|
// The runtime-locked canvas context, reported by the worker once it locks.
|
|
@@ -9860,7 +9684,7 @@ class rA {
|
|
|
9860
9684
|
cpuMs: { min: 0, avg: 0, max: 0 },
|
|
9861
9685
|
frameIntervalMs: { min: 0, avg: 0, max: 0 }
|
|
9862
9686
|
},
|
|
9863
|
-
capabilities:
|
|
9687
|
+
capabilities: bI()
|
|
9864
9688
|
};
|
|
9865
9689
|
// Live perf/capability listeners (Set-based, mirroring sceneRuntimeErrorListeners).
|
|
9866
9690
|
// Reporting is gated on listener presence (attaching is the implicit enable).
|
|
@@ -10273,7 +10097,7 @@ class rA {
|
|
|
10273
10097
|
this.parameterValues.set(A, Q), this.workerManager && this.workerManager.postMessage("parameter-update", {
|
|
10274
10098
|
name: A,
|
|
10275
10099
|
value: Q
|
|
10276
|
-
}), (I?.type === "coordinate" ?
|
|
10100
|
+
}), (I?.type === "coordinate" ? gB(g, Q) : g === Q) || this.notifyParameterListeners(A, Q);
|
|
10277
10101
|
}
|
|
10278
10102
|
/**
|
|
10279
10103
|
* Internal method to handle image parameter loading and transfer
|
|
@@ -10338,7 +10162,7 @@ class rA {
|
|
|
10338
10162
|
this.parameterValues.set(Q, E), B.push({
|
|
10339
10163
|
name: Q,
|
|
10340
10164
|
value: E
|
|
10341
|
-
}), (this.getParameterDefinition(Q)?.type === "coordinate" ?
|
|
10165
|
+
}), (this.getParameterDefinition(Q)?.type === "coordinate" ? gB(C, E) : C === E) || I.push({ name: Q, value: E });
|
|
10342
10166
|
}
|
|
10343
10167
|
B.length > 0 && this.workerManager && this.workerManager.postMessage("parameter-batch-update", {
|
|
10344
10168
|
updates: B
|
|
@@ -10474,7 +10298,7 @@ class rA {
|
|
|
10474
10298
|
*/
|
|
10475
10299
|
ensureDirectFrameSlots(A) {
|
|
10476
10300
|
A <= this.directFrameSlots || (this.directFrameSlots = A, this.workerManager.postMessage("video-streams-prepare", {
|
|
10477
|
-
directFrameBaseIndex:
|
|
10301
|
+
directFrameBaseIndex: uA.DIRECT_FRAME_BASE,
|
|
10478
10302
|
directFrameCount: A
|
|
10479
10303
|
}), this.debugLog(`[Compositor] Prepared ${A} direct frame slot(s)`));
|
|
10480
10304
|
}
|
|
@@ -10488,7 +10312,7 @@ class rA {
|
|
|
10488
10312
|
throw new d("Core not ready", "NOT_READY");
|
|
10489
10313
|
this.ensureDirectFrameSlots(B + 1), this.workerManager.postMessage("video-frame-direct", {
|
|
10490
10314
|
imageBitmap: A,
|
|
10491
|
-
streamIndex:
|
|
10315
|
+
streamIndex: uA.DIRECT_FRAME_BASE + B,
|
|
10492
10316
|
timestamp: performance.now()
|
|
10493
10317
|
}, [A]);
|
|
10494
10318
|
}
|
|
@@ -11349,7 +11173,7 @@ class rA {
|
|
|
11349
11173
|
*/
|
|
11350
11174
|
importSessionState: (A, B) => {
|
|
11351
11175
|
this.validateReady();
|
|
11352
|
-
const I =
|
|
11176
|
+
const I = CB.validateOnsetPayload(A);
|
|
11353
11177
|
if (I) {
|
|
11354
11178
|
this.fireStateImportError(I);
|
|
11355
11179
|
return;
|
|
@@ -11777,14 +11601,12 @@ function WI(D) {
|
|
|
11777
11601
|
expectedVersion: 1
|
|
11778
11602
|
} : typeof A.senderTime != "number" ? { code: "invalid-field", details: "senderTime must be a number", field: "senderTime" } : null;
|
|
11779
11603
|
}
|
|
11780
|
-
const qI = "0.
|
|
11604
|
+
const qI = "0.14.0";
|
|
11781
11605
|
export {
|
|
11782
|
-
|
|
11783
|
-
uI as
|
|
11784
|
-
mI as I,
|
|
11606
|
+
rI as C,
|
|
11607
|
+
uI as I,
|
|
11785
11608
|
qI as V,
|
|
11786
|
-
|
|
11787
|
-
|
|
11788
|
-
d as c,
|
|
11609
|
+
uA as a,
|
|
11610
|
+
d as b,
|
|
11789
11611
|
CI as g
|
|
11790
11612
|
};
|