@ultrst-armada/kloks 1.26.3 → 1.26.4
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/README.md +39 -0
- package/index.d.ts +16 -10
- package/index.js +3 -0
- package/package.json +60 -7
- package/packages/audio-midi/dist/{audioClipEngine-BOT33JKI.js → audioClipEngine-LKZRWTJ3.js} +2 -2
- package/packages/audio-midi/dist/{audioInputManager-BLDGGLAR.js → audioInputManager-5BNHLOJM.js} +1 -1
- package/packages/audio-midi/dist/{chunk-N55BWOC6.js → chunk-M4JFGTHE.js} +1 -1
- package/packages/audio-midi/dist/{chunk-3GRGELA4.js → chunk-OUOFTYHY.js} +50 -11
- package/packages/audio-midi/dist/engine/audio/entities/AudioEffects/functionalities/Compressor/manifest.json +7 -0
- package/packages/audio-midi/dist/engine/audio/entities/AudioEffects/functionalities/Delay/manifest.json +7 -0
- package/packages/audio-midi/dist/engine/audio/entities/AudioEffects/functionalities/Equalizer/manifest.json +7 -0
- package/packages/audio-midi/dist/engine/audio/entities/AudioEffects/functionalities/Limiter/manifest.json +7 -0
- package/packages/audio-midi/dist/engine/audio/entities/AudioEffects/functionalities/MultibandCompressor/manifest.json +7 -0
- package/packages/audio-midi/dist/engine/audio/entities/AudioEffects/functionalities/Reverb/manifest.json +7 -0
- package/packages/audio-midi/dist/engine/audio/entities/AudioEffects/functionalities/Saturation/manifest.json +7 -0
- package/packages/audio-midi/dist/index.d.ts +10 -1
- package/packages/audio-midi/dist/index.js +36 -20
- package/packages/audio-midi/package.json +8 -0
- package/packages/backend/dist/ai-models/index.js +2 -2
- package/packages/backend/dist/ai-routing/index.js +3 -3
- package/packages/backend/dist/api/BaseApiRoute.d.ts +1 -1
- package/packages/backend/dist/api/index.js +1 -1
- package/packages/backend/dist/auth/CanonicalAuthClient.d.ts +6 -6
- package/packages/backend/dist/auth/index.js +2 -1
- package/packages/backend/dist/chunk-2Y2EXYDK.js +0 -0
- package/packages/backend/dist/{chunk-3S2NSIFA.js → chunk-3FZSYSJC.js} +16 -10
- package/packages/backend/dist/chunk-5F5V7NAG.js +54 -0
- package/packages/backend/dist/{chunk-WAQDOIGQ.js → chunk-BVXGUHLZ.js} +1 -1
- package/packages/backend/dist/chunk-DAG2L4RN.js +0 -0
- package/packages/backend/dist/{chunk-KPZQUA7R.js → chunk-G7PPVOFP.js} +16 -53
- package/packages/backend/dist/{chunk-GKQ42CYW.js → chunk-H6ET362U.js} +3 -3
- package/packages/backend/dist/chunk-HUY4272L.js +69 -0
- package/packages/backend/dist/chunk-JQKKMUCT.js +0 -0
- package/packages/backend/dist/{chunk-PT6J6UEU.js → chunk-LMAU62ZG.js} +4 -4
- package/packages/backend/dist/{chunk-EDKCP5CQ.js → chunk-MZK362U4.js} +16 -16
- package/packages/backend/dist/{chunk-U4UI6KK4.js → chunk-NGEB3CF5.js} +3 -35
- package/packages/backend/dist/{chunk-3VWBZEMG.js → chunk-NTKUQVCQ.js} +4 -5
- package/packages/backend/dist/chunk-NY2SQOXI.js +34 -0
- package/packages/backend/dist/{chunk-JOTDEFRG.js → chunk-OXEP3AP6.js} +5 -4
- package/packages/backend/dist/chunk-RABSY2JU.js +0 -0
- package/packages/backend/dist/{chunk-GWCLYVJT.js → chunk-RFPGUJAZ.js} +9 -9
- package/packages/backend/dist/{chunk-TWCEVES2.js → chunk-WC6EPW3A.js} +1 -1
- package/packages/backend/dist/{chunk-FU6TYLI2.js → chunk-Y5ENDXU2.js} +72 -129
- package/packages/backend/dist/{chunk-EO5VUYYU.js → chunk-Y7ZE6D5H.js} +4 -4
- package/packages/backend/dist/{chunk-RCCQ7IRM.js → chunk-ZBNSK26X.js} +2 -2
- package/packages/backend/dist/control-plane/AuditLogger.d.ts +1 -1
- package/packages/backend/dist/control-plane/ControlPlaneManager.d.ts +1 -1
- package/packages/backend/dist/control-plane/index.js +1 -1
- package/packages/backend/dist/core/dynamicRouteResolver.d.ts +1 -1
- package/packages/backend/dist/core/routesCore.d.ts +1 -1
- package/packages/backend/dist/core/vercelTransformer.d.ts +1 -1
- package/packages/backend/dist/core/workspaceCore.d.ts +2 -2
- package/packages/backend/dist/data/BaseDataProvider.d.ts +1 -1
- package/packages/backend/dist/development/index.js +30 -17
- package/packages/backend/dist/development/playwrightInspectionService.js +1 -2
- package/packages/backend/dist/development/webContainerService.js +1 -2
- package/packages/backend/dist/index.d.ts +4 -24
- package/packages/backend/dist/index.js +12 -4655
- package/packages/backend/dist/krnl-ai-services.d.ts +9 -9
- package/packages/backend/dist/krnl-ai-services.js +5 -6
- package/packages/backend/dist/krnl-services.js +8 -7
- package/packages/backend/dist/node.d.ts +28 -0
- package/packages/backend/dist/node.js +4754 -0
- package/packages/backend/dist/resourceEngine/BaseResourceFetcher.d.ts +3 -3
- package/packages/backend/dist/resourceEngine/CloudflareResourceFetcher.d.ts +3 -3
- package/packages/backend/dist/resourceEngine/ResourceFetcherRegistry.d.ts +5 -5
- package/packages/backend/dist/resourceEngine/VercelResourceFetcher.d.ts +3 -3
- package/packages/backend/dist/resourceEngine/adapters/CloudflareResourceAdapter.d.ts +2 -2
- package/packages/backend/dist/resourceEngine/adapters/VercelResourceAdapter.d.ts +2 -2
- package/packages/backend/dist/resourceEngine/calculator/UniversalResourceCalculator.d.ts +1 -1
- package/packages/backend/dist/resourceEngine/calculator/types.d.ts +1 -1
- package/packages/backend/dist/resourceEngine/index.d.ts +6 -6
- package/packages/backend/dist/resourceEngine/types/depm/entities.d.ts +2 -2
- package/packages/backend/dist/resourceEngine/types.d.ts +1 -1
- package/packages/backend/dist/resourceEngine/weightEngine/helpers.d.ts +1 -1
- package/packages/backend/dist/resourceEngine/weightEngine/index.d.ts +2 -2
- package/packages/backend/dist/resourceEngine/weightEngine/weightEngine.d.ts +1 -1
- package/packages/backend/dist/resourceEngine/weightEngine.d.ts +1 -1
- package/packages/backend/dist/server/services/assetPoolService/assetPoolService.d.ts +3 -3
- package/packages/backend/dist/server/services/projectService/projectService.d.ts +3 -3
- package/packages/backend/dist/services/index.d.ts +2 -10
- package/packages/backend/dist/services/index.js +1 -37
- package/packages/backend/dist/services/node.d.ts +10 -0
- package/packages/backend/dist/services/node.js +38 -0
- package/packages/backend/dist/srkl/index.js +1 -1
- package/packages/backend/dist/storage/BaseStorageAdapter.d.ts +1 -1
- package/packages/backend/dist/storage/S3Adapter.d.ts +5 -0
- package/packages/backend/dist/storage/googleDriveSdk.d.ts +1 -7
- package/packages/backend/dist/storage/index.d.ts +1 -10
- package/packages/backend/dist/storage/index.js +5 -40
- package/packages/backend/dist/storage/node.d.ts +14 -0
- package/packages/backend/dist/storage/node.js +66 -0
- package/packages/backend/dist/workspace/WorkspaceCloneSyncEngine.d.ts +1 -1
- package/packages/backend/dist/workspace/index.d.ts +1 -5
- package/packages/backend/dist/workspace/index.js +4 -24
- package/packages/backend/dist/workspace/node.d.ts +8 -0
- package/packages/backend/dist/workspace/node.js +30 -0
- package/packages/backend/package.json +35 -3
- package/packages/functions/dist/base-DDYO-DzM.d.ts +64 -0
- package/packages/functions/dist/base.d.ts +1 -0
- package/packages/functions/dist/base.js +6 -0
- package/packages/functions/dist/chunk-6EHIZHO4.js +555 -0
- package/packages/functions/dist/chunk-Z4LM5TOJ.js +114 -0
- package/packages/functions/dist/index.d.ts +4 -373
- package/packages/functions/dist/index.js +53 -1693
- package/packages/functions/dist/node.d.ts +110 -0
- package/packages/functions/dist/node.js +442 -0
- package/packages/functions/dist/portable.d.ts +207 -0
- package/packages/functions/dist/portable.js +94 -0
- package/packages/functions/package.json +23 -1
- package/packages/{functions/dist/chunk-K6H7T3EP.js → services/dist/chunk-P54QSKOQ.js} +1 -3
- package/packages/{state-graph/dist/dist-es-TLPJYZTE.js → services/dist/dist-es-2P6LFFZL.js} +1 -1
- package/packages/{state-graph/dist/dist-es-5IACWOIO.js → services/dist/dist-es-OZCE67MW.js} +1 -1
- package/packages/services/dist/{dist-es-3DGJJFOU.js → dist-es-RUJB3ALN.js} +3 -3
- package/packages/{state-graph/dist/dist-es-QZ6GKMM7.js → services/dist/dist-es-SSJGP5AI.js} +4 -4
- package/packages/services/dist/{loadSso-M3ZIZDGO.js → loadSso-3PZYFUB7.js} +1 -1
- package/packages/{functions/dist/signin-YXALFRYB.js → services/dist/signin-WYPGSXHF.js} +1 -1
- package/packages/{state-graph/dist/sso-oidc-NXFKRL6O.js → services/dist/sso-oidc-PQMIMLJU.js} +1 -1
- package/packages/{state-graph/dist/sts-MICPT37B.js → services/dist/sts-Z7LR3AZH.js} +1 -1
- package/packages/state-graph/dist/browser.d.ts +8 -18
- package/packages/state-graph/dist/browser.js +334 -23
- package/packages/state-graph/dist/browser.test.d.ts +1 -0
- package/packages/state-graph/dist/{chunk-KG6QYS26.js → chunk-5KP74NMF.js} +80 -80
- package/packages/state-graph/dist/{chunk-4UVGXFEM.js → chunk-LVULR5M4.js} +1 -1
- package/packages/state-graph/dist/{chunk-S22PMERU.js → chunk-OXUDG6HE.js} +1 -1
- package/packages/state-graph/dist/{chunk-2CQQGFMF.js → chunk-UKTICGGV.js} +2616 -432
- package/packages/state-graph/dist/domain/index.js +2 -3
- package/packages/state-graph/dist/engine/AudioConcepts.d.ts +1 -1
- package/packages/state-graph/dist/engine/GraphConcepts.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/archetypes/audioArchetypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/archetypes/effectArchetypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/archetypes/primitiveArchetypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/archetypes/routingArchetypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/archetypes/triggerModuleArchetypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/assets/containerSprites.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/assets/effectSprites.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/assets/primitiveSprites.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/assets/routingSprites.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/canonicalIo/CanonicalAudioInputEndpoint.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/canonicalIo/CanonicalMidiInputEndpoint.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/canonicalIo/topLevelIoRegistry.d.ts +6 -6
- package/packages/state-graph/dist/engine/core/canonicalIo/types.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/graphDataService.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/hierarchy/index.d.ts +11 -11
- package/packages/state-graph/dist/engine/core/hierarchy/nodes/GraphNodeParent.d.ts +3 -3
- package/packages/state-graph/dist/engine/core/hierarchy/nodes/GraphNodeTypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/hierarchy/sockets/GraphSocketParent.d.ts +2 -2
- package/packages/state-graph/dist/engine/core/hierarchy/sockets/GraphSocketTypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/hierarchy/ui/UIElementBase.d.ts +3 -3
- package/packages/state-graph/dist/engine/core/hierarchy/wires/GraphWireParent.d.ts +2 -2
- package/packages/state-graph/dist/engine/core/hierarchy/wires/GraphWireTypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/nodeArchetypeRegistry.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/socketRegistry/containersSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/socketRegistry/customRegistry.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/socketRegistry/landmarksSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/socketRegistry/primitivesSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/socketRegistry/processorsSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/arrangementControlSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/audioSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/folderButtonSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/moduleSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/playbackSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/primitiveSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/routingSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/samplerSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/stripSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/arrangementFactory.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/codeNodeParser/codeNodeParser.d.ts +2 -2
- package/packages/state-graph/dist/engine/functions/codeNodeParser/helpers.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/connection/portMatching.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/connection/signalCompatibility/helpers.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/connection/signalCompatibility/signalCompatibility.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/connection/signalCompatibility.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/connection/wireValidation.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/containerClipSync.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/containerFactory/containerFactory.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/effectLogic.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/graphManager/graphManager.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/graphManager.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/nodeFactory/nodeFactory.d.ts +8 -8
- package/packages/state-graph/dist/engine/functions/nodeFactory.d.ts +2 -2
- package/packages/state-graph/dist/engine/functions/signalTable/audioMidiSignals.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/signalTable/canonicalEffectsTable.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/signalTable/dataSignals.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/socketCompatibilitySpawner/helpers.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/socketCompatibilitySpawner/socketCompatibilitySpawner.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/socketCompatibilitySpawner.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/spawnNodeFactory.d.ts +1 -1
- package/packages/state-graph/dist/engine/predictive/predictiveGraphEngine/helpers.d.ts +1 -1
- package/packages/state-graph/dist/engine/predictive/predictiveGraphEngine.d.ts +2 -2
- package/packages/state-graph/dist/engine/types/auth.d.ts +1 -1
- package/packages/state-graph/dist/engine/types/hardwareBus.d.ts +1 -1
- package/packages/state-graph/dist/engine/types/legacyTypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/types/nodesArrangement.d.ts +2 -2
- package/packages/state-graph/dist/engine/types/nodesAudio.d.ts +5 -5
- package/packages/state-graph/dist/engine/types/nodesControl.d.ts +2 -2
- package/packages/state-graph/dist/engine/types/nodesPlayback.d.ts +2 -2
- package/packages/state-graph/dist/engine/types/nodesPrimitives.d.ts +6 -6
- package/packages/state-graph/dist/engine/types/nodesRouting.d.ts +2 -2
- package/packages/state-graph/dist/engine/types/sceneData.d.ts +2 -2
- package/packages/state-graph/dist/engine/types/sceneState.d.ts +4 -4
- package/packages/state-graph/dist/engine/types/signals.d.ts +2 -2
- package/packages/state-graph/dist/engine/types/stripsTypes.d.ts +2 -2
- package/packages/state-graph/dist/index.js +110 -2850
- package/packages/state-graph/dist/rules/index.js +0 -1
- package/packages/state-graph/dist/spatial/index.js +0 -1
- package/packages/state-graph/dist/state/index.js +0 -1
- package/packages/state-graph/dist/store/CommandApi.d.ts +2 -2
- package/packages/state-graph/dist/store/index.js +2 -3
- package/packages/state-graph/package.json +7 -2
- package/scripts/normalize-package-declarations.mjs +63 -0
- package/packages/backend/dist/chunk-SXDYW3QA.js +0 -579
- package/packages/functions/dist/bowser-F6LIZBYW.js +0 -2821
- package/packages/functions/dist/chunk-34KJBG4F.js +0 -357
- package/packages/functions/dist/chunk-EAQYK3U2.js +0 -41
- package/packages/functions/dist/chunk-IOAPEUC7.js +0 -3424
- package/packages/functions/dist/chunk-J64ZDIIX.js +0 -2753
- package/packages/functions/dist/chunk-N3MSTUJN.js +0 -4785
- package/packages/functions/dist/chunk-VP26OHBN.js +0 -480
- package/packages/functions/dist/chunk-VRLVLNLG.js +0 -1727
- package/packages/functions/dist/dist-TKZ5TDRN.js +0 -1124
- package/packages/functions/dist/dist-W7ZJS3LZ.js +0 -899
- package/packages/functions/dist/dist-es-3DGJJFOU.js +0 -338
- package/packages/functions/dist/dist-es-5IACWOIO.js +0 -69
- package/packages/functions/dist/dist-es-BWLDIBIA.js +0 -47
- package/packages/functions/dist/dist-es-DO3F4OBN.js +0 -377
- package/packages/functions/dist/dist-es-NN7AKU7P.js +0 -175
- package/packages/functions/dist/dist-es-QZ6GKMM7.js +0 -220
- package/packages/functions/dist/dist-es-R3VEGXOP.js +0 -87
- package/packages/functions/dist/dist-es-TLPJYZTE.js +0 -294
- package/packages/functions/dist/event-streams-DRE6QVD6.js +0 -940
- package/packages/functions/dist/loadSso-M3ZIZDGO.js +0 -586
- package/packages/functions/dist/multipart-parser-YYFFJ4QD.js +0 -371
- package/packages/functions/dist/src-2QCYQXYH.js +0 -1396
- package/packages/functions/dist/sso-oidc-NXFKRL6O.js +0 -847
- package/packages/functions/dist/sts-MICPT37B.js +0 -1253
- package/packages/functions/dist/transformers.node-R6VHTGC2.js +0 -43879
- package/packages/services/dist/chunk-K6H7T3EP.js +0 -1991
- package/packages/services/dist/dist-es-5IACWOIO.js +0 -69
- package/packages/services/dist/dist-es-QZ6GKMM7.js +0 -220
- package/packages/services/dist/dist-es-TLPJYZTE.js +0 -294
- package/packages/services/dist/signin-YXALFRYB.js +0 -831
- package/packages/services/dist/sso-oidc-NXFKRL6O.js +0 -847
- package/packages/services/dist/sts-MICPT37B.js +0 -1253
- package/packages/state-graph/dist/bowser-F6LIZBYW.js +0 -2821
- package/packages/state-graph/dist/chunk-34KJBG4F.js +0 -357
- package/packages/state-graph/dist/chunk-EAQYK3U2.js +0 -41
- package/packages/state-graph/dist/chunk-IOAPEUC7.js +0 -3424
- package/packages/state-graph/dist/chunk-J64ZDIIX.js +0 -2753
- package/packages/state-graph/dist/chunk-K6H7T3EP.js +0 -1991
- package/packages/state-graph/dist/chunk-N3MSTUJN.js +0 -4785
- package/packages/state-graph/dist/chunk-VP26OHBN.js +0 -480
- package/packages/state-graph/dist/chunk-VRLVLNLG.js +0 -1727
- package/packages/state-graph/dist/dist-TKZ5TDRN.js +0 -1124
- package/packages/state-graph/dist/dist-W7ZJS3LZ.js +0 -899
- package/packages/state-graph/dist/dist-es-3DGJJFOU.js +0 -338
- package/packages/state-graph/dist/dist-es-BWLDIBIA.js +0 -47
- package/packages/state-graph/dist/dist-es-DO3F4OBN.js +0 -377
- package/packages/state-graph/dist/dist-es-NN7AKU7P.js +0 -175
- package/packages/state-graph/dist/dist-es-R3VEGXOP.js +0 -87
- package/packages/state-graph/dist/event-streams-DRE6QVD6.js +0 -940
- package/packages/state-graph/dist/loadSso-M3ZIZDGO.js +0 -586
- package/packages/state-graph/dist/multipart-parser-YYFFJ4QD.js +0 -371
- package/packages/state-graph/dist/signin-YXALFRYB.js +0 -831
- package/packages/state-graph/dist/src-2QCYQXYH.js +0 -1396
- package/packages/state-graph/dist/transformers.node-R6VHTGC2.js +0 -43879
- package/packages/backend/dist/{chunk-LMWXONZG.js → chunk-EREYT3WJ.js} +3 -3
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DataHandle
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-OXUDG6HE.js";
|
|
4
|
+
import {
|
|
5
|
+
BaseNode
|
|
6
|
+
} from "./chunk-5KP74NMF.js";
|
|
4
7
|
import {
|
|
5
8
|
AttractionEngine
|
|
6
9
|
} from "./chunk-JXDJZSFW.js";
|
|
@@ -8,9 +11,6 @@ import {
|
|
|
8
11
|
HandleTypeRegistry,
|
|
9
12
|
WireTypeRegistry
|
|
10
13
|
} from "./chunk-TZOL3RN7.js";
|
|
11
|
-
import {
|
|
12
|
-
BaseNode
|
|
13
|
-
} from "./chunk-KG6QYS26.js";
|
|
14
14
|
import {
|
|
15
15
|
AutoSolidify,
|
|
16
16
|
TraceEngine
|
|
@@ -22,6 +22,362 @@ import {
|
|
|
22
22
|
CompatibilityMatrix
|
|
23
23
|
} from "./chunk-ISFNY7EZ.js";
|
|
24
24
|
|
|
25
|
+
// src/Viewport.ts
|
|
26
|
+
function screenToCanvas(clientX, clientY, viewport) {
|
|
27
|
+
return {
|
|
28
|
+
x: (clientX - viewport.panX) / viewport.zoom,
|
|
29
|
+
y: (clientY - viewport.panY) / viewport.zoom
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function canvasToScreen(canvasX, canvasY, viewport) {
|
|
33
|
+
return {
|
|
34
|
+
x: canvasX * viewport.zoom + viewport.panX,
|
|
35
|
+
y: canvasY * viewport.zoom + viewport.panY
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function zoomAtPoint(mouseX, mouseY, delta, viewport, config = {}) {
|
|
39
|
+
const currentZoom = viewport.zoom;
|
|
40
|
+
let newZoom = currentZoom + delta;
|
|
41
|
+
newZoom = clampZoom(newZoom, config);
|
|
42
|
+
const graphX = (mouseX - viewport.panX) / currentZoom;
|
|
43
|
+
const graphY = (mouseY - viewport.panY) / currentZoom;
|
|
44
|
+
const panX = mouseX - graphX * newZoom;
|
|
45
|
+
const panY = mouseY - graphY * newZoom;
|
|
46
|
+
return { zoom: newZoom, panX, panY };
|
|
47
|
+
}
|
|
48
|
+
function clampZoom(zoom, config = {}) {
|
|
49
|
+
const minZoom = config.minZoom ?? 0.25;
|
|
50
|
+
const maxZoom = config.maxZoom ?? 2.5;
|
|
51
|
+
return Math.max(minZoom, Math.min(maxZoom, zoom));
|
|
52
|
+
}
|
|
53
|
+
function fitToView(nodes, containerWidth, containerHeight, padding = 50) {
|
|
54
|
+
if (nodes.length === 0) {
|
|
55
|
+
return { panX: containerWidth / 2, panY: containerHeight / 2, zoom: 1 };
|
|
56
|
+
}
|
|
57
|
+
let minX = Infinity, minY = Infinity;
|
|
58
|
+
let maxX = -Infinity, maxY = -Infinity;
|
|
59
|
+
for (const node of nodes) {
|
|
60
|
+
minX = Math.min(minX, node.position.x);
|
|
61
|
+
minY = Math.min(minY, node.position.y);
|
|
62
|
+
const width = node.width ?? 150;
|
|
63
|
+
const height = node.height ?? 100;
|
|
64
|
+
maxX = Math.max(maxX, node.position.x + width);
|
|
65
|
+
maxY = Math.max(maxY, node.position.y + height);
|
|
66
|
+
}
|
|
67
|
+
const graphWidth = maxX - minX;
|
|
68
|
+
const graphHeight = maxY - minY;
|
|
69
|
+
const zoomX = (containerWidth - padding * 2) / graphWidth;
|
|
70
|
+
const zoomY = (containerHeight - padding * 2) / graphHeight;
|
|
71
|
+
const targetZoom = Math.min(zoomX, zoomY, 1);
|
|
72
|
+
const panX = (containerWidth - graphWidth * targetZoom) / 2 - minX * targetZoom;
|
|
73
|
+
const panY = (containerHeight - graphHeight * targetZoom) / 2 - minY * targetZoom;
|
|
74
|
+
return { zoom: targetZoom, panX, panY };
|
|
75
|
+
}
|
|
76
|
+
function isNodeInCenterDeadZone(node, viewport, containerWidth, containerHeight, deadZoneRatio = 0.35) {
|
|
77
|
+
const centerX = containerWidth / 2;
|
|
78
|
+
const centerY = containerHeight / 2;
|
|
79
|
+
const nodeW = node.width ?? 130;
|
|
80
|
+
const nodeH = node.height ?? 130;
|
|
81
|
+
const nodeCenterX = node.position.x + nodeW / 2;
|
|
82
|
+
const nodeCenterY = node.position.y + nodeH / 2;
|
|
83
|
+
const screenNodeX = nodeCenterX * viewport.zoom + viewport.panX;
|
|
84
|
+
const screenNodeY = nodeCenterY * viewport.zoom + viewport.panY;
|
|
85
|
+
const dist = Math.hypot(screenNodeX - centerX, screenNodeY - centerY);
|
|
86
|
+
const deadZoneRadius = Math.min(containerWidth, containerHeight) * deadZoneRatio;
|
|
87
|
+
return dist <= deadZoneRadius;
|
|
88
|
+
}
|
|
89
|
+
function getCenterPanForNode(node, viewport, containerWidth, containerHeight) {
|
|
90
|
+
const centerX = containerWidth / 2;
|
|
91
|
+
const centerY = containerHeight / 2;
|
|
92
|
+
const nodeW = node.width ?? 130;
|
|
93
|
+
const nodeH = node.height ?? 130;
|
|
94
|
+
const nodeCenterX = node.position.x + nodeW / 2;
|
|
95
|
+
const nodeCenterY = node.position.y + nodeH / 2;
|
|
96
|
+
return {
|
|
97
|
+
panX: Math.round(centerX - nodeCenterX * viewport.zoom),
|
|
98
|
+
panY: Math.round(centerY - nodeCenterY * viewport.zoom)
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// src/BoxSelection.ts
|
|
103
|
+
function getNodesInSelection(startX, startY, endX, endY, nodes, viewport) {
|
|
104
|
+
const canvasStartX = (startX - viewport.panX) / viewport.zoom;
|
|
105
|
+
const canvasStartY = (startY - viewport.panY) / viewport.zoom;
|
|
106
|
+
const canvasEndX = (endX - viewport.panX) / viewport.zoom;
|
|
107
|
+
const canvasEndY = (endY - viewport.panY) / viewport.zoom;
|
|
108
|
+
const minX = Math.min(canvasStartX, canvasEndX);
|
|
109
|
+
const maxX = Math.max(canvasStartX, canvasEndX);
|
|
110
|
+
const minY = Math.min(canvasStartY, canvasEndY);
|
|
111
|
+
const maxY = Math.max(canvasStartY, canvasEndY);
|
|
112
|
+
return nodes.filter((node) => {
|
|
113
|
+
const nodeWidth = node.width ?? 150;
|
|
114
|
+
const nodeHeight = node.height ?? 100;
|
|
115
|
+
const intersectX = node.position.x < maxX && node.position.x + nodeWidth > minX;
|
|
116
|
+
const intersectY = node.position.y < maxY && node.position.y + nodeHeight > minY;
|
|
117
|
+
return intersectX && intersectY;
|
|
118
|
+
}).map((node) => node.id);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// src/engine/types/stripsTypes.ts
|
|
122
|
+
function createDefaultMapIoConfig() {
|
|
123
|
+
return {
|
|
124
|
+
inputs: [
|
|
125
|
+
{
|
|
126
|
+
id: "map-in-audio-bus-in-1",
|
|
127
|
+
sourceId: "bus-in-1",
|
|
128
|
+
name: "Physical Audio In 1",
|
|
129
|
+
type: "audio",
|
|
130
|
+
direction: "input",
|
|
131
|
+
enabled: true,
|
|
132
|
+
gain: 1,
|
|
133
|
+
color: "#f59e0b",
|
|
134
|
+
audioFormat: "mono",
|
|
135
|
+
signalType: "audio_mono",
|
|
136
|
+
ioLevel: "physical",
|
|
137
|
+
portType: "external_endpoint"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
id: "map-in-midi-profile-1",
|
|
141
|
+
sourceId: "midi-profile-1",
|
|
142
|
+
name: "Physical MIDI In (Main Stage)",
|
|
143
|
+
type: "midi",
|
|
144
|
+
direction: "input",
|
|
145
|
+
enabled: true,
|
|
146
|
+
color: "#38bdf8",
|
|
147
|
+
signalType: "midi_stream",
|
|
148
|
+
ioLevel: "physical",
|
|
149
|
+
portType: "external_endpoint"
|
|
150
|
+
}
|
|
151
|
+
],
|
|
152
|
+
outputs: [
|
|
153
|
+
{
|
|
154
|
+
id: "map-out-audio-master",
|
|
155
|
+
sourceId: "bus-out-master",
|
|
156
|
+
name: "Master Output L/R",
|
|
157
|
+
type: "audio",
|
|
158
|
+
direction: "output",
|
|
159
|
+
enabled: true,
|
|
160
|
+
gain: 1,
|
|
161
|
+
color: "#10b981",
|
|
162
|
+
audioFormat: "stereo",
|
|
163
|
+
signalType: "audio_stereo",
|
|
164
|
+
ioLevel: "physical",
|
|
165
|
+
portType: "external_endpoint"
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// src/engine/AudioConcepts.ts
|
|
172
|
+
function getDivisionBeatLength(division) {
|
|
173
|
+
switch (division) {
|
|
174
|
+
case "none":
|
|
175
|
+
return 0;
|
|
176
|
+
case "1/16":
|
|
177
|
+
return 0.25;
|
|
178
|
+
case "1/8":
|
|
179
|
+
return 0.5;
|
|
180
|
+
case "1/4":
|
|
181
|
+
return 1;
|
|
182
|
+
case "1/2":
|
|
183
|
+
return 2;
|
|
184
|
+
case "1_bar":
|
|
185
|
+
return 4;
|
|
186
|
+
case "2_bars":
|
|
187
|
+
return 8;
|
|
188
|
+
case "4_bars":
|
|
189
|
+
return 16;
|
|
190
|
+
default:
|
|
191
|
+
return 4;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function calculateNextQuantizeBeat(currentBeat, division, beatsPerBar = 4) {
|
|
195
|
+
const divBeats = getDivisionBeatLength(division);
|
|
196
|
+
if (divBeats <= 0) {
|
|
197
|
+
return currentBeat;
|
|
198
|
+
}
|
|
199
|
+
const epsilon = 1e-3;
|
|
200
|
+
const nextDivisionIndex = Math.floor((currentBeat + epsilon) / divBeats) + 1;
|
|
201
|
+
return nextDivisionIndex * divBeats;
|
|
202
|
+
}
|
|
203
|
+
function formatBeatToBarBeat(beat, beatsPerBar = 4) {
|
|
204
|
+
const safeBeat = Math.max(0, beat);
|
|
205
|
+
const bar = Math.floor(safeBeat / beatsPerBar) + 1;
|
|
206
|
+
const beatInBar = safeBeat % beatsPerBar + 1;
|
|
207
|
+
return `Bar ${bar}, Beat ${beatInBar.toFixed(1)}`;
|
|
208
|
+
}
|
|
209
|
+
function formatQuantizeDivisionLabel(division) {
|
|
210
|
+
switch (division) {
|
|
211
|
+
case "none":
|
|
212
|
+
return "Off (Instant)";
|
|
213
|
+
case "1/16":
|
|
214
|
+
return "1/16 (16th Note)";
|
|
215
|
+
case "1/8":
|
|
216
|
+
return "1/8 (8th Note)";
|
|
217
|
+
case "1/4":
|
|
218
|
+
return "1/4 (1 Beat)";
|
|
219
|
+
case "1/2":
|
|
220
|
+
return "1/2 (2 Beats)";
|
|
221
|
+
case "1_bar":
|
|
222
|
+
return "1 Bar (Downbeat)";
|
|
223
|
+
case "2_bars":
|
|
224
|
+
return "2 Bars";
|
|
225
|
+
case "4_bars":
|
|
226
|
+
return "4 Bars";
|
|
227
|
+
default:
|
|
228
|
+
return "1 Bar";
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function linearToDb(gain) {
|
|
232
|
+
if (gain <= 1e-4) return -96;
|
|
233
|
+
return 20 * Math.log10(gain);
|
|
234
|
+
}
|
|
235
|
+
function dbToLinear(db) {
|
|
236
|
+
return Math.pow(10, db / 20);
|
|
237
|
+
}
|
|
238
|
+
function midiToFrequency(note) {
|
|
239
|
+
return 440 * Math.pow(2, (note - 69) / 12);
|
|
240
|
+
}
|
|
241
|
+
var AudioConcepts = {
|
|
242
|
+
getDivisionBeatLength,
|
|
243
|
+
calculateNextQuantizeBeat,
|
|
244
|
+
formatBeatToBarBeat,
|
|
245
|
+
formatQuantizeDivisionLabel,
|
|
246
|
+
linearToDb,
|
|
247
|
+
dbToLinear,
|
|
248
|
+
midiToFrequency
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
// src/engine/BufferConcepts.ts
|
|
252
|
+
var BufferConcepts = {
|
|
253
|
+
/**
|
|
254
|
+
* Calculates current rolling cycle metrics, progress, and tolerance target cycle index.
|
|
255
|
+
*/
|
|
256
|
+
calculateCycleMetrics(currentBeat, bufferBars = 4, beatsPerBar = 4, tolBeforeBeats = 2, tolAfterBeats = 2) {
|
|
257
|
+
const bufferBeats = bufferBars * beatsPerBar;
|
|
258
|
+
const currentCycleIndex = Math.floor(currentBeat / bufferBeats);
|
|
259
|
+
const beatInCurrentCycle = currentBeat % bufferBeats;
|
|
260
|
+
const cycleProgress = Math.min(1, Math.max(0, beatInCurrentCycle / bufferBeats));
|
|
261
|
+
const isInPostToleranceZone = beatInCurrentCycle <= tolAfterBeats && currentCycleIndex > 0;
|
|
262
|
+
const isInPreToleranceZone = beatInCurrentCycle >= bufferBeats - tolBeforeBeats;
|
|
263
|
+
let targetedCycleIndex = currentCycleIndex;
|
|
264
|
+
if (isInPostToleranceZone) {
|
|
265
|
+
targetedCycleIndex = currentCycleIndex - 1;
|
|
266
|
+
}
|
|
267
|
+
return {
|
|
268
|
+
bufferBeats,
|
|
269
|
+
bufferBars,
|
|
270
|
+
currentCycleIndex,
|
|
271
|
+
beatInCurrentCycle,
|
|
272
|
+
cycleProgress,
|
|
273
|
+
isInPostToleranceZone,
|
|
274
|
+
isInPreToleranceZone,
|
|
275
|
+
targetedCycleIndex
|
|
276
|
+
};
|
|
277
|
+
},
|
|
278
|
+
/**
|
|
279
|
+
* Derives cycle start and end beat boundaries for a given cycle index.
|
|
280
|
+
*/
|
|
281
|
+
getCycleBoundaries(cycleIndex, bufferBars = 4, beatsPerBar = 4) {
|
|
282
|
+
const bufferBeats = bufferBars * beatsPerBar;
|
|
283
|
+
const startBeat = cycleIndex * bufferBeats;
|
|
284
|
+
const endBeat = startBeat + bufferBeats;
|
|
285
|
+
return { startBeat, endBeat };
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
// src/engine/GraphConcepts.ts
|
|
290
|
+
var GraphConcepts = {
|
|
291
|
+
/**
|
|
292
|
+
* Finds connected source node for a given target node & port/socket.
|
|
293
|
+
*/
|
|
294
|
+
findSourceNode(targetNodeId, targetPort, connections, allNodes) {
|
|
295
|
+
const conn = connections.find(
|
|
296
|
+
(c) => c.toNodeId === targetNodeId && (c.toPort === targetPort || c.toSocketIndex === 0)
|
|
297
|
+
);
|
|
298
|
+
if (!conn) return null;
|
|
299
|
+
return allNodes.find((n) => n.id === conn.fromNodeId) || null;
|
|
300
|
+
},
|
|
301
|
+
/**
|
|
302
|
+
* Finds connected target node for a given source node & port/socket.
|
|
303
|
+
*/
|
|
304
|
+
findTargetNode(sourceNodeId, sourcePort, connections, allNodes) {
|
|
305
|
+
const conn = connections.find(
|
|
306
|
+
(c) => c.fromNodeId === sourceNodeId && (c.fromPort === sourcePort || c.fromSocketIndex === 0)
|
|
307
|
+
);
|
|
308
|
+
if (!conn) return null;
|
|
309
|
+
return allNodes.find((n) => n.id === conn.toNodeId) || null;
|
|
310
|
+
},
|
|
311
|
+
/**
|
|
312
|
+
* Finds connected container target for a node (e.g. for Player or Recorder).
|
|
313
|
+
*/
|
|
314
|
+
findTargetContainer(sourceNodeId, sourcePort, connections, allNodes) {
|
|
315
|
+
const node = GraphConcepts.findTargetNode(sourceNodeId, sourcePort, connections, allNodes);
|
|
316
|
+
if (node && node.type === "container") {
|
|
317
|
+
return node;
|
|
318
|
+
}
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
var findSourceNode = GraphConcepts.findSourceNode;
|
|
323
|
+
var findTargetNode = GraphConcepts.findTargetNode;
|
|
324
|
+
var findTargetContainer = GraphConcepts.findTargetContainer;
|
|
325
|
+
|
|
326
|
+
// src/engine/UIConcepts.ts
|
|
327
|
+
var activePaletteResolver = () => ({
|
|
328
|
+
id: "black_and_gold",
|
|
329
|
+
name: "Black & Gold",
|
|
330
|
+
backgroundPrimary: "#0a0a0d",
|
|
331
|
+
accentPrimary: "#f59e0b"
|
|
332
|
+
});
|
|
333
|
+
function configureActivePaletteResolver(resolver) {
|
|
334
|
+
activePaletteResolver = resolver;
|
|
335
|
+
}
|
|
336
|
+
function getActivePalette() {
|
|
337
|
+
return activePaletteResolver();
|
|
338
|
+
}
|
|
339
|
+
function resolveTooltipDirection(preferred = "bottom", elementRect, topThreshold = 80) {
|
|
340
|
+
if (elementRect && elementRect.top < topThreshold) {
|
|
341
|
+
return "bottom";
|
|
342
|
+
}
|
|
343
|
+
return preferred;
|
|
344
|
+
}
|
|
345
|
+
function getTooltipPlacementClasses(direction) {
|
|
346
|
+
switch (direction) {
|
|
347
|
+
case "top":
|
|
348
|
+
return "bottom-full mb-1.5 left-1/2 -translate-x-1/2";
|
|
349
|
+
case "bottom":
|
|
350
|
+
return "top-full mt-1.5 left-1/2 -translate-x-1/2";
|
|
351
|
+
case "left":
|
|
352
|
+
return "right-full mr-1.5 top-1/2 -translate-y-1/2";
|
|
353
|
+
case "right":
|
|
354
|
+
return "left-full ml-1.5 top-1/2 -translate-y-1/2";
|
|
355
|
+
default:
|
|
356
|
+
return "top-full mt-1.5 left-1/2 -translate-x-1/2";
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
function parseBufferedNumber(raw, min, max, fallback) {
|
|
360
|
+
const trimmed = raw.trim();
|
|
361
|
+
if (trimmed === "") return fallback;
|
|
362
|
+
const num = Number(trimmed);
|
|
363
|
+
if (isNaN(num)) return fallback;
|
|
364
|
+
return Math.max(min, Math.min(max, num));
|
|
365
|
+
}
|
|
366
|
+
var UIConcepts = {
|
|
367
|
+
resolveTooltipDirection,
|
|
368
|
+
getTooltipPlacementClasses,
|
|
369
|
+
parseBufferedNumber,
|
|
370
|
+
getActivePalette,
|
|
371
|
+
glows: {
|
|
372
|
+
amber: "shadow-[0_0_12px_rgba(245,158,11,0.35)]",
|
|
373
|
+
sky: "shadow-[0_0_12px_rgba(14,165,233,0.35)]",
|
|
374
|
+
emerald: "shadow-[0_0_12px_rgba(16,185,129,0.35)]",
|
|
375
|
+
rose: "shadow-[0_0_12px_rgba(244,63,94,0.35)]",
|
|
376
|
+
cyan: "shadow-[0_0_12px_rgba(6,182,212,0.35)]",
|
|
377
|
+
purple: "shadow-[0_0_12px_rgba(168,85,247,0.35)]"
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
|
|
25
381
|
// src/engine/core/hierarchy/core/GraphEntityParent.ts
|
|
26
382
|
var GraphEntityParent = class {
|
|
27
383
|
id;
|
|
@@ -91,56 +447,6 @@ var GraphEntityParent = class {
|
|
|
91
447
|
}
|
|
92
448
|
};
|
|
93
449
|
|
|
94
|
-
// src/engine/types/stripsTypes.ts
|
|
95
|
-
function createDefaultMapIoConfig() {
|
|
96
|
-
return {
|
|
97
|
-
inputs: [
|
|
98
|
-
{
|
|
99
|
-
id: "map-in-audio-bus-in-1",
|
|
100
|
-
sourceId: "bus-in-1",
|
|
101
|
-
name: "Physical Audio In 1",
|
|
102
|
-
type: "audio",
|
|
103
|
-
direction: "input",
|
|
104
|
-
enabled: true,
|
|
105
|
-
gain: 1,
|
|
106
|
-
color: "#f59e0b",
|
|
107
|
-
audioFormat: "mono",
|
|
108
|
-
signalType: "audio_mono",
|
|
109
|
-
ioLevel: "physical",
|
|
110
|
-
portType: "external_endpoint"
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
id: "map-in-midi-profile-1",
|
|
114
|
-
sourceId: "midi-profile-1",
|
|
115
|
-
name: "Physical MIDI In (Main Stage)",
|
|
116
|
-
type: "midi",
|
|
117
|
-
direction: "input",
|
|
118
|
-
enabled: true,
|
|
119
|
-
color: "#38bdf8",
|
|
120
|
-
signalType: "midi_stream",
|
|
121
|
-
ioLevel: "physical",
|
|
122
|
-
portType: "external_endpoint"
|
|
123
|
-
}
|
|
124
|
-
],
|
|
125
|
-
outputs: [
|
|
126
|
-
{
|
|
127
|
-
id: "map-out-audio-master",
|
|
128
|
-
sourceId: "bus-out-master",
|
|
129
|
-
name: "Master Output L/R",
|
|
130
|
-
type: "audio",
|
|
131
|
-
direction: "output",
|
|
132
|
-
enabled: true,
|
|
133
|
-
gain: 1,
|
|
134
|
-
color: "#10b981",
|
|
135
|
-
audioFormat: "stereo",
|
|
136
|
-
signalType: "audio_stereo",
|
|
137
|
-
ioLevel: "physical",
|
|
138
|
-
portType: "external_endpoint"
|
|
139
|
-
}
|
|
140
|
-
]
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
|
|
144
450
|
// src/engine/functions/codeNodeParser.ts
|
|
145
451
|
function stripComments(code) {
|
|
146
452
|
let result = code.replace(/\/\/[^\n\r]*/g, (match) => " ".repeat(match.length));
|
|
@@ -4279,12 +4585,12 @@ function constrainSocketOffset(node, socketId, isOutput, index, totalSockets, ra
|
|
|
4279
4585
|
var constrainSocketNudge = constrainSocketOffset;
|
|
4280
4586
|
|
|
4281
4587
|
// src/engine/core/hierarchy/ui/UIElementBase.ts
|
|
4282
|
-
var
|
|
4588
|
+
var activePaletteResolver2 = () => ({});
|
|
4283
4589
|
function registerQwnsrPaletteResolver(fn) {
|
|
4284
|
-
|
|
4590
|
+
activePaletteResolver2 = fn;
|
|
4285
4591
|
}
|
|
4286
|
-
function
|
|
4287
|
-
return
|
|
4592
|
+
function getActivePalette2() {
|
|
4593
|
+
return activePaletteResolver2();
|
|
4288
4594
|
}
|
|
4289
4595
|
var UIElementBase = class extends GraphEntityParent {
|
|
4290
4596
|
themeRole;
|
|
@@ -4304,7 +4610,7 @@ var UIElementBase = class extends GraphEntityParent {
|
|
|
4304
4610
|
this.tooltipDir = "bottom";
|
|
4305
4611
|
}
|
|
4306
4612
|
getPalette() {
|
|
4307
|
-
return
|
|
4613
|
+
return getActivePalette2();
|
|
4308
4614
|
}
|
|
4309
4615
|
setDisabled(disabled) {
|
|
4310
4616
|
if (this.isDisabled !== disabled) {
|
|
@@ -4553,58 +4859,6 @@ var MagneticGraphManager = class {
|
|
|
4553
4859
|
}
|
|
4554
4860
|
};
|
|
4555
4861
|
|
|
4556
|
-
// src/engine/functions/rotaryGeometry.ts
|
|
4557
|
-
function polarToCartesian(centerX, centerY, rad, angleInDegrees) {
|
|
4558
|
-
const angleInRadians = (angleInDegrees - 90) * Math.PI / 180;
|
|
4559
|
-
return {
|
|
4560
|
-
x: centerX + rad * Math.cos(angleInRadians),
|
|
4561
|
-
y: centerY + rad * Math.sin(angleInRadians)
|
|
4562
|
-
};
|
|
4563
|
-
}
|
|
4564
|
-
function describeSvgArc(x, y, rad, startAng, endAng) {
|
|
4565
|
-
const start = polarToCartesian(x, y, rad, endAng);
|
|
4566
|
-
const end = polarToCartesian(x, y, rad, startAng);
|
|
4567
|
-
const arcSweep = endAng - startAng <= 180 ? "0" : "1";
|
|
4568
|
-
return ["M", start.x, start.y, "A", rad, rad, 0, arcSweep, 0, end.x, end.y].join(" ");
|
|
4569
|
-
}
|
|
4570
|
-
|
|
4571
|
-
// src/engine/GraphConcepts.ts
|
|
4572
|
-
var GraphConcepts = {
|
|
4573
|
-
/**
|
|
4574
|
-
* Finds connected source node for a given target node & port/socket.
|
|
4575
|
-
*/
|
|
4576
|
-
findSourceNode(targetNodeId, targetPort, connections, allNodes) {
|
|
4577
|
-
const conn = connections.find(
|
|
4578
|
-
(c) => c.toNodeId === targetNodeId && (c.toPort === targetPort || c.toSocketIndex === 0)
|
|
4579
|
-
);
|
|
4580
|
-
if (!conn) return null;
|
|
4581
|
-
return allNodes.find((n) => n.id === conn.fromNodeId) || null;
|
|
4582
|
-
},
|
|
4583
|
-
/**
|
|
4584
|
-
* Finds connected target node for a given source node & port/socket.
|
|
4585
|
-
*/
|
|
4586
|
-
findTargetNode(sourceNodeId, sourcePort, connections, allNodes) {
|
|
4587
|
-
const conn = connections.find(
|
|
4588
|
-
(c) => c.fromNodeId === sourceNodeId && (c.fromPort === sourcePort || c.fromSocketIndex === 0)
|
|
4589
|
-
);
|
|
4590
|
-
if (!conn) return null;
|
|
4591
|
-
return allNodes.find((n) => n.id === conn.toNodeId) || null;
|
|
4592
|
-
},
|
|
4593
|
-
/**
|
|
4594
|
-
* Finds connected container target for a node (e.g. for Player or Recorder).
|
|
4595
|
-
*/
|
|
4596
|
-
findTargetContainer(sourceNodeId, sourcePort, connections, allNodes) {
|
|
4597
|
-
const node = GraphConcepts.findTargetNode(sourceNodeId, sourcePort, connections, allNodes);
|
|
4598
|
-
if (node && node.type === "container") {
|
|
4599
|
-
return node;
|
|
4600
|
-
}
|
|
4601
|
-
return null;
|
|
4602
|
-
}
|
|
4603
|
-
};
|
|
4604
|
-
var findSourceNode = GraphConcepts.findSourceNode;
|
|
4605
|
-
var findTargetNode = GraphConcepts.findTargetNode;
|
|
4606
|
-
var findTargetContainer = GraphConcepts.findTargetContainer;
|
|
4607
|
-
|
|
4608
4862
|
// src/engine/functions/containerFactory.ts
|
|
4609
4863
|
function createContainerNode(type, index, bpm, position, audioFormat) {
|
|
4610
4864
|
const id = `cont-${Date.now()}`;
|
|
@@ -6481,116 +6735,206 @@ function initializeCoreArchetypes() {
|
|
|
6481
6735
|
}
|
|
6482
6736
|
initializeCoreArchetypes();
|
|
6483
6737
|
|
|
6484
|
-
// src/engine/
|
|
6485
|
-
function
|
|
6486
|
-
const
|
|
6487
|
-
const
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6738
|
+
// src/engine/core/exposedSocketsManager.ts
|
|
6739
|
+
function getAllProjectSockets(nodes) {
|
|
6740
|
+
const allInputs = [];
|
|
6741
|
+
const allOutputs = [];
|
|
6742
|
+
const exposedList = [];
|
|
6743
|
+
nodes.forEach((node) => {
|
|
6744
|
+
const nodeExposedRefs = node.exposedSockets || [];
|
|
6745
|
+
const exposedSocketIdSet = new Set(nodeExposedRefs.map((r) => `${r.socketId}_${r.direction}`));
|
|
6746
|
+
const { inputs, outputs } = getNodeSockets(node);
|
|
6747
|
+
inputs.forEach((sock, idx) => {
|
|
6748
|
+
const isExposed = exposedSocketIdSet.has(`${sock.socketId}_input`);
|
|
6749
|
+
const ref = {
|
|
6750
|
+
id: `${node.id}_${sock.socketId}_in`,
|
|
6751
|
+
nodeId: node.id,
|
|
6752
|
+
nodeName: node.name || node.label || "Node",
|
|
6753
|
+
nodeType: node.type,
|
|
6754
|
+
socketId: sock.socketId,
|
|
6755
|
+
socketIndex: idx,
|
|
6756
|
+
label: sock.label || sock.socketId,
|
|
6757
|
+
direction: "input",
|
|
6758
|
+
signalType: sock.signalType || "trigger",
|
|
6759
|
+
medium: sock.medium,
|
|
6760
|
+
dataType: sock.dataType,
|
|
6761
|
+
isExposed
|
|
6762
|
+
};
|
|
6763
|
+
allInputs.push(ref);
|
|
6764
|
+
if (isExposed) exposedList.push(ref);
|
|
6765
|
+
});
|
|
6766
|
+
outputs.forEach((sock, idx) => {
|
|
6767
|
+
const isExposed = exposedSocketIdSet.has(`${sock.socketId}_output`);
|
|
6768
|
+
const ref = {
|
|
6769
|
+
id: `${node.id}_${sock.socketId}_out`,
|
|
6770
|
+
nodeId: node.id,
|
|
6771
|
+
nodeName: node.name || node.label || "Node",
|
|
6772
|
+
nodeType: node.type,
|
|
6773
|
+
socketId: sock.socketId,
|
|
6774
|
+
socketIndex: idx,
|
|
6775
|
+
label: sock.label || sock.socketId,
|
|
6776
|
+
direction: "output",
|
|
6777
|
+
signalType: sock.signalType || "trigger",
|
|
6778
|
+
medium: sock.medium,
|
|
6779
|
+
dataType: sock.dataType,
|
|
6780
|
+
isExposed
|
|
6781
|
+
};
|
|
6782
|
+
allOutputs.push(ref);
|
|
6783
|
+
if (isExposed) exposedList.push(ref);
|
|
6784
|
+
});
|
|
6785
|
+
});
|
|
6786
|
+
return {
|
|
6787
|
+
inputs: allInputs,
|
|
6788
|
+
outputs: allOutputs,
|
|
6789
|
+
exposedList
|
|
6790
|
+
};
|
|
6791
|
+
}
|
|
6792
|
+
function toggleNodeSocketExposure(nodes, nodeId, socketId, direction) {
|
|
6793
|
+
return nodes.map((node) => {
|
|
6794
|
+
if (node.id !== nodeId) return node;
|
|
6795
|
+
const currentExposed = node.exposedSockets || [];
|
|
6796
|
+
const existsIndex = currentExposed.findIndex(
|
|
6797
|
+
(r) => r.socketId === socketId && r.direction === direction
|
|
6798
|
+
);
|
|
6799
|
+
let updatedExposed;
|
|
6800
|
+
if (existsIndex >= 0) {
|
|
6801
|
+
updatedExposed = currentExposed.filter((_, idx) => idx !== existsIndex);
|
|
6802
|
+
} else {
|
|
6803
|
+
const { inputs, outputs } = getNodeSockets(node);
|
|
6804
|
+
const pool = direction === "input" ? inputs : outputs;
|
|
6805
|
+
const sockDef = pool.find((s) => s.socketId === socketId) || pool[0];
|
|
6806
|
+
const newRef = {
|
|
6807
|
+
id: `${node.id}_${socketId}_${direction}`,
|
|
6808
|
+
nodeId: node.id,
|
|
6809
|
+
nodeName: node.name || node.label || "Node",
|
|
6810
|
+
nodeType: node.type,
|
|
6811
|
+
socketId,
|
|
6812
|
+
socketIndex: sockDef?.socketIndex ?? 0,
|
|
6813
|
+
label: sockDef?.label || socketId,
|
|
6814
|
+
direction,
|
|
6815
|
+
signalType: sockDef?.signalType || "trigger",
|
|
6816
|
+
medium: sockDef?.medium,
|
|
6817
|
+
dataType: sockDef?.dataType,
|
|
6818
|
+
isExposed: true
|
|
6819
|
+
};
|
|
6820
|
+
updatedExposed = [...currentExposed, newRef];
|
|
6821
|
+
}
|
|
6502
6822
|
return {
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
portLabel: targetSocket.label,
|
|
6506
|
-
socketTitle,
|
|
6507
|
-
signalName: `${mediumLabel} (${dataFormatLabel})`,
|
|
6508
|
-
signalColor: targetSocket.colorStr
|
|
6823
|
+
...node,
|
|
6824
|
+
exposedSockets: updatedExposed
|
|
6509
6825
|
};
|
|
6826
|
+
});
|
|
6827
|
+
}
|
|
6828
|
+
|
|
6829
|
+
// src/engine/core/subgraphIoTransform.ts
|
|
6830
|
+
function convertPhysicalInputToStreamHandle(channel, index) {
|
|
6831
|
+
let medium = "audio_stereo";
|
|
6832
|
+
let signalType = "audio_stereo";
|
|
6833
|
+
if (channel.type === "trigger" || channel.signalType === "trigger" || channel.signalType === "trigger_stream") {
|
|
6834
|
+
medium = "trigger";
|
|
6835
|
+
signalType = "trigger_stream";
|
|
6836
|
+
} else if (channel.type === "audio") {
|
|
6837
|
+
const isMono = channel.signalType === "audio_mono" || channel.audioFormat === "mono";
|
|
6838
|
+
medium = isMono ? "audio_mono" : "audio_stereo";
|
|
6839
|
+
signalType = isMono ? "audio_mono" : "audio_stereo";
|
|
6840
|
+
} else if (channel.type === "midi") {
|
|
6841
|
+
medium = "midi";
|
|
6842
|
+
signalType = "midi_stream";
|
|
6843
|
+
} else if (channel.type === "osc" || channel.signalType === "curve" || channel.signalType === "curve_stream") {
|
|
6844
|
+
medium = "curve";
|
|
6845
|
+
signalType = "curve_stream";
|
|
6846
|
+
} else {
|
|
6847
|
+
medium = "data";
|
|
6848
|
+
signalType = channel.signalType || "data";
|
|
6510
6849
|
}
|
|
6511
|
-
const
|
|
6512
|
-
const
|
|
6850
|
+
const formatLabel = channel.type === "audio" ? medium === "audio_mono" ? "Mono" : "Stereo" : "";
|
|
6851
|
+
const typeLabel = channel.type === "audio" ? `Audio ${formatLabel}`.trim() : channel.type.toUpperCase();
|
|
6513
6852
|
return {
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6853
|
+
id: `sub-in-${channel.id || channel.sourceId || index}`,
|
|
6854
|
+
name: channel.name || `${typeLabel} Stream In`,
|
|
6855
|
+
direction: "input",
|
|
6856
|
+
polarity: "input",
|
|
6857
|
+
type: channel.type,
|
|
6858
|
+
signalType,
|
|
6859
|
+
medium,
|
|
6860
|
+
variant: "stream",
|
|
6861
|
+
// Enforced STREAM variant rule
|
|
6862
|
+
dataType: "stream",
|
|
6863
|
+
audioFormat: channel.audioFormat || (medium === "audio_mono" ? "mono" : "stereo"),
|
|
6864
|
+
color: channel.color || (channel.type === "audio" ? "#38bdf8" : channel.type === "midi" ? "#ec4899" : "#eab308"),
|
|
6865
|
+
sourceChannelId: channel.id,
|
|
6866
|
+
socketIndex: index
|
|
6519
6867
|
};
|
|
6520
6868
|
}
|
|
6521
|
-
function
|
|
6522
|
-
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
medium
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
bgStr: "#212c47",
|
|
6541
|
-
iconName: "zap",
|
|
6542
|
-
isCustom: false
|
|
6543
|
-
};
|
|
6544
|
-
const options = [];
|
|
6545
|
-
const archetypes = getAllNodeArchetypes();
|
|
6546
|
-
for (const archetype of archetypes) {
|
|
6547
|
-
const prototypeNode = archetype.createPrototype();
|
|
6548
|
-
const candidateSockets = getNodeSockets(prototypeNode);
|
|
6549
|
-
if (direction === "in") {
|
|
6550
|
-
for (const candidateOut of candidateSockets.outputs) {
|
|
6551
|
-
const comp = areSignalsCompatible(candidateOut, sourceSocket);
|
|
6552
|
-
if (comp.isCompatible) {
|
|
6553
|
-
options.push({
|
|
6554
|
-
id: `${archetype.id}:${candidateOut.socketId}`,
|
|
6555
|
-
category: archetype.category,
|
|
6556
|
-
label: archetype.label,
|
|
6557
|
-
description: candidateOut.description || archetype.defaultDescription,
|
|
6558
|
-
iconName: candidateOut.iconName || archetype.iconName,
|
|
6559
|
-
colorHex: candidateOut.colorStr,
|
|
6560
|
-
badge: `${candidateOut.label} \u2794 ${sourceSocket.label}`,
|
|
6561
|
-
matchingSocketId: candidateOut.socketId,
|
|
6562
|
-
matchingSocketIndex: candidateOut.socketIndex,
|
|
6563
|
-
spawnType: archetype.spawnType
|
|
6564
|
-
});
|
|
6565
|
-
break;
|
|
6566
|
-
}
|
|
6567
|
-
}
|
|
6568
|
-
} else {
|
|
6569
|
-
for (const candidateIn of candidateSockets.inputs) {
|
|
6570
|
-
const comp = areSignalsCompatible(sourceSocket, candidateIn);
|
|
6571
|
-
if (comp.isCompatible) {
|
|
6572
|
-
options.push({
|
|
6573
|
-
id: `${archetype.id}:${candidateIn.socketId}`,
|
|
6574
|
-
category: archetype.category,
|
|
6575
|
-
label: archetype.label,
|
|
6576
|
-
description: candidateIn.description || archetype.defaultDescription,
|
|
6577
|
-
iconName: candidateIn.iconName || archetype.iconName,
|
|
6578
|
-
colorHex: candidateIn.colorStr,
|
|
6579
|
-
badge: `${sourceSocket.label} \u2794 ${candidateIn.label}`,
|
|
6580
|
-
matchingSocketId: candidateIn.socketId,
|
|
6581
|
-
matchingSocketIndex: candidateIn.socketIndex,
|
|
6582
|
-
spawnType: archetype.spawnType
|
|
6583
|
-
});
|
|
6584
|
-
break;
|
|
6585
|
-
}
|
|
6586
|
-
}
|
|
6587
|
-
}
|
|
6869
|
+
function convertPhysicalOutputToStreamHandle(channel, index) {
|
|
6870
|
+
let medium = "audio_stereo";
|
|
6871
|
+
let signalType = "audio_stereo";
|
|
6872
|
+
if (channel.type === "trigger" || channel.signalType === "trigger" || channel.signalType === "trigger_stream") {
|
|
6873
|
+
medium = "trigger";
|
|
6874
|
+
signalType = "trigger_stream";
|
|
6875
|
+
} else if (channel.type === "audio") {
|
|
6876
|
+
const isMono = channel.signalType === "audio_mono" || channel.audioFormat === "mono";
|
|
6877
|
+
medium = isMono ? "audio_mono" : "audio_stereo";
|
|
6878
|
+
signalType = isMono ? "audio_mono" : "audio_stereo";
|
|
6879
|
+
} else if (channel.type === "midi") {
|
|
6880
|
+
medium = "midi";
|
|
6881
|
+
signalType = "midi_stream";
|
|
6882
|
+
} else if (channel.type === "osc" || channel.signalType === "curve" || channel.signalType === "curve_stream") {
|
|
6883
|
+
medium = "curve";
|
|
6884
|
+
signalType = "curve_stream";
|
|
6885
|
+
} else {
|
|
6886
|
+
medium = "data";
|
|
6887
|
+
signalType = channel.signalType || "data";
|
|
6588
6888
|
}
|
|
6889
|
+
const formatLabel = channel.type === "audio" ? medium === "audio_mono" ? "Mono" : "Stereo" : "";
|
|
6890
|
+
const typeLabel = channel.type === "audio" ? `Audio ${formatLabel}`.trim() : channel.type.toUpperCase();
|
|
6589
6891
|
return {
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
|
|
6892
|
+
id: `sub-out-${channel.id || channel.sourceId || index}`,
|
|
6893
|
+
name: channel.name || `${typeLabel} Stream Out`,
|
|
6894
|
+
direction: "output",
|
|
6895
|
+
polarity: "output",
|
|
6896
|
+
type: channel.type,
|
|
6897
|
+
signalType,
|
|
6898
|
+
medium,
|
|
6899
|
+
variant: "stream",
|
|
6900
|
+
// Enforced STREAM variant rule
|
|
6901
|
+
dataType: "stream",
|
|
6902
|
+
audioFormat: channel.audioFormat || (medium === "audio_mono" ? "mono" : "stereo"),
|
|
6903
|
+
color: channel.color || (channel.type === "audio" ? "#10b981" : channel.type === "midi" ? "#ec4899" : "#eab308"),
|
|
6904
|
+
sourceChannelId: channel.id,
|
|
6905
|
+
socketIndex: index
|
|
6906
|
+
};
|
|
6907
|
+
}
|
|
6908
|
+
function deriveSubgraphHandlesFromGraph(graphDefinition) {
|
|
6909
|
+
const ioConfig = graphDefinition?.mapIoConfig || createDefaultMapIoConfig();
|
|
6910
|
+
const physicalInputs = ioConfig.inputs || [];
|
|
6911
|
+
const physicalOutputs = ioConfig.outputs || [];
|
|
6912
|
+
const inputHandles = physicalInputs.map((input, idx) => convertPhysicalInputToStreamHandle(input, idx));
|
|
6913
|
+
const outputHandles = physicalOutputs.map((output, idx) => convertPhysicalOutputToStreamHandle(output, idx));
|
|
6914
|
+
return {
|
|
6915
|
+
inputHandles,
|
|
6916
|
+
outputHandles
|
|
6917
|
+
};
|
|
6918
|
+
}
|
|
6919
|
+
function instantiateSubgraphNode(graphDefinition, nodeIndex, position = [0, 0, 0]) {
|
|
6920
|
+
const { inputHandles, outputHandles } = deriveSubgraphHandlesFromGraph(graphDefinition);
|
|
6921
|
+
return {
|
|
6922
|
+
id: `subgraph-${graphDefinition.id}-${Date.now()}-${Math.random().toString(36).substring(2, 6)}`,
|
|
6923
|
+
type: "subgraph",
|
|
6924
|
+
name: graphDefinition.name || "Subgraph Node",
|
|
6925
|
+
position,
|
|
6926
|
+
color: "#8b5cf6",
|
|
6927
|
+
// Violet Subgraph theme color
|
|
6928
|
+
radius: 1.8,
|
|
6929
|
+
label: `Graph: ${graphDefinition.name || graphDefinition.id}`,
|
|
6930
|
+
active: true,
|
|
6931
|
+
graphId: graphDefinition.id,
|
|
6932
|
+
graphName: graphDefinition.name || "Invoked Graph",
|
|
6933
|
+
graphType: graphDefinition.type || "custom",
|
|
6934
|
+
customTypeTag: graphDefinition.customTypeTag,
|
|
6935
|
+
inputHandles,
|
|
6936
|
+
outputHandles,
|
|
6937
|
+
innerGraphDefinition: graphDefinition
|
|
6594
6938
|
};
|
|
6595
6939
|
}
|
|
6596
6940
|
|
|
@@ -6670,70 +7014,1970 @@ function executeSceneGraphSpawningSequence(nodes, connections) {
|
|
|
6670
7014
|
};
|
|
6671
7015
|
}
|
|
6672
7016
|
|
|
6673
|
-
// src/engine/
|
|
6674
|
-
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
);
|
|
6682
|
-
|
|
6683
|
-
return
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
|
|
6696
|
-
|
|
6697
|
-
|
|
6698
|
-
|
|
6699
|
-
|
|
6700
|
-
|
|
6701
|
-
|
|
6702
|
-
|
|
7017
|
+
// src/engine/core/graphDataService.ts
|
|
7018
|
+
var GraphDataService = class {
|
|
7019
|
+
/**
|
|
7020
|
+
* Fetches enriched node payloads with pluggable 2D sprite descriptors.
|
|
7021
|
+
*/
|
|
7022
|
+
static getEnrichedNodes(nodes, connections) {
|
|
7023
|
+
return nodes.map((node) => {
|
|
7024
|
+
const inCount = connections.filter((c) => c.toNodeId === node.id).length;
|
|
7025
|
+
const outCount = connections.filter((c) => c.fromNodeId === node.id).length;
|
|
7026
|
+
const sprite2D = NodeAssetRegistry.get2DSpriteSetting(node);
|
|
7027
|
+
return {
|
|
7028
|
+
node,
|
|
7029
|
+
sprite2D,
|
|
7030
|
+
connectedInputCount: inCount,
|
|
7031
|
+
connectedOutputCount: outCount
|
|
7032
|
+
};
|
|
7033
|
+
});
|
|
7034
|
+
}
|
|
7035
|
+
/**
|
|
7036
|
+
* Resolves 2D canvas coordinates from 3D world coordinates.
|
|
7037
|
+
* In 3D space: [X, Y (elevation), Z (depth)] -> In 2D plane: [X, Z] mapped to screen (x, y).
|
|
7038
|
+
*/
|
|
7039
|
+
static worldToCanvasCoords(worldPos, pan, zoom, center, worldScale = 40) {
|
|
7040
|
+
const screenX = center.cx + (worldPos[0] * worldScale + pan.x) * zoom;
|
|
7041
|
+
const screenY = center.cy + (worldPos[2] * worldScale + pan.y) * zoom;
|
|
7042
|
+
return { x: screenX, y: screenY };
|
|
7043
|
+
}
|
|
7044
|
+
/**
|
|
7045
|
+
* Resolves 3D world coordinates from 2D screen click coordinates.
|
|
7046
|
+
*/
|
|
7047
|
+
static canvasToWorldCoords(screenPos, pan, zoom, center, worldScale = 40) {
|
|
7048
|
+
const worldX = (screenPos.x - center.cx) / (worldScale * zoom) - pan.x / worldScale;
|
|
7049
|
+
const worldZ = (screenPos.y - center.cy) / (worldScale * zoom) - pan.y / worldScale;
|
|
7050
|
+
return [worldX, 0, worldZ];
|
|
7051
|
+
}
|
|
7052
|
+
/**
|
|
7053
|
+
* Creates a standardized snapshot of the active graph.
|
|
7054
|
+
*/
|
|
7055
|
+
static createGraphSnapshot(nodes, connections) {
|
|
7056
|
+
const validation = validateProjectGraph(nodes, connections);
|
|
7057
|
+
return {
|
|
7058
|
+
nodes: nodes.map((n) => projectNodeToGroundSurface(n)),
|
|
7059
|
+
connections,
|
|
7060
|
+
meta: {
|
|
7061
|
+
nodeCount: nodes.length,
|
|
7062
|
+
wireCount: connections.length,
|
|
7063
|
+
isValid: validation.isValid,
|
|
7064
|
+
timestamp: Date.now()
|
|
7065
|
+
}
|
|
7066
|
+
};
|
|
7067
|
+
}
|
|
7068
|
+
};
|
|
7069
|
+
|
|
7070
|
+
// src/engine/core/graphDependencyValidator.ts
|
|
7071
|
+
function validateGraphImport(existingGraphs, targetGraphId, candidateImportId) {
|
|
7072
|
+
if (targetGraphId === candidateImportId) {
|
|
7073
|
+
return {
|
|
7074
|
+
valid: false,
|
|
7075
|
+
error: `Circular dependency: A graph package cannot import itself ('${targetGraphId}').`,
|
|
7076
|
+
cycleChain: [targetGraphId, targetGraphId]
|
|
7077
|
+
};
|
|
7078
|
+
}
|
|
7079
|
+
const target = existingGraphs[targetGraphId];
|
|
7080
|
+
if (target?.importedGraphIds?.includes(candidateImportId)) {
|
|
7081
|
+
return {
|
|
7082
|
+
valid: false,
|
|
7083
|
+
error: `Graph '${target.name || targetGraphId}' already imports '${candidateImportId}'.`
|
|
7084
|
+
};
|
|
7085
|
+
}
|
|
7086
|
+
const adj = /* @__PURE__ */ new Map();
|
|
7087
|
+
for (const [id, graph] of Object.entries(existingGraphs)) {
|
|
7088
|
+
const list = Array.isArray(graph.importedGraphIds) ? [...graph.importedGraphIds] : [];
|
|
7089
|
+
adj.set(id, list);
|
|
7090
|
+
}
|
|
7091
|
+
if (!adj.has(targetGraphId)) adj.set(targetGraphId, []);
|
|
7092
|
+
if (!adj.has(candidateImportId)) adj.set(candidateImportId, []);
|
|
7093
|
+
adj.get(targetGraphId).push(candidateImportId);
|
|
7094
|
+
const visited = /* @__PURE__ */ new Set();
|
|
7095
|
+
const recursionStack = /* @__PURE__ */ new Set();
|
|
7096
|
+
const currentPath = [];
|
|
7097
|
+
function detectCycle(current) {
|
|
7098
|
+
visited.add(current);
|
|
7099
|
+
recursionStack.add(current);
|
|
7100
|
+
currentPath.push(current);
|
|
7101
|
+
const neighbors = adj.get(current) || [];
|
|
7102
|
+
for (const neighbor of neighbors) {
|
|
7103
|
+
if (!visited.has(neighbor)) {
|
|
7104
|
+
const cycle = detectCycle(neighbor);
|
|
7105
|
+
if (cycle) return cycle;
|
|
7106
|
+
} else if (recursionStack.has(neighbor)) {
|
|
7107
|
+
const cycleStartIndex = currentPath.indexOf(neighbor);
|
|
7108
|
+
const cyclePath = [...currentPath.slice(cycleStartIndex), neighbor];
|
|
7109
|
+
return cyclePath;
|
|
7110
|
+
}
|
|
7111
|
+
}
|
|
7112
|
+
currentPath.pop();
|
|
7113
|
+
recursionStack.delete(current);
|
|
7114
|
+
return null;
|
|
7115
|
+
}
|
|
7116
|
+
for (const node of adj.keys()) {
|
|
7117
|
+
if (!visited.has(node)) {
|
|
7118
|
+
currentPath.length = 0;
|
|
7119
|
+
const cycle = detectCycle(node);
|
|
7120
|
+
if (cycle) {
|
|
7121
|
+
const names = cycle.map((id) => existingGraphs[id]?.name || id);
|
|
7122
|
+
return {
|
|
7123
|
+
valid: false,
|
|
7124
|
+
error: `Circular dependency detected: ${names.join(" \u2794 ")}`,
|
|
7125
|
+
cycleChain: cycle
|
|
7126
|
+
};
|
|
7127
|
+
}
|
|
7128
|
+
}
|
|
7129
|
+
}
|
|
7130
|
+
return { valid: true };
|
|
7131
|
+
}
|
|
7132
|
+
function getTopologicalDependencyOrder(existingGraphs, rootGraphId) {
|
|
7133
|
+
const result = [];
|
|
7134
|
+
const visited = /* @__PURE__ */ new Set();
|
|
7135
|
+
function dfs(currentId) {
|
|
7136
|
+
if (visited.has(currentId)) return;
|
|
7137
|
+
visited.add(currentId);
|
|
7138
|
+
const graph = existingGraphs[currentId];
|
|
7139
|
+
if (graph?.importedGraphIds) {
|
|
7140
|
+
for (const impId of graph.importedGraphIds) {
|
|
7141
|
+
dfs(impId);
|
|
7142
|
+
}
|
|
7143
|
+
}
|
|
7144
|
+
result.push(currentId);
|
|
7145
|
+
}
|
|
7146
|
+
dfs(rootGraphId);
|
|
7147
|
+
return result;
|
|
7148
|
+
}
|
|
7149
|
+
|
|
7150
|
+
// src/engine/core/graphTypeSystem.ts
|
|
7151
|
+
var GRAPH_TYPE_DEFINITIONS = {
|
|
7152
|
+
intro_motif: {
|
|
7153
|
+
id: "intro_motif",
|
|
7154
|
+
label: "Intro / Motif",
|
|
7155
|
+
category: "Composition",
|
|
7156
|
+
description: "Hook, thematic motif, melodic ostinato, or musical intro sequence",
|
|
7157
|
+
badgeColor: "#38bdf8",
|
|
7158
|
+
badgeBg: "rgba(56, 189, 248, 0.15)",
|
|
7159
|
+
borderColor: "#0284c7",
|
|
7160
|
+
iconName: "Sparkles",
|
|
7161
|
+
defaultBpm: 120,
|
|
7162
|
+
recommendedNodes: ["trigger", "container", "effect"]
|
|
7163
|
+
},
|
|
7164
|
+
arrangement: {
|
|
7165
|
+
id: "arrangement",
|
|
7166
|
+
label: "Arrangement",
|
|
7167
|
+
category: "Composition",
|
|
7168
|
+
description: "Timeline-ordered multitrack arrangement and structured song form sections",
|
|
7169
|
+
badgeColor: "#a855f7",
|
|
7170
|
+
badgeBg: "rgba(168, 85, 247, 0.15)",
|
|
7171
|
+
borderColor: "#7e22ce",
|
|
7172
|
+
iconName: "Layers",
|
|
7173
|
+
defaultBpm: 120,
|
|
7174
|
+
recommendedNodes: ["arrangement", "container", "effect", "input_strip", "output_strip"]
|
|
7175
|
+
},
|
|
7176
|
+
song: {
|
|
7177
|
+
id: "song",
|
|
7178
|
+
label: "Song",
|
|
7179
|
+
category: "Composition",
|
|
7180
|
+
description: "Complete musical work combining multiple motifs, verses, choruses, and stems",
|
|
7181
|
+
badgeColor: "#f59e0b",
|
|
7182
|
+
badgeBg: "rgba(245, 158, 11, 0.15)",
|
|
7183
|
+
borderColor: "#b45309",
|
|
7184
|
+
iconName: "Music",
|
|
7185
|
+
defaultBpm: 124,
|
|
7186
|
+
recommendedNodes: ["arrangement", "container", "module", "output_strip"]
|
|
7187
|
+
},
|
|
7188
|
+
performance: {
|
|
7189
|
+
id: "performance",
|
|
7190
|
+
label: "Performance",
|
|
7191
|
+
category: "Performance",
|
|
7192
|
+
description: "Live interactive matrix with mapped MIDI/OSC controls, pads, and real-time triggers",
|
|
7193
|
+
badgeColor: "#10b981",
|
|
7194
|
+
badgeBg: "rgba(16, 185, 129, 0.15)",
|
|
7195
|
+
borderColor: "#047857",
|
|
7196
|
+
iconName: "Activity",
|
|
7197
|
+
defaultBpm: 128,
|
|
7198
|
+
recommendedNodes: ["control", "audio_pads", "button", "trigger", "effect"]
|
|
7199
|
+
},
|
|
7200
|
+
synth_patch: {
|
|
7201
|
+
id: "synth_patch",
|
|
7202
|
+
label: "Synth Patch / Sound Design",
|
|
7203
|
+
category: "Sound Design",
|
|
7204
|
+
description: "Self-contained modular synthesizer patch or acoustic instrument instrument package",
|
|
7205
|
+
badgeColor: "#ec4899",
|
|
7206
|
+
badgeBg: "rgba(236, 72, 153, 0.15)",
|
|
7207
|
+
borderColor: "#be185d",
|
|
7208
|
+
iconName: "Radio",
|
|
7209
|
+
defaultBpm: 120,
|
|
7210
|
+
recommendedNodes: ["container", "effect", "combiner", "converter"]
|
|
7211
|
+
},
|
|
7212
|
+
fx_chain: {
|
|
7213
|
+
id: "fx_chain",
|
|
7214
|
+
label: "Audio FX Chain",
|
|
7215
|
+
category: "Sound Design",
|
|
7216
|
+
description: "Chained processing rack with EQ, dynamics, delay, modulation, and spatial reverb",
|
|
7217
|
+
badgeColor: "#06b6d4",
|
|
7218
|
+
badgeBg: "rgba(6, 182, 212, 0.15)",
|
|
7219
|
+
borderColor: "#0e7490",
|
|
7220
|
+
iconName: "Sliders",
|
|
7221
|
+
defaultBpm: 120,
|
|
7222
|
+
recommendedNodes: ["effect", "combiner", "multiplexer"]
|
|
7223
|
+
},
|
|
7224
|
+
rhythm_beat: {
|
|
7225
|
+
id: "rhythm_beat",
|
|
7226
|
+
label: "Rhythm / Beat Grid",
|
|
7227
|
+
category: "Composition",
|
|
7228
|
+
description: "Euclidean pulse generator, drum sample matrix, and rhythmic trigger sequencer",
|
|
7229
|
+
badgeColor: "#f97316",
|
|
7230
|
+
badgeBg: "rgba(249, 115, 22, 0.15)",
|
|
7231
|
+
borderColor: "#c2410c",
|
|
7232
|
+
iconName: "Grid",
|
|
7233
|
+
defaultBpm: 130,
|
|
7234
|
+
recommendedNodes: ["trigger", "audio_pads", "container"]
|
|
7235
|
+
},
|
|
7236
|
+
generative: {
|
|
7237
|
+
id: "generative",
|
|
7238
|
+
label: "Generative Algorithmic",
|
|
7239
|
+
category: "Experimental",
|
|
7240
|
+
description: "Algorithmic procedural music generator utilizing code nodes and probabilistic rules",
|
|
7241
|
+
badgeColor: "#8b5cf6",
|
|
7242
|
+
badgeBg: "rgba(139, 92, 246, 0.15)",
|
|
7243
|
+
borderColor: "#6d28d9",
|
|
7244
|
+
iconName: "Code",
|
|
7245
|
+
defaultBpm: 110,
|
|
7246
|
+
recommendedNodes: ["code", "trigger", "primitive_number", "primitive_object"]
|
|
7247
|
+
},
|
|
7248
|
+
live_set: {
|
|
7249
|
+
id: "live_set",
|
|
7250
|
+
label: "Live Set / Session",
|
|
7251
|
+
category: "Performance",
|
|
7252
|
+
description: "Master live session setup integrating multiple imported song packages and cue strips",
|
|
7253
|
+
badgeColor: "#e11d48",
|
|
7254
|
+
badgeBg: "rgba(225, 29, 72, 0.15)",
|
|
7255
|
+
borderColor: "#9f1239",
|
|
7256
|
+
iconName: "PlayCircle",
|
|
7257
|
+
defaultBpm: 126,
|
|
7258
|
+
recommendedNodes: ["input_strip", "output_strip", "control", "arrangement"]
|
|
7259
|
+
},
|
|
7260
|
+
utility_macro: {
|
|
7261
|
+
id: "utility_macro",
|
|
7262
|
+
label: "Utility / Macro",
|
|
7263
|
+
category: "Utility",
|
|
7264
|
+
description: "Signal multiplexers, stereo/mono converters, math routers, and bus utilities",
|
|
7265
|
+
badgeColor: "#64748b",
|
|
7266
|
+
badgeBg: "rgba(100, 116, 139, 0.15)",
|
|
7267
|
+
borderColor: "#475569",
|
|
7268
|
+
iconName: "Cpu",
|
|
7269
|
+
defaultBpm: 120,
|
|
7270
|
+
recommendedNodes: ["converter", "combiner", "multiplexer", "primitive_string"]
|
|
7271
|
+
},
|
|
7272
|
+
custom: {
|
|
7273
|
+
id: "custom",
|
|
7274
|
+
label: "Custom / Experimental",
|
|
7275
|
+
category: "Experimental",
|
|
7276
|
+
description: "Freeform experimental node package with custom user-defined metadata tag",
|
|
7277
|
+
badgeColor: "#14b8a6",
|
|
7278
|
+
badgeBg: "rgba(20, 184, 166, 0.15)",
|
|
7279
|
+
borderColor: "#0f766e",
|
|
7280
|
+
iconName: "Box",
|
|
7281
|
+
defaultBpm: 120,
|
|
7282
|
+
recommendedNodes: ["container", "trigger", "effect", "module"]
|
|
7283
|
+
}
|
|
7284
|
+
};
|
|
7285
|
+
var ALL_GRAPH_TYPES = Object.keys(GRAPH_TYPE_DEFINITIONS);
|
|
7286
|
+
function getGraphTypeDefinition(type) {
|
|
7287
|
+
if (type && type in GRAPH_TYPE_DEFINITIONS) {
|
|
7288
|
+
return GRAPH_TYPE_DEFINITIONS[type];
|
|
7289
|
+
}
|
|
7290
|
+
return GRAPH_TYPE_DEFINITIONS.custom;
|
|
7291
|
+
}
|
|
7292
|
+
|
|
7293
|
+
// src/engine/core/controlDispatcher.ts
|
|
7294
|
+
var configuredControlEngines = {};
|
|
7295
|
+
function configureControlDispatcher(engines) {
|
|
7296
|
+
configuredControlEngines = { ...configuredControlEngines, ...engines };
|
|
7297
|
+
if (engines.synthEngine) {
|
|
7298
|
+
globalThis.__KLOKS_SYNTH_ENGINE__ = engines.synthEngine;
|
|
7299
|
+
globalThis.__QWNSR_SYNTH_ENGINE__ = engines.synthEngine;
|
|
7300
|
+
}
|
|
7301
|
+
}
|
|
7302
|
+
var synthEngine = new Proxy(
|
|
7303
|
+
{},
|
|
7304
|
+
{
|
|
7305
|
+
get(_target, prop) {
|
|
7306
|
+
const globalEngine = configuredControlEngines.synthEngine || globalThis.__KLOKS_SYNTH_ENGINE__ || globalThis.__QWNSR_SYNTH_ENGINE__;
|
|
7307
|
+
if (globalEngine && typeof globalEngine[prop] === "function") {
|
|
7308
|
+
return globalEngine[prop].bind(globalEngine);
|
|
7309
|
+
}
|
|
7310
|
+
return () => true;
|
|
7311
|
+
}
|
|
7312
|
+
}
|
|
7313
|
+
);
|
|
7314
|
+
var ControlDispatcher = class {
|
|
7315
|
+
feedbackListeners = /* @__PURE__ */ new Set();
|
|
7316
|
+
addFeedbackListener(fn) {
|
|
7317
|
+
this.feedbackListeners.add(fn);
|
|
7318
|
+
return () => this.feedbackListeners.delete(fn);
|
|
7319
|
+
}
|
|
7320
|
+
/**
|
|
7321
|
+
* Main dispatch entry point called whenever a user interacts with a ControlElement.
|
|
7322
|
+
* Modulations affect graph node parameters and exposed socket targets.
|
|
7323
|
+
* External hardware transmissions are strictly restricted to the Output Strip.
|
|
7324
|
+
*/
|
|
7325
|
+
dispatchElementPayload(element, value, context) {
|
|
7326
|
+
const binding = element.binding;
|
|
7327
|
+
const now = Date.now();
|
|
7328
|
+
let summary = `Updated ${element.label} = ${JSON.stringify(value)}`;
|
|
7329
|
+
if (!binding) {
|
|
7330
|
+
const fb = {
|
|
7331
|
+
timestamp: now,
|
|
7332
|
+
elementId: element.id,
|
|
7333
|
+
payloadType: "none",
|
|
7334
|
+
summary
|
|
7335
|
+
};
|
|
7336
|
+
this.notifyFeedback(fb);
|
|
7337
|
+
return fb;
|
|
7338
|
+
}
|
|
7339
|
+
const { payloadType, synthParam, targetNodeId } = binding;
|
|
7340
|
+
if (payloadType === "synth_param" && synthParam) {
|
|
7341
|
+
const numVal = typeof value === "number" ? value : parseFloat(String(value)) || 0;
|
|
7342
|
+
switch (synthParam) {
|
|
7343
|
+
case "cutoff":
|
|
7344
|
+
synthEngine.setMasterFilterCutoff?.(numVal);
|
|
7345
|
+
summary = `Synth Cutoff set to ${Math.round(numVal)} Hz`;
|
|
7346
|
+
break;
|
|
7347
|
+
case "resonance":
|
|
7348
|
+
synthEngine.setMasterFilterResonance?.(numVal);
|
|
7349
|
+
summary = `Synth Resonance set to ${numVal.toFixed(1)}`;
|
|
7350
|
+
break;
|
|
7351
|
+
case "bpm":
|
|
7352
|
+
summary = `Transport BPM set to ${Math.round(numVal)}`;
|
|
7353
|
+
break;
|
|
7354
|
+
case "volume":
|
|
7355
|
+
case "masterVolume":
|
|
7356
|
+
synthEngine.setMasterVolume(Math.max(0, Math.min(2, numVal / 100)));
|
|
7357
|
+
summary = `Master Volume set to ${Math.round(numVal)}%`;
|
|
7358
|
+
break;
|
|
7359
|
+
default:
|
|
7360
|
+
summary = `Modulated ${synthParam} \u2794 ${numVal}`;
|
|
7361
|
+
break;
|
|
7362
|
+
}
|
|
7363
|
+
} else if (payloadType === "trigger_pulse") {
|
|
7364
|
+
if (targetNodeId && context.onTriggerNode) {
|
|
7365
|
+
context.onTriggerNode(targetNodeId);
|
|
7366
|
+
summary = `Trigger pulse sent to node [${targetNodeId}]`;
|
|
7367
|
+
} else {
|
|
7368
|
+
synthEngine.playAuditionTestPulse();
|
|
7369
|
+
summary = `Master Trigger pulse fired`;
|
|
7370
|
+
}
|
|
7371
|
+
} else if (payloadType === "midi_cc") {
|
|
7372
|
+
const channel = binding.midiChannel || 1;
|
|
7373
|
+
const ccNum = binding.midiCC ?? 1;
|
|
7374
|
+
const ccVal = typeof value === "number" ? Math.round(value) : value ? 127 : 0;
|
|
7375
|
+
summary = `MIDI CC #${ccNum} (Ch ${channel}) = ${ccVal}`;
|
|
7376
|
+
} else if (payloadType === "midi_note") {
|
|
7377
|
+
const channel = binding.midiChannel || 1;
|
|
7378
|
+
const note = binding.midiNote || 60;
|
|
7379
|
+
const vel = binding.midiVelocity || (typeof value === "number" ? Math.round(value) : 100);
|
|
7380
|
+
summary = `MIDI Note #${note} (Ch ${channel}) Vel ${vel}`;
|
|
7381
|
+
} else if (payloadType === "curve_value") {
|
|
7382
|
+
if (Array.isArray(value)) {
|
|
7383
|
+
summary = `XY Orbit = [${value[0].toFixed(2)}, ${value[1].toFixed(2)}]`;
|
|
7384
|
+
} else {
|
|
7385
|
+
summary = `CV Modulation = ${value}`;
|
|
7386
|
+
}
|
|
7387
|
+
} else if (payloadType === "raw_json" || payloadType === "custom_string") {
|
|
7388
|
+
let templated = binding.dynamicTemplate || String(binding.staticPayload || "");
|
|
7389
|
+
templated = templated.replace(/\{value\}/g, String(value));
|
|
7390
|
+
summary = `Custom Payload: ${templated}`;
|
|
7391
|
+
}
|
|
7392
|
+
const feedback = {
|
|
7393
|
+
timestamp: now,
|
|
7394
|
+
elementId: element.id,
|
|
7395
|
+
payloadType,
|
|
7396
|
+
summary
|
|
7397
|
+
};
|
|
7398
|
+
this.notifyFeedback(feedback);
|
|
7399
|
+
return feedback;
|
|
7400
|
+
}
|
|
7401
|
+
notifyFeedback(fb) {
|
|
7402
|
+
this.feedbackListeners.forEach((fn) => fn(fb));
|
|
7403
|
+
}
|
|
7404
|
+
};
|
|
7405
|
+
var controlDispatcher = new ControlDispatcher();
|
|
7406
|
+
|
|
7407
|
+
// src/engine/functions/musicTheory.ts
|
|
7408
|
+
var NOTE_NAMES = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"];
|
|
7409
|
+
function midiToNoteName(midi) {
|
|
7410
|
+
const octave = Math.floor(midi / 12) - 1;
|
|
7411
|
+
const noteIndex = midi % 12;
|
|
7412
|
+
return `${NOTE_NAMES[noteIndex]}${octave}`;
|
|
7413
|
+
}
|
|
7414
|
+
function midiToFreq(midi) {
|
|
7415
|
+
return 440 * Math.pow(2, (midi - 69) / 12);
|
|
7416
|
+
}
|
|
7417
|
+
function noteNameToMidi(name) {
|
|
7418
|
+
const match = name.match(/^([A-G]#?)(-?\d+)$/);
|
|
7419
|
+
if (!match) return 60;
|
|
7420
|
+
const noteIndex = NOTE_NAMES.indexOf(match[1]);
|
|
7421
|
+
const octave = parseInt(match[2], 10);
|
|
7422
|
+
return (octave + 1) * 12 + noteIndex;
|
|
7423
|
+
}
|
|
7424
|
+
var PRESET_SCALES = {
|
|
7425
|
+
"Major Pentatonic": [0, 2, 4, 7, 9],
|
|
7426
|
+
"Minor Pentatonic": [0, 3, 5, 7, 10],
|
|
7427
|
+
"Cosmic Lydian": [0, 2, 4, 6, 7, 9, 11],
|
|
7428
|
+
"Dorian Myst": [0, 2, 3, 5, 7, 9, 10],
|
|
7429
|
+
"Aeolian Dark": [0, 2, 3, 5, 7, 8, 10],
|
|
7430
|
+
"Chromatic Universe": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
|
|
7431
|
+
};
|
|
7432
|
+
var COLOR_PALETTES = [
|
|
7433
|
+
"#f59e0b",
|
|
7434
|
+
// Amber / Gold Star
|
|
7435
|
+
"#38bdf8",
|
|
7436
|
+
// Celestial Sky
|
|
7437
|
+
"#c084fc",
|
|
7438
|
+
// Nebula Violet
|
|
7439
|
+
"#f43f5e",
|
|
7440
|
+
// Quasar Crimson
|
|
7441
|
+
"#34d399",
|
|
7442
|
+
// Aurora Emerald
|
|
7443
|
+
"#fb7185",
|
|
7444
|
+
// Coral Supernova
|
|
7445
|
+
"#a78bfa",
|
|
7446
|
+
// Pulsar Indigo
|
|
7447
|
+
"#2dd4bf"
|
|
7448
|
+
// Cyan Comet
|
|
7449
|
+
];
|
|
7450
|
+
|
|
7451
|
+
// src/engine/core/canonicalIo/types.ts
|
|
7452
|
+
function calculateAudioMeterLevel(peak, rms, gain = 1) {
|
|
7453
|
+
if (peak <= 5e-4 && rms <= 5e-4) {
|
|
7454
|
+
return 0;
|
|
7455
|
+
}
|
|
7456
|
+
const raw = peak * 0.75 + rms * 0.25;
|
|
7457
|
+
return Math.min(1, Math.max(0, raw * 1.5 * gain));
|
|
7458
|
+
}
|
|
7459
|
+
|
|
7460
|
+
// src/engine/core/canonicalIo/CanonicalAudioInputEndpoint.ts
|
|
7461
|
+
var CanonicalAudioInputEndpoint = class {
|
|
7462
|
+
id;
|
|
7463
|
+
name;
|
|
7464
|
+
channel;
|
|
7465
|
+
gain = 1;
|
|
7466
|
+
isMuted = false;
|
|
7467
|
+
connected = true;
|
|
7468
|
+
level = 0;
|
|
7469
|
+
peak = 0;
|
|
7470
|
+
rms = 0;
|
|
7471
|
+
sampleCount = 0;
|
|
7472
|
+
noiseFloor = 0;
|
|
7473
|
+
audioNode = null;
|
|
7474
|
+
analyser = null;
|
|
7475
|
+
cachedTimeData = null;
|
|
7476
|
+
cachedFreqData = null;
|
|
7477
|
+
listeners = /* @__PURE__ */ new Set();
|
|
7478
|
+
constructor(id, name, channel = 1) {
|
|
7479
|
+
this.id = id;
|
|
7480
|
+
this.name = name;
|
|
7481
|
+
this.channel = channel;
|
|
7482
|
+
}
|
|
7483
|
+
subscribe(fn) {
|
|
7484
|
+
this.listeners.add(fn);
|
|
7485
|
+
fn(this.getState());
|
|
7486
|
+
return () => this.listeners.delete(fn);
|
|
7487
|
+
}
|
|
7488
|
+
getState() {
|
|
7489
|
+
return {
|
|
7490
|
+
id: this.id,
|
|
7491
|
+
name: this.name,
|
|
7492
|
+
channel: this.channel,
|
|
7493
|
+
gain: this.gain,
|
|
7494
|
+
isMuted: this.isMuted,
|
|
7495
|
+
connected: this.connected,
|
|
7496
|
+
level: this.level,
|
|
7497
|
+
peak: this.peak,
|
|
7498
|
+
rms: this.rms,
|
|
7499
|
+
sampleCount: this.sampleCount,
|
|
7500
|
+
noiseFloor: this.noiseFloor
|
|
7501
|
+
};
|
|
7502
|
+
}
|
|
7503
|
+
processAudioBuffer(buffer) {
|
|
7504
|
+
if (!this.connected || this.isMuted) {
|
|
7505
|
+
this.peak = 0;
|
|
7506
|
+
this.rms = 0;
|
|
7507
|
+
this.level = 0;
|
|
7508
|
+
this.sampleCount = buffer.length;
|
|
7509
|
+
this.notify();
|
|
7510
|
+
return;
|
|
7511
|
+
}
|
|
7512
|
+
this.sampleCount = buffer.length;
|
|
7513
|
+
if (this.sampleCount === 0) {
|
|
7514
|
+
this.peak = 0;
|
|
7515
|
+
this.rms = 0;
|
|
7516
|
+
this.level = this.noiseFloor;
|
|
7517
|
+
this.notify();
|
|
7518
|
+
return;
|
|
7519
|
+
}
|
|
7520
|
+
let peak = 0;
|
|
7521
|
+
let sumSq = 0;
|
|
7522
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
7523
|
+
const abs = Math.abs(buffer[i]);
|
|
7524
|
+
if (abs > peak) peak = abs;
|
|
7525
|
+
sumSq += abs * abs;
|
|
7526
|
+
}
|
|
7527
|
+
const rms = Math.sqrt(sumSq / buffer.length);
|
|
7528
|
+
this.peak = peak;
|
|
7529
|
+
this.rms = rms;
|
|
7530
|
+
this.level = calculateAudioMeterLevel(peak, rms, this.gain);
|
|
7531
|
+
this.notify();
|
|
7532
|
+
}
|
|
7533
|
+
sampleFromAnalyser() {
|
|
7534
|
+
if (!this.connected || this.isMuted) {
|
|
7535
|
+
this.level = 0;
|
|
7536
|
+
this.peak = 0;
|
|
7537
|
+
this.rms = 0;
|
|
7538
|
+
this.notify();
|
|
7539
|
+
return;
|
|
7540
|
+
}
|
|
7541
|
+
if (!this.analyser) {
|
|
7542
|
+
this.level = 0;
|
|
7543
|
+
return;
|
|
7544
|
+
}
|
|
7545
|
+
try {
|
|
7546
|
+
if (typeof this.analyser.getFloatTimeDomainData === "function") {
|
|
7547
|
+
const fftSize = this.analyser.fftSize || 64;
|
|
7548
|
+
if (!this.cachedTimeData || this.cachedTimeData.length !== fftSize) {
|
|
7549
|
+
this.cachedTimeData = new Float32Array(fftSize);
|
|
7550
|
+
}
|
|
7551
|
+
this.analyser.getFloatTimeDomainData(this.cachedTimeData);
|
|
7552
|
+
this.processAudioBuffer(this.cachedTimeData);
|
|
7553
|
+
} else {
|
|
7554
|
+
const binCount = this.analyser.frequencyBinCount || 32;
|
|
7555
|
+
if (!this.cachedFreqData || this.cachedFreqData.length !== binCount) {
|
|
7556
|
+
this.cachedFreqData = new Uint8Array(binCount);
|
|
7557
|
+
}
|
|
7558
|
+
this.analyser.getByteFrequencyData(this.cachedFreqData);
|
|
7559
|
+
let maxVal = 0;
|
|
7560
|
+
let sum = 0;
|
|
7561
|
+
for (let i = 0; i < this.cachedFreqData.length; i++) {
|
|
7562
|
+
const v = this.cachedFreqData[i];
|
|
7563
|
+
if (v > maxVal) maxVal = v;
|
|
7564
|
+
sum += v;
|
|
7565
|
+
}
|
|
7566
|
+
this.sampleCount = this.cachedFreqData.length;
|
|
7567
|
+
if (maxVal === 0) {
|
|
7568
|
+
this.peak = 0;
|
|
7569
|
+
this.rms = 0;
|
|
7570
|
+
this.level = this.noiseFloor;
|
|
7571
|
+
} else {
|
|
7572
|
+
const maxNorm = maxVal / 255;
|
|
7573
|
+
const avgNorm = sum / this.cachedFreqData.length / 255;
|
|
7574
|
+
this.peak = maxNorm;
|
|
7575
|
+
this.rms = avgNorm;
|
|
7576
|
+
this.level = calculateAudioMeterLevel(maxNorm, avgNorm, this.gain);
|
|
7577
|
+
}
|
|
7578
|
+
this.notify();
|
|
7579
|
+
}
|
|
7580
|
+
} catch {
|
|
7581
|
+
this.level = this.noiseFloor;
|
|
7582
|
+
this.notify();
|
|
7583
|
+
}
|
|
7584
|
+
}
|
|
7585
|
+
setConnected(connected) {
|
|
7586
|
+
this.connected = connected;
|
|
7587
|
+
if (!connected) {
|
|
7588
|
+
this.level = 0;
|
|
7589
|
+
this.peak = 0;
|
|
7590
|
+
this.rms = 0;
|
|
7591
|
+
}
|
|
7592
|
+
this.notify();
|
|
7593
|
+
}
|
|
7594
|
+
setGain(gain) {
|
|
7595
|
+
this.gain = gain;
|
|
7596
|
+
this.level = calculateAudioMeterLevel(this.peak, this.rms, this.gain);
|
|
7597
|
+
this.notify();
|
|
7598
|
+
}
|
|
7599
|
+
setMuted(muted) {
|
|
7600
|
+
this.isMuted = muted;
|
|
7601
|
+
if (muted) {
|
|
7602
|
+
this.level = 0;
|
|
7603
|
+
} else {
|
|
7604
|
+
this.level = calculateAudioMeterLevel(this.peak, this.rms, this.gain);
|
|
7605
|
+
}
|
|
7606
|
+
this.notify();
|
|
7607
|
+
}
|
|
7608
|
+
notify() {
|
|
7609
|
+
const state = this.getState();
|
|
7610
|
+
this.listeners.forEach((fn) => fn(state));
|
|
7611
|
+
}
|
|
7612
|
+
};
|
|
7613
|
+
|
|
7614
|
+
// src/engine/core/canonicalIo/CanonicalMidiInputEndpoint.ts
|
|
7615
|
+
var CanonicalMidiInputEndpoint = class {
|
|
7616
|
+
id;
|
|
7617
|
+
name;
|
|
7618
|
+
connected = true;
|
|
7619
|
+
active = false;
|
|
7620
|
+
currentNote = null;
|
|
7621
|
+
currentNoteName = null;
|
|
7622
|
+
velocity = 0;
|
|
7623
|
+
activeNotes = /* @__PURE__ */ new Set();
|
|
7624
|
+
lastEventTimestamp = 0;
|
|
7625
|
+
noteHistory = [];
|
|
7626
|
+
listeners = /* @__PURE__ */ new Set();
|
|
7627
|
+
eventListeners = /* @__PURE__ */ new Set();
|
|
7628
|
+
constructor(id, name) {
|
|
7629
|
+
this.id = id;
|
|
7630
|
+
this.name = name;
|
|
7631
|
+
}
|
|
7632
|
+
subscribe(fn) {
|
|
7633
|
+
this.listeners.add(fn);
|
|
7634
|
+
fn(this.getState());
|
|
7635
|
+
return () => this.listeners.delete(fn);
|
|
7636
|
+
}
|
|
7637
|
+
addEventListener(fn) {
|
|
7638
|
+
this.eventListeners.add(fn);
|
|
7639
|
+
return () => this.eventListeners.delete(fn);
|
|
7640
|
+
}
|
|
7641
|
+
getState() {
|
|
7642
|
+
return {
|
|
7643
|
+
id: this.id,
|
|
7644
|
+
name: this.name,
|
|
7645
|
+
connected: this.connected,
|
|
7646
|
+
active: this.active,
|
|
7647
|
+
currentNote: this.currentNote,
|
|
7648
|
+
currentNoteName: this.currentNoteName,
|
|
7649
|
+
velocity: this.velocity,
|
|
7650
|
+
activeNotes: new Set(this.activeNotes),
|
|
7651
|
+
lastEventTimestamp: this.lastEventTimestamp
|
|
7652
|
+
};
|
|
7653
|
+
}
|
|
7654
|
+
handleMidiEvent(evt) {
|
|
7655
|
+
if (!this.connected) return;
|
|
7656
|
+
this.lastEventTimestamp = evt.timestamp || Date.now();
|
|
7657
|
+
if (evt.type === "noteon" && (evt.velocity ?? 0) > 0) {
|
|
7658
|
+
this.activeNotes.add(evt.note);
|
|
7659
|
+
this.noteHistory = this.noteHistory.filter((n) => n !== evt.note);
|
|
7660
|
+
this.noteHistory.push(evt.note);
|
|
7661
|
+
this.currentNote = evt.note;
|
|
7662
|
+
this.currentNoteName = evt.noteName || midiToNoteName(evt.note);
|
|
7663
|
+
this.velocity = evt.velocity ?? 0.8;
|
|
7664
|
+
this.active = true;
|
|
7665
|
+
} else if (evt.type === "noteoff" || evt.type === "noteon" && (evt.velocity ?? 0) === 0) {
|
|
7666
|
+
this.activeNotes.delete(evt.note);
|
|
7667
|
+
this.noteHistory = this.noteHistory.filter((n) => n !== evt.note);
|
|
7668
|
+
if (this.activeNotes.size > 0) {
|
|
7669
|
+
const lastRemaining = this.noteHistory[this.noteHistory.length - 1];
|
|
7670
|
+
this.currentNote = lastRemaining;
|
|
7671
|
+
this.currentNoteName = midiToNoteName(lastRemaining);
|
|
7672
|
+
this.active = true;
|
|
7673
|
+
} else {
|
|
7674
|
+
this.active = false;
|
|
7675
|
+
this.currentNote = null;
|
|
7676
|
+
this.currentNoteName = null;
|
|
7677
|
+
this.velocity = 0;
|
|
7678
|
+
}
|
|
7679
|
+
}
|
|
7680
|
+
this.notify();
|
|
7681
|
+
this.eventListeners.forEach((fn) => fn(evt));
|
|
7682
|
+
}
|
|
7683
|
+
setConnected(connected) {
|
|
7684
|
+
this.connected = connected;
|
|
7685
|
+
if (!connected) {
|
|
7686
|
+
this.active = false;
|
|
7687
|
+
this.currentNote = null;
|
|
7688
|
+
this.currentNoteName = null;
|
|
7689
|
+
this.velocity = 0;
|
|
7690
|
+
this.activeNotes.clear();
|
|
7691
|
+
this.noteHistory = [];
|
|
7692
|
+
}
|
|
7693
|
+
this.notify();
|
|
7694
|
+
}
|
|
7695
|
+
notify() {
|
|
7696
|
+
const state = this.getState();
|
|
7697
|
+
this.listeners.forEach((fn) => fn(state));
|
|
7698
|
+
}
|
|
7699
|
+
};
|
|
7700
|
+
var canonicalMidiBridgeRef = null;
|
|
7701
|
+
function configureCanonicalMidiBridge(midiManagerInstance) {
|
|
7702
|
+
canonicalMidiBridgeRef = midiManagerInstance;
|
|
7703
|
+
globalThis.__KLOKS_MIDI_MANAGER__ = midiManagerInstance;
|
|
7704
|
+
}
|
|
7705
|
+
function getCanonicalMidiBridge() {
|
|
7706
|
+
return canonicalMidiBridgeRef || globalThis.__KLOKS_MIDI_MANAGER__;
|
|
7707
|
+
}
|
|
7708
|
+
|
|
7709
|
+
// src/engine/core/canonicalIo/topLevelIoRegistry.ts
|
|
7710
|
+
var TopLevelIoRegistry = class {
|
|
7711
|
+
audioEndpoints = /* @__PURE__ */ new Map();
|
|
7712
|
+
midiEndpoints = /* @__PURE__ */ new Map();
|
|
7713
|
+
registryListeners = /* @__PURE__ */ new Set();
|
|
7714
|
+
debugTraceLog = [];
|
|
7715
|
+
constructor() {
|
|
7716
|
+
this.initDefaultEndpoints();
|
|
7717
|
+
}
|
|
7718
|
+
initDefaultEndpoints() {
|
|
7719
|
+
this.getOrCreateAudioEndpoint("bus-in-1", "Physical Audio In 1", 1);
|
|
7720
|
+
this.getOrCreateAudioEndpoint("bus-in-2", "Physical Audio In 2", 2);
|
|
7721
|
+
this.getOrCreateMidiEndpoint("midi-profile-1", "Main Stage Synth / Keyboard");
|
|
7722
|
+
this.getOrCreateMidiEndpoint("midi-profile-2", "External MIDI Controller / Pads");
|
|
7723
|
+
this.getOrCreateMidiEndpoint("virtual-keyboard", "Virtual MIDI Keyboard");
|
|
7724
|
+
this.getOrCreateMidiEndpoint("all", "All Physical MIDI Inputs (Omni)");
|
|
7725
|
+
}
|
|
7726
|
+
subscribeRegistry(fn) {
|
|
7727
|
+
this.registryListeners.add(fn);
|
|
7728
|
+
return () => this.registryListeners.delete(fn);
|
|
7729
|
+
}
|
|
7730
|
+
notifyRegistry() {
|
|
7731
|
+
this.registryListeners.forEach((fn) => fn());
|
|
7732
|
+
}
|
|
7733
|
+
getOrCreateAudioEndpoint(id, name, channel = 1) {
|
|
7734
|
+
let ep = this.audioEndpoints.get(id);
|
|
7735
|
+
if (!ep) {
|
|
7736
|
+
ep = new CanonicalAudioInputEndpoint(id, name, channel);
|
|
7737
|
+
this.audioEndpoints.set(id, ep);
|
|
7738
|
+
this.notifyRegistry();
|
|
7739
|
+
}
|
|
7740
|
+
return ep;
|
|
7741
|
+
}
|
|
7742
|
+
getAudioEndpoint(id) {
|
|
7743
|
+
return this.audioEndpoints.get(id);
|
|
7744
|
+
}
|
|
7745
|
+
getAllAudioEndpoints() {
|
|
7746
|
+
return Array.from(this.audioEndpoints.values());
|
|
7747
|
+
}
|
|
7748
|
+
getOrCreateMidiEndpoint(id, name) {
|
|
7749
|
+
let ep = this.midiEndpoints.get(id);
|
|
7750
|
+
if (!ep) {
|
|
7751
|
+
ep = new CanonicalMidiInputEndpoint(id, name);
|
|
7752
|
+
this.midiEndpoints.set(id, ep);
|
|
7753
|
+
this.notifyRegistry();
|
|
7754
|
+
}
|
|
7755
|
+
return ep;
|
|
7756
|
+
}
|
|
7757
|
+
getMidiEndpoint(id) {
|
|
7758
|
+
return this.midiEndpoints.get(id);
|
|
7759
|
+
}
|
|
7760
|
+
getAllMidiEndpoints() {
|
|
7761
|
+
return Array.from(this.midiEndpoints.values());
|
|
7762
|
+
}
|
|
7763
|
+
/**
|
|
7764
|
+
* Dispatches a canonical MIDI event from device adapter into matching endpoints.
|
|
7765
|
+
*/
|
|
7766
|
+
dispatchMidiEvent(evt) {
|
|
7767
|
+
const devId = evt.deviceId || "virtual-keyboard";
|
|
7768
|
+
const directEp = this.midiEndpoints.get(devId);
|
|
7769
|
+
if (directEp) {
|
|
7770
|
+
directEp.handleMidiEvent(evt);
|
|
7771
|
+
}
|
|
7772
|
+
this.midiEndpoints.forEach((ep) => {
|
|
7773
|
+
if (ep.id === devId) return;
|
|
7774
|
+
if (ep.id === "all" || ep.id.startsWith("midi-profile-")) {
|
|
7775
|
+
ep.handleMidiEvent(evt);
|
|
7776
|
+
}
|
|
7777
|
+
});
|
|
7778
|
+
this.logTrace("MIDI", "EVENT_PARSED", {
|
|
7779
|
+
type: evt.type,
|
|
7780
|
+
note: evt.note,
|
|
7781
|
+
noteName: evt.noteName,
|
|
7782
|
+
velocity: evt.velocity,
|
|
7783
|
+
deviceId: devId
|
|
7784
|
+
});
|
|
7785
|
+
}
|
|
7786
|
+
logTrace(category, stage, data, assertionsPassed = true) {
|
|
7787
|
+
const entry = {
|
|
7788
|
+
category,
|
|
7789
|
+
stage,
|
|
7790
|
+
timestamp: performance.now ? performance.now() : Date.now(),
|
|
7791
|
+
data,
|
|
7792
|
+
assertionsPassed
|
|
7793
|
+
};
|
|
7794
|
+
this.debugTraceLog.push(entry);
|
|
7795
|
+
if (this.debugTraceLog.length > 500) {
|
|
7796
|
+
this.debugTraceLog.shift();
|
|
7797
|
+
}
|
|
7798
|
+
}
|
|
7799
|
+
clearTraceLog() {
|
|
7800
|
+
this.debugTraceLog = [];
|
|
7801
|
+
}
|
|
7802
|
+
};
|
|
7803
|
+
var topLevelIoRegistry = new TopLevelIoRegistry();
|
|
7804
|
+
|
|
7805
|
+
// src/engine/core/l2_drivers/audioBusDriver.ts
|
|
7806
|
+
var AudioBusDriver = class {
|
|
7807
|
+
channelSplitter = null;
|
|
7808
|
+
channelAnalysers = /* @__PURE__ */ new Map();
|
|
7809
|
+
namedAnalyserMap = /* @__PURE__ */ new Map();
|
|
7810
|
+
namedGainMap = /* @__PURE__ */ new Map();
|
|
7811
|
+
activeMonitorGains = /* @__PURE__ */ new Map();
|
|
7812
|
+
sharedAnalyserBuffer = new Uint8Array(64);
|
|
7813
|
+
setupSplitter(ctx, sourceNode, channelCount) {
|
|
7814
|
+
const splitCount = Math.min(32, Math.max(2, channelCount));
|
|
7815
|
+
try {
|
|
7816
|
+
this.channelSplitter = ctx.createChannelSplitter(splitCount);
|
|
7817
|
+
sourceNode.connect(this.channelSplitter);
|
|
7818
|
+
this.channelAnalysers.clear();
|
|
7819
|
+
for (let i = 0; i < splitCount; i++) {
|
|
7820
|
+
const analyser = ctx.createAnalyser();
|
|
7821
|
+
analyser.fftSize = 64;
|
|
7822
|
+
this.channelSplitter.connect(analyser, i);
|
|
7823
|
+
this.channelAnalysers.set(i + 1, analyser);
|
|
7824
|
+
}
|
|
7825
|
+
return this.channelSplitter;
|
|
7826
|
+
} catch (e) {
|
|
7827
|
+
console.warn("Could not set up multi-channel splitter:", e);
|
|
7828
|
+
return null;
|
|
7829
|
+
}
|
|
7830
|
+
}
|
|
7831
|
+
setupNamedAnalysers(ctx, inputs) {
|
|
7832
|
+
this.namedAnalyserMap.clear();
|
|
7833
|
+
this.namedGainMap.clear();
|
|
7834
|
+
if (!this.channelSplitter) return;
|
|
7835
|
+
inputs.forEach((input) => {
|
|
7836
|
+
if (input.busType !== "input" || !this.channelSplitter) return;
|
|
7837
|
+
const analyser = ctx.createAnalyser();
|
|
7838
|
+
analyser.fftSize = 64;
|
|
7839
|
+
const gain = ctx.createGain();
|
|
7840
|
+
const rawGain = input.gain ?? 1;
|
|
7841
|
+
const safeGain = typeof rawGain === "number" && isFinite(rawGain) ? rawGain : 1;
|
|
7842
|
+
gain.gain.value = input.isMuted ? 0 : safeGain;
|
|
7843
|
+
const ch = input.channel ?? 1;
|
|
7844
|
+
let targetOutputIndex = 0;
|
|
7845
|
+
if (ch > 0 && ch <= 32) {
|
|
7846
|
+
targetOutputIndex = ch - 1;
|
|
7847
|
+
} else if (ch > 100) {
|
|
7848
|
+
targetOutputIndex = Math.floor(ch / 100) - 1;
|
|
7849
|
+
}
|
|
7850
|
+
try {
|
|
7851
|
+
this.channelSplitter.connect(gain, targetOutputIndex);
|
|
7852
|
+
gain.connect(analyser);
|
|
7853
|
+
this.namedAnalyserMap.set(input.id, analyser);
|
|
7854
|
+
this.namedGainMap.set(input.id, gain);
|
|
7855
|
+
} catch (e) {
|
|
7856
|
+
console.warn(`Could not connect bus ${input.name} to channel output ${targetOutputIndex}:`, e);
|
|
7857
|
+
}
|
|
7858
|
+
});
|
|
7859
|
+
}
|
|
7860
|
+
getChannelLevel(channelNum) {
|
|
7861
|
+
const analyser = this.channelAnalysers.get(channelNum);
|
|
7862
|
+
if (!analyser) return 0;
|
|
7863
|
+
return this.readAnalyserLevel(analyser);
|
|
7864
|
+
}
|
|
7865
|
+
getNamedBusLevel(busId, fallbackChannelNum) {
|
|
7866
|
+
const analyser = this.namedAnalyserMap.get(busId);
|
|
7867
|
+
if (analyser) {
|
|
7868
|
+
return this.readAnalyserLevel(analyser);
|
|
7869
|
+
}
|
|
7870
|
+
return this.getChannelLevel(fallbackChannelNum);
|
|
7871
|
+
}
|
|
7872
|
+
readAnalyserLevel(analyser) {
|
|
7873
|
+
const binCount = analyser.frequencyBinCount || 32;
|
|
7874
|
+
if (this.sharedAnalyserBuffer.length !== binCount) {
|
|
7875
|
+
this.sharedAnalyserBuffer = new Uint8Array(binCount);
|
|
7876
|
+
}
|
|
7877
|
+
const data = this.sharedAnalyserBuffer;
|
|
7878
|
+
analyser.getByteFrequencyData(data);
|
|
7879
|
+
let sum = 0;
|
|
7880
|
+
let maxVal = 0;
|
|
7881
|
+
for (let i = 0; i < data.length; i++) {
|
|
7882
|
+
const v = data[i];
|
|
7883
|
+
sum += v;
|
|
7884
|
+
if (v > maxVal) maxVal = v;
|
|
7885
|
+
}
|
|
7886
|
+
if (maxVal === 0) return 0;
|
|
7887
|
+
const maxNorm = maxVal / 255;
|
|
7888
|
+
const avgNorm = sum / data.length / 255;
|
|
7889
|
+
return Math.min(1, (maxNorm * 0.75 + avgNorm * 0.25) * 1.8);
|
|
7890
|
+
}
|
|
7891
|
+
updateMonitoring(ctx, masterGainNode, nodes, _connections, isNodeConnectedToOutput) {
|
|
7892
|
+
if (!this.channelSplitter) return;
|
|
7893
|
+
this.activeMonitorGains.forEach((gain, id) => {
|
|
7894
|
+
try {
|
|
7895
|
+
gain.disconnect();
|
|
7896
|
+
} catch {
|
|
7897
|
+
}
|
|
7898
|
+
this.activeMonitorGains.delete(id);
|
|
7899
|
+
});
|
|
7900
|
+
}
|
|
7901
|
+
cleanup() {
|
|
7902
|
+
this.activeMonitorGains.forEach((g) => {
|
|
7903
|
+
try {
|
|
7904
|
+
g.disconnect();
|
|
7905
|
+
} catch {
|
|
7906
|
+
}
|
|
7907
|
+
});
|
|
7908
|
+
this.activeMonitorGains.clear();
|
|
7909
|
+
this.namedAnalyserMap.clear();
|
|
7910
|
+
this.namedGainMap.clear();
|
|
7911
|
+
this.channelAnalysers.clear();
|
|
7912
|
+
this.channelSplitter = null;
|
|
7913
|
+
}
|
|
7914
|
+
};
|
|
7915
|
+
|
|
7916
|
+
// src/engine/core/l2_drivers/audioDeviceDriver.ts
|
|
7917
|
+
var STORAGE_KEY = "celestial_connections_config";
|
|
7918
|
+
function loadStoredConfig(defaultInputs, defaultDevId = "default", defaultOutId = "default") {
|
|
7919
|
+
try {
|
|
7920
|
+
const stored = localStorage.getItem(STORAGE_KEY);
|
|
7921
|
+
if (stored) {
|
|
7922
|
+
const parsed = JSON.parse(stored);
|
|
7923
|
+
return {
|
|
7924
|
+
selectedAudioDeviceId: parsed.selectedAudioDeviceId || defaultDevId,
|
|
7925
|
+
selectedAudioOutputDeviceId: parsed.selectedAudioOutputDeviceId || defaultOutId,
|
|
7926
|
+
namedAudioInputs: Array.isArray(parsed.namedAudioInputs) && parsed.namedAudioInputs.length > 0 ? parsed.namedAudioInputs.map((bus) => ({
|
|
7927
|
+
...bus,
|
|
7928
|
+
busType: bus.busType || (bus.outputChannels ? "output" : "input")
|
|
7929
|
+
})) : defaultInputs,
|
|
7930
|
+
selectedMidiDeviceId: null,
|
|
7931
|
+
midiConfigs: {}
|
|
7932
|
+
};
|
|
7933
|
+
}
|
|
7934
|
+
} catch (e) {
|
|
7935
|
+
console.warn("Could not read connections config from storage:", e);
|
|
7936
|
+
}
|
|
7937
|
+
return {
|
|
7938
|
+
selectedAudioDeviceId: defaultDevId,
|
|
7939
|
+
selectedAudioOutputDeviceId: defaultOutId,
|
|
7940
|
+
namedAudioInputs: defaultInputs,
|
|
7941
|
+
selectedMidiDeviceId: null,
|
|
7942
|
+
midiConfigs: {}
|
|
7943
|
+
};
|
|
7944
|
+
}
|
|
7945
|
+
function saveStoredConfig(config) {
|
|
7946
|
+
try {
|
|
7947
|
+
localStorage.setItem(STORAGE_KEY, JSON.stringify(config));
|
|
7948
|
+
} catch (e) {
|
|
7949
|
+
console.warn("Could not save connections config:", e);
|
|
7950
|
+
}
|
|
7951
|
+
}
|
|
7952
|
+
async function enumerateSystemAudioDevices() {
|
|
7953
|
+
if (typeof navigator === "undefined" || !navigator.mediaDevices?.enumerateDevices) {
|
|
7954
|
+
return {
|
|
7955
|
+
inputs: [
|
|
7956
|
+
{ deviceId: "default", label: "Default System Audio Input", groupId: "", kind: "audioinput" }
|
|
7957
|
+
],
|
|
7958
|
+
outputs: [
|
|
7959
|
+
{ deviceId: "default", label: "Default System Audio Output", groupId: "", kind: "audiooutput" }
|
|
7960
|
+
]
|
|
7961
|
+
};
|
|
7962
|
+
}
|
|
7963
|
+
try {
|
|
7964
|
+
const devices = await navigator.mediaDevices.enumerateDevices();
|
|
7965
|
+
const inputs = devices.filter((d) => d.kind === "audioinput").map((d, index) => ({
|
|
7966
|
+
deviceId: d.deviceId || `audioinput-${index}`,
|
|
7967
|
+
label: d.label || (index === 0 ? "Default Audio Input / Mic" : `Hardware Audio Input ${index + 1}`),
|
|
7968
|
+
groupId: d.groupId || "",
|
|
7969
|
+
kind: "audioinput"
|
|
7970
|
+
}));
|
|
7971
|
+
const rawOutputs = devices.filter((d) => d.kind === "audiooutput").map((d, index) => ({
|
|
7972
|
+
deviceId: d.deviceId || `audiooutput-${index}`,
|
|
7973
|
+
label: d.label || (index === 0 ? "Default System Audio Output" : `Hardware Audio Output ${index + 1}`),
|
|
7974
|
+
groupId: d.groupId || "",
|
|
7975
|
+
kind: "audiooutput"
|
|
7976
|
+
}));
|
|
7977
|
+
if (inputs.length === 0) {
|
|
7978
|
+
inputs.push({ deviceId: "default", label: "Default System Audio Input / Interface", groupId: "", kind: "audioinput" });
|
|
7979
|
+
}
|
|
7980
|
+
const outputs = [...rawOutputs];
|
|
7981
|
+
inputs.forEach((input) => {
|
|
7982
|
+
if (!input.label) return;
|
|
7983
|
+
const isNotGeneric = !input.label.toLowerCase().startsWith("default") && !input.label.toLowerCase().startsWith("hardware audio input");
|
|
7984
|
+
if (isNotGeneric) {
|
|
7985
|
+
const alreadyInOutputs = outputs.some(
|
|
7986
|
+
(o) => o.groupId === input.groupId || o.label.toLowerCase().includes(input.label.toLowerCase().replace(/input|mic/i, "").trim())
|
|
7987
|
+
);
|
|
7988
|
+
if (!alreadyInOutputs) {
|
|
7989
|
+
outputs.push({
|
|
7990
|
+
deviceId: input.deviceId,
|
|
7991
|
+
label: `${input.label} (Hardware Outputs / Monitors)`,
|
|
7992
|
+
groupId: input.groupId,
|
|
7993
|
+
kind: "audiooutput",
|
|
7994
|
+
isAutoPaired: true
|
|
7995
|
+
});
|
|
7996
|
+
}
|
|
7997
|
+
}
|
|
7998
|
+
});
|
|
7999
|
+
if (outputs.length === 0) {
|
|
8000
|
+
outputs.push(
|
|
8001
|
+
{ deviceId: "default", label: "Default System Audio Output (Speakers / Headphones)", groupId: "", kind: "audiooutput" },
|
|
8002
|
+
{ deviceId: "communications", label: "Communications Audio Output", groupId: "", kind: "audiooutput" }
|
|
8003
|
+
);
|
|
8004
|
+
}
|
|
8005
|
+
return { inputs, outputs };
|
|
8006
|
+
} catch (e) {
|
|
8007
|
+
console.warn("Failed to enumerate audio devices:", e);
|
|
8008
|
+
return {
|
|
8009
|
+
inputs: [
|
|
8010
|
+
{ deviceId: "default", label: "Default Audio Input", groupId: "", kind: "audioinput" }
|
|
8011
|
+
],
|
|
8012
|
+
outputs: [
|
|
8013
|
+
{ deviceId: "default", label: "Default Audio Output", groupId: "", kind: "audiooutput" }
|
|
8014
|
+
]
|
|
8015
|
+
};
|
|
8016
|
+
}
|
|
8017
|
+
}
|
|
8018
|
+
|
|
8019
|
+
// src/engine/core/l2_drivers/audioStreamDriver.ts
|
|
8020
|
+
async function acquireAudioInputStream(targetDeviceId) {
|
|
8021
|
+
if (typeof window === "undefined" || !navigator.mediaDevices?.getUserMedia) {
|
|
8022
|
+
return null;
|
|
8023
|
+
}
|
|
8024
|
+
const constraints = {
|
|
8025
|
+
audio: {
|
|
8026
|
+
...targetDeviceId && targetDeviceId !== "default" ? { deviceId: { exact: targetDeviceId } } : {},
|
|
8027
|
+
echoCancellation: false,
|
|
8028
|
+
noiseSuppression: false,
|
|
8029
|
+
autoGainControl: false,
|
|
8030
|
+
channelCount: { ideal: 32 }
|
|
8031
|
+
},
|
|
8032
|
+
video: false
|
|
8033
|
+
};
|
|
8034
|
+
const mediaStream = await navigator.mediaDevices.getUserMedia(constraints);
|
|
8035
|
+
let detectedTrackChannelCount = 2;
|
|
8036
|
+
const track = mediaStream.getAudioTracks()[0];
|
|
8037
|
+
if (track) {
|
|
8038
|
+
const settings = track.getSettings();
|
|
8039
|
+
const capabilities = track.getCapabilities ? track.getCapabilities() : {};
|
|
8040
|
+
const count = settings.channelCount || capabilities?.channelCount?.max || 2;
|
|
8041
|
+
detectedTrackChannelCount = Math.max(2, count);
|
|
8042
|
+
}
|
|
8043
|
+
return { mediaStream, detectedTrackChannelCount };
|
|
8044
|
+
}
|
|
8045
|
+
function stopAudioMediaStream(stream) {
|
|
8046
|
+
if (stream) {
|
|
8047
|
+
stream.getTracks().forEach((t) => t.stop());
|
|
8048
|
+
}
|
|
8049
|
+
}
|
|
8050
|
+
|
|
8051
|
+
// src/engine/functions/socketCompatibilitySpawner.ts
|
|
8052
|
+
function resolveSocketDetails(sourceNode, direction, portId, socketIndex, explicitSignalType) {
|
|
8053
|
+
const { inputs, outputs } = getNodeSockets(sourceNode);
|
|
8054
|
+
const socketList = direction === "in" ? inputs : outputs;
|
|
8055
|
+
let targetSocket;
|
|
8056
|
+
if (portId) {
|
|
8057
|
+
targetSocket = socketList.find((s) => s.socketId === portId);
|
|
8058
|
+
}
|
|
8059
|
+
if (!targetSocket && socketIndex !== void 0 && socketIndex >= 0 && socketIndex < socketList.length) {
|
|
8060
|
+
targetSocket = socketList[socketIndex];
|
|
8061
|
+
}
|
|
8062
|
+
if (!targetSocket && socketList.length > 0) {
|
|
8063
|
+
targetSocket = socketList[0];
|
|
8064
|
+
}
|
|
8065
|
+
if (targetSocket) {
|
|
8066
|
+
const socketTitle = direction === "in" ? `Feed into [${targetSocket.label}] on ${sourceNode.name}` : `Route [${targetSocket.label}] from ${sourceNode.name}`;
|
|
8067
|
+
const dataFormatLabel = targetSocket.dataType === "packet" ? "PACKET" : targetSocket.dataType === "pulse" ? "PULSE" : "STREAM";
|
|
8068
|
+
const mediumLabel = targetSocket.medium.toUpperCase().replace("_", " ");
|
|
8069
|
+
return {
|
|
8070
|
+
socketDef: targetSocket,
|
|
8071
|
+
signalType: targetSocket.signalType,
|
|
8072
|
+
portLabel: targetSocket.label,
|
|
8073
|
+
socketTitle,
|
|
8074
|
+
signalName: `${mediumLabel} (${dataFormatLabel})`,
|
|
8075
|
+
signalColor: targetSocket.colorStr
|
|
8076
|
+
};
|
|
8077
|
+
}
|
|
8078
|
+
const fallbackSig = explicitSignalType || "trigger";
|
|
8079
|
+
const def = CANONICAL_SIGNAL_TYPES[fallbackSig] || CANONICAL_SIGNAL_TYPES.trigger;
|
|
8080
|
+
return {
|
|
8081
|
+
signalType: fallbackSig,
|
|
8082
|
+
portLabel: direction === "in" ? "In" : "Out",
|
|
8083
|
+
socketTitle: `${sourceNode.name} (${direction.toUpperCase()})`,
|
|
8084
|
+
signalName: def.name.toUpperCase(),
|
|
8085
|
+
signalColor: def.colorStr
|
|
8086
|
+
};
|
|
8087
|
+
}
|
|
8088
|
+
function getCompatibleNodesForSocket(sourceNode, direction, portId, socketIndex, signalType) {
|
|
8089
|
+
const details = resolveSocketDetails(sourceNode, direction, portId, socketIndex, signalType);
|
|
8090
|
+
const resolvedSig = signalType || details.signalType || "trigger";
|
|
8091
|
+
const isAudioMono = resolvedSig === "audio_mono";
|
|
8092
|
+
const isAudio = resolvedSig.includes("audio");
|
|
8093
|
+
const isMidi = resolvedSig.includes("midi");
|
|
8094
|
+
const isCurve = resolvedSig.includes("curve");
|
|
8095
|
+
const sourceSocket = details.socketDef || {
|
|
8096
|
+
socketId: portId || "socket_fallback",
|
|
8097
|
+
label: details.portLabel || (direction === "in" ? "In" : "Out"),
|
|
8098
|
+
polarity: direction === "out" ? "output" : "input",
|
|
8099
|
+
medium: isAudio ? isAudioMono ? "audio_mono" : "audio_stereo" : isMidi ? "midi" : isCurve ? "curve" : "trigger",
|
|
8100
|
+
dataType: resolvedSig.includes("packet") ? "packet" : resolvedSig === "trigger" ? "pulse" : "stream",
|
|
8101
|
+
signalType: resolvedSig,
|
|
8102
|
+
connectivity: direction === "out" ? "multi" : "single",
|
|
8103
|
+
socketIndex: socketIndex ?? 0,
|
|
8104
|
+
description: details.socketTitle,
|
|
8105
|
+
colorHex: details.signalColor ? parseInt(details.signalColor.replace("#", "0x")) : 16096779,
|
|
8106
|
+
colorStr: details.signalColor || "#f59e0b",
|
|
8107
|
+
bgStr: "#212c47",
|
|
8108
|
+
iconName: "zap",
|
|
8109
|
+
isCustom: false
|
|
8110
|
+
};
|
|
8111
|
+
const options = [];
|
|
8112
|
+
const archetypes = getAllNodeArchetypes();
|
|
8113
|
+
for (const archetype of archetypes) {
|
|
8114
|
+
const prototypeNode = archetype.createPrototype();
|
|
8115
|
+
const candidateSockets = getNodeSockets(prototypeNode);
|
|
8116
|
+
if (direction === "in") {
|
|
8117
|
+
for (const candidateOut of candidateSockets.outputs) {
|
|
8118
|
+
const comp = areSignalsCompatible(candidateOut, sourceSocket);
|
|
8119
|
+
if (comp.isCompatible) {
|
|
8120
|
+
options.push({
|
|
8121
|
+
id: `${archetype.id}:${candidateOut.socketId}`,
|
|
8122
|
+
category: archetype.category,
|
|
8123
|
+
label: archetype.label,
|
|
8124
|
+
description: candidateOut.description || archetype.defaultDescription,
|
|
8125
|
+
iconName: candidateOut.iconName || archetype.iconName,
|
|
8126
|
+
colorHex: candidateOut.colorStr,
|
|
8127
|
+
badge: `${candidateOut.label} \u2794 ${sourceSocket.label}`,
|
|
8128
|
+
matchingSocketId: candidateOut.socketId,
|
|
8129
|
+
matchingSocketIndex: candidateOut.socketIndex,
|
|
8130
|
+
spawnType: archetype.spawnType
|
|
8131
|
+
});
|
|
8132
|
+
break;
|
|
8133
|
+
}
|
|
8134
|
+
}
|
|
8135
|
+
} else {
|
|
8136
|
+
for (const candidateIn of candidateSockets.inputs) {
|
|
8137
|
+
const comp = areSignalsCompatible(sourceSocket, candidateIn);
|
|
8138
|
+
if (comp.isCompatible) {
|
|
8139
|
+
options.push({
|
|
8140
|
+
id: `${archetype.id}:${candidateIn.socketId}`,
|
|
8141
|
+
category: archetype.category,
|
|
8142
|
+
label: archetype.label,
|
|
8143
|
+
description: candidateIn.description || archetype.defaultDescription,
|
|
8144
|
+
iconName: candidateIn.iconName || archetype.iconName,
|
|
8145
|
+
colorHex: candidateIn.colorStr,
|
|
8146
|
+
badge: `${sourceSocket.label} \u2794 ${candidateIn.label}`,
|
|
8147
|
+
matchingSocketId: candidateIn.socketId,
|
|
8148
|
+
matchingSocketIndex: candidateIn.socketIndex,
|
|
8149
|
+
spawnType: archetype.spawnType
|
|
8150
|
+
});
|
|
8151
|
+
break;
|
|
8152
|
+
}
|
|
8153
|
+
}
|
|
8154
|
+
}
|
|
8155
|
+
}
|
|
8156
|
+
return {
|
|
8157
|
+
socketTitle: details.socketTitle,
|
|
8158
|
+
signalName: details.signalName,
|
|
8159
|
+
signalColor: details.signalColor,
|
|
8160
|
+
options
|
|
8161
|
+
};
|
|
8162
|
+
}
|
|
8163
|
+
|
|
8164
|
+
// src/engine/functions/containerClipSync.ts
|
|
8165
|
+
function syncConnectedContainersToArrangement(arrangement, allNodes) {
|
|
8166
|
+
const containerMap = /* @__PURE__ */ new Map();
|
|
8167
|
+
allNodes.forEach((n) => {
|
|
8168
|
+
if (n.type === "container") containerMap.set(n.id, n);
|
|
8169
|
+
});
|
|
8170
|
+
let changed = false;
|
|
8171
|
+
const newTracks = arrangement.tracks.map((track) => {
|
|
8172
|
+
let trackChanged = false;
|
|
8173
|
+
const newClips = track.clips.map((clip) => {
|
|
8174
|
+
if (!clip.containerId) return clip;
|
|
8175
|
+
const sourceContainer = containerMap.get(clip.containerId);
|
|
8176
|
+
if (!sourceContainer) return clip;
|
|
8177
|
+
const isAudio = sourceContainer.containerType === "audio";
|
|
8178
|
+
const isMidi = sourceContainer.containerType !== "audio" && sourceContainer.containerType !== "curve";
|
|
8179
|
+
let needsUpdate = false;
|
|
8180
|
+
if (isAudio && sourceContainer.audioTrack) {
|
|
8181
|
+
if (clip.sampleType !== sourceContainer.audioTrack.sampleType || clip.customAudioUrl !== sourceContainer.audioTrack.customAudioUrl || clip.name !== (sourceContainer.name || clip.name)) {
|
|
8182
|
+
needsUpdate = true;
|
|
8183
|
+
}
|
|
8184
|
+
} else if (isMidi && sourceContainer.pattern) {
|
|
8185
|
+
const sourceNotesCount = sourceContainer.pattern.notes?.length || 0;
|
|
8186
|
+
const clipNotesCount = clip.notes?.length || 0;
|
|
8187
|
+
if (sourceNotesCount !== clipNotesCount || clip.name !== (sourceContainer.name || clip.name)) {
|
|
8188
|
+
needsUpdate = true;
|
|
8189
|
+
}
|
|
8190
|
+
}
|
|
8191
|
+
if (needsUpdate) {
|
|
8192
|
+
trackChanged = true;
|
|
8193
|
+
changed = true;
|
|
8194
|
+
return {
|
|
8195
|
+
...clip,
|
|
8196
|
+
name: sourceContainer.name || clip.name,
|
|
8197
|
+
audioTrack: sourceContainer.audioTrack ? { ...sourceContainer.audioTrack } : clip.audioTrack,
|
|
8198
|
+
sampleType: sourceContainer.audioTrack?.sampleType || clip.sampleType,
|
|
8199
|
+
customAudioUrl: sourceContainer.audioTrack?.customAudioUrl || clip.customAudioUrl,
|
|
8200
|
+
pattern: sourceContainer.pattern ? JSON.parse(JSON.stringify(sourceContainer.pattern)) : clip.pattern,
|
|
8201
|
+
notes: sourceContainer.pattern?.notes ? [...sourceContainer.pattern.notes] : clip.notes,
|
|
8202
|
+
curveData: sourceContainer.curveData ? JSON.parse(JSON.stringify(sourceContainer.curveData)) : clip.curveData
|
|
8203
|
+
};
|
|
8204
|
+
}
|
|
8205
|
+
return clip;
|
|
8206
|
+
});
|
|
8207
|
+
return trackChanged ? { ...track, clips: newClips } : track;
|
|
8208
|
+
});
|
|
8209
|
+
let maxEndBeat = (arrangement.totalBars || 4) * 4;
|
|
8210
|
+
let lengthExtended = false;
|
|
8211
|
+
newTracks.forEach((t) => {
|
|
8212
|
+
t.clips.forEach((c) => {
|
|
8213
|
+
const end = (c.startBeat || 0) + (c.durationBeats || 0);
|
|
8214
|
+
if (end > maxEndBeat) {
|
|
8215
|
+
maxEndBeat = end;
|
|
8216
|
+
lengthExtended = true;
|
|
8217
|
+
}
|
|
8218
|
+
});
|
|
8219
|
+
});
|
|
8220
|
+
if (lengthExtended) {
|
|
8221
|
+
const newTotalBars = Math.ceil(maxEndBeat / 4);
|
|
8222
|
+
return {
|
|
8223
|
+
updated: true,
|
|
8224
|
+
arrangement: {
|
|
8225
|
+
...arrangement,
|
|
8226
|
+
totalBars: newTotalBars,
|
|
8227
|
+
loopEndBeat: Math.max(arrangement.loopEndBeat || 0, newTotalBars * 4),
|
|
8228
|
+
tracks: newTracks
|
|
8229
|
+
}
|
|
8230
|
+
};
|
|
8231
|
+
}
|
|
8232
|
+
return {
|
|
8233
|
+
updated: changed,
|
|
8234
|
+
arrangement: changed ? { ...arrangement, tracks: newTracks } : arrangement
|
|
8235
|
+
};
|
|
8236
|
+
}
|
|
8237
|
+
function ingestContainerIntoArrangement(arrangement, container, targetTrackId, targetBeat) {
|
|
8238
|
+
const cType = container.containerType || "midi";
|
|
8239
|
+
const isAudio = cType === "audio";
|
|
8240
|
+
const isCurve = cType === "curve";
|
|
8241
|
+
const containerSig = isAudio ? container.audioFormat === "mono" ? "audio_mono" : "audio_stereo" : isCurve ? "curve" : "midi";
|
|
8242
|
+
let tracks = [...arrangement.tracks];
|
|
8243
|
+
let targetTrack = targetTrackId ? tracks.find((t) => t.id === targetTrackId) : null;
|
|
8244
|
+
if (targetTrack && !isSignalCompatibleWithTrack(containerSig, targetTrack.signalType)) {
|
|
8245
|
+
targetTrack = null;
|
|
8246
|
+
}
|
|
8247
|
+
if (!targetTrack) {
|
|
8248
|
+
targetTrack = tracks.find((t) => t.signalType === containerSig) || null;
|
|
8249
|
+
}
|
|
8250
|
+
if (!targetTrack) {
|
|
8251
|
+
targetTrack = tracks.find((t) => isSignalCompatibleWithTrack(containerSig, t.signalType)) || null;
|
|
8252
|
+
}
|
|
8253
|
+
if (!targetTrack) {
|
|
8254
|
+
const sameTypeCount = tracks.filter((t) => t.signalType === containerSig).length;
|
|
8255
|
+
const newTrack = createTrackForSignalType(
|
|
8256
|
+
containerSig,
|
|
8257
|
+
sameTypeCount + 1
|
|
8258
|
+
);
|
|
8259
|
+
tracks.push(newTrack);
|
|
8260
|
+
targetTrack = newTrack;
|
|
8261
|
+
}
|
|
8262
|
+
let startBeat = targetBeat ?? 0;
|
|
8263
|
+
if (targetBeat == null && targetTrack.clips.length > 0) {
|
|
8264
|
+
const lastClip = targetTrack.clips[targetTrack.clips.length - 1];
|
|
8265
|
+
startBeat = Math.ceil(lastClip.startBeat + lastClip.durationBeats);
|
|
8266
|
+
}
|
|
8267
|
+
const existingIndex = targetTrack.clips.findIndex((c) => c.containerId === container.id);
|
|
8268
|
+
const newClip = createClipFromContainer(
|
|
8269
|
+
container,
|
|
8270
|
+
existingIndex >= 0 ? targetTrack.clips[existingIndex].startBeat : startBeat
|
|
8271
|
+
);
|
|
8272
|
+
let updatedClips;
|
|
8273
|
+
if (existingIndex >= 0) {
|
|
8274
|
+
updatedClips = [...targetTrack.clips];
|
|
8275
|
+
updatedClips[existingIndex] = {
|
|
8276
|
+
...newClip,
|
|
8277
|
+
startBeat: targetTrack.clips[existingIndex].startBeat,
|
|
8278
|
+
durationBeats: targetTrack.clips[existingIndex].durationBeats || newClip.durationBeats
|
|
8279
|
+
};
|
|
8280
|
+
} else {
|
|
8281
|
+
updatedClips = [...targetTrack.clips, newClip];
|
|
8282
|
+
}
|
|
8283
|
+
const updatedTracks = tracks.map((t) => t.id === targetTrack.id ? { ...t, clips: updatedClips } : t);
|
|
8284
|
+
const clipEndBeat = (existingIndex >= 0 ? targetTrack.clips[existingIndex].startBeat : startBeat) + newClip.durationBeats;
|
|
8285
|
+
const currentMaxBeat = (arrangement.totalBars || 4) * 4;
|
|
8286
|
+
let totalBars = arrangement.totalBars || 4;
|
|
8287
|
+
let loopEndBeat = arrangement.loopEndBeat ?? totalBars * 4;
|
|
8288
|
+
if (clipEndBeat > currentMaxBeat) {
|
|
8289
|
+
totalBars = Math.ceil(clipEndBeat / 4);
|
|
8290
|
+
loopEndBeat = totalBars * 4;
|
|
8291
|
+
}
|
|
8292
|
+
return {
|
|
8293
|
+
...arrangement,
|
|
8294
|
+
totalBars,
|
|
8295
|
+
loopEndBeat,
|
|
8296
|
+
tracks: updatedTracks
|
|
8297
|
+
};
|
|
8298
|
+
}
|
|
8299
|
+
function isSignalCompatibleWithTrack(sourceSig, trackSig) {
|
|
8300
|
+
if (sourceSig === trackSig) return true;
|
|
8301
|
+
if (sourceSig === "audio_mono" || trackSig === "audio_mono") return false;
|
|
8302
|
+
if (sourceSig === "audio_stereo" || trackSig === "audio_stereo") return false;
|
|
8303
|
+
if (sourceSig.includes("audio") && trackSig.includes("audio")) return true;
|
|
8304
|
+
if (sourceSig.includes("midi") && trackSig.includes("midi")) return true;
|
|
8305
|
+
if (sourceSig === "trigger" && trackSig === "trigger") return true;
|
|
8306
|
+
if (sourceSig.includes("curve") && trackSig.includes("curve")) return true;
|
|
8307
|
+
return false;
|
|
8308
|
+
}
|
|
8309
|
+
|
|
8310
|
+
// src/engine/functions/spawnNodeFactory.ts
|
|
8311
|
+
function createNodeFromSpawnType(spawnType, nodeIndex, bpm, worldPos) {
|
|
8312
|
+
switch (spawnType.kind) {
|
|
8313
|
+
case "arrangement":
|
|
8314
|
+
return projectNodeToGroundSurface(createArrangementNode(nodeIndex, worldPos));
|
|
8315
|
+
case "container":
|
|
8316
|
+
return projectNodeToGroundSurface(
|
|
8317
|
+
createContainerNode(spawnType.containerType, nodeIndex, bpm, worldPos, spawnType.audioFormat)
|
|
8318
|
+
);
|
|
8319
|
+
case "recorder":
|
|
8320
|
+
return projectNodeToGroundSurface(
|
|
8321
|
+
createRecorderNode(
|
|
8322
|
+
spawnType.recorderType || "audio_stereo",
|
|
8323
|
+
nodeIndex,
|
|
8324
|
+
worldPos,
|
|
8325
|
+
spawnType.recordingMode || "standard"
|
|
8326
|
+
)
|
|
8327
|
+
);
|
|
8328
|
+
case "player":
|
|
8329
|
+
return projectNodeToGroundSurface(
|
|
8330
|
+
createPlayerNode(spawnType.playerType || "audio_stereo", nodeIndex, worldPos)
|
|
8331
|
+
);
|
|
8332
|
+
case "sampler":
|
|
8333
|
+
return projectNodeToGroundSurface(createSamplerNode(nodeIndex, worldPos));
|
|
8334
|
+
case "audio_pads":
|
|
8335
|
+
return projectNodeToGroundSurface(createAudioPadsNode(nodeIndex, worldPos));
|
|
8336
|
+
case "trigger": {
|
|
8337
|
+
const trig = createTriggerNode(nodeIndex, worldPos);
|
|
8338
|
+
trig.triggerType = spawnType.triggerType;
|
|
8339
|
+
return projectNodeToGroundSurface(trig);
|
|
8340
|
+
}
|
|
8341
|
+
case "button":
|
|
8342
|
+
return projectNodeToGroundSurface(createButtonNode(nodeIndex, worldPos));
|
|
8343
|
+
case "code":
|
|
8344
|
+
return projectNodeToGroundSurface(createCodeNode(nodeIndex, worldPos));
|
|
8345
|
+
case "primitive_string":
|
|
8346
|
+
case "string":
|
|
8347
|
+
return projectNodeToGroundSurface(createStringNode(nodeIndex, worldPos, spawnType.initialValue));
|
|
8348
|
+
case "primitive_number":
|
|
8349
|
+
case "number":
|
|
8350
|
+
return projectNodeToGroundSurface(createNumberNode(nodeIndex, worldPos, spawnType.initialValue));
|
|
8351
|
+
case "primitive_boolean":
|
|
8352
|
+
case "boolean":
|
|
8353
|
+
return projectNodeToGroundSurface(createBooleanNode(nodeIndex, worldPos, spawnType.initialValue));
|
|
8354
|
+
case "primitive_object":
|
|
8355
|
+
case "object":
|
|
8356
|
+
return projectNodeToGroundSurface(createObjectNode(nodeIndex, worldPos, spawnType.initialValue));
|
|
8357
|
+
case "folder_path":
|
|
8358
|
+
return projectNodeToGroundSurface(createFolderPathNode(nodeIndex, worldPos, spawnType.scope));
|
|
8359
|
+
case "effect":
|
|
8360
|
+
return projectNodeToGroundSurface(createEffectNode(spawnType.effectType, nodeIndex, worldPos));
|
|
8361
|
+
case "combiner":
|
|
8362
|
+
return projectNodeToGroundSurface(createCombinerNode(nodeIndex, 3, worldPos, spawnType.signalType));
|
|
8363
|
+
case "multiplexer":
|
|
8364
|
+
return projectNodeToGroundSurface(createMultiplexerNode(nodeIndex, 4, worldPos, spawnType.signalType));
|
|
8365
|
+
case "module":
|
|
8366
|
+
return projectNodeToGroundSurface(createModuleNode(nodeIndex, "Custom Flow Module", worldPos));
|
|
8367
|
+
case "control":
|
|
8368
|
+
return projectNodeToGroundSurface(createControlNode(nodeIndex, worldPos));
|
|
8369
|
+
case "converter":
|
|
8370
|
+
return projectNodeToGroundSurface(createConverterNode(spawnType.converterType, nodeIndex, worldPos));
|
|
8371
|
+
default:
|
|
8372
|
+
return null;
|
|
8373
|
+
}
|
|
8374
|
+
}
|
|
8375
|
+
|
|
8376
|
+
// src/engine/functions/componentSocketRegistry.ts
|
|
8377
|
+
function getComponentSocketConstraint(targetNode, targetPort) {
|
|
8378
|
+
if (targetNode.type === "combiner" || targetNode.type === "multiplexer") {
|
|
8379
|
+
const sigType = targetNode.signalType;
|
|
8380
|
+
if (sigType === "component") {
|
|
8381
|
+
return {
|
|
8382
|
+
allowedNodeTypes: ["container"],
|
|
8383
|
+
allowedContainerTypes: ["audio"],
|
|
8384
|
+
description: "Component Combiner/Multiplexer ONLY accepts Audio Container nodes"
|
|
8385
|
+
};
|
|
8386
|
+
}
|
|
8387
|
+
}
|
|
8388
|
+
if (targetNode.type === "module") {
|
|
8389
|
+
if (targetPort && targetPort.includes("comp")) {
|
|
8390
|
+
return {
|
|
8391
|
+
allowedNodeTypes: ["container"],
|
|
8392
|
+
allowedContainerTypes: ["audio"],
|
|
8393
|
+
description: "Component input socket accepts Audio Container components"
|
|
8394
|
+
};
|
|
8395
|
+
}
|
|
8396
|
+
}
|
|
8397
|
+
return null;
|
|
8398
|
+
}
|
|
8399
|
+
function validateComponentSocketConnection(fromNode, constraint) {
|
|
8400
|
+
if (!constraint.allowedNodeTypes.includes(fromNode.type)) {
|
|
8401
|
+
return {
|
|
8402
|
+
isValid: false,
|
|
8403
|
+
reason: `Socket Constraint Rejection: Target requires node of type [${constraint.allowedNodeTypes.join(
|
|
8404
|
+
", "
|
|
8405
|
+
)}], but source is '${fromNode.type}'`
|
|
8406
|
+
};
|
|
8407
|
+
}
|
|
8408
|
+
if (fromNode.type === "container") {
|
|
8409
|
+
const cNode = fromNode;
|
|
8410
|
+
const cType = cNode.containerType;
|
|
8411
|
+
if (constraint.allowedContainerTypes && !constraint.allowedContainerTypes.includes(cType)) {
|
|
8412
|
+
return {
|
|
8413
|
+
isValid: false,
|
|
8414
|
+
reason: `Socket Constraint Rejection: Target requires container of type [${constraint.allowedContainerTypes.join(
|
|
8415
|
+
", "
|
|
8416
|
+
)}], but source is '${cType}' container`
|
|
8417
|
+
};
|
|
8418
|
+
}
|
|
8419
|
+
if (cType === "audio" && constraint.allowedAudioFormats) {
|
|
8420
|
+
const srcFormat = cNode.audioFormat || "mono";
|
|
8421
|
+
if (!constraint.allowedAudioFormats.includes(srcFormat)) {
|
|
8422
|
+
return {
|
|
8423
|
+
isValid: false,
|
|
8424
|
+
reason: `Socket Constraint Rejection: Stereo Sampler only accepts Stereo Audio Containers (source is '${srcFormat}')`
|
|
8425
|
+
};
|
|
8426
|
+
}
|
|
8427
|
+
}
|
|
8428
|
+
}
|
|
8429
|
+
return { isValid: true };
|
|
8430
|
+
}
|
|
8431
|
+
|
|
8432
|
+
// src/engine/functions/effectLogic.ts
|
|
8433
|
+
function getActiveEffectsForWire(conn, allNodes) {
|
|
8434
|
+
return getEffectsAffectingWire(conn, allNodes);
|
|
8435
|
+
}
|
|
8436
|
+
function getActiveEffectsForNodeWires(sourceNodeId, connections, allNodes) {
|
|
8437
|
+
const outgoing = connections.filter((c) => c.fromNodeId === sourceNodeId);
|
|
8438
|
+
return outgoing.map((conn) => ({
|
|
8439
|
+
connection: conn,
|
|
8440
|
+
effects: getEffectsAffectingWire(conn, allNodes)
|
|
8441
|
+
}));
|
|
8442
|
+
}
|
|
8443
|
+
function getActiveEffectsForNode(target, allNodes, connections = []) {
|
|
8444
|
+
const relevantConns = connections.filter(
|
|
8445
|
+
(c) => c.fromNodeId === target.id || c.toNodeId === target.id
|
|
8446
|
+
);
|
|
8447
|
+
const effectsMap = /* @__PURE__ */ new Map();
|
|
8448
|
+
relevantConns.forEach((conn) => {
|
|
8449
|
+
const effs = getEffectsAffectingWire(conn, allNodes);
|
|
8450
|
+
effs.forEach((e) => effectsMap.set(e.id, e));
|
|
8451
|
+
});
|
|
8452
|
+
return Array.from(effectsMap.values());
|
|
8453
|
+
}
|
|
8454
|
+
|
|
8455
|
+
// src/engine/functions/triggerLogic.ts
|
|
8456
|
+
function getTriggerStepDuration(node) {
|
|
8457
|
+
const mode = node.divisionMode || "every_beat";
|
|
8458
|
+
const divisions = Math.max(2, Math.min(64, node.divisionsPerBeat || 4));
|
|
8459
|
+
switch (mode) {
|
|
8460
|
+
case "every_bar":
|
|
8461
|
+
return { stepDuration: 4, totalSteps: 1, divisionsPerBeat: 1 };
|
|
8462
|
+
case "every_beat":
|
|
8463
|
+
return { stepDuration: 1, totalSteps: 4, divisionsPerBeat: 1 };
|
|
8464
|
+
case "divisions":
|
|
8465
|
+
return {
|
|
8466
|
+
stepDuration: 1 / divisions,
|
|
8467
|
+
totalSteps: 4 * divisions,
|
|
8468
|
+
divisionsPerBeat: divisions
|
|
8469
|
+
};
|
|
8470
|
+
case "4_4":
|
|
8471
|
+
return { stepDuration: 1, totalSteps: 4, divisionsPerBeat: 1 };
|
|
8472
|
+
case "2_4":
|
|
8473
|
+
return { stepDuration: 1, totalSteps: 2, divisionsPerBeat: 1 };
|
|
8474
|
+
case "16th":
|
|
8475
|
+
return { stepDuration: 0.25, totalSteps: 16, divisionsPerBeat: 4 };
|
|
8476
|
+
case "32nd":
|
|
8477
|
+
return { stepDuration: 0.125, totalSteps: 16, divisionsPerBeat: 8 };
|
|
8478
|
+
case "64th":
|
|
8479
|
+
return { stepDuration: 0.0625, totalSteps: 16, divisionsPerBeat: 16 };
|
|
8480
|
+
case "selected_beats":
|
|
8481
|
+
return { stepDuration: node.intervalBeats || 1, totalSteps: node.stepsPerCycle || 4, divisionsPerBeat: 1 };
|
|
8482
|
+
case "custom":
|
|
8483
|
+
return {
|
|
8484
|
+
stepDuration: 1 / divisions,
|
|
8485
|
+
totalSteps: 4 * divisions,
|
|
8486
|
+
divisionsPerBeat: divisions
|
|
8487
|
+
};
|
|
8488
|
+
default:
|
|
8489
|
+
return { stepDuration: node.intervalBeats || 1, totalSteps: 4, divisionsPerBeat: 1 };
|
|
8490
|
+
}
|
|
8491
|
+
}
|
|
8492
|
+
function shouldTriggerFireAtClock(node, prevBeat, currBeat) {
|
|
8493
|
+
if (!node.active) return false;
|
|
8494
|
+
const isFractions = node.triggerType === "beat_fractions" || node.divisionMode === "divisions" || node.divisionMode === "custom";
|
|
8495
|
+
if (isFractions) {
|
|
8496
|
+
const divs = Math.max(2, Math.min(64, node.divisionsPerBeat || 64));
|
|
8497
|
+
const stepDuration = 1 / divs;
|
|
8498
|
+
const prevStep2 = Math.floor(prevBeat / stepDuration);
|
|
8499
|
+
const currStep2 = Math.floor(currBeat / stepDuration);
|
|
8500
|
+
if (currStep2 <= prevStep2) return false;
|
|
8501
|
+
const fractionIndex = (currStep2 % divs + divs) % divs;
|
|
8502
|
+
if (node.activeFractions && node.activeFractions.length > 0) {
|
|
8503
|
+
const fracIndex = fractionIndex % node.activeFractions.length;
|
|
8504
|
+
return !!node.activeFractions[fracIndex];
|
|
8505
|
+
}
|
|
8506
|
+
return true;
|
|
8507
|
+
}
|
|
8508
|
+
const mode = node.divisionMode || "every_beat";
|
|
8509
|
+
if (mode === "every_bar") {
|
|
8510
|
+
const prevBar = Math.floor(prevBeat / 4);
|
|
8511
|
+
const currBar = Math.floor(currBeat / 4);
|
|
8512
|
+
return currBar > prevBar;
|
|
8513
|
+
}
|
|
8514
|
+
const prevStep = Math.floor(prevBeat);
|
|
8515
|
+
const currStep = Math.floor(currBeat);
|
|
8516
|
+
if (currStep <= prevStep) return false;
|
|
8517
|
+
const beatIndex = (currStep % 4 + 4) % 4;
|
|
8518
|
+
if (node.activeSteps && node.activeSteps.length > 0) {
|
|
8519
|
+
const maskIndex = beatIndex % node.activeSteps.length;
|
|
8520
|
+
return !!node.activeSteps[maskIndex];
|
|
8521
|
+
}
|
|
8522
|
+
return true;
|
|
8523
|
+
}
|
|
8524
|
+
function getDefaultActiveSteps(mode, totalSteps) {
|
|
8525
|
+
switch (mode) {
|
|
8526
|
+
case "every_bar":
|
|
8527
|
+
return [true];
|
|
8528
|
+
case "every_beat":
|
|
8529
|
+
return [true, true, true, true];
|
|
8530
|
+
case "divisions":
|
|
8531
|
+
return [true, true, true, true];
|
|
8532
|
+
default:
|
|
8533
|
+
return Array(totalSteps).fill(true);
|
|
8534
|
+
}
|
|
8535
|
+
}
|
|
8536
|
+
function getDefaultActiveFractions(divisions) {
|
|
8537
|
+
return Array(divisions).fill(true);
|
|
8538
|
+
}
|
|
8539
|
+
|
|
8540
|
+
// src/engine/functions/rotaryGeometry.ts
|
|
8541
|
+
function polarToCartesian(centerX, centerY, rad, angleInDegrees) {
|
|
8542
|
+
const angleInRadians = (angleInDegrees - 90) * Math.PI / 180;
|
|
8543
|
+
return {
|
|
8544
|
+
x: centerX + rad * Math.cos(angleInRadians),
|
|
8545
|
+
y: centerY + rad * Math.sin(angleInRadians)
|
|
8546
|
+
};
|
|
8547
|
+
}
|
|
8548
|
+
function describeSvgArc(x, y, rad, startAng, endAng) {
|
|
8549
|
+
const start = polarToCartesian(x, y, rad, endAng);
|
|
8550
|
+
const end = polarToCartesian(x, y, rad, startAng);
|
|
8551
|
+
const arcSweep = endAng - startAng <= 180 ? "0" : "1";
|
|
8552
|
+
return ["M", start.x, start.y, "A", rad, rad, 0, arcSweep, 0, end.x, end.y].join(" ");
|
|
8553
|
+
}
|
|
8554
|
+
|
|
8555
|
+
// src/engine/functions/clientWavEncoder.ts
|
|
8556
|
+
function encodeFloat32ToWavBase64(sampleRate, numChannels, channelData) {
|
|
8557
|
+
const numSamples = channelData[0].length;
|
|
8558
|
+
const bytesPerSample = 2;
|
|
8559
|
+
const blockAlign = numChannels * bytesPerSample;
|
|
8560
|
+
const byteRate = sampleRate * blockAlign;
|
|
8561
|
+
const dataSize = numSamples * blockAlign;
|
|
8562
|
+
const arrayBuffer = new ArrayBuffer(44 + dataSize);
|
|
8563
|
+
const view = new DataView(arrayBuffer);
|
|
8564
|
+
function writeString(offset2, string) {
|
|
8565
|
+
for (let i = 0; i < string.length; i++) {
|
|
8566
|
+
view.setUint8(offset2 + i, string.charCodeAt(i));
|
|
8567
|
+
}
|
|
8568
|
+
}
|
|
8569
|
+
writeString(0, "RIFF");
|
|
8570
|
+
view.setUint32(4, 36 + dataSize, true);
|
|
8571
|
+
writeString(8, "WAVE");
|
|
8572
|
+
writeString(12, "fmt ");
|
|
8573
|
+
view.setUint32(16, 16, true);
|
|
8574
|
+
view.setUint16(20, 1, true);
|
|
8575
|
+
view.setUint16(22, numChannels, true);
|
|
8576
|
+
view.setUint32(24, sampleRate, true);
|
|
8577
|
+
view.setUint32(28, byteRate, true);
|
|
8578
|
+
view.setUint16(32, blockAlign, true);
|
|
8579
|
+
view.setUint16(34, 16, true);
|
|
8580
|
+
writeString(36, "data");
|
|
8581
|
+
view.setUint32(40, dataSize, true);
|
|
8582
|
+
let offset = 44;
|
|
8583
|
+
for (let i = 0; i < numSamples; i++) {
|
|
8584
|
+
for (let ch = 0; ch < numChannels; ch++) {
|
|
8585
|
+
const sample = Math.max(-1, Math.min(1, channelData[ch][i] || 0));
|
|
8586
|
+
const intSample = sample < 0 ? sample * 32768 : sample * 32767;
|
|
8587
|
+
view.setInt16(offset, Math.floor(intSample), true);
|
|
8588
|
+
offset += 2;
|
|
8589
|
+
}
|
|
8590
|
+
}
|
|
8591
|
+
const bytes = new Uint8Array(arrayBuffer);
|
|
8592
|
+
let binary = "";
|
|
8593
|
+
const chunkSize = 8192;
|
|
8594
|
+
for (let i = 0; i < bytes.length; i += chunkSize) {
|
|
8595
|
+
const chunk = bytes.subarray(i, i + chunkSize);
|
|
8596
|
+
binary += String.fromCharCode.apply(null, Array.from(chunk));
|
|
8597
|
+
}
|
|
8598
|
+
return btoa(binary);
|
|
8599
|
+
}
|
|
8600
|
+
function generateWavBase64FromWaveform(peaks, durationSec = 2, isMono = false) {
|
|
8601
|
+
const sampleRate = 44100;
|
|
8602
|
+
const numSamples = Math.floor(sampleRate * durationSec);
|
|
8603
|
+
const numChannels = isMono ? 1 : 2;
|
|
8604
|
+
const chL = new Float32Array(numSamples);
|
|
8605
|
+
const chR = isMono ? chL : new Float32Array(numSamples);
|
|
8606
|
+
const peaksLen = peaks.length || 32;
|
|
8607
|
+
for (let i = 0; i < numSamples; i++) {
|
|
8608
|
+
const progress = i / numSamples;
|
|
8609
|
+
const peakIdx = Math.min(peaksLen - 1, Math.floor(progress * peaksLen));
|
|
8610
|
+
const amp = Math.max(0.05, Math.min(1, peaks[peakIdx] || 0.3));
|
|
8611
|
+
const t = i / sampleRate;
|
|
8612
|
+
const freq = 120 + Math.sin(progress * Math.PI) * 40;
|
|
8613
|
+
const val = Math.sin(2 * Math.PI * freq * t) * amp * Math.exp(-progress * 1.5);
|
|
8614
|
+
chL[i] = val;
|
|
8615
|
+
if (!isMono) {
|
|
8616
|
+
chR[i] = val * (0.9 + Math.sin(t * 5) * 0.1);
|
|
8617
|
+
}
|
|
8618
|
+
}
|
|
8619
|
+
return encodeFloat32ToWavBase64(sampleRate, numChannels, isMono ? [chL] : [chL, chR]);
|
|
8620
|
+
}
|
|
8621
|
+
|
|
8622
|
+
// src/engine/functions/sampleContainerExtractor.ts
|
|
8623
|
+
var GM_DRUM_NOTES = [
|
|
8624
|
+
36,
|
|
8625
|
+
// C1: Bass Drum 1
|
|
8626
|
+
38,
|
|
8627
|
+
// D1: Acoustic Snare
|
|
8628
|
+
42,
|
|
8629
|
+
// F#1: Closed Hi-Hat
|
|
8630
|
+
46,
|
|
8631
|
+
// A#1: Open Hi-Hat
|
|
8632
|
+
37,
|
|
8633
|
+
// C#1: Side Stick
|
|
8634
|
+
39,
|
|
8635
|
+
// D#1: Hand Clap
|
|
8636
|
+
41,
|
|
8637
|
+
// F1: Low Floor Tom
|
|
8638
|
+
43,
|
|
8639
|
+
// G1: High Floor Tom
|
|
8640
|
+
45,
|
|
8641
|
+
// A1: Low Tom
|
|
8642
|
+
47,
|
|
8643
|
+
// B1: Low-Mid Tom
|
|
8644
|
+
48,
|
|
8645
|
+
// C2: High-Mid Tom
|
|
8646
|
+
50,
|
|
8647
|
+
// D2: High Tom
|
|
8648
|
+
49,
|
|
8649
|
+
// C#2: Crash Cymbal 1
|
|
8650
|
+
51,
|
|
8651
|
+
// D#2: Ride Cymbal 1
|
|
8652
|
+
52,
|
|
8653
|
+
// E2: Chinese Cymbal
|
|
8654
|
+
53
|
|
8655
|
+
// F2: Ride Bell
|
|
8656
|
+
];
|
|
8657
|
+
function getDefaultPadMidiNote(index) {
|
|
8658
|
+
if (index < GM_DRUM_NOTES.length) {
|
|
8659
|
+
return GM_DRUM_NOTES[index];
|
|
8660
|
+
}
|
|
8661
|
+
return 36 + index % 48;
|
|
8662
|
+
}
|
|
8663
|
+
function extractSamplesFromConnectedContainers(targetNodeId, connections = [], allNodes = []) {
|
|
8664
|
+
const relevantConns = connections.filter(
|
|
8665
|
+
(c) => c.toNodeId === targetNodeId && (c.toPort === "store_in" || c.toPort === "packet_in" || c.toSocketId === "store_in" || c.toSocketId === "packet_in" || c.signalType === "audio_packet" || c.toSocketIndex === 0)
|
|
8666
|
+
);
|
|
8667
|
+
const connectedContainerIds = new Set(relevantConns.map((c) => c.fromNodeId));
|
|
8668
|
+
const connectedContainers = allNodes.filter(
|
|
8669
|
+
(n) => n.type === "container" && n.containerType === "audio" && connectedContainerIds.has(n.id)
|
|
8670
|
+
);
|
|
8671
|
+
const samples = [];
|
|
8672
|
+
connectedContainers.forEach((container) => {
|
|
8673
|
+
const containerFormat = container.audioFormat === "mono" ? "mono" : "stereo";
|
|
8674
|
+
if (container.audioTrack) {
|
|
8675
|
+
const clip = container.audioTrack;
|
|
8676
|
+
const clipId = clip.id || `clip-${container.id}`;
|
|
8677
|
+
samples.push({
|
|
8678
|
+
id: `${container.id}_${clipId}`,
|
|
8679
|
+
clipId,
|
|
8680
|
+
name: clip.name || container.name || "Audio Container",
|
|
8681
|
+
containerId: container.id,
|
|
8682
|
+
containerName: container.name || "Audio Container",
|
|
8683
|
+
audioFormat: containerFormat,
|
|
8684
|
+
sampleType: clip.sampleType || "kick",
|
|
8685
|
+
customAudioUrl: clip.customAudioUrl,
|
|
8686
|
+
waveformData: clip.waveformData,
|
|
8687
|
+
audioTrack: {
|
|
8688
|
+
...clip,
|
|
8689
|
+
id: clipId,
|
|
8690
|
+
name: clip.name || container.name || "Audio Container"
|
|
8691
|
+
}
|
|
8692
|
+
});
|
|
8693
|
+
}
|
|
8694
|
+
});
|
|
8695
|
+
return { samples, connectedContainers };
|
|
8696
|
+
}
|
|
8697
|
+
|
|
8698
|
+
// src/engine/functions/midiDeviceRegistry.ts
|
|
8699
|
+
var CUSTOM_NAMES_KEY = "celestial_midi_custom_names";
|
|
8700
|
+
var VIRTUAL_DEVS_KEY = "celestial_midi_virtual_devices";
|
|
8701
|
+
var NAMED_PROFILES_KEY = "celestial_midi_named_profiles";
|
|
8702
|
+
var DEFAULT_NAMED_MIDI_PROFILES = [
|
|
8703
|
+
{
|
|
8704
|
+
id: "midi-profile-1",
|
|
8705
|
+
name: "Main Stage Synth / Keyboard",
|
|
8706
|
+
sourceDeviceId: "virtual-keyboard",
|
|
8707
|
+
channel: 0,
|
|
8708
|
+
color: "#38bdf8",
|
|
8709
|
+
enabled: true
|
|
8710
|
+
},
|
|
8711
|
+
{
|
|
8712
|
+
id: "midi-profile-2",
|
|
8713
|
+
name: "External MIDI Controller / Pads",
|
|
8714
|
+
sourceDeviceId: "all",
|
|
8715
|
+
channel: 1,
|
|
8716
|
+
color: "#f59e0b",
|
|
8717
|
+
enabled: true
|
|
8718
|
+
}
|
|
8719
|
+
];
|
|
8720
|
+
function getCustomMidiNames() {
|
|
8721
|
+
if (typeof window === "undefined") return {};
|
|
8722
|
+
try {
|
|
8723
|
+
const raw = localStorage.getItem(CUSTOM_NAMES_KEY);
|
|
8724
|
+
return raw ? JSON.parse(raw) : {};
|
|
8725
|
+
} catch {
|
|
8726
|
+
return {};
|
|
8727
|
+
}
|
|
8728
|
+
}
|
|
8729
|
+
function saveCustomMidiNames(names) {
|
|
8730
|
+
if (typeof window === "undefined") return;
|
|
8731
|
+
localStorage.setItem(CUSTOM_NAMES_KEY, JSON.stringify(names));
|
|
8732
|
+
}
|
|
8733
|
+
function getCustomMidiName(id) {
|
|
8734
|
+
return getCustomMidiNames()[id];
|
|
8735
|
+
}
|
|
8736
|
+
function setCustomMidiName(id, name) {
|
|
8737
|
+
const current = getCustomMidiNames();
|
|
8738
|
+
if (!name.trim()) {
|
|
8739
|
+
delete current[id];
|
|
8740
|
+
} else {
|
|
8741
|
+
current[id] = name.trim();
|
|
8742
|
+
}
|
|
8743
|
+
saveCustomMidiNames(current);
|
|
8744
|
+
}
|
|
8745
|
+
function getVirtualMidiDevices() {
|
|
8746
|
+
if (typeof window === "undefined") return [];
|
|
8747
|
+
try {
|
|
8748
|
+
const raw = localStorage.getItem(VIRTUAL_DEVS_KEY);
|
|
8749
|
+
return raw ? JSON.parse(raw) : [];
|
|
8750
|
+
} catch {
|
|
8751
|
+
return [];
|
|
8752
|
+
}
|
|
8753
|
+
}
|
|
8754
|
+
function saveVirtualMidiDevices(devices) {
|
|
8755
|
+
if (typeof window === "undefined") return;
|
|
8756
|
+
localStorage.setItem(VIRTUAL_DEVS_KEY, JSON.stringify(devices));
|
|
8757
|
+
}
|
|
8758
|
+
function createVirtualMidiDevice(name) {
|
|
8759
|
+
const devices = getVirtualMidiDevices();
|
|
8760
|
+
const newDevice = {
|
|
8761
|
+
id: `virtual-midi-dev-${Date.now()}`,
|
|
8762
|
+
name: name.trim() || `Virtual MIDI Port ${devices.length + 1}`,
|
|
8763
|
+
manufacturer: "Celestial Studio (Virtual)",
|
|
8764
|
+
state: "connected"
|
|
8765
|
+
};
|
|
8766
|
+
devices.push(newDevice);
|
|
8767
|
+
saveVirtualMidiDevices(devices);
|
|
8768
|
+
return newDevice;
|
|
8769
|
+
}
|
|
8770
|
+
function deleteVirtualMidiDevice(id) {
|
|
8771
|
+
const devices = getVirtualMidiDevices();
|
|
8772
|
+
const filtered = devices.filter((d) => d.id !== id);
|
|
8773
|
+
saveVirtualMidiDevices(filtered);
|
|
8774
|
+
}
|
|
8775
|
+
function getNamedMidiProfiles() {
|
|
8776
|
+
if (typeof window === "undefined") return DEFAULT_NAMED_MIDI_PROFILES;
|
|
8777
|
+
try {
|
|
8778
|
+
const raw = localStorage.getItem(NAMED_PROFILES_KEY);
|
|
8779
|
+
if (!raw) {
|
|
8780
|
+
localStorage.setItem(NAMED_PROFILES_KEY, JSON.stringify(DEFAULT_NAMED_MIDI_PROFILES));
|
|
8781
|
+
return DEFAULT_NAMED_MIDI_PROFILES;
|
|
8782
|
+
}
|
|
8783
|
+
return JSON.parse(raw);
|
|
8784
|
+
} catch {
|
|
8785
|
+
return DEFAULT_NAMED_MIDI_PROFILES;
|
|
8786
|
+
}
|
|
8787
|
+
}
|
|
8788
|
+
function saveNamedMidiProfiles(profiles) {
|
|
8789
|
+
if (typeof window === "undefined") return;
|
|
8790
|
+
localStorage.setItem(NAMED_PROFILES_KEY, JSON.stringify(profiles));
|
|
8791
|
+
}
|
|
8792
|
+
function addNamedMidiProfile(profile) {
|
|
8793
|
+
const profiles = getNamedMidiProfiles();
|
|
8794
|
+
const newProfile = {
|
|
8795
|
+
...profile,
|
|
8796
|
+
id: `midi-profile-${Date.now()}-${Math.random().toString(36).substr(2, 4)}`
|
|
8797
|
+
};
|
|
8798
|
+
profiles.push(newProfile);
|
|
8799
|
+
saveNamedMidiProfiles(profiles);
|
|
8800
|
+
return newProfile;
|
|
8801
|
+
}
|
|
8802
|
+
function updateNamedMidiProfile(updated) {
|
|
8803
|
+
const profiles = getNamedMidiProfiles();
|
|
8804
|
+
const index = profiles.findIndex((p) => p.id === updated.id);
|
|
8805
|
+
if (index !== -1) {
|
|
8806
|
+
profiles[index] = updated;
|
|
8807
|
+
saveNamedMidiProfiles(profiles);
|
|
8808
|
+
}
|
|
8809
|
+
}
|
|
8810
|
+
function deleteNamedMidiProfile(id) {
|
|
8811
|
+
const profiles = getNamedMidiProfiles();
|
|
8812
|
+
const filtered = profiles.filter((p) => p.id !== id);
|
|
8813
|
+
saveNamedMidiProfiles(filtered);
|
|
8814
|
+
}
|
|
8815
|
+
function getResolvedMidiDevices(physicalDevices) {
|
|
8816
|
+
const customNames = getCustomMidiNames();
|
|
8817
|
+
const virtualDevices = getVirtualMidiDevices();
|
|
8818
|
+
const namedProfiles = getNamedMidiProfiles();
|
|
8819
|
+
const builtInVirtualKeyboard = {
|
|
8820
|
+
id: "virtual-keyboard",
|
|
8821
|
+
name: "Virtual MIDI Keyboard",
|
|
8822
|
+
manufacturer: "Celestial Studio (Built-in)",
|
|
8823
|
+
state: "connected"
|
|
8824
|
+
};
|
|
8825
|
+
const profileDevs = namedProfiles.map((p) => {
|
|
8826
|
+
const chLabel = !p.channel || p.channel === 0 ? "Omni" : `Ch ${p.channel}`;
|
|
8827
|
+
return {
|
|
8828
|
+
id: p.id,
|
|
8829
|
+
name: p.name,
|
|
8830
|
+
manufacturer: `Named Profile (${chLabel})`,
|
|
8831
|
+
state: "connected"
|
|
8832
|
+
};
|
|
8833
|
+
});
|
|
8834
|
+
const rawList = [...profileDevs, builtInVirtualKeyboard, ...physicalDevices, ...virtualDevices];
|
|
8835
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
8836
|
+
const uniqueDevices = [];
|
|
8837
|
+
for (const dev of rawList) {
|
|
8838
|
+
if (dev && dev.id && !seenIds.has(dev.id)) {
|
|
8839
|
+
seenIds.add(dev.id);
|
|
8840
|
+
uniqueDevices.push(dev);
|
|
8841
|
+
}
|
|
8842
|
+
}
|
|
8843
|
+
return uniqueDevices.map((dev) => ({
|
|
8844
|
+
...dev,
|
|
8845
|
+
name: customNames[dev.id] || dev.name
|
|
8846
|
+
}));
|
|
8847
|
+
}
|
|
8848
|
+
|
|
8849
|
+
// src/engine/functions/nodePerformanceTracker.ts
|
|
8850
|
+
var configuredPerfEngines = {};
|
|
8851
|
+
function configureNodePerformanceTracker(engines) {
|
|
8852
|
+
configuredPerfEngines = { ...configuredPerfEngines, ...engines };
|
|
8853
|
+
if (engines.synthEngine) {
|
|
8854
|
+
globalThis.__KLOKS_SYNTH_ENGINE__ = engines.synthEngine;
|
|
8855
|
+
globalThis.__QWNSR_SYNTH_ENGINE__ = engines.synthEngine;
|
|
8856
|
+
}
|
|
8857
|
+
}
|
|
8858
|
+
var synthEngine2 = new Proxy(
|
|
8859
|
+
{},
|
|
8860
|
+
{
|
|
8861
|
+
get(_target, prop) {
|
|
8862
|
+
const globalEngine = configuredPerfEngines.synthEngine || globalThis.__KLOKS_SYNTH_ENGINE__ || globalThis.__QWNSR_SYNTH_ENGINE__;
|
|
8863
|
+
if (globalEngine && typeof globalEngine[prop] === "function") {
|
|
8864
|
+
return globalEngine[prop].bind(globalEngine);
|
|
8865
|
+
}
|
|
8866
|
+
return () => true;
|
|
8867
|
+
}
|
|
8868
|
+
}
|
|
8869
|
+
);
|
|
8870
|
+
var smoothedLoads = /* @__PURE__ */ new Map();
|
|
8871
|
+
function calculateNodePerformance(nodes, connections, isPlaying, bpm) {
|
|
8872
|
+
const metrics = /* @__PURE__ */ new Map();
|
|
8873
|
+
let maxLoad = -1;
|
|
8874
|
+
let maxNodeId = null;
|
|
8875
|
+
let totalDspload = 0;
|
|
8876
|
+
const outgoingMap = /* @__PURE__ */ new Map();
|
|
8877
|
+
connections.forEach((c) => {
|
|
8878
|
+
outgoingMap.set(c.fromNodeId, (outgoingMap.get(c.fromNodeId) || 0) + 1);
|
|
8879
|
+
});
|
|
8880
|
+
const now = performance.now() * 1e-3;
|
|
8881
|
+
nodes.forEach((node) => {
|
|
8882
|
+
let rawLoad = 0;
|
|
8883
|
+
let voiceCount = 0;
|
|
8884
|
+
let detailLabel = "0% DSP";
|
|
8885
|
+
let dspStatus = "IDLE";
|
|
8886
|
+
const isActive = node.active !== false && !node.isMuted;
|
|
8887
|
+
if (!isActive) {
|
|
8888
|
+
rawLoad = 0;
|
|
8889
|
+
dspStatus = "OFFLINE";
|
|
8890
|
+
detailLabel = "MUTED / OFF";
|
|
8891
|
+
} else {
|
|
8892
|
+
const isConnected = synthEngine2.isNodeConnectedToOutput(node.id);
|
|
8893
|
+
if (node.type === "container") {
|
|
8894
|
+
const cNode = node;
|
|
8895
|
+
if (!isConnected) {
|
|
8896
|
+
rawLoad = 1;
|
|
8897
|
+
detailLabel = "NO OUTPUT";
|
|
8898
|
+
dspStatus = "IDLE";
|
|
8899
|
+
} else {
|
|
8900
|
+
const cType = cNode.containerType || "midi";
|
|
8901
|
+
if (cType === "midi") {
|
|
8902
|
+
const noteCount = cNode.pattern?.notes.length || 0;
|
|
8903
|
+
const synthType = cNode.synthPreset?.synthType || "poly";
|
|
8904
|
+
const baseTypeLoad = synthType === "drums" ? 22 : synthType === "lead" ? 18 : synthType === "bass" ? 14 : 15;
|
|
8905
|
+
let fxLoad = 0;
|
|
8906
|
+
if (cNode.synthPreset?.reverb && cNode.synthPreset.reverb > 0.05) fxLoad += 12;
|
|
8907
|
+
if (cNode.synthPreset?.delay && cNode.synthPreset.delay > 0.05) fxLoad += 10;
|
|
8908
|
+
if (cNode.synthPreset?.cutoff && cNode.synthPreset.cutoff < 14e3) fxLoad += 6;
|
|
8909
|
+
voiceCount = Math.min(16, Math.max(1, Math.ceil(noteCount * 0.4)));
|
|
8910
|
+
rawLoad = baseTypeLoad + fxLoad + voiceCount * 3.5;
|
|
8911
|
+
if (isPlaying) {
|
|
8912
|
+
const pulse = (Math.sin(now * (bpm / 60) * Math.PI * 2 + node.position[0]) + 1) * 0.5;
|
|
8913
|
+
rawLoad += pulse * 18;
|
|
8914
|
+
}
|
|
8915
|
+
} else if (cType === "audio") {
|
|
8916
|
+
const track = cNode.audioTrack;
|
|
8917
|
+
voiceCount = track ? 1 : 0;
|
|
8918
|
+
rawLoad = track ? 24 : 5;
|
|
8919
|
+
if (isPlaying) {
|
|
8920
|
+
const pulse = (Math.cos(now * 8 + node.position[2]) + 1) * 0.5;
|
|
8921
|
+
rawLoad += pulse * 22;
|
|
8922
|
+
}
|
|
8923
|
+
} else if (cType === "curve") {
|
|
8924
|
+
rawLoad = 12 + (isPlaying ? Math.sin(now * 5) * 8 : 0);
|
|
8925
|
+
}
|
|
8926
|
+
}
|
|
8927
|
+
} else if (node.type === "trigger") {
|
|
8928
|
+
const tNode = node;
|
|
8929
|
+
const interval = tNode.intervalBeats || 1;
|
|
8930
|
+
const divisions = tNode.divisionsPerBeat || 1;
|
|
8931
|
+
const rateFactor = divisions > 4 ? 28 : divisions > 1 ? 18 : interval < 0.5 ? 22 : 10;
|
|
8932
|
+
const outgoingCount = outgoingMap.get(node.id) || 0;
|
|
8933
|
+
rawLoad = rateFactor + outgoingCount * 6;
|
|
8934
|
+
if (isPlaying) {
|
|
8935
|
+
const tick = (Math.sin(now * (bpm / 30)) + 1) * 0.5;
|
|
8936
|
+
rawLoad += tick * 15;
|
|
8937
|
+
}
|
|
8938
|
+
} else if (node.type === "effect") {
|
|
8939
|
+
const eNode = node;
|
|
8940
|
+
const eType = eNode.effectType;
|
|
8941
|
+
const base = eType === "repeater" ? 22 : 26;
|
|
8942
|
+
rawLoad = base;
|
|
8943
|
+
if (isPlaying) {
|
|
8944
|
+
rawLoad += (Math.sin(now * 4 + node.position[0]) + 1) * 10;
|
|
8945
|
+
}
|
|
8946
|
+
}
|
|
8947
|
+
}
|
|
8948
|
+
rawLoad = Math.min(98, Math.max(0, rawLoad));
|
|
8949
|
+
const prev = smoothedLoads.get(node.id) || rawLoad;
|
|
8950
|
+
const smoothed = prev + (rawLoad - prev) * 0.15;
|
|
8951
|
+
smoothedLoads.set(node.id, smoothed);
|
|
8952
|
+
const finalLoad = Math.round(smoothed);
|
|
8953
|
+
if (dspStatus !== "OFFLINE") {
|
|
8954
|
+
if (finalLoad > 75) dspStatus = "PEAK";
|
|
8955
|
+
else if (finalLoad > 45) dspStatus = "HIGH";
|
|
8956
|
+
else if (finalLoad > 10) dspStatus = "ACTIVE";
|
|
8957
|
+
else dspStatus = "IDLE";
|
|
8958
|
+
}
|
|
8959
|
+
detailLabel = `${finalLoad}% DSP`;
|
|
8960
|
+
if (finalLoad > maxLoad && dspStatus !== "OFFLINE") {
|
|
8961
|
+
maxLoad = finalLoad;
|
|
8962
|
+
maxNodeId = node.id;
|
|
8963
|
+
}
|
|
8964
|
+
totalDspload += finalLoad;
|
|
8965
|
+
metrics.set(node.id, {
|
|
8966
|
+
nodeId: node.id,
|
|
8967
|
+
loadPercentage: finalLoad,
|
|
8968
|
+
isMaxNode: false,
|
|
8969
|
+
voiceCount,
|
|
8970
|
+
dspStatus,
|
|
8971
|
+
detailLabel
|
|
8972
|
+
});
|
|
8973
|
+
});
|
|
8974
|
+
if (maxNodeId && metrics.has(maxNodeId)) {
|
|
8975
|
+
const item = metrics.get(maxNodeId);
|
|
8976
|
+
if (item.loadPercentage > 5) {
|
|
8977
|
+
item.isMaxNode = true;
|
|
6703
8978
|
}
|
|
6704
|
-
case "button":
|
|
6705
|
-
return projectNodeToGroundSurface(createButtonNode(nodeIndex, worldPos));
|
|
6706
|
-
case "code":
|
|
6707
|
-
return projectNodeToGroundSurface(createCodeNode(nodeIndex, worldPos));
|
|
6708
|
-
case "primitive_string":
|
|
6709
|
-
case "string":
|
|
6710
|
-
return projectNodeToGroundSurface(createStringNode(nodeIndex, worldPos, spawnType.initialValue));
|
|
6711
|
-
case "primitive_number":
|
|
6712
|
-
case "number":
|
|
6713
|
-
return projectNodeToGroundSurface(createNumberNode(nodeIndex, worldPos, spawnType.initialValue));
|
|
6714
|
-
case "primitive_boolean":
|
|
6715
|
-
case "boolean":
|
|
6716
|
-
return projectNodeToGroundSurface(createBooleanNode(nodeIndex, worldPos, spawnType.initialValue));
|
|
6717
|
-
case "primitive_object":
|
|
6718
|
-
case "object":
|
|
6719
|
-
return projectNodeToGroundSurface(createObjectNode(nodeIndex, worldPos, spawnType.initialValue));
|
|
6720
|
-
case "folder_path":
|
|
6721
|
-
return projectNodeToGroundSurface(createFolderPathNode(nodeIndex, worldPos, spawnType.scope));
|
|
6722
|
-
case "effect":
|
|
6723
|
-
return projectNodeToGroundSurface(createEffectNode(spawnType.effectType, nodeIndex, worldPos));
|
|
6724
|
-
case "combiner":
|
|
6725
|
-
return projectNodeToGroundSurface(createCombinerNode(nodeIndex, 3, worldPos, spawnType.signalType));
|
|
6726
|
-
case "multiplexer":
|
|
6727
|
-
return projectNodeToGroundSurface(createMultiplexerNode(nodeIndex, 4, worldPos, spawnType.signalType));
|
|
6728
|
-
case "module":
|
|
6729
|
-
return projectNodeToGroundSurface(createModuleNode(nodeIndex, "Custom Flow Module", worldPos));
|
|
6730
|
-
case "control":
|
|
6731
|
-
return projectNodeToGroundSurface(createControlNode(nodeIndex, worldPos));
|
|
6732
|
-
case "converter":
|
|
6733
|
-
return projectNodeToGroundSurface(createConverterNode(spawnType.converterType, nodeIndex, worldPos));
|
|
6734
|
-
default:
|
|
6735
|
-
return null;
|
|
6736
8979
|
}
|
|
8980
|
+
return { metrics, maxNodeId, totalDspload };
|
|
6737
8981
|
}
|
|
6738
8982
|
|
|
6739
8983
|
// src/engine/predictive/predictiveGraphEngine/predictiveGraphEngine.ts
|
|
@@ -6925,152 +9169,6 @@ function computePredictiveGraph(selectedNodes, connections, scenarioIndex = 0) {
|
|
|
6925
9169
|
return { ghostNodes, traces, selectedNodesWithGhosts };
|
|
6926
9170
|
}
|
|
6927
9171
|
|
|
6928
|
-
// src/engine/functions/containerClipSync.ts
|
|
6929
|
-
function syncConnectedContainersToArrangement(arrangement, allNodes) {
|
|
6930
|
-
const containerMap = /* @__PURE__ */ new Map();
|
|
6931
|
-
allNodes.forEach((n) => {
|
|
6932
|
-
if (n.type === "container") containerMap.set(n.id, n);
|
|
6933
|
-
});
|
|
6934
|
-
let changed = false;
|
|
6935
|
-
const newTracks = arrangement.tracks.map((track) => {
|
|
6936
|
-
let trackChanged = false;
|
|
6937
|
-
const newClips = track.clips.map((clip) => {
|
|
6938
|
-
if (!clip.containerId) return clip;
|
|
6939
|
-
const sourceContainer = containerMap.get(clip.containerId);
|
|
6940
|
-
if (!sourceContainer) return clip;
|
|
6941
|
-
const isAudio = sourceContainer.containerType === "audio";
|
|
6942
|
-
const isMidi = sourceContainer.containerType !== "audio" && sourceContainer.containerType !== "curve";
|
|
6943
|
-
let needsUpdate = false;
|
|
6944
|
-
if (isAudio && sourceContainer.audioTrack) {
|
|
6945
|
-
if (clip.sampleType !== sourceContainer.audioTrack.sampleType || clip.customAudioUrl !== sourceContainer.audioTrack.customAudioUrl || clip.name !== (sourceContainer.name || clip.name)) {
|
|
6946
|
-
needsUpdate = true;
|
|
6947
|
-
}
|
|
6948
|
-
} else if (isMidi && sourceContainer.pattern) {
|
|
6949
|
-
const sourceNotesCount = sourceContainer.pattern.notes?.length || 0;
|
|
6950
|
-
const clipNotesCount = clip.notes?.length || 0;
|
|
6951
|
-
if (sourceNotesCount !== clipNotesCount || clip.name !== (sourceContainer.name || clip.name)) {
|
|
6952
|
-
needsUpdate = true;
|
|
6953
|
-
}
|
|
6954
|
-
}
|
|
6955
|
-
if (needsUpdate) {
|
|
6956
|
-
trackChanged = true;
|
|
6957
|
-
changed = true;
|
|
6958
|
-
return {
|
|
6959
|
-
...clip,
|
|
6960
|
-
name: sourceContainer.name || clip.name,
|
|
6961
|
-
audioTrack: sourceContainer.audioTrack ? { ...sourceContainer.audioTrack } : clip.audioTrack,
|
|
6962
|
-
sampleType: sourceContainer.audioTrack?.sampleType || clip.sampleType,
|
|
6963
|
-
customAudioUrl: sourceContainer.audioTrack?.customAudioUrl || clip.customAudioUrl,
|
|
6964
|
-
pattern: sourceContainer.pattern ? JSON.parse(JSON.stringify(sourceContainer.pattern)) : clip.pattern,
|
|
6965
|
-
notes: sourceContainer.pattern?.notes ? [...sourceContainer.pattern.notes] : clip.notes,
|
|
6966
|
-
curveData: sourceContainer.curveData ? JSON.parse(JSON.stringify(sourceContainer.curveData)) : clip.curveData
|
|
6967
|
-
};
|
|
6968
|
-
}
|
|
6969
|
-
return clip;
|
|
6970
|
-
});
|
|
6971
|
-
return trackChanged ? { ...track, clips: newClips } : track;
|
|
6972
|
-
});
|
|
6973
|
-
let maxEndBeat = (arrangement.totalBars || 4) * 4;
|
|
6974
|
-
let lengthExtended = false;
|
|
6975
|
-
newTracks.forEach((t) => {
|
|
6976
|
-
t.clips.forEach((c) => {
|
|
6977
|
-
const end = (c.startBeat || 0) + (c.durationBeats || 0);
|
|
6978
|
-
if (end > maxEndBeat) {
|
|
6979
|
-
maxEndBeat = end;
|
|
6980
|
-
lengthExtended = true;
|
|
6981
|
-
}
|
|
6982
|
-
});
|
|
6983
|
-
});
|
|
6984
|
-
if (lengthExtended) {
|
|
6985
|
-
const newTotalBars = Math.ceil(maxEndBeat / 4);
|
|
6986
|
-
return {
|
|
6987
|
-
updated: true,
|
|
6988
|
-
arrangement: {
|
|
6989
|
-
...arrangement,
|
|
6990
|
-
totalBars: newTotalBars,
|
|
6991
|
-
loopEndBeat: Math.max(arrangement.loopEndBeat || 0, newTotalBars * 4),
|
|
6992
|
-
tracks: newTracks
|
|
6993
|
-
}
|
|
6994
|
-
};
|
|
6995
|
-
}
|
|
6996
|
-
return {
|
|
6997
|
-
updated: changed,
|
|
6998
|
-
arrangement: changed ? { ...arrangement, tracks: newTracks } : arrangement
|
|
6999
|
-
};
|
|
7000
|
-
}
|
|
7001
|
-
function ingestContainerIntoArrangement(arrangement, container, targetTrackId, targetBeat) {
|
|
7002
|
-
const cType = container.containerType || "midi";
|
|
7003
|
-
const isAudio = cType === "audio";
|
|
7004
|
-
const isCurve = cType === "curve";
|
|
7005
|
-
const containerSig = isAudio ? container.audioFormat === "mono" ? "audio_mono" : "audio_stereo" : isCurve ? "curve" : "midi";
|
|
7006
|
-
let tracks = [...arrangement.tracks];
|
|
7007
|
-
let targetTrack = targetTrackId ? tracks.find((t) => t.id === targetTrackId) : null;
|
|
7008
|
-
if (targetTrack && !isSignalCompatibleWithTrack(containerSig, targetTrack.signalType)) {
|
|
7009
|
-
targetTrack = null;
|
|
7010
|
-
}
|
|
7011
|
-
if (!targetTrack) {
|
|
7012
|
-
targetTrack = tracks.find((t) => t.signalType === containerSig) || null;
|
|
7013
|
-
}
|
|
7014
|
-
if (!targetTrack) {
|
|
7015
|
-
targetTrack = tracks.find((t) => isSignalCompatibleWithTrack(containerSig, t.signalType)) || null;
|
|
7016
|
-
}
|
|
7017
|
-
if (!targetTrack) {
|
|
7018
|
-
const sameTypeCount = tracks.filter((t) => t.signalType === containerSig).length;
|
|
7019
|
-
const newTrack = createTrackForSignalType(
|
|
7020
|
-
containerSig,
|
|
7021
|
-
sameTypeCount + 1
|
|
7022
|
-
);
|
|
7023
|
-
tracks.push(newTrack);
|
|
7024
|
-
targetTrack = newTrack;
|
|
7025
|
-
}
|
|
7026
|
-
let startBeat = targetBeat ?? 0;
|
|
7027
|
-
if (targetBeat == null && targetTrack.clips.length > 0) {
|
|
7028
|
-
const lastClip = targetTrack.clips[targetTrack.clips.length - 1];
|
|
7029
|
-
startBeat = Math.ceil(lastClip.startBeat + lastClip.durationBeats);
|
|
7030
|
-
}
|
|
7031
|
-
const existingIndex = targetTrack.clips.findIndex((c) => c.containerId === container.id);
|
|
7032
|
-
const newClip = createClipFromContainer(
|
|
7033
|
-
container,
|
|
7034
|
-
existingIndex >= 0 ? targetTrack.clips[existingIndex].startBeat : startBeat
|
|
7035
|
-
);
|
|
7036
|
-
let updatedClips;
|
|
7037
|
-
if (existingIndex >= 0) {
|
|
7038
|
-
updatedClips = [...targetTrack.clips];
|
|
7039
|
-
updatedClips[existingIndex] = {
|
|
7040
|
-
...newClip,
|
|
7041
|
-
startBeat: targetTrack.clips[existingIndex].startBeat,
|
|
7042
|
-
durationBeats: targetTrack.clips[existingIndex].durationBeats || newClip.durationBeats
|
|
7043
|
-
};
|
|
7044
|
-
} else {
|
|
7045
|
-
updatedClips = [...targetTrack.clips, newClip];
|
|
7046
|
-
}
|
|
7047
|
-
const updatedTracks = tracks.map((t) => t.id === targetTrack.id ? { ...t, clips: updatedClips } : t);
|
|
7048
|
-
const clipEndBeat = (existingIndex >= 0 ? targetTrack.clips[existingIndex].startBeat : startBeat) + newClip.durationBeats;
|
|
7049
|
-
const currentMaxBeat = (arrangement.totalBars || 4) * 4;
|
|
7050
|
-
let totalBars = arrangement.totalBars || 4;
|
|
7051
|
-
let loopEndBeat = arrangement.loopEndBeat ?? totalBars * 4;
|
|
7052
|
-
if (clipEndBeat > currentMaxBeat) {
|
|
7053
|
-
totalBars = Math.ceil(clipEndBeat / 4);
|
|
7054
|
-
loopEndBeat = totalBars * 4;
|
|
7055
|
-
}
|
|
7056
|
-
return {
|
|
7057
|
-
...arrangement,
|
|
7058
|
-
totalBars,
|
|
7059
|
-
loopEndBeat,
|
|
7060
|
-
tracks: updatedTracks
|
|
7061
|
-
};
|
|
7062
|
-
}
|
|
7063
|
-
function isSignalCompatibleWithTrack(sourceSig, trackSig) {
|
|
7064
|
-
if (sourceSig === trackSig) return true;
|
|
7065
|
-
if (sourceSig === "audio_mono" || trackSig === "audio_mono") return false;
|
|
7066
|
-
if (sourceSig === "audio_stereo" || trackSig === "audio_stereo") return false;
|
|
7067
|
-
if (sourceSig.includes("audio") && trackSig.includes("audio")) return true;
|
|
7068
|
-
if (sourceSig.includes("midi") && trackSig.includes("midi")) return true;
|
|
7069
|
-
if (sourceSig === "trigger" && trackSig === "trigger") return true;
|
|
7070
|
-
if (sourceSig.includes("curve") && trackSig.includes("curve")) return true;
|
|
7071
|
-
return false;
|
|
7072
|
-
}
|
|
7073
|
-
|
|
7074
9172
|
// src/engine/predictive/solidifyExecution.ts
|
|
7075
9173
|
var configuredSolidifySynthEngine = null;
|
|
7076
9174
|
function configureSolidifyExecution(synthEngineInstance) {
|
|
@@ -7169,8 +9267,35 @@ function materializePredictiveGhostBatch(ghosts, existingNodes, bpm, existingCon
|
|
|
7169
9267
|
}
|
|
7170
9268
|
|
|
7171
9269
|
export {
|
|
7172
|
-
|
|
9270
|
+
screenToCanvas,
|
|
9271
|
+
canvasToScreen,
|
|
9272
|
+
zoomAtPoint,
|
|
9273
|
+
clampZoom,
|
|
9274
|
+
fitToView,
|
|
9275
|
+
isNodeInCenterDeadZone,
|
|
9276
|
+
getCenterPanForNode,
|
|
9277
|
+
getNodesInSelection,
|
|
7173
9278
|
createDefaultMapIoConfig,
|
|
9279
|
+
getDivisionBeatLength,
|
|
9280
|
+
calculateNextQuantizeBeat,
|
|
9281
|
+
formatBeatToBarBeat,
|
|
9282
|
+
formatQuantizeDivisionLabel,
|
|
9283
|
+
linearToDb,
|
|
9284
|
+
dbToLinear,
|
|
9285
|
+
midiToFrequency,
|
|
9286
|
+
AudioConcepts,
|
|
9287
|
+
BufferConcepts,
|
|
9288
|
+
GraphConcepts,
|
|
9289
|
+
findSourceNode,
|
|
9290
|
+
findTargetNode,
|
|
9291
|
+
findTargetContainer,
|
|
9292
|
+
configureActivePaletteResolver,
|
|
9293
|
+
getActivePalette,
|
|
9294
|
+
resolveTooltipDirection,
|
|
9295
|
+
getTooltipPlacementClasses,
|
|
9296
|
+
parseBufferedNumber,
|
|
9297
|
+
UIConcepts,
|
|
9298
|
+
GraphEntityParent,
|
|
7174
9299
|
parseCodeNodeIO,
|
|
7175
9300
|
transpileCodeNodeScript,
|
|
7176
9301
|
executeCodeNodeScript,
|
|
@@ -7276,12 +9401,6 @@ export {
|
|
|
7276
9401
|
initializeMagneticRules,
|
|
7277
9402
|
mapSpaceNodeToBridgeNode,
|
|
7278
9403
|
MagneticGraphManager,
|
|
7279
|
-
polarToCartesian,
|
|
7280
|
-
describeSvgArc,
|
|
7281
|
-
GraphConcepts,
|
|
7282
|
-
findSourceNode,
|
|
7283
|
-
findTargetNode,
|
|
7284
|
-
findTargetContainer,
|
|
7285
9404
|
createContainerNode,
|
|
7286
9405
|
createRecorderNode,
|
|
7287
9406
|
createPlayerNode,
|
|
@@ -7321,18 +9440,83 @@ export {
|
|
|
7321
9440
|
unregisterNodeArchetype,
|
|
7322
9441
|
getAllNodeArchetypes,
|
|
7323
9442
|
initializeCoreArchetypes,
|
|
7324
|
-
|
|
7325
|
-
|
|
9443
|
+
getAllProjectSockets,
|
|
9444
|
+
toggleNodeSocketExposure,
|
|
9445
|
+
convertPhysicalInputToStreamHandle,
|
|
9446
|
+
convertPhysicalOutputToStreamHandle,
|
|
9447
|
+
deriveSubgraphHandlesFromGraph,
|
|
9448
|
+
instantiateSubgraphNode,
|
|
7326
9449
|
SPAWN_ELEVATIONS,
|
|
7327
9450
|
getNodeSpawnElevation,
|
|
7328
9451
|
projectNodeToGroundSurface,
|
|
7329
9452
|
projectWireEndpointsToSurface,
|
|
7330
9453
|
executeSceneGraphSpawningSequence,
|
|
7331
|
-
|
|
7332
|
-
|
|
9454
|
+
GraphDataService,
|
|
9455
|
+
validateGraphImport,
|
|
9456
|
+
getTopologicalDependencyOrder,
|
|
9457
|
+
GRAPH_TYPE_DEFINITIONS,
|
|
9458
|
+
ALL_GRAPH_TYPES,
|
|
9459
|
+
getGraphTypeDefinition,
|
|
9460
|
+
configureControlDispatcher,
|
|
9461
|
+
controlDispatcher,
|
|
9462
|
+
midiToNoteName,
|
|
9463
|
+
midiToFreq,
|
|
9464
|
+
noteNameToMidi,
|
|
9465
|
+
PRESET_SCALES,
|
|
9466
|
+
COLOR_PALETTES,
|
|
9467
|
+
calculateAudioMeterLevel,
|
|
9468
|
+
CanonicalAudioInputEndpoint,
|
|
9469
|
+
CanonicalMidiInputEndpoint,
|
|
9470
|
+
configureCanonicalMidiBridge,
|
|
9471
|
+
getCanonicalMidiBridge,
|
|
9472
|
+
TopLevelIoRegistry,
|
|
9473
|
+
topLevelIoRegistry,
|
|
9474
|
+
AudioBusDriver,
|
|
9475
|
+
STORAGE_KEY,
|
|
9476
|
+
loadStoredConfig,
|
|
9477
|
+
saveStoredConfig,
|
|
9478
|
+
enumerateSystemAudioDevices,
|
|
9479
|
+
acquireAudioInputStream,
|
|
9480
|
+
stopAudioMediaStream,
|
|
9481
|
+
resolveSocketDetails,
|
|
9482
|
+
getCompatibleNodesForSocket,
|
|
7333
9483
|
syncConnectedContainersToArrangement,
|
|
7334
9484
|
ingestContainerIntoArrangement,
|
|
7335
9485
|
isSignalCompatibleWithTrack,
|
|
9486
|
+
createNodeFromSpawnType,
|
|
9487
|
+
getComponentSocketConstraint,
|
|
9488
|
+
validateComponentSocketConnection,
|
|
9489
|
+
getActiveEffectsForWire,
|
|
9490
|
+
getActiveEffectsForNodeWires,
|
|
9491
|
+
getActiveEffectsForNode,
|
|
9492
|
+
getTriggerStepDuration,
|
|
9493
|
+
shouldTriggerFireAtClock,
|
|
9494
|
+
getDefaultActiveSteps,
|
|
9495
|
+
getDefaultActiveFractions,
|
|
9496
|
+
polarToCartesian,
|
|
9497
|
+
describeSvgArc,
|
|
9498
|
+
encodeFloat32ToWavBase64,
|
|
9499
|
+
generateWavBase64FromWaveform,
|
|
9500
|
+
GM_DRUM_NOTES,
|
|
9501
|
+
getDefaultPadMidiNote,
|
|
9502
|
+
extractSamplesFromConnectedContainers,
|
|
9503
|
+
getCustomMidiNames,
|
|
9504
|
+
saveCustomMidiNames,
|
|
9505
|
+
getCustomMidiName,
|
|
9506
|
+
setCustomMidiName,
|
|
9507
|
+
getVirtualMidiDevices,
|
|
9508
|
+
saveVirtualMidiDevices,
|
|
9509
|
+
createVirtualMidiDevice,
|
|
9510
|
+
deleteVirtualMidiDevice,
|
|
9511
|
+
getNamedMidiProfiles,
|
|
9512
|
+
saveNamedMidiProfiles,
|
|
9513
|
+
addNamedMidiProfile,
|
|
9514
|
+
updateNamedMidiProfile,
|
|
9515
|
+
deleteNamedMidiProfile,
|
|
9516
|
+
getResolvedMidiDevices,
|
|
9517
|
+
configureNodePerformanceTracker,
|
|
9518
|
+
calculateNodePerformance,
|
|
9519
|
+
computePredictiveGraph,
|
|
7336
9520
|
configureSolidifyExecution,
|
|
7337
9521
|
getSolidifySynthEngine,
|
|
7338
9522
|
materializePredictiveGhostBatch
|