@wildshard/sdk 0.0.1 → 0.2.3
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/GUIDE.md +790 -0
- package/README.md +13 -5
- package/bin/wildshard.mjs +38 -0
- package/lint/declaration-config.d.mts +2 -0
- package/lint/declaration-config.mjs +19 -0
- package/lint/engine-plugin.d.mts +2 -0
- package/lint/engine-plugin.mjs +40 -0
- package/lint/host-callbacks.d.mts +6 -0
- package/lint/host-callbacks.mjs +123 -0
- package/lint/host-files.d.mts +1 -0
- package/lint/host-files.mjs +7 -0
- package/lint/layer-exports.d.mts +2 -0
- package/lint/layer-exports.mjs +21 -0
- package/lint/legacy-line-basis.json +995 -0
- package/lint/nine-tiling-baseline.json +35 -0
- package/lint/ratchet.json +11 -0
- package/lint/runtime-files.d.mts +12 -0
- package/lint/runtime-files.json +16 -0
- package/lint/runtime-files.mjs +69 -0
- package/lint/runtime-performance.d.mts +6 -0
- package/lint/runtime-performance.mjs +184 -0
- package/lint/sdk-plugin.d.mts +4 -0
- package/lint/sdk-plugin.mjs +134 -0
- package/lint/shardfile-boundaries.d.mts +10 -0
- package/lint/shardfile-boundaries.mjs +122 -0
- package/lint/tile-bake-debt.json +556 -0
- package/package.json +365 -3
- package/scripts/agent-parity.mjs +1524 -0
- package/scripts/agent-sync.mjs +518 -0
- package/scripts/apfs-clone.mjs +67 -0
- package/scripts/assert-store-layout.mjs +23 -0
- package/scripts/astc6-phone-cap.d.mts +3 -0
- package/scripts/astc6-phone-cap.mjs +137 -0
- package/scripts/audit-assets.d.mts +10 -0
- package/scripts/audit-assets.mjs +151 -0
- package/scripts/bake/coatFiles.d.mts +6 -0
- package/scripts/bake/coatFiles.mjs +37 -0
- package/scripts/bake/environment.d.mts +2 -0
- package/scripts/bake/environment.mjs +58 -0
- package/scripts/bake/far-proxies.mjs +45 -0
- package/scripts/bake/keyed-sky.d.mts +4 -0
- package/scripts/bake/keyed-sky.mjs +34 -0
- package/scripts/bake/movers.mjs +56 -0
- package/scripts/bake/nativeWorld.d.mts +6 -0
- package/scripts/bake/nativeWorld.mjs +43 -0
- package/scripts/bake/navmeshGround.ts +22 -0
- package/scripts/bake/near-placeholder.mjs +331 -0
- package/scripts/bake/placeholderShards.mjs +41 -0
- package/scripts/bake/skins.mjs +15 -0
- package/scripts/bake/template-skins.mjs +33 -0
- package/scripts/bake/viewmodelBytes.ts +26 -0
- package/scripts/bake/viewmodelPage.ts +11 -0
- package/scripts/bake/worldHost.d.mts +35 -0
- package/scripts/bake/worldHost.mjs +110 -0
- package/scripts/bake-astc6.cache.json +80 -0
- package/scripts/bake-astc6.far-reach.cache.json +23 -0
- package/scripts/bake-astc6.list.json +111 -0
- package/scripts/bake-astc6.mjs +279 -0
- package/scripts/bake-astc6.nalati-grasslands.cache.json +42 -0
- package/scripts/bake-catalogue.mjs +44 -0
- package/scripts/bake-check.mjs +54 -0
- package/scripts/bake-chunk.mjs +124 -0
- package/scripts/bake-cloud-field.mjs +24 -0
- package/scripts/bake-coats.mjs +110 -0
- package/scripts/bake-data-maps.d.mts +24 -0
- package/scripts/bake-data-maps.mjs +72 -0
- package/scripts/bake-entry-programs.mjs +117 -0
- package/scripts/bake-geometry.mjs +106 -0
- package/scripts/bake-hybrid-tiles.mjs +28 -0
- package/scripts/bake-ktx2.cache.json +276 -0
- package/scripts/bake-ktx2.list.json +365 -0
- package/scripts/bake-ktx2.mjs +477 -0
- package/scripts/bake-map-glb.mjs +127 -0
- package/scripts/bake-map-rest.d.mts +7 -0
- package/scripts/bake-map-rest.mjs +50 -0
- package/scripts/bake-maps.mjs +200 -0
- package/scripts/bake-navmesh.mjs +259 -0
- package/scripts/bake-packs.mjs +129 -0
- package/scripts/bake-pickups.mjs +102 -0
- package/scripts/bake-query-terrain.mjs +64 -0
- package/scripts/bake-recurve-pool.mjs +16 -0
- package/scripts/bake-section-schemas.d.mts +3 -0
- package/scripts/bake-template-shardfile.mjs +32 -0
- package/scripts/bake-textures.mjs +80 -0
- package/scripts/bake-viewmodel-sets.json +45 -0
- package/scripts/bake-viewmodel-sets.mjs +137 -0
- package/scripts/bake-voxel-ao.mjs +119 -0
- package/scripts/bake-water-ripples.mjs +25 -0
- package/scripts/blender/README.md +129 -0
- package/scripts/blender/build.sh +166 -0
- package/scripts/blender/lib/export-scene.mjs +129 -0
- package/scripts/blender/lib/glb-digest.mjs +188 -0
- package/scripts/blender/lib/glb.py +68 -0
- package/scripts/blender/lib/save_blend.py +17 -0
- package/scripts/blender/lib/world_fixture.py +55 -0
- package/scripts/blender/targets.json +591 -0
- package/scripts/build-sdk.mjs +95 -0
- package/scripts/build-shardfiles.d.mts +7 -0
- package/scripts/build-shardfiles.mjs +206 -0
- package/scripts/capture-hero.mjs +137 -0
- package/scripts/check-lift-review.mjs +23 -0
- package/scripts/chromium-keychain-check.mjs +139 -0
- package/scripts/chromium-keychain.d.mts +1 -0
- package/scripts/chromium-keychain.mjs +5 -0
- package/scripts/compile-script.d.mts +3 -0
- package/scripts/compile-script.mjs +8 -0
- package/scripts/creature-color.mjs +255 -0
- package/scripts/decide/calibrate.py +127 -0
- package/scripts/decide/calibration/2026-10-03/labels-s1.tsv +281 -0
- package/scripts/decide/calibration/2026-10-03/labels-s2.tsv +97 -0
- package/scripts/decide/calibration/2026-10-03/labels-s3.tsv +48 -0
- package/scripts/decide/calibration/2026-10-03/labels-s3b.tsv +26 -0
- package/scripts/decide/calibration/2026-10-03/res-capture-status-v1.jsonl +376 -0
- package/scripts/decide/calibration/2026-10-03/res-text-garbled-strings.jsonl +48 -0
- package/scripts/decide/calibration/2026-10-03/res-text-garbled-v1.jsonl +73 -0
- package/scripts/decide/decide.py +262 -0
- package/scripts/decide/decide.sh +50 -0
- package/scripts/decide/layer-purity-pilot.mjs +41 -0
- package/scripts/decide/sets/capture-status.json +46 -0
- package/scripts/decide/sets/layer-purity.json +28 -0
- package/scripts/decide/sets/text-garbled.json +17 -0
- package/scripts/decide/test_decide.py +37 -0
- package/scripts/docs.mjs +15 -0
- package/scripts/entry-reads/crawl.ts +152 -0
- package/scripts/entry-reads/tsconfig.json +25 -0
- package/scripts/gen-format-schema.d.mts +2 -0
- package/scripts/gen-format-schema.mjs +21 -0
- package/scripts/gen-host-catalogue.d.mts +14 -0
- package/scripts/gen-host-catalogue.mjs +108 -0
- package/scripts/gen-shard-layout-doc.d.mts +4 -0
- package/scripts/gen-shard-layout-doc.mjs +55 -0
- package/scripts/gen-shards.d.mts +17 -0
- package/scripts/gen-shards.mjs +311 -0
- package/scripts/goldens/capture-inputs.d.mts +4 -0
- package/scripts/goldens/capture-inputs.mjs +34 -0
- package/scripts/goldens/colour_shift.py +27 -0
- package/scripts/goldens/native-residency.d.mts +10 -0
- package/scripts/goldens/native-residency.mjs +104 -0
- package/scripts/goldens/plot-inputs.d.mts +12 -0
- package/scripts/goldens/plot-inputs.mjs +46 -0
- package/scripts/gpu-texmem.mjs +98 -0
- package/scripts/horizon-matte/config.py +24 -0
- package/scripts/horizon-matte/encode.py +91 -0
- package/scripts/horizon-matte/key.py +141 -0
- package/scripts/horizon-matte/mkjobs.py +33 -0
- package/scripts/horizon-matte/mkjobs_day2.py +11 -0
- package/scripts/horizon-matte/overlap.py +80 -0
- package/scripts/horizon-matte/run_codex.py +57 -0
- package/scripts/horizon-matte/stitch.py +133 -0
- package/scripts/img2mesh/CC0.md +105 -0
- package/scripts/img2mesh/README.md +209 -0
- package/scripts/img2mesh/ab_board.py +102 -0
- package/scripts/img2mesh/birds/birds.json +255 -0
- package/scripts/img2mesh/birds/birds_atlas.py +150 -0
- package/scripts/img2mesh/birds/birds_fix_preview.mjs +103 -0
- package/scripts/img2mesh/birds/birds_fix_render.py +75 -0
- package/scripts/img2mesh/birds/birds_pack.py +110 -0
- package/scripts/img2mesh/birds/birds_phone_b.py +112 -0
- package/scripts/img2mesh/birds/birds_post.py +550 -0
- package/scripts/img2mesh/birds/birds_render.py +125 -0
- package/scripts/img2mesh/birds/birds_sheet.py +33 -0
- package/scripts/img2mesh/birds/birds_view.py +60 -0
- package/scripts/img2mesh/board.py +100 -0
- package/scripts/img2mesh/build_cc0.sh +52 -0
- package/scripts/img2mesh/build_driftwood.sh +12 -0
- package/scripts/img2mesh/build_faces.sh +53 -0
- package/scripts/img2mesh/build_props.py +81 -0
- package/scripts/img2mesh/cc0_export.py +186 -0
- package/scripts/img2mesh/driftwood_post.py +571 -0
- package/scripts/img2mesh/e304_faces.sh +67 -0
- package/scripts/img2mesh/face_remaster.py +911 -0
- package/scripts/img2mesh/face_views.py +95 -0
- package/scripts/img2mesh/faces-e304.json +9 -0
- package/scripts/img2mesh/faces.json +30 -0
- package/scripts/img2mesh/head_cut.py +100 -0
- package/scripts/img2mesh/hi3d_paint.py +94 -0
- package/scripts/img2mesh/hi3d_refine.py +161 -0
- package/scripts/img2mesh/hunyuan_cpu_rasterizer.sh +42 -0
- package/scripts/img2mesh/pine_hollow_phone.sh +13 -0
- package/scripts/img2mesh/props/coral-arch.json +32 -0
- package/scripts/img2mesh/props/ember-furnace.json +30 -0
- package/scripts/img2mesh/props/night-market-gate.json +10 -0
- package/scripts/img2mesh/render_still.py +86 -0
- package/scripts/img2mesh/rig_strip.mjs +46 -0
- package/scripts/img2mesh/rig_transfer.mjs +104 -0
- package/scripts/img2mesh/split_sheet.py +48 -0
- package/scripts/img2mesh/trellis_batch.py +110 -0
- package/scripts/img2mesh/versus_board.py +114 -0
- package/scripts/import-bundle.d.mts +2 -0
- package/scripts/import-bundle.mjs +20 -0
- package/scripts/ktx2-ab-board.py +133 -0
- package/scripts/ktx2-ab.mjs +111 -0
- package/scripts/ktx2-settings.mjs +18 -0
- package/scripts/land.d.mts +14 -0
- package/scripts/land.mjs +809 -0
- package/scripts/lint-dispatch.mjs +14 -0
- package/scripts/map-bake-frames.d.mts +4 -0
- package/scripts/map-bake-frames.mjs +23 -0
- package/scripts/map-geometry.d.mts +9 -0
- package/scripts/map-geometry.mjs +29 -0
- package/scripts/map-world.mjs +162 -0
- package/scripts/mockup-local.sh +46 -0
- package/scripts/music/export-midi.mjs +68 -0
- package/scripts/music/gen/analyze.py +308 -0
- package/scripts/music/gen/audio_jobs.py +46 -0
- package/scripts/music/gen/briefs.json +51 -0
- package/scripts/music/gen/build_page.py +334 -0
- package/scripts/music/gen/folk.json +3187 -0
- package/scripts/music/gen/gen_ace_step.py +156 -0
- package/scripts/music/gen/gen_heartmula.py +187 -0
- package/scripts/music/gen/gen_minimax.py +143 -0
- package/scripts/music/gen/gen_sao.py +122 -0
- package/scripts/music/gen/gen_sao_small.py +104 -0
- package/scripts/music/gen/gen_sfx.py +98 -0
- package/scripts/music/gen/gen_sfx_ezaudio.py +112 -0
- package/scripts/music/gen/gen_sfx_moss.py +112 -0
- package/scripts/music/gen/models.json +61 -0
- package/scripts/music/gen/nalati-jobs.json +104 -0
- package/scripts/music/gen/nalati-score-build.json +119 -0
- package/scripts/music/gen/nalati-score.json +3448 -0
- package/scripts/music/gen/ob7-fit-decisions.json +38 -0
- package/scripts/music/gen/ob7-score-jobs.json +152 -0
- package/scripts/music/gen/ob7-sfx-jobs.json +897 -0
- package/scripts/music/gen/ob7_build.py +469 -0
- package/scripts/music/gen/ob7_generate.py +67 -0
- package/scripts/music/gen/ob7_run.sh +42 -0
- package/scripts/music/gen/orchestral.json +3187 -0
- package/scripts/music/gen/own_score.py +486 -0
- package/scripts/music/gen/ph-jobs.json +27 -0
- package/scripts/music/gen/ph_page.py +222 -0
- package/scripts/music/gen/piano.json +3175 -0
- package/scripts/music/gen/rank_v3.py +248 -0
- package/scripts/music/gen/sfx-best.json +2486 -0
- package/scripts/music/gen/sfx-ezaudio.json +4082 -0
- package/scripts/music/gen/sfx-jobs.json +57 -0
- package/scripts/music/gen/sfx-minimax-jobs.json +16 -0
- package/scripts/music/gen/sfx-minimax.json +289 -0
- package/scripts/music/gen/sfx-moss.json +4082 -0
- package/scripts/music/gen/sfx-nalati-b3-jobs.json +17 -0
- package/scripts/music/gen/sfx-nalati-jobs.json +338 -0
- package/scripts/music/gen/sfx-nalati.json +11202 -0
- package/scripts/music/gen/sfx-nd-jobs.json +57 -0
- package/scripts/music/gen/sfx-nd-moss.json +2097 -0
- package/scripts/music/gen/sfx-nd-sa3-medium.json +2097 -0
- package/scripts/music/gen/sfx-nd-summary.json +38 -0
- package/scripts/music/gen/sfx-peaks.json +7 -0
- package/scripts/music/gen/sfx-ph-jobs.json +169 -0
- package/scripts/music/gen/sfx-ph-moss.json +6564 -0
- package/scripts/music/gen/sfx-ph-sa3-medium.json +7239 -0
- package/scripts/music/gen/sfx-ph-summary.json +63 -0
- package/scripts/music/gen/sfx-sa3-medium.json +4082 -0
- package/scripts/music/gen/sfx-sa3.json +4082 -0
- package/scripts/music/gen/sfx-summary.json +107 -0
- package/scripts/music/gen/sfx_build.py +332 -0
- package/scripts/music/gen/sfx_merge.py +255 -0
- package/scripts/music/gen/sfx_minimax.py +61 -0
- package/scripts/music/gen/sfx_nalati.py +331 -0
- package/scripts/music/gen/sfx_sprite.py +424 -0
- package/scripts/music/gen/stems.py +539 -0
- package/scripts/music/gen/test_loop_meter.py +29 -0
- package/scripts/music/gen/test_ob7_provenance.py +77 -0
- package/scripts/music/gen/v3-folk-build.json +148 -0
- package/scripts/music/gen/v3-folk.json +1818 -0
- package/scripts/music/gen/v3-jobs.json +145 -0
- package/scripts/music/gen/v3-orchestral-build.json +148 -0
- package/scripts/music/gen/v3-orchestral.json +1813 -0
- package/scripts/music/gen/v3-ph-folk-build.json +94 -0
- package/scripts/music/gen/v3-ph-folk.json +1806 -0
- package/scripts/music/gen/v3-ph-orchestral-build.json +94 -0
- package/scripts/music/gen/v3-ph-orchestral.json +1824 -0
- package/scripts/music/gen/v3-ph-piano-build.json +94 -0
- package/scripts/music/gen/v3-ph-piano.json +1818 -0
- package/scripts/music/gen/v3-piano-build.json +148 -0
- package/scripts/music/gen/v3-piano.json +1813 -0
- package/scripts/music/wildshard-theme.mid +0 -0
- package/scripts/music/wildshard-trailer30.mid +0 -0
- package/scripts/named-blob-output.d.mts +8 -0
- package/scripts/named-blob-output.mjs +48 -0
- package/scripts/pack-all.mjs +15 -0
- package/scripts/pid-lock.d.mts +1 -0
- package/scripts/pid-lock.mjs +63 -0
- package/scripts/practice/bake_dummy.py +53 -0
- package/scripts/practice/build_dummies.sh +43 -0
- package/scripts/practice/dummy_parts.py +568 -0
- package/scripts/practice/dummy_rig_gate.py +139 -0
- package/scripts/practice/gate_sheet.py +36 -0
- package/scripts/practice/generate_dummy_unimate.py +132 -0
- package/scripts/practice/pack_dummy.mjs +59 -0
- package/scripts/practice/repair_dummy_weights.mjs +68 -0
- package/scripts/practice/rig_dummy.py +828 -0
- package/scripts/practice/verify_unimate_skin.mjs +356 -0
- package/scripts/preparation-seed.mjs +15 -0
- package/scripts/prepare-basis-tool.mjs +6 -0
- package/scripts/prepare-product.d.mts +14 -0
- package/scripts/prepare-product.mjs +101 -0
- package/scripts/product-build-tools.d.mts +3 -0
- package/scripts/product-build-tools.json +3 -0
- package/scripts/product-build-tools.mjs +31 -0
- package/scripts/publish-public.mjs +7 -0
- package/scripts/push-tables.d.mts +1 -0
- package/scripts/push-tables.mjs +28 -0
- package/scripts/record-shard-mounts.mjs +133 -0
- package/scripts/sdk-externals.d.mts +2 -0
- package/scripts/sdk-externals.mjs +2 -0
- package/scripts/section-inventory.ts +209 -0
- package/scripts/select-candidate.mjs +15 -0
- package/scripts/shard-build-pool.d.mts +4 -0
- package/scripts/shard-build-pool.mjs +53 -0
- package/scripts/shard-line-baseline.json +17 -0
- package/scripts/shard-milestones.d.mts +15 -0
- package/scripts/shard-milestones.mjs +105 -0
- package/scripts/shard-output-report.d.mts +9 -0
- package/scripts/shard-output-report.mjs +85 -0
- package/scripts/shard-platform-cli.mjs +93 -0
- package/scripts/shard-progress.mjs +212 -0
- package/scripts/shard-timelapse.py +102 -0
- package/scripts/shardfile-cold-boot.mjs +79 -0
- package/scripts/shardfile-vite.d.mts +4 -0
- package/scripts/shardfile-vite.mjs +20 -0
- package/scripts/simplify-models.mjs +24 -0
- package/scripts/site-facts.mjs +88 -0
- package/scripts/test-template-gate.mjs +44 -0
- package/scripts/test_golden_compare.py +68 -0
- package/scripts/tex-tiers.cache.json +181 -0
- package/scripts/tex-tiers.mjs +240 -0
- package/scripts/texmem-probe.mjs +184 -0
- package/scripts/unused-assets.mjs +173 -0
- package/scripts/vite-tmp.d.mts +23 -0
- package/scripts/vite-tmp.mjs +157 -0
- package/scripts/wave-line-baselines.json +32 -0
- package/scripts/wildshard.d.mts +4 -0
- package/scripts/wildshard.mjs +105 -0
- package/scripts/witness-checkpoints.d.mts +10 -0
- package/scripts/witness-checkpoints.mjs +84 -0
- package/scripts/witness-generation.d.mts +10 -0
- package/scripts/witness-generation.mjs +45 -0
- package/scripts/witness-manifests.d.mts +8 -0
- package/scripts/witness-manifests.mjs +157 -0
- package/scripts/worktree-ignore.d.mts +4 -0
- package/scripts/worktree-ignore.mjs +36 -0
- package/scripts/worktree-reap.mjs +214 -0
- package/scripts/worktree.mjs +396 -0
- package/scripts/worldclaw/capture-front.sh +28 -0
- package/scripts/worldclaw/design-template.md +62 -0
- package/scripts/worldclaw/spec-map.py +92 -0
- package/scripts/worldclaw/spec.ts +96 -0
- package/skills/wildshard/SKILL.md +50 -0
- package/skills/wildshard-goldens/SKILL.md +54 -0
- package/skills/wildshard-mockup-to-model/SKILL.md +56 -0
- package/skills/wildshard-upgrade/SKILL.md +46 -0
- package/src/.oxfmtrc.json +50 -0
- package/src/.oxlintrc.json +173 -0
- package/src/cli/account/account.ts +199 -0
- package/src/cli/account/command.ts +193 -0
- package/src/cli/account/key.ts +154 -0
- package/src/cli/args.ts +97 -0
- package/src/cli/audio/audio.ts +24 -0
- package/src/cli/bin.mjs +8 -0
- package/src/cli/delete/delete.ts +258 -0
- package/src/cli/help.ts +196 -0
- package/src/cli/hero/adopt.ts +103 -0
- package/src/cli/hero/hero.ts +112 -0
- package/src/cli/hero/stamp.ts +298 -0
- package/src/cli/main.ts +292 -0
- package/src/cli/report.ts +16 -0
- package/src/cli/shardfile/command.ts +50 -0
- package/src/cli/shardfile/shardfile.ts +192 -0
- package/src/cli/upload/api.ts +246 -0
- package/src/cli/upload/compress.ts +55 -0
- package/src/cli/upload/hero.ts +62 -0
- package/src/cli/upload/placement.ts +115 -0
- package/src/cli/upload/provenance.ts +192 -0
- package/src/cli/upload/signature.ts +30 -0
- package/src/cli/upload/upload.ts +269 -0
- package/src/cli/upload/validate.ts +74 -0
- package/src/cli/upload/wire.ts +147 -0
- package/src/cli/version.ts +63 -0
- package/src/commons/bake/portableMath.ts +187 -0
- package/src/commons/catalogue.ts +10 -0
- package/src/commons/courseProgram.ts +32 -0
- package/src/commons/practiceCourse.ts +16 -0
- package/src/commons/scripts/abi.as +14 -0
- package/src/commons/scripts/bridge.as +14 -0
- package/src/commons/scripts/course.as +63 -0
- package/src/scripts/ask-new.sh +29 -0
- package/src/scripts/asks.mjs +141 -0
- package/src/scripts/herdr-prompt.sh +34 -0
- package/src/scripts/herdr-question-open.sh +67 -0
- package/src/scripts/md-wrap.mjs +229 -0
- package/src/server/app.ts +19 -0
- package/src/server/serve.ts +49 -0
- package/src/sharddev/admission.ts +7 -0
- package/src/sharddev/arenaView.ts +15 -0
- package/src/sharddev/as/groupBankV2.ts +36 -0
- package/src/sharddev/as/groupStepV2.ts +13 -0
- package/src/sharddev/as/ws.ts +30 -0
- package/src/sharddev/as/wsV2.ts +180 -0
- package/src/sharddev/assemblyscriptCompiler.d.mts +5 -0
- package/src/sharddev/assemblyscriptCompiler.mjs +14 -0
- package/src/sharddev/assetHandle.ts +84 -0
- package/src/sharddev/assetOwner.ts +70 -0
- package/src/sharddev/assetScope.ts +30 -0
- package/src/sharddev/assets.ts +21 -0
- package/src/sharddev/audio.ts +9 -0
- package/src/sharddev/audioEncode.ts +211 -0
- package/src/sharddev/author.ts +3 -0
- package/src/sharddev/authorError.ts +28 -0
- package/src/sharddev/authorManifest.ts +39 -0
- package/src/sharddev/bake/annulus.ts +19 -0
- package/src/sharddev/bake/assemblyscriptMemo.ts +76 -0
- package/src/sharddev/bake/assemblyscriptMemoPort.ts +4 -0
- package/src/sharddev/bake/authoredWorld.ts +201 -0
- package/src/sharddev/bake/basisEncoder.ts +95 -0
- package/src/sharddev/bake/basisGlb.ts +85 -0
- package/src/sharddev/bake/basisTool.ts +74 -0
- package/src/sharddev/bake/basisToolInputs.ts +476 -0
- package/src/sharddev/bake/byteCodec.ts +33 -0
- package/src/sharddev/bake/canvasAtlas.ts +406 -0
- package/src/sharddev/bake/coarseCopy.ts +59 -0
- package/src/sharddev/bake/colliders.ts +87 -0
- package/src/sharddev/bake/compactGlb.ts +224 -0
- package/src/sharddev/bake/compileScript.ts +119 -0
- package/src/sharddev/bake/compileScriptV2.ts +75 -0
- package/src/sharddev/bake/contactRows.ts +84 -0
- package/src/sharddev/bake/creaturePlacement.ts +117 -0
- package/src/sharddev/bake/export.ts +67 -0
- package/src/sharddev/bake/facetedGeometry.ts +379 -0
- package/src/sharddev/bake/farImpostor.ts +120 -0
- package/src/sharddev/bake/forest.ts +100 -0
- package/src/sharddev/bake/format-hook.mjs +2 -0
- package/src/sharddev/bake/generatorGlb.ts +23 -0
- package/src/sharddev/bake/geometryBounds.ts +77 -0
- package/src/sharddev/bake/geometryError.ts +48 -0
- package/src/sharddev/bake/glb.ts +355 -0
- package/src/sharddev/bake/glbCompression.ts +143 -0
- package/src/sharddev/bake/gltfSource.ts +59 -0
- package/src/sharddev/bake/groundMap.ts +142 -0
- package/src/sharddev/bake/image.ts +20 -0
- package/src/sharddev/bake/isleMap.ts +64 -0
- package/src/sharddev/bake/json.mjs +84 -0
- package/src/sharddev/bake/keyedSky.ts +47 -0
- package/src/sharddev/bake/keyedSkyMemo.ts +39 -0
- package/src/sharddev/bake/kinds.ts +137 -0
- package/src/sharddev/bake/lightSources.ts +31 -0
- package/src/sharddev/bake/mapAssembly.ts +84 -0
- package/src/sharddev/bake/mapRaster.ts +173 -0
- package/src/sharddev/bake/mapRest.ts +57 -0
- package/src/sharddev/bake/mapScenes.ts +234 -0
- package/src/sharddev/bake/materialGraph.ts +32 -0
- package/src/sharddev/bake/meadow.ts +27 -0
- package/src/sharddev/bake/meshoptChoiceMemo.ts +34 -0
- package/src/sharddev/bake/nativeInteractionFacts.ts +5 -0
- package/src/sharddev/bake/nativeLattice.ts +178 -0
- package/src/sharddev/bake/nativeRaster.ts +106 -0
- package/src/sharddev/bake/nativeTerrainField.ts +11 -0
- package/src/sharddev/bake/navigation-json.mjs +38 -0
- package/src/sharddev/bake/navigation.ts +113 -0
- package/src/sharddev/bake/navigationAsset.ts +18 -0
- package/src/sharddev/bake/nearPlaceholder.ts +206 -0
- package/src/sharddev/bake/normalizeRig.ts +80 -0
- package/src/sharddev/bake/phoneAstc.ts +93 -0
- package/src/sharddev/bake/placeholders.ts +581 -0
- package/src/sharddev/bake/placement.ts +80 -0
- package/src/sharddev/bake/portableBytes.ts +18 -0
- package/src/sharddev/bake/portableBytesMemo.ts +50 -0
- package/src/sharddev/bake/practiceCourse.ts +49 -0
- package/src/sharddev/bake/primitives.ts +96 -0
- package/src/sharddev/bake/props.ts +443 -0
- package/src/sharddev/bake/questPlacement.ts +98 -0
- package/src/sharddev/bake/rawTexture.ts +26 -0
- package/src/sharddev/bake/riderArms.ts +97 -0
- package/src/sharddev/bake/rig.ts +95 -0
- package/src/sharddev/bake/riggedHullRecipes.ts +40 -0
- package/src/sharddev/bake/signPlacements.ts +25 -0
- package/src/sharddev/bake/simplifier.ts +52 -0
- package/src/sharddev/bake/skinned.ts +312 -0
- package/src/sharddev/bake/slabChunks.ts +149 -0
- package/src/sharddev/bake/slabs.ts +263 -0
- package/src/sharddev/bake/source-loader.mjs +55 -0
- package/src/sharddev/bake/sourceMetadata.ts +54 -0
- package/src/sharddev/bake/species.ts +368 -0
- package/src/sharddev/bake/specimenCatalogue.ts +47 -0
- package/src/sharddev/bake/splatGround.ts +141 -0
- package/src/sharddev/bake/staticMaterials.ts +171 -0
- package/src/sharddev/bake/terrain.ts +195 -0
- package/src/sharddev/bake/texture.ts +33 -0
- package/src/sharddev/bake/textureWasm.ts +81 -0
- package/src/sharddev/bake/tileEncoder.ts +11 -0
- package/src/sharddev/bake/tileGrid.ts +62 -0
- package/src/sharddev/bake/v2Finite.ts +160 -0
- package/src/sharddev/bake/v2Fuel.ts +71 -0
- package/src/sharddev/bake/wholePartition.ts +74 -0
- package/src/sharddev/bake/wholePieceJoin.ts +147 -0
- package/src/sharddev/bake/world.ts +173 -0
- package/src/sharddev/bake/worldCollision.ts +128 -0
- package/src/sharddev/bake/worldGeometry.ts +237 -0
- package/src/sharddev/bake/worldGlb.ts +123 -0
- package/src/sharddev/bake/worldImage.ts +12 -0
- package/src/sharddev/bake/worldLod.ts +128 -0
- package/src/sharddev/bake/worldRows.ts +102 -0
- package/src/sharddev/bake/worldTextureMemo.ts +63 -0
- package/src/sharddev/bake/zstdBytesMemo.ts +52 -0
- package/src/sharddev/bake.ts +193 -0
- package/src/sharddev/bakePublication.ts +31 -0
- package/src/sharddev/behaviourSource.ts +94 -0
- package/src/sharddev/bin/wildshard.mjs +7 -0
- package/src/sharddev/blobBytes.ts +65 -0
- package/src/sharddev/blobs.ts +138 -0
- package/src/sharddev/bootInventory.ts +129 -0
- package/src/sharddev/bossProfiles.ts +18 -0
- package/src/sharddev/buildBehaviour.ts +77 -0
- package/src/sharddev/buildCacheMetrics.ts +17 -0
- package/src/sharddev/buildDecisionScripts.ts +122 -0
- package/src/sharddev/check.ts +117 -0
- package/src/sharddev/checkProject.ts +126 -0
- package/src/sharddev/cli.ts +191 -0
- package/src/sharddev/clientChannels.ts +169 -0
- package/src/sharddev/clientScripts.ts +10 -0
- package/src/sharddev/commons.ts +77 -0
- package/src/sharddev/commonsCosts.ts +11 -0
- package/src/sharddev/compileMovers.ts +11 -0
- package/src/sharddev/configBoundary.ts +6 -0
- package/src/sharddev/cookInput.ts +40 -0
- package/src/sharddev/crowds.ts +6 -0
- package/src/sharddev/decisionBindingMap.ts +11 -0
- package/src/sharddev/decisionScriptBindings.ts +117 -0
- package/src/sharddev/decisionScripts.ts +28 -0
- package/src/sharddev/decisionSource.ts +51 -0
- package/src/sharddev/dev.ts +113 -0
- package/src/sharddev/director.ts +26 -0
- package/src/sharddev/directorAbi.ts +77 -0
- package/src/sharddev/discoveryDocument.ts +97 -0
- package/src/sharddev/draft.ts +11 -0
- package/src/sharddev/eliteEntryRows.ts +29 -0
- package/src/sharddev/entries.ts +76 -0
- package/src/sharddev/entryReads.ts +73 -0
- package/src/sharddev/executeBundle.ts +55 -0
- package/src/sharddev/finds.ts +5 -0
- package/src/sharddev/formatJsonSchema.ts +3 -0
- package/src/sharddev/generationCache.ts +257 -0
- package/src/sharddev/generationRecipe.ts +94 -0
- package/src/sharddev/handwritten.ts +110 -0
- package/src/sharddev/immutable.ts +14 -0
- package/src/sharddev/interactions.ts +38 -0
- package/src/sharddev/kit/bakedGeometry.ts +16 -0
- package/src/sharddev/kit/geometryPack.ts +110 -0
- package/src/sharddev/ledger.ts +13 -0
- package/src/sharddev/looks/tileField.ts +67 -0
- package/src/sharddev/materialGraphFiles.ts +57 -0
- package/src/sharddev/materials.ts +574 -0
- package/src/sharddev/measure.ts +18 -0
- package/src/sharddev/modes.ts +115 -0
- package/src/sharddev/moverPrograms.ts +213 -0
- package/src/sharddev/movers.ts +75 -0
- package/src/sharddev/nativePopulationRows.ts +46 -0
- package/src/sharddev/newProject.ts +247 -0
- package/src/sharddev/noise.ts +54 -0
- package/src/sharddev/outputProduct.ts +188 -0
- package/src/sharddev/outputRuntime.ts +66 -0
- package/src/sharddev/performancePolicy.ts +18 -0
- package/src/sharddev/phasedBoss.ts +34 -0
- package/src/sharddev/physics.ts +194 -0
- package/src/sharddev/platformSections.ts +42 -0
- package/src/sharddev/plumbing.ts +8 -0
- package/src/sharddev/productOutput.ts +128 -0
- package/src/sharddev/project.ts +337 -0
- package/src/sharddev/projectCompilerIdentity.ts +94 -0
- package/src/sharddev/projectDecisions.ts +66 -0
- package/src/sharddev/projectEntryProof.ts +32 -0
- package/src/sharddev/projectGeneration.ts +219 -0
- package/src/sharddev/projectInputFiles.ts +47 -0
- package/src/sharddev/projectManifest.ts +108 -0
- package/src/sharddev/projectMap.ts +35 -0
- package/src/sharddev/projectOutput.ts +242 -0
- package/src/sharddev/projectPolicy.ts +17 -0
- package/src/sharddev/projectSections.ts +27 -0
- package/src/sharddev/questGraph.ts +25 -0
- package/src/sharddev/quests.ts +65 -0
- package/src/sharddev/random.ts +61 -0
- package/src/sharddev/refusals.ts +234 -0
- package/src/sharddev/reportCard.ts +13 -0
- package/src/sharddev/returnProjectionV2.ts +81 -0
- package/src/sharddev/rows.ts +192 -0
- package/src/sharddev/runtimeImports.ts +38 -0
- package/src/sharddev/runtimeMirrors.ts +39 -0
- package/src/sharddev/runtimePerformance.ts +38 -0
- package/src/sharddev/scene.ts +321 -0
- package/src/sharddev/sceneAnimation.ts +54 -0
- package/src/sharddev/sceneAudio.ts +64 -0
- package/src/sharddev/sceneDeclarations.ts +100 -0
- package/src/sharddev/sceneGraph.ts +139 -0
- package/src/sharddev/sceneTransform.ts +12 -0
- package/src/sharddev/schemaValidation.ts +61 -0
- package/src/sharddev/sections.ts +47 -0
- package/src/sharddev/shardSource.ts +59 -0
- package/src/sharddev/sourceReader.ts +26 -0
- package/src/sharddev/spawns.ts +38 -0
- package/src/sharddev/species/clips.ts +24 -0
- package/src/sharddev/species.ts +29 -0
- package/src/sharddev/speciesBrains.ts +19 -0
- package/src/sharddev/synth.ts +66 -0
- package/src/sharddev/test/compileDualScriptV2.ts +71 -0
- package/src/sharddev/test/compileSimV2.ts +21 -0
- package/src/sharddev/test/diskScriptScenario.ts +86 -0
- package/src/sharddev/test/scriptScenario.ts +249 -0
- package/src/sharddev/test/scriptSource.ts +12 -0
- package/src/sharddev/version.ts +4 -0
- package/src/sharddev/weapons/bowProfile.ts +20 -0
- package/src/sharddev/weapons/firearmRows.ts +11 -0
- package/src/sharddev/weapons/meleeProfile.ts +71 -0
- package/src/sharddev/weapons/thrownProfile.ts +10 -0
- package/src/sharddev/worldScenes.ts +308 -0
- package/src/sharddev/worldSource.ts +82 -0
- package/src/shards/_template/README.md +78 -0
- package/src/shards/_template/assets/2bf489fdb15f1734ddb4c4f32d500ec6da85c765ec7a4eb28dc6781160e7ec8c +0 -0
- package/src/shards/_template/assets/97ec4d8f75f5fa6239ee919444d6dc19fd35896bb305930c1f050ac6e0e0e6a6 +1 -0
- package/src/shards/_template/assets/a6a587a31327f936b1b04c05ade818c73fc8964260918662db43539465e27586 +0 -0
- package/src/shards/_template/assets/b4fbde0422e125b498c3dc8b9a5cc2516c8598f09e9d0e5f6b639b32f98179e6 +0 -0
- package/src/shards/_template/assets/bfa4dfc9c18979f904557ee8deab0058b8a399be10266f5fb1578b403f482fd4 +1 -0
- package/src/shards/_template/assets/ef3b7ff4fd22715771cb7d68a3977a903c5e7c3dc293542687d04b3ef3ace2cb +0 -0
- package/src/shards/_template/assets/f2db05998615ce1cb79ea96be32c168842eb6a2b34ec01feb86d36404603ee54 +0 -0
- package/src/shards/_template/assets/fef98ebb7fce6f66b26e78ac699e5c90f9bdcfaf8cabeb2b58125347eea8b4ab +0 -0
- package/src/shards/_template/behaviour/boss.as +39 -0
- package/src/shards/_template/behaviour/door.as +32 -0
- package/src/shards/_template/behaviour/hooks.json +129 -0
- package/src/shards/_template/behaviour/idle.as +75 -0
- package/src/shards/_template/behaviour/items.as +22 -0
- package/src/shards/_template/card/landscape.jpg +0 -0
- package/src/shards/_template/card/portrait.jpg +0 -0
- package/src/shards/_template/card/thumb.jpg +0 -0
- package/src/shards/_template/data/audio.json +45 -0
- package/src/shards/_template/data/bossDecision.json +83 -0
- package/src/shards/_template/data/budgets.json +70 -0
- package/src/shards/_template/data/card.json +281 -0
- package/src/shards/_template/data/clientScripts.json +987 -0
- package/src/shards/_template/data/creatures.json +65 -0
- package/src/shards/_template/data/director.json +39 -0
- package/src/shards/_template/data/encounters.json +96 -0
- package/src/shards/_template/data/items.json +172 -0
- package/src/shards/_template/data/layout.json +66 -0
- package/src/shards/_template/data/ledger.json +32 -0
- package/src/shards/_template/data/look.json +521 -0
- package/src/shards/_template/data/map.json +64 -0
- package/src/shards/_template/data/moves.json +16 -0
- package/src/shards/_template/data/placeholder.json +8 -0
- package/src/shards/_template/data/plumbing.json +32 -0
- package/src/shards/_template/data/quests.json +223 -0
- package/src/shards/_template/data/rows.json +423 -0
- package/src/shards/_template/data/skins.json +66 -0
- package/src/shards/_template/data/spawn.json +6 -0
- package/src/shards/_template/data/targets.json +150 -0
- package/src/shards/_template/data/text.json +12 -0
- package/src/shards/_template/data/ui.json +33 -0
- package/src/shards/_template/data/water.json +13 -0
- package/src/shards/_template/generators/behaviour.ts +34 -0
- package/src/shards/_template/generators/boss.ts +29 -0
- package/src/shards/_template/generators/buildOptions.ts +2 -0
- package/src/shards/_template/generators/cell.ts +224 -0
- package/src/shards/_template/generators/districts.ts +215 -0
- package/src/shards/_template/generators/farLook.ts +15 -0
- package/src/shards/_template/generators/generate.ts +27 -0
- package/src/shards/_template/generators/ground.ts +15 -0
- package/src/shards/_template/generators/kit.ts +69 -0
- package/src/shards/_template/generators/landscape.ts +59 -0
- package/src/shards/_template/generators/landscapeNoise.ts +62 -0
- package/src/shards/_template/generators/mapInputs.ts +10 -0
- package/src/shards/_template/generators/product.ts +100 -0
- package/src/shards/_template/generators/productOutput.ts +18 -0
- package/src/shards/_template/generators/props.ts +9 -0
- package/src/shards/_template/generators/templatePropsSource.ts +58 -0
- package/src/shards/_template/generators/terrain.ts +17 -0
- package/src/shards/_template/generators/world.ts +630 -0
- package/src/shards/_template/hero.json +10 -0
- package/src/shards/_template/look/entry-reads.json +20 -0
- package/src/shards/_template/manifest.json +281 -0
- package/src/shards/_template/shard.config.ts +10 -0
- package/src/shared/health.ts +10 -0
- package/src/tools/build-web.ts +59 -0
- package/src/tsconfig.json +30 -0
- package/src/web/app.tsx +53 -0
- package/src/web/index.html +12 -0
- package/src/web/main.tsx +10 -0
- package/src/web/tsconfig.json +13 -0
- package/tsconfig.author.json +23 -0
- package/tsconfig.commons.json +21 -0
- package/tsconfig.json +47 -0
- package/tsconfig.sharddev.json +20 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"""The final sound set (AGENTS.md "Audio engines", the user 2026-09-23): every sound effect is generated with
|
|
2
|
+
MOSS-SoundEffect v2 and Stable Audio 3 Medium, and the better take of the two ships, in ONE merged set.
|
|
3
|
+
|
|
4
|
+
python3 scripts/music/gen/sfx_merge.py
|
|
5
|
+
|
|
6
|
+
No generation and no re-encoding: reads the two shipped sets (public/assets/sfx/moss/, public/assets/sfx/sa3-medium/,
|
|
7
|
+
built by sfx_build.py) and their CLAP rankings (scripts/music/gen/sfx-moss.json, sfx-sa3-medium.json), and per family:
|
|
8
|
+
the winner is the lower CLAP rank of the two models' best takes (ties -> the higher CLAP p). A family whose winner
|
|
9
|
+
ranks worse than SHIP_MAX_RANK (5) is in neither set, so it stays in `synth_keeps` and the synth plays it.
|
|
10
|
+
The winner's files (already content-addressed, loop points already measured on the decoded file) are copied as they are
|
|
11
|
+
into public/assets/sfx/best/, with its sfx.json entry; the provenance keeps the per-file `source` model.
|
|
12
|
+
Writes public/assets/sfx/best/sfx.json and scripts/music/gen/sfx-best.json (the per-family decision table).
|
|
13
|
+
|
|
14
|
+
python3 scripts/music/gen/sfx_merge.py --jobs sfx-ph-jobs.json --stage <dir>
|
|
15
|
+
|
|
16
|
+
PINE-HOLLOW-REMASTER PH-A2..A4: the same rule for another families file whose per-model sets sfx_build.py --stage wrote to
|
|
17
|
+
<dir>/moss/ and <dir>/sa3-medium/ (rankings in sfx-ph-<set>.json). Each family goes where its `into` says:
|
|
18
|
+
best merged INTO public/assets/sfx/best/ additively: that family's old files and provenance are replaced by the
|
|
19
|
+
winner's; if neither new take ranks in the top 5 the family's round-2 files stay. Everything else in best/
|
|
20
|
+
is untouched.
|
|
21
|
+
pine-hollow public/assets/sfx/pine-hollow/ (rebuilt): Pine Hollow's zoned beds (with their `zone` / `live`), barks and the
|
|
22
|
+
sounds ready for events that do not exist yet. Not in Settings' SFX_SETS, so the loading bar does not
|
|
23
|
+
download it for every shard; Pine Hollow reads it itself.
|
|
24
|
+
The decision rows land in scripts/music/gen/sfx-best.json next to round 2's (a `round: "pine-hollow"` and `into` on each).
|
|
25
|
+
Last, merge_set runs scripts/music/gen/sfx_sprite.py on the rebuilt own set (without it a regeneration would un-pack
|
|
26
|
+
the set): every one-shot + bark goes into ONE audio sprite (the loading bar fetches one file, not 63), and with --raw
|
|
27
|
+
<sfx-raw-dir> (the lossless takes; the analysis venv) the sprite is cut from them and the mono-sourced beds ship mono.
|
|
28
|
+
|
|
29
|
+
python3 scripts/music/gen/sfx_merge.py --jobs sfx-ph-jobs.json --stage <dir> --raw <sfx-raw-dir> --only fam,fam,...
|
|
30
|
+
|
|
31
|
+
A later round of a few families (sfx_build.py --only; the remaster's sound gaps): only those families are decided, copied
|
|
32
|
+
and given decision rows; pine-hollow/ is NOT rebuilt (every other family, bed and file stays as it is) and best/ is only
|
|
33
|
+
touched when one of them goes `into` it. The sprite is re-packed with the new takes after the old (sfx_sprite.py).
|
|
34
|
+
|
|
35
|
+
E357 S1.5: --tag nd reads sfx-nd-<model>.json and into: nine-dragon-stack builds that own set.
|
|
36
|
+
--dry prints the exact pre-sprite JSON writes without touching any files or loading models.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
from __future__ import annotations
|
|
40
|
+
|
|
41
|
+
import json
|
|
42
|
+
import shutil
|
|
43
|
+
import sys
|
|
44
|
+
from pathlib import Path
|
|
45
|
+
|
|
46
|
+
HERE = Path(__file__).resolve().parent
|
|
47
|
+
sys.path.insert(0, str(HERE))
|
|
48
|
+
from audio_jobs import family_key, read_sfx, tag_name # noqa: E402
|
|
49
|
+
REPO = HERE.parents[2]
|
|
50
|
+
SFX = REPO / "public/assets/sfx"
|
|
51
|
+
SHIP_MAX_RANK = 5
|
|
52
|
+
SOURCES = {"moss": "MOSS-SoundEffect v2.0 (OpenMOSS-Team/MOSS-SoundEffect-v2.0, Apache-2.0)",
|
|
53
|
+
"sa3-medium": "Stable Audio 3 Medium (stabilityai/stable-audio-3-medium, Stability AI Community License)"}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def main() -> None:
|
|
57
|
+
import argparse
|
|
58
|
+
|
|
59
|
+
ap = argparse.ArgumentParser()
|
|
60
|
+
ap.add_argument("--jobs", default=None, help="another families file (sfx-ph-jobs.json); needs --stage")
|
|
61
|
+
ap.add_argument("--stage", default=None, help="where sfx_build.py --stage wrote the per-model sets")
|
|
62
|
+
ap.add_argument("--raw", default=None, help="with --jobs: the sfx raw dir (lossless takes) for sfx_sprite.py")
|
|
63
|
+
ap.add_argument("--only", default="", help="with --jobs: decide and ship only these families (comma list); the rest stay")
|
|
64
|
+
ap.add_argument("--tag", default="ph", type=tag_name, help="staged ranking prefix (default ph)")
|
|
65
|
+
ap.add_argument("--dry", action="store_true", help="print the JSON writes; no copies, deletions, encoding or models")
|
|
66
|
+
ap.add_argument("--list", action="store_true", help="validate and print job families without reading rankings")
|
|
67
|
+
args = ap.parse_args()
|
|
68
|
+
only = {f for f in args.only.split(",") if f}
|
|
69
|
+
ph = args.jobs is not None
|
|
70
|
+
fams = read_sfx(HERE / (args.jobs or "sfx-jobs.json"))["families"]
|
|
71
|
+
if args.list:
|
|
72
|
+
print(json.dumps(fams, indent=2, ensure_ascii=False))
|
|
73
|
+
return
|
|
74
|
+
if only - fams.keys():
|
|
75
|
+
ap.error(f"unknown --only families: {sorted(only - fams.keys())}")
|
|
76
|
+
if ph and args.stage is None:
|
|
77
|
+
raise SystemExit("--jobs needs --stage")
|
|
78
|
+
src_root = Path(args.stage) if ph else SFX
|
|
79
|
+
sets = {s: json.loads((src_root / s / "sfx.json").read_text()) for s in SOURCES}
|
|
80
|
+
ranking = {s: json.loads((HERE / f'{"sfx-" + args.tag + "-" if ph else "sfx-"}{s}.json').read_text())["families"] for s in SOURCES}
|
|
81
|
+
|
|
82
|
+
def entry(s: str, fam: str) -> tuple[dict | None, list[str]]:
|
|
83
|
+
m = sets[s]
|
|
84
|
+
kind = fams[fam]["kind"]
|
|
85
|
+
if kind == "oneshot":
|
|
86
|
+
e = m["oneshots"].get(fam)
|
|
87
|
+
return e, (e["files"] if e else [])
|
|
88
|
+
key = family_key(fam)
|
|
89
|
+
e = m["beds" if kind == "bed" else "hums"].get(key)
|
|
90
|
+
return e, ([e["file"]] if e else [])
|
|
91
|
+
|
|
92
|
+
def score(s: str, fam: str) -> tuple[int, float]:
|
|
93
|
+
_, files = entry(s, fam)
|
|
94
|
+
prov = {p["file"]: p for p in sets[s]["provenance"]}
|
|
95
|
+
if files: # the take that set actually ships
|
|
96
|
+
p = prov[files[0]]
|
|
97
|
+
return int(p["clap_rank"]), float(p["clap_p"])
|
|
98
|
+
best = ranking[s][fam][0] # not shipped by that set: its best take's rank
|
|
99
|
+
return int(best["rank"]), float(best["p"])
|
|
100
|
+
|
|
101
|
+
if ph:
|
|
102
|
+
destinations = {j.get("into", "pine-hollow") for j in fams.values()} - {"best"}
|
|
103
|
+
if len(destinations) > 1:
|
|
104
|
+
ap.error("one jobs file must target at most one own set (plus best)")
|
|
105
|
+
own_set = next(iter(destinations), "pine-hollow")
|
|
106
|
+
merge_set(own_set, fams, sets, ranking, src_root, entry, score, Path(args.raw) if args.raw else None, only, args.tag, args.dry)
|
|
107
|
+
return
|
|
108
|
+
|
|
109
|
+
dest = SFX / "best"
|
|
110
|
+
if not args.dry:
|
|
111
|
+
dest.mkdir(parents=True, exist_ok=True)
|
|
112
|
+
for old in dest.glob("*.m4a"): # this folder holds only this script's output
|
|
113
|
+
old.unlink()
|
|
114
|
+
man: dict = {"model": "MOSS-SoundEffect v2 + Stable Audio 3 Medium",
|
|
115
|
+
"credit": "Sound effects: MOSS-SoundEffect v2 · Stable Audio 3 Medium — Powered by Stability AI",
|
|
116
|
+
"licence": "Per file (see provenance.source): MOSS-SoundEffect v2.0 is Apache-2.0; Stable Audio 3 Medium is the Stability AI "
|
|
117
|
+
"Community License (free below USD 1M revenue, register with Stability AI for commercial use, show 'Powered by Stability AI').",
|
|
118
|
+
"beds": {}, "hums": {}, "oneshots": {}, "provenance": []}
|
|
119
|
+
table, keeps, total = {}, [], 0
|
|
120
|
+
for fam in fams:
|
|
121
|
+
(rm, pm), (rs, ps) = score("moss", fam), score("sa3-medium", fam)
|
|
122
|
+
win = "moss" if (rm, -pm) <= (rs, -ps) else "sa3-medium"
|
|
123
|
+
rank = rm if win == "moss" else rs
|
|
124
|
+
table[fam] = {"winner": win, "moss": {"rank": rm, "p": pm}, "sa3-medium": {"rank": rs, "p": ps}}
|
|
125
|
+
e, files = entry(win, fam)
|
|
126
|
+
if rank > SHIP_MAX_RANK or e is None:
|
|
127
|
+
keeps.append(fam)
|
|
128
|
+
table[fam]["winner"] = "synth"
|
|
129
|
+
continue
|
|
130
|
+
for f in files:
|
|
131
|
+
if not args.dry:
|
|
132
|
+
shutil.copy2(SFX / win / f, dest / f)
|
|
133
|
+
total += (SFX / win / f).stat().st_size
|
|
134
|
+
p = next(x for x in sets[win]["provenance"] if x["file"] == f)
|
|
135
|
+
man["provenance"].append({**p, "source": SOURCES[win], "set_of_origin": win})
|
|
136
|
+
kind = fams[fam]["kind"]
|
|
137
|
+
if kind == "oneshot":
|
|
138
|
+
man["oneshots"][fam] = e
|
|
139
|
+
else:
|
|
140
|
+
man["beds" if kind == "bed" else "hums"][family_key(fam)] = e
|
|
141
|
+
man["synth_keeps"] = keeps
|
|
142
|
+
writes = {str(dest / "sfx.json"): json.dumps(man, indent=2, ensure_ascii=False) + "\n"}
|
|
143
|
+
wins = {k: sum(1 for t in table.values() if t["winner"] == k) for k in ("moss", "sa3-medium", "synth")}
|
|
144
|
+
writes[str(HERE / "sfx-best.json")] = json.dumps({"rule": "lower CLAP rank wins, ties to the higher p; ships only in the top 5",
|
|
145
|
+
"wins": wins, "families": table}, indent=2) + "\n"
|
|
146
|
+
if args.dry:
|
|
147
|
+
print(json.dumps(writes, indent=2, ensure_ascii=False))
|
|
148
|
+
return
|
|
149
|
+
for path, value in writes.items():
|
|
150
|
+
Path(path).write_text(value)
|
|
151
|
+
print(f"best: {total / 1e6:.2f} MB, wins {wins}, synth keeps {keeps}")
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def merge_set(set_name: str, fams: dict, sets: dict, ranking: dict, src_root: Path, entry, score, raw: Path | None = None, # noqa: ANN001 - the closures above
|
|
155
|
+
only: set[str] | None = None, tag: str = "ph", dry: bool = False) -> dict[str, str]:
|
|
156
|
+
tag_name(set_name)
|
|
157
|
+
best_dir, ph_dir = SFX / "best", SFX / set_name
|
|
158
|
+
if not dry:
|
|
159
|
+
ph_dir.mkdir(parents=True, exist_ok=True)
|
|
160
|
+
best = json.loads((best_dir / "sfx.json").read_text())
|
|
161
|
+
selected = {f: j for f, j in fams.items() if not only or f in only}
|
|
162
|
+
touches_best = any(j.get("into", set_name) == "best" for j in selected.values())
|
|
163
|
+
# Own-only merges must never reserialize the shared manifest or its decision ledger (E357 B18).
|
|
164
|
+
table_path = HERE / ("sfx-best.json" if touches_best else f"sfx-{tag}-best.json")
|
|
165
|
+
table_doc = json.loads(table_path.read_text()) if table_path.exists() else {
|
|
166
|
+
"rule": "lower CLAP rank wins, ties to the higher p; ships only in the top 5", "wins": {}, "families": {}}
|
|
167
|
+
table = table_doc["families"]
|
|
168
|
+
if only: # a later round: the set stays, these families are replaced in it
|
|
169
|
+
man = json.loads((ph_dir / "sfx.json").read_text())
|
|
170
|
+
for fam in only:
|
|
171
|
+
kind = fams[fam]["kind"]
|
|
172
|
+
sec, key = (man["oneshots"], fam) if kind == "oneshot" else (man["beds" if kind == "bed" else "hums"], family_key(fam))
|
|
173
|
+
e = sec.pop(key, None)
|
|
174
|
+
olds = [] if e is None else e["files"] if "files" in e else [e["file"]]
|
|
175
|
+
man["provenance"] = [p for p in man["provenance"] if p["file"] not in olds]
|
|
176
|
+
if not dry:
|
|
177
|
+
for f in olds:
|
|
178
|
+
(ph_dir / f).unlink(missing_ok=True) # a packed take has no file: the re-pack drops its clip
|
|
179
|
+
else:
|
|
180
|
+
if not dry:
|
|
181
|
+
for old in ph_dir.glob("*.m4a"): # this folder holds only this function's output
|
|
182
|
+
old.unlink()
|
|
183
|
+
man = {"model": best["model"], "credit": best["credit"], "licence": best["licence"], "set": set_name,
|
|
184
|
+
"beds": {}, "hums": {}, "oneshots": {}, "provenance": []}
|
|
185
|
+
keeps, total = [], {"best": 0, set_name: 0}
|
|
186
|
+
|
|
187
|
+
def section(m: dict, fam: str) -> tuple[dict, str]:
|
|
188
|
+
kind = fams[fam]["kind"]
|
|
189
|
+
return (m["oneshots"], fam) if kind == "oneshot" else (m["beds" if kind == "bed" else "hums"], family_key(fam))
|
|
190
|
+
|
|
191
|
+
missing = []
|
|
192
|
+
for fam, j in fams.items():
|
|
193
|
+
if only and fam not in only:
|
|
194
|
+
continue
|
|
195
|
+
if any(fam not in ranking[s] for s in SOURCES): # not rendered by both models yet: left as it is
|
|
196
|
+
missing.append(fam)
|
|
197
|
+
continue
|
|
198
|
+
(rm, pm), (rs, ps) = score("moss", fam), score("sa3-medium", fam)
|
|
199
|
+
win = "moss" if (rm, -pm) <= (rs, -ps) else "sa3-medium"
|
|
200
|
+
rank = rm if win == "moss" else rs
|
|
201
|
+
into = j.get("into", set_name)
|
|
202
|
+
if into not in ("best", set_name):
|
|
203
|
+
raise ValueError(f"{fam}: unsupported destination {into}")
|
|
204
|
+
row = {"winner": win, "moss": {"rank": rm, "p": pm}, "sa3-medium": {"rank": rs, "p": ps}, "round": set_name, "into": into}
|
|
205
|
+
e, files = entry(win, fam)
|
|
206
|
+
if rank > SHIP_MAX_RANK or e is None:
|
|
207
|
+
keeps.append(fam)
|
|
208
|
+
row["winner"] = "synth" if fam not in table or into != "best" else "kept-round-2"
|
|
209
|
+
if into == "best" and fam in table:
|
|
210
|
+
row["kept"] = table[fam] # the round-2 decision, whose files stay
|
|
211
|
+
table[fam] = row
|
|
212
|
+
continue
|
|
213
|
+
target, m = (best_dir, best) if into == "best" else (ph_dir, man)
|
|
214
|
+
sec, key = section(m, fam)
|
|
215
|
+
if into == "best" and key in sec: # replace the round-2 files of this family
|
|
216
|
+
olds = sec[key]["files"] if "files" in sec[key] else [sec[key]["file"]]
|
|
217
|
+
if not dry:
|
|
218
|
+
for f in olds:
|
|
219
|
+
(best_dir / f).unlink(missing_ok=True)
|
|
220
|
+
best["provenance"] = [p for p in best["provenance"] if p["file"] not in olds]
|
|
221
|
+
for f in files:
|
|
222
|
+
if not dry:
|
|
223
|
+
shutil.copy2(src_root / win / f, target / f)
|
|
224
|
+
total[into] += (src_root / win / f).stat().st_size
|
|
225
|
+
p = next(x for x in sets[win]["provenance"] if x["file"] == f)
|
|
226
|
+
m["provenance"].append({**p, "source": SOURCES[win], "set_of_origin": win, "round": set_name})
|
|
227
|
+
e = dict(e)
|
|
228
|
+
if fams[fam]["kind"] == "bed":
|
|
229
|
+
e["zone"], e["live"] = j.get("zone"), bool(j.get("live"))
|
|
230
|
+
sec[key] = e
|
|
231
|
+
table[fam] = row
|
|
232
|
+
new_keeps = [f for f in keeps if fams[f].get("into") != "best"]
|
|
233
|
+
man["synth_keeps"] = [f for f in man.get("synth_keeps", []) if f not in only] + new_keeps if only else new_keeps
|
|
234
|
+
if touches_best:
|
|
235
|
+
best["synth_keeps"] = sorted(set(best.get("synth_keeps", [])) - {f for f in fams if table.get(f, {}).get("winner", "synth") not in ("synth", "kept-round-2")})
|
|
236
|
+
writes = {}
|
|
237
|
+
if touches_best:
|
|
238
|
+
writes[str(best_dir / "sfx.json")] = json.dumps(best, indent=2, ensure_ascii=False) + "\n"
|
|
239
|
+
writes[str(ph_dir / "sfx.json")] = json.dumps(man, indent=2, ensure_ascii=False) + "\n"
|
|
240
|
+
table_doc["wins"] = {k: sum(1 for t in table.values() if t["winner"] == k) for k in ("moss", "sa3-medium", "synth", "kept-round-2")}
|
|
241
|
+
writes[str(table_path)] = json.dumps(table_doc, indent=2) + "\n"
|
|
242
|
+
if dry:
|
|
243
|
+
print(json.dumps(writes, indent=2, ensure_ascii=False))
|
|
244
|
+
return writes
|
|
245
|
+
for path, value in writes.items():
|
|
246
|
+
Path(path).write_text(value)
|
|
247
|
+
print(f"{set_name}: best += {total['best'] / 1e6:.2f} MB, {set_name} {total[set_name] / 1e6:.2f} MB, wins {table_doc['wins']}, not shipped {keeps}, not rendered yet {missing}")
|
|
248
|
+
from sfx_sprite import run as pack # the rebuilt set is one file per sound again: pack it (and, with --raw, its beds)
|
|
249
|
+
|
|
250
|
+
pack(ph_dir, raw, set_name=set_name, tag=tag)
|
|
251
|
+
return writes
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
if __name__ == "__main__":
|
|
255
|
+
main()
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""SFX round 2: file MiniMax Music 3's sound-effect takes for sfx_build.py, each trimmed to its best-matching segment.
|
|
2
|
+
|
|
3
|
+
~/ml/music/analysis/.venv/bin/python scripts/music/gen/sfx_minimax.py <minimax-out> <sfx-raw>
|
|
4
|
+
|
|
5
|
+
<minimax-out>/sfx-<family>/minimax3-<seed>.wav (gen_minimax.py --jobs sfx-minimax-jobs.json) ->
|
|
6
|
+
<sfx-raw>/minimax/<family>/<seed>.wav + .json. The trim: CLAP (clap-htsat-fused) scores every window of the family's
|
|
7
|
+
length (beds 8 s, hums 6 s, one-shots 1.5-3 s, hop 0.25 s) against the family description; the best window is kept.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import json
|
|
13
|
+
import sys
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
|
|
16
|
+
import librosa
|
|
17
|
+
import numpy as np
|
|
18
|
+
import soundfile as sf
|
|
19
|
+
|
|
20
|
+
HERE = Path(__file__).resolve().parent
|
|
21
|
+
sys.path.insert(0, str(HERE))
|
|
22
|
+
from analyze import CLAP_DIR, _tensor # noqa: E402
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def main() -> None:
|
|
26
|
+
import torch
|
|
27
|
+
from transformers import ClapModel, ClapProcessor
|
|
28
|
+
|
|
29
|
+
src, dst = Path(sys.argv[1]), Path(sys.argv[2])
|
|
30
|
+
fams = json.loads((HERE / "sfx-jobs.json").read_text())["families"]
|
|
31
|
+
clap = ClapModel.from_pretrained(str(CLAP_DIR)).eval()
|
|
32
|
+
proc = ClapProcessor.from_pretrained(str(CLAP_DIR))
|
|
33
|
+
for wav in sorted(src.glob("sfx-*/minimax3-*.wav")):
|
|
34
|
+
fam = wav.parent.name[len("sfx-"):]
|
|
35
|
+
side = json.loads(wav.with_suffix(".json").read_text())
|
|
36
|
+
j = fams[fam]
|
|
37
|
+
x, sr = sf.read(str(wav), always_2d=True)
|
|
38
|
+
win = {"bed": 8.0, "hum": 6.0}.get(j["kind"], min(max(float(j["duration"]), 1.5), 3.0))
|
|
39
|
+
y48 = librosa.resample(x.mean(1).astype(np.float32), orig_sr=sr, target_sr=48000)
|
|
40
|
+
starts = np.arange(0, max(len(y48) / 48000 - win, 0) + 1e-6, 0.25)
|
|
41
|
+
with torch.no_grad():
|
|
42
|
+
t = torch.nn.functional.normalize(_tensor(clap.get_text_features(**proc(text=[j["desc"]], return_tensors="pt"))), dim=-1)
|
|
43
|
+
chunks = [y48[int(s * 48000): int((s + win) * 48000)] for s in starts]
|
|
44
|
+
a = torch.nn.functional.normalize(_tensor(clap.get_audio_features(**proc(audio=chunks, sampling_rate=48000, return_tensors="pt"))), dim=-1)
|
|
45
|
+
sims = (a @ t.T)[:, 0]
|
|
46
|
+
k = int(sims.argmax())
|
|
47
|
+
s0 = float(starts[k])
|
|
48
|
+
seg = x[int(s0 * sr): int((s0 + win) * sr)]
|
|
49
|
+
out = dst / "minimax" / fam / f"{side['seed']}.wav"
|
|
50
|
+
out.parent.mkdir(parents=True, exist_ok=True)
|
|
51
|
+
sf.write(str(out), seg, sr)
|
|
52
|
+
out.with_suffix(".json").write_text(json.dumps({
|
|
53
|
+
"model": "MiniMax Music 3", "repo": "MiniMaxAI/MiniMax-Music3", "code_commit": side["code_commit"],
|
|
54
|
+
"family": fam, "kind": j["kind"], "seed": side["seed"], "prompt": side["prompt"], "desc": j["desc"],
|
|
55
|
+
"duration_s": win, "steps": side["steps"], "gen_time_s": side["gen_time_s"], "mps_driver_gb": side.get("mps_driver_gb"),
|
|
56
|
+
"trimmed_from_s": round(s0, 2), "rendered_s": round(len(x) / sr, 2)}, indent=2))
|
|
57
|
+
print(f"{fam} seed {side['seed']}: best {win:.1f} s window at {s0:.2f} s (CLAP sim {float(sims[k]):.3f})")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
if __name__ == "__main__":
|
|
61
|
+
main()
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
"""NALATI-MERGE A1: Nalati's sound families into main's ONE merged set (AGENTS.md "Audio engines": every sound generated
|
|
2
|
+
with MOSS-SoundEffect v2 AND Stable Audio 3 Medium, the better take ships, picked per sound).
|
|
3
|
+
|
|
4
|
+
~/ml/music/analysis/.venv/bin/python scripts/music/gen/sfx_nalati.py <sfx-raw-dir> [--dry-run]
|
|
5
|
+
|
|
6
|
+
Reads <raw>/moss/<family>/<seed>.wav and <raw>/medium/<family>/<seed>.wav (+ .json) — gen_sfx_moss.py / gen_sfx.py
|
|
7
|
+
--jobs sfx-nalati-jobs.json. Per take, CLAP (laion/clap-htsat-fused) as in sfx_build.py: the softmax of its own family
|
|
8
|
+
description against every OTHER Nalati family's description (siblings in the same `group` left out: a hoof on grass is
|
|
9
|
+
not a hoof on gravel's competitor) plus the three foils; `rank` 1 = its own description matches best.
|
|
10
|
+
Per family: each model's best take (rank <= 3 first, then p, beds weighted by their loop seam); the winner is the lower
|
|
11
|
+
rank of the two, ties to the higher p (sfx_merge.py's rule). It ships only if it ranks <= SHIP_MAX_RANK (5); a one-shot
|
|
12
|
+
adds the winner's second take as a variant when that also ranks <= 3. A family nobody wins keeps its synth.
|
|
13
|
+
Encoding (sfx_build.py's): one-shots mono AAC 64 kb/s trimmed to the sounding part at -18 LUFS; beds stereo AAC 64 kb/s
|
|
14
|
+
(the budget: +~2 MB accepted by the user) at -24 LUFS, looped on the best seam >= 10 s (analyze.loop_seam on a 5 s grid),
|
|
15
|
+
the seam crossfaded (stems.seam) and the loop points re-measured on the decoded file.
|
|
16
|
+
Merged INTO public/assets/sfx/best/ additively: every entry is tagged `shard: 'nalati'` (src/client/engine/audio/preload.ts decodes it on
|
|
17
|
+
the steppe only); a re-run first removes the previous Nalati files (the provenance rows marked `round: 'nalati'`) and
|
|
18
|
+
nothing else. Writes scripts/music/gen/sfx-nalati.json (every take, every score, the decision per family) and adds the
|
|
19
|
+
rows to sfx-best.json under `nalati`.
|
|
20
|
+
|
|
21
|
+
... sfx_nalati.py <new-raw-dir> --only fam,fam,... (NALATI-FINISH B3)
|
|
22
|
+
|
|
23
|
+
A later round of a few families, after the first round's raw takes are gone: only these families' takes in <raw> are
|
|
24
|
+
ranked (against every family's description, as ever) and pooled with the takes sfx-nalati.json already scored for them;
|
|
25
|
+
the same rule decides. A first-round take that still ships keeps its shipped file (found by family, seed and engine in
|
|
26
|
+
the provenance); one that was never shipped cannot be re-encoded and is skipped; one scored by another rubric (the family
|
|
27
|
+
got a `clap_desc` since) is left out of the pool. Only these families' files, rows and
|
|
28
|
+
`synth_keeps` entries change; every other Nalati family, bed and file stays as it is.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
from __future__ import annotations
|
|
32
|
+
|
|
33
|
+
import argparse
|
|
34
|
+
import json
|
|
35
|
+
import sys
|
|
36
|
+
from pathlib import Path
|
|
37
|
+
|
|
38
|
+
import librosa
|
|
39
|
+
import numpy as np
|
|
40
|
+
import soundfile as sf
|
|
41
|
+
|
|
42
|
+
HERE = Path(__file__).resolve().parent
|
|
43
|
+
sys.path.insert(0, str(HERE))
|
|
44
|
+
from analyze import CLAP_DIR, _tensor, loop_seam # noqa: E402
|
|
45
|
+
from sfx_build import FOILS, LEVEL, SHIP_MAX_RANK, trim # noqa: E402
|
|
46
|
+
from stems import decode_offset, lufs, seam, shipped_name # noqa: E402
|
|
47
|
+
|
|
48
|
+
REPO = HERE.parents[2]
|
|
49
|
+
BEST = REPO / "public/assets/sfx/best"
|
|
50
|
+
MODELS = {"moss": "MOSS-SoundEffect v2.0 (OpenMOSS-Team/MOSS-SoundEffect-v2.0, Apache-2.0)",
|
|
51
|
+
"medium": "Stable Audio 3 Medium (stabilityai/stable-audio-3-medium, Stability AI Community License)"}
|
|
52
|
+
SET_OF = {"moss": "moss", "medium": "sa3-medium"}
|
|
53
|
+
BED_GAIN = 0.5
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def encode(x: np.ndarray, sr: int, dest: Path, mono: bool) -> int:
|
|
57
|
+
"""AAC-LC .m4a at 48 kHz, 64 kb/s (mono one-shots, stereo beds)"""
|
|
58
|
+
import subprocess
|
|
59
|
+
import tempfile
|
|
60
|
+
|
|
61
|
+
dest.parent.mkdir(parents=True, exist_ok=True)
|
|
62
|
+
y = librosa.resample(x, orig_sr=sr, target_sr=48000, res_type="soxr_hq") if sr != 48000 else x
|
|
63
|
+
if mono:
|
|
64
|
+
y = y.mean(0, keepdims=True)
|
|
65
|
+
with tempfile.NamedTemporaryFile(suffix=".wav") as f:
|
|
66
|
+
sf.write(f.name, y.T, 48000, subtype="FLOAT")
|
|
67
|
+
subprocess.run(["ffmpeg", "-y", "-loglevel", "error", "-i", f.name, "-ac", "1" if mono else "2", "-c:a", "aac", "-b:a", "64k",
|
|
68
|
+
"-movflags", "+faststart", str(dest)], check=True)
|
|
69
|
+
return dest.stat().st_size
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def rank_all(raw: Path, fams: dict, only: set[str] | None = None) -> dict[str, dict[str, list[dict]]]:
|
|
73
|
+
import torch
|
|
74
|
+
from transformers import ClapModel, ClapProcessor
|
|
75
|
+
|
|
76
|
+
clap = ClapModel.from_pretrained(str(CLAP_DIR)).eval()
|
|
77
|
+
proc = ClapProcessor.from_pretrained(str(CLAP_DIR))
|
|
78
|
+
scale = float(clap.logit_scale_a.detach().exp())
|
|
79
|
+
names = list(fams)
|
|
80
|
+
texts = [fams[f]["desc"] for f in names] + FOILS
|
|
81
|
+
with torch.no_grad():
|
|
82
|
+
te = torch.nn.functional.normalize(_tensor(clap.get_text_features(**proc(text=texts, return_tensors="pt", padding=True))), dim=-1)
|
|
83
|
+
# `clap_desc`: the text a family's OWN takes are judged by, when its `desc` is a weak CLAP anchor (B3: "a spear thrust fast
|
|
84
|
+
# forward" lost to a bowstring on every take, whatever the take). Other families still meet its plain `desc` as a rival.
|
|
85
|
+
own = {f: fams[f]["clap_desc"] for f in names if "clap_desc" in fams[f]}
|
|
86
|
+
with torch.no_grad():
|
|
87
|
+
te_own = {f: torch.nn.functional.normalize(_tensor(clap.get_text_features(**proc(text=[t], return_tensors="pt", padding=True))), dim=-1)[0]
|
|
88
|
+
for f, t in own.items()}
|
|
89
|
+
out: dict[str, dict[str, list[dict]]] = {}
|
|
90
|
+
for model in MODELS:
|
|
91
|
+
by: dict[str, list[dict]] = {}
|
|
92
|
+
for wav in sorted((raw / model).glob("*/*.wav")):
|
|
93
|
+
side = json.loads(wav.with_suffix(".json").read_text())
|
|
94
|
+
fam = side["family"]
|
|
95
|
+
if fam not in fams or (only and fam not in only):
|
|
96
|
+
continue
|
|
97
|
+
x, sr = sf.read(str(wav), always_2d=True)
|
|
98
|
+
y = x.mean(1).astype(np.float32)
|
|
99
|
+
y48 = librosa.resample(y, orig_sr=sr, target_sr=48000)
|
|
100
|
+
seg = 48000 * 10
|
|
101
|
+
chunks = [y48[i:i + seg] for i in range(0, max(len(y48) - seg // 2, 1), seg)] or [y48]
|
|
102
|
+
with torch.no_grad():
|
|
103
|
+
a = proc(audio=chunks, sampling_rate=48000, return_tensors="pt")
|
|
104
|
+
ae = torch.nn.functional.normalize(_tensor(clap.get_audio_features(**a)), dim=-1).mean(0, keepdim=True)
|
|
105
|
+
sims = (torch.nn.functional.normalize(ae, dim=-1) @ te.T)[0]
|
|
106
|
+
i = names.index(fam)
|
|
107
|
+
ttexts = list(texts)
|
|
108
|
+
if fam in te_own:
|
|
109
|
+
sims = sims.clone()
|
|
110
|
+
sims[i] = float((torch.nn.functional.normalize(ae, dim=-1)[0] * te_own[fam]).sum())
|
|
111
|
+
ttexts[i] = own[fam]
|
|
112
|
+
grp = fams[fam].get("group")
|
|
113
|
+
keep = torch.tensor([j == i or j >= len(names) or grp is None or fams[names[j]].get("group") != grp for j in range(len(texts))])
|
|
114
|
+
ks, ki = sims[keep], int(keep[:i].sum())
|
|
115
|
+
r = {"family": fam, "model": model, "seed": side["seed"], "wav": str(wav), "side": side,
|
|
116
|
+
"p": round(float(torch.softmax(ks * scale, 0)[ki]), 3), "rank": int((ks > ks[ki]).sum()) + 1,
|
|
117
|
+
"best_match": ttexts[int(sims.argmax())], "rubric": ttexts[i], "peak": round(float(np.abs(x).max()), 3)}
|
|
118
|
+
if fams[fam]["kind"] == "bed":
|
|
119
|
+
r["seam"] = loop_seam(librosa.resample(y, orig_sr=sr, target_sr=22050), 22050, 48.0, len(y) / sr) # a 5 s grid, >= 10 s loops
|
|
120
|
+
by.setdefault(fam, []).append(r)
|
|
121
|
+
for rs in by.values():
|
|
122
|
+
order(rs)
|
|
123
|
+
out[model] = by
|
|
124
|
+
return out
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def order(rs: list[dict]) -> None:
|
|
128
|
+
"""best take first: rank <= 3 first, then p (a bed's p weighted by its loop seam)"""
|
|
129
|
+
rs.sort(key=lambda r: (r["rank"] <= 3, r["p"] * (0.7 + 0.3 * max(r.get("seam", {}).get("score", 1.0), 0.0))), reverse=True)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def main() -> None:
|
|
133
|
+
ap = argparse.ArgumentParser()
|
|
134
|
+
ap.add_argument("raw")
|
|
135
|
+
ap.add_argument("--dry-run", action="store_true", help="rank and decide only; write sfx-nalati.json, touch no shipped file")
|
|
136
|
+
ap.add_argument("--only", default="", help="a later round: rank just these families' new takes, pool them with the scored ones, replace only these")
|
|
137
|
+
args = ap.parse_args()
|
|
138
|
+
raw = Path(args.raw)
|
|
139
|
+
fams = json.loads((HERE / "sfx-nalati-jobs.json").read_text())["families"]
|
|
140
|
+
only = {f for f in args.only.split(",") if f}
|
|
141
|
+
if only:
|
|
142
|
+
unknown = only - set(fams)
|
|
143
|
+
if unknown:
|
|
144
|
+
raise SystemExit(f"--only: not Nalati families: {sorted(unknown)}")
|
|
145
|
+
only_round(raw, fams, only, args.dry_run)
|
|
146
|
+
return
|
|
147
|
+
ranked = rank_all(raw, fams)
|
|
148
|
+
|
|
149
|
+
table: dict[str, dict] = {}
|
|
150
|
+
winners: dict[str, list[dict]] = {}
|
|
151
|
+
for fam in fams:
|
|
152
|
+
best = {m: ranked[m].get(fam, []) for m in MODELS}
|
|
153
|
+
row: dict = {m: ({"rank": rs[0]["rank"], "p": rs[0]["p"], "seed": rs[0]["seed"], "best_match": rs[0]["best_match"]} if rs else None) for m, rs in best.items()}
|
|
154
|
+
cands = [(rs[0]["rank"], -rs[0]["p"], m) for m, rs in best.items() if rs]
|
|
155
|
+
if not cands:
|
|
156
|
+
row["winner"] = "missing"
|
|
157
|
+
else:
|
|
158
|
+
rank, _, win = min(cands)
|
|
159
|
+
row["winner"] = win if rank <= SHIP_MAX_RANK else "synth"
|
|
160
|
+
if rank <= SHIP_MAX_RANK:
|
|
161
|
+
rs = best[win]
|
|
162
|
+
winners[fam] = rs[:1] if fams[fam]["kind"] != "oneshot" else [r for r in rs[:2] if r is rs[0] or r["rank"] <= 3]
|
|
163
|
+
table[fam] = row
|
|
164
|
+
wins = {k: sum(1 for t in table.values() if t["winner"] == k) for k in ("moss", "medium", "synth", "missing")}
|
|
165
|
+
rec = {"rule": "per family: each model's best take by CLAP (siblings in a group not competing); the lower rank wins, ties to the higher p; ships only in the top 5",
|
|
166
|
+
"wins": wins, "families": table,
|
|
167
|
+
"takes": {m: {f: [{k: v for k, v in r.items() if k != "wav"} for r in rs] for f, rs in by.items()} for m, by in ranked.items()}}
|
|
168
|
+
if args.dry_run:
|
|
169
|
+
(HERE / "sfx-nalati.json").write_text(json.dumps(rec, indent=2, ensure_ascii=False) + "\n")
|
|
170
|
+
print(f"dry run: wins {wins}")
|
|
171
|
+
return
|
|
172
|
+
|
|
173
|
+
man = json.loads((BEST / "sfx.json").read_text())
|
|
174
|
+
# the previous Nalati round out (its files and rows only)
|
|
175
|
+
old = [p for p in man["provenance"] if p.get("round") == "nalati"]
|
|
176
|
+
for p in old:
|
|
177
|
+
(BEST / p["file"]).unlink(missing_ok=True)
|
|
178
|
+
man["provenance"] = [p for p in man["provenance"] if p.get("round") != "nalati"]
|
|
179
|
+
for sec in ("beds", "oneshots"):
|
|
180
|
+
for k in [k for k, v in man[sec].items() if v.get("shard") == "nalati"]:
|
|
181
|
+
del man[sec][k]
|
|
182
|
+
total = 0
|
|
183
|
+
for fam, takes in winners.items():
|
|
184
|
+
kind = fams[fam]["kind"]
|
|
185
|
+
for r in takes:
|
|
186
|
+
x, sr = sf.read(r["wav"], always_2d=True)
|
|
187
|
+
x = x.T.astype(np.float64)
|
|
188
|
+
if kind == "bed":
|
|
189
|
+
s = r["seam"]
|
|
190
|
+
y, _ = seam(x, sr, {"loopStart": s["start_s"], "loopEnd": s["end_s"]}, 1.0)
|
|
191
|
+
else:
|
|
192
|
+
y = trim(x, sr, 5.0 if fam in ("stampede", "thunder-near", "thunder-far", "wolf_howl") else 3.0)
|
|
193
|
+
L, tp = lufs(y, sr)
|
|
194
|
+
y = y * 10 ** (min(LEVEL[kind] - L, -1.0 - tp) / 20)
|
|
195
|
+
tmp = BEST / ".tmp.m4a"
|
|
196
|
+
total += encode(y, sr, tmp, mono=(kind == "oneshot"))
|
|
197
|
+
lag, dlen = decode_offset(tmp, y, sr) if kind == "bed" else (0.0, 0.0)
|
|
198
|
+
fname = shipped_name(BEST, tmp, f"{fam}-{r['seed']}")
|
|
199
|
+
if kind == "bed":
|
|
200
|
+
e = {"file": fname, "loopStart": round(r["seam"]["start_s"] + lag, 4), "loopEnd": round(r["seam"]["end_s"] + lag, 4),
|
|
201
|
+
"duration": round(dlen, 4), "gain": BED_GAIN, "shard": "nalati"}
|
|
202
|
+
assert e["loopEnd"] <= dlen and e["loopEnd"] - e["loopStart"] > 0.5
|
|
203
|
+
man["beds"][fam.split("-", 1)[1]] = e
|
|
204
|
+
else:
|
|
205
|
+
man["oneshots"].setdefault(fam, {"files": [], "gain": 1.0, "shard": "nalati"})["files"].append(fname)
|
|
206
|
+
man["provenance"].append({"file": fname, "model": r["side"]["repo"], "code": r["side"]["code_commit"], "prompt": r["side"]["prompt"],
|
|
207
|
+
"seed": r["seed"], "steps": r["side"]["steps"], "clap_p": r["p"], "clap_rank": r["rank"],
|
|
208
|
+
"source": MODELS[r["model"]], "set_of_origin": SET_OF[r["model"]], "round": "nalati"})
|
|
209
|
+
man["synth_keeps"] = sorted(set(man.get("synth_keeps", [])) | {f for f, t in table.items() if t["winner"] in ("synth", "missing")})
|
|
210
|
+
(BEST / "sfx.json").write_text(json.dumps(man, indent=2, ensure_ascii=False) + "\n")
|
|
211
|
+
rec["bytes"] = total
|
|
212
|
+
(HERE / "sfx-nalati.json").write_text(json.dumps(rec, indent=2, ensure_ascii=False) + "\n")
|
|
213
|
+
bt = json.loads((HERE / "sfx-best.json").read_text())
|
|
214
|
+
bt["nalati"] = {"rule": rec["rule"], "wins": wins, "bytes": total, "families": table}
|
|
215
|
+
(HERE / "sfx-best.json").write_text(json.dumps(bt, indent=2) + "\n")
|
|
216
|
+
print(f"nalati: +{total / 1e6:.2f} MB into best/, wins {wins}")
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
def ship_take(r: dict, fam: str, kind: str) -> tuple[str, int, dict]:
|
|
220
|
+
"""trim / level / encode one take into best/ (sfx_build.py's rules); returns its file name, bytes and bed entry"""
|
|
221
|
+
x, sr = sf.read(r["wav"], always_2d=True)
|
|
222
|
+
x = x.T.astype(np.float64)
|
|
223
|
+
if kind == "bed":
|
|
224
|
+
s = r["seam"]
|
|
225
|
+
y, _ = seam(x, sr, {"loopStart": s["start_s"], "loopEnd": s["end_s"]}, 1.0)
|
|
226
|
+
else:
|
|
227
|
+
y = trim(x, sr, 5.0 if fam in ("stampede", "thunder-near", "thunder-far", "wolf_howl") else 3.0)
|
|
228
|
+
L, tp = lufs(y, sr)
|
|
229
|
+
y = y * 10 ** (min(LEVEL[kind] - L, -1.0 - tp) / 20)
|
|
230
|
+
tmp = BEST / ".tmp.m4a"
|
|
231
|
+
size = encode(y, sr, tmp, mono=(kind == "oneshot"))
|
|
232
|
+
lag, dlen = decode_offset(tmp, y, sr) if kind == "bed" else (0.0, 0.0)
|
|
233
|
+
fname = shipped_name(BEST, tmp, f"{fam}-{r['seed']}")
|
|
234
|
+
bed: dict = {}
|
|
235
|
+
if kind == "bed":
|
|
236
|
+
bed = {"file": fname, "loopStart": round(r["seam"]["start_s"] + lag, 4), "loopEnd": round(r["seam"]["end_s"] + lag, 4),
|
|
237
|
+
"duration": round(dlen, 4), "gain": BED_GAIN, "shard": "nalati"}
|
|
238
|
+
assert bed["loopEnd"] <= dlen and bed["loopEnd"] - bed["loopStart"] > 0.5
|
|
239
|
+
return fname, size, bed
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def only_round(raw: Path, fams: dict, only: set[str], dry_run: bool) -> None:
|
|
243
|
+
"""NALATI-FINISH B3: a later round of `only`, pooled with the takes sfx-nalati.json already scored"""
|
|
244
|
+
rec = json.loads((HERE / "sfx-nalati.json").read_text())
|
|
245
|
+
new = rank_all(raw, fams, only)
|
|
246
|
+
man = json.loads((BEST / "sfx.json").read_text())
|
|
247
|
+
prov = {p["file"]: p for p in man["provenance"] if p.get("round") == "nalati"}
|
|
248
|
+
for fam in sorted(only):
|
|
249
|
+
kind = fams[fam]["kind"]
|
|
250
|
+
pools: dict[str, list[dict]] = {}
|
|
251
|
+
for m in MODELS:
|
|
252
|
+
fresh = new[m].get(fam, [])
|
|
253
|
+
seeds = {r["seed"] for r in fresh}
|
|
254
|
+
rubric = fams[fam].get("clap_desc", fams[fam]["desc"]) # a take scored by another rubric is not comparable: left out
|
|
255
|
+
prior = [{**r, "prior": True} for r in rec["takes"].get(m, {}).get(fam, [])
|
|
256
|
+
if r["seed"] not in seeds and r.get("rubric", fams[fam]["desc"]) == rubric]
|
|
257
|
+
pools[m] = prior + fresh
|
|
258
|
+
order(pools[m])
|
|
259
|
+
row: dict = {m: ({"rank": rs[0]["rank"], "p": rs[0]["p"], "seed": rs[0]["seed"], "best_match": rs[0]["best_match"]} if rs else None)
|
|
260
|
+
for m, rs in pools.items()}
|
|
261
|
+
cands = [(rs[0]["rank"], -rs[0]["p"], m) for m, rs in pools.items() if rs]
|
|
262
|
+
rank, _, win = min(cands)
|
|
263
|
+
row["winner"] = win if rank <= SHIP_MAX_RANK else "synth"
|
|
264
|
+
chosen: list[dict] = []
|
|
265
|
+
if rank <= SHIP_MAX_RANK:
|
|
266
|
+
rs = pools[win]
|
|
267
|
+
chosen = rs[:1] if kind != "oneshot" else [r for r in rs[:2] if r is rs[0] or r["rank"] <= 3]
|
|
268
|
+
row["round"] = "b3"
|
|
269
|
+
old_files = [f for f, p in prov.items() if p["file"].startswith(f"{fam}-") and
|
|
270
|
+
(man["oneshots"].get(fam, {}).get("files", []).count(f) or man["beds"].get(fam.split("-", 1)[1], {}).get("file") == f)]
|
|
271
|
+
keep: list[tuple[dict, str | None]] = []
|
|
272
|
+
for r in chosen:
|
|
273
|
+
if r.get("prior"):
|
|
274
|
+
f = next((f for f in old_files if f.startswith(f"{fam}-{r['seed']}-") and prov[f]["set_of_origin"] == SET_OF[r["model"]]), None)
|
|
275
|
+
if f is None:
|
|
276
|
+
print(f" {fam}: {r['model']} seed {r['seed']} (first round) was never shipped and its wav is gone: skipped")
|
|
277
|
+
continue
|
|
278
|
+
keep.append((r, f))
|
|
279
|
+
else:
|
|
280
|
+
keep.append((r, None))
|
|
281
|
+
row["ships"] = [f"{r['model']} seed {r['seed']} rank {r['rank']} p {r['p']}" + (" (kept)" if f else " (new)") for r, f in keep]
|
|
282
|
+
print(f"{fam}: winner {row['winner']} " + "; ".join(row["ships"]) + f" (was {rec['families'].get(fam, {}).get('winner')})")
|
|
283
|
+
rec["families"][fam] = row
|
|
284
|
+
for m in MODELS:
|
|
285
|
+
rec["takes"].setdefault(m, {})[fam] = [{k: v for k, v in r.items() if k != "wav"} for r in pools[m]]
|
|
286
|
+
if dry_run:
|
|
287
|
+
continue
|
|
288
|
+
kept = {f for _, f in keep if f}
|
|
289
|
+
for f in old_files:
|
|
290
|
+
if f not in kept:
|
|
291
|
+
(BEST / f).unlink(missing_ok=True)
|
|
292
|
+
man["provenance"] = [p for p in man["provenance"] if not (p["file"] in old_files and p["file"] not in kept)]
|
|
293
|
+
files: list[str] = []
|
|
294
|
+
for r, f in keep:
|
|
295
|
+
if f is None:
|
|
296
|
+
f, _, bed = ship_take(r, fam, kind)
|
|
297
|
+
if kind == "bed":
|
|
298
|
+
man["beds"][fam.split("-", 1)[1]] = bed
|
|
299
|
+
man["provenance"].append({"file": f, "model": r["side"]["repo"], "code": r["side"]["code_commit"], "prompt": r["side"]["prompt"],
|
|
300
|
+
"seed": r["seed"], "steps": r["side"]["steps"], "clap_p": r["p"], "clap_rank": r["rank"],
|
|
301
|
+
"source": MODELS[r["model"]], "set_of_origin": SET_OF[r["model"]], "round": "nalati"})
|
|
302
|
+
files.append(f)
|
|
303
|
+
if kind == "oneshot":
|
|
304
|
+
if files:
|
|
305
|
+
man["oneshots"][fam] = {"files": files, "gain": man["oneshots"].get(fam, {}).get("gain", 1.0), "shard": "nalati"}
|
|
306
|
+
else:
|
|
307
|
+
man["oneshots"].pop(fam, None)
|
|
308
|
+
elif not files:
|
|
309
|
+
man["beds"].pop(fam.split("-", 1)[1], None)
|
|
310
|
+
keeps = set(man.get("synth_keeps", []))
|
|
311
|
+
man["synth_keeps"] = sorted(keeps - {fam} if files else keeps | {fam})
|
|
312
|
+
rec["wins"] = {k: sum(1 for t in rec["families"].values() if t["winner"] == k) for k in ("moss", "medium", "synth", "missing")}
|
|
313
|
+
(HERE / "sfx-nalati.json").write_text(json.dumps(rec, indent=2, ensure_ascii=False) + "\n")
|
|
314
|
+
if dry_run:
|
|
315
|
+
print(f"dry run: wins {rec['wins']}")
|
|
316
|
+
return
|
|
317
|
+
# a family the first round shipped but left in synth_keeps (the camp bed's re-roll): out
|
|
318
|
+
shipped = {k for k, v in man["oneshots"].items() if v.get("shard") == "nalati"} | {f"bed-{k}" for k, v in man["beds"].items() if v.get("shard") == "nalati"}
|
|
319
|
+
man["synth_keeps"] = sorted(set(man["synth_keeps"]) - shipped)
|
|
320
|
+
(BEST / "sfx.json").write_text(json.dumps(man, indent=2, ensure_ascii=False) + "\n")
|
|
321
|
+
total = sum((BEST / p["file"]).stat().st_size for p in man["provenance"] if p.get("round") == "nalati")
|
|
322
|
+
rec["bytes"] = total
|
|
323
|
+
(HERE / "sfx-nalati.json").write_text(json.dumps(rec, indent=2, ensure_ascii=False) + "\n")
|
|
324
|
+
bt = json.loads((HERE / "sfx-best.json").read_text())
|
|
325
|
+
bt["nalati"] = {"rule": rec["rule"], "wins": rec["wins"], "bytes": total, "families": rec["families"]}
|
|
326
|
+
(HERE / "sfx-best.json").write_text(json.dumps(bt, indent=2) + "\n")
|
|
327
|
+
print(f"nalati ({','.join(sorted(only))}): {total / 1e6:.2f} MB of Nalati files in best/, wins {rec['wins']}")
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
if __name__ == "__main__":
|
|
331
|
+
main()
|