@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,486 @@
|
|
|
1
|
+
"""NALATI-MERGE A3: the Nalati score - measure, rank, preview and build MiniMax Music 3 takes.
|
|
2
|
+
|
|
3
|
+
PY=~/ml/music/analysis/.venv/bin/python
|
|
4
|
+
$PY scripts/music/gen/own_score.py analyze <raw> [--set nalati|nine-dragon-stack]
|
|
5
|
+
$PY scripts/music/gen/own_score.py rank <raw> [--dry] # --dry: JSON only, no files or models
|
|
6
|
+
$PY scripts/music/gen/own_score.py build <raw> [--pick grass=minimax3-305 ...]
|
|
7
|
+
|
|
8
|
+
<raw>/<group>-<name>/minimax3-<seed>.wav + .json come from gen_minimax.py --jobs nalati-jobs.json (test/* = the six-take
|
|
9
|
+
instrument test, nalati/<slot> = the score). Nobody can listen from here, so the ranking is measurement (the user picks by ear
|
|
10
|
+
on the page; until he does, the game ships the rank-1 take of every slot):
|
|
11
|
+
kazakh CLAP (laion/clap-htsat-fused): the softmax share of four Kazakh-instrument SOUNDS (a plucked two-string lute, a
|
|
12
|
+
raspy bowed fiddle, a breathy wooden flute, throat singing) against six foils (orchestra, piano, acoustic guitar,
|
|
13
|
+
synths, a rock band, a singer with words)
|
|
14
|
+
groove htdemucs: drums + bass present across the take (the tension layer is exactly those stems)
|
|
15
|
+
seam the best bar-aligned loop seam (analyze.loop_seam)
|
|
16
|
+
clean no clipping, no gap > 2 s, full band
|
|
17
|
+
full full length, no fade-out
|
|
18
|
+
drone (night / King only, 25 %) CLAP's throat-singing share: the drone is the point of those cues
|
|
19
|
+
folk the total x (0.5 + 0.5 min(1, kazakh / 0.6)): an orchestral / rock-band drift is scaled down as a whole
|
|
20
|
+
voice the separated vocal stem's share: over 20 % disqualifies a take, EXCEPT in the night and the King's slots, where the
|
|
21
|
+
throat drone is wanted (the user, wave 6: the throat drone only in the night + boss cues) and only over 60 % does
|
|
22
|
+
Build (stems.py's recipe): htdemucs -> calm = mix - drums - bass/2, tension = drums + bass/2 (in the night / King slots the
|
|
23
|
+
voice stays in calm - it is the drone); beat grid, a downbeat loop <= MAX_LOOP_S, the seam crossfade, -18 LUFS, one limiter
|
|
24
|
+
curve for both stems; calm stereo AAC 96 kb/s, tension mono 64 kb/s; loop points re-measured on the decoded files. Stings are
|
|
25
|
+
cut from the grass theme (death = its last chord, chunk = its biggest downbeat swell, pickup = its brightest onset).
|
|
26
|
+
Writes public/assets/music/nalati/music.json (+ files) and scripts/music/gen/nalati-score.json (every take, every score, picks).
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
from __future__ import annotations
|
|
30
|
+
|
|
31
|
+
import argparse
|
|
32
|
+
import html
|
|
33
|
+
import json
|
|
34
|
+
import subprocess
|
|
35
|
+
import sys
|
|
36
|
+
import tempfile
|
|
37
|
+
from pathlib import Path
|
|
38
|
+
|
|
39
|
+
HERE = Path(__file__).resolve().parent
|
|
40
|
+
sys.path.insert(0, str(HERE))
|
|
41
|
+
from audio_jobs import read_score # noqa: E402
|
|
42
|
+
REPO = HERE.parents[2]
|
|
43
|
+
ART = REPO / "art/music/round-4-nalati"
|
|
44
|
+
OUT = REPO / "public/assets/music/nalati"
|
|
45
|
+
JOBS = json.loads((HERE / "nalati-jobs.json").read_text())
|
|
46
|
+
SLOTS = ("grass", "sky", "snow", "night", "storm", "king")
|
|
47
|
+
VOICE_OK = ("night", "king")
|
|
48
|
+
MAX_LOOP_S = 56.0
|
|
49
|
+
# CLAP does not know the instruments' names (dombra, kobyz, sybyzgy): a first pass with them heard "sybyzgy" in every take.
|
|
50
|
+
# So each is described by its sound, and the foils are the western timbres MiniMax drifts to.
|
|
51
|
+
INSTR = {
|
|
52
|
+
"dombra": "a plucked and strummed two-string folk lute",
|
|
53
|
+
"kobyz": "a bowed string fiddle with a scratchy raspy tone",
|
|
54
|
+
"sybyzgy": "a breathy wooden flute melody",
|
|
55
|
+
"throat": "throat singing, a deep growling overtone chant",
|
|
56
|
+
}
|
|
57
|
+
FOILS = ["orchestral strings and brass", "piano", "acoustic guitar", "electronic synthesizer music",
|
|
58
|
+
"a rock band with electric guitar and drums", "a person singing a melody with words"]
|
|
59
|
+
HEARD = {"dombra": "plucked lute", "kobyz": "bowed fiddle", "sybyzgy": "wooden flute", "throat": "throat singing"}
|
|
60
|
+
TEST_TARGET = {"dombra": ["dombra"], "kobyz": ["kobyz"], "sybyzgy": ["sybyzgy"], "throat": ["throat"],
|
|
61
|
+
"ensemble-day": ["dombra", "sybyzgy", "kobyz"], "ensemble-night": ["throat", "kobyz"]}
|
|
62
|
+
W_LOOP = {"kazakh": 0.35, "groove": 0.2, "seam": 0.2, "clean": 0.15, "full": 0.1}
|
|
63
|
+
# the night and the King: the throat drone is the point of them (wave 6), so it is scored on its own
|
|
64
|
+
W_DRONE = {"kazakh": 0.15, "drone": 0.25, "groove": 0.15, "seam": 0.2, "clean": 0.15, "full": 0.1}
|
|
65
|
+
SLOT_TITLE = {"grass": "Nalati Grasslands", "sky": "Sky Grassland", "snow": "Snow Lotus Valley", "night": "Night on the steppe",
|
|
66
|
+
"storm": "The storm (Jel Ata)", "king": "The Golden King"}
|
|
67
|
+
SLOT_NOTE = {"grass": "the green Kunes valley and the camp: the calm exploration theme",
|
|
68
|
+
"sky": "the golden bowl: the same theme, higher and wider", "snow": "the snow ring: the theme, cold and sparse",
|
|
69
|
+
"night": "every zone after dusk: the throat drone lives here", "storm": "a storm rolling in, and Jel Ata's fight",
|
|
70
|
+
"king": "the kurgan: a dirge that rises into battle (the tension stem is the battle)"}
|
|
71
|
+
SET = "nalati"
|
|
72
|
+
GROUP = "nalati"
|
|
73
|
+
METRIC = "kazakh"
|
|
74
|
+
PROB = "kazakh_prob"
|
|
75
|
+
STING_SLOT = "grass"
|
|
76
|
+
SCORE_FILE = HERE / "nalati-score.json"
|
|
77
|
+
BUILD_FILE = HERE / "nalati-score-build.json"
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def configure(name: str, art: Path | None = None) -> None:
|
|
81
|
+
"""Keep Nalati's defaults and its JSON schema; select Nine Dragon's instrument probes and destinations."""
|
|
82
|
+
global SET, GROUP, METRIC, PROB, STING_SLOT, SCORE_FILE, BUILD_FILE, ART, OUT, JOBS, SLOTS, VOICE_OK
|
|
83
|
+
global INSTR, HEARD, TEST_TARGET, W_LOOP, SLOT_TITLE, SLOT_NOTE
|
|
84
|
+
SET = name
|
|
85
|
+
if name == "nine-dragon-stack":
|
|
86
|
+
GROUP, METRIC, PROB, STING_SLOT = "nd", "instruments", "instrument_prob_total", "nd-market"
|
|
87
|
+
JOBS = read_score(HERE / "nd-score-jobs.json")
|
|
88
|
+
SLOTS = tuple(j["slot"] for j in JOBS["jobs"].values())
|
|
89
|
+
VOICE_OK = ()
|
|
90
|
+
INSTR = {"guzheng": "a plucked Chinese zither (guzheng)", "erhu": "a bowed two-string Chinese fiddle (erhu)",
|
|
91
|
+
"pad": "a soft analog synth pad"}
|
|
92
|
+
HEARD = {"guzheng": "guzheng", "erhu": "erhu", "pad": "analog pad"}
|
|
93
|
+
TEST_TARGET = {}
|
|
94
|
+
W_LOOP = {"instruments": 0.35, "groove": 0.2, "seam": 0.2, "clean": 0.15, "full": 0.1}
|
|
95
|
+
SLOT_TITLE = {"nd-market": "Neon night market", "nd-well": "The Well", "nd-fight": "The market rises"}
|
|
96
|
+
SLOT_NOTE = {"nd-market": "guzheng and erhu over a soft analog pad, rain-lit streets",
|
|
97
|
+
"nd-well": "erhu, a low drone and wind-chime colour in the deep shaft",
|
|
98
|
+
"nd-fight": "the market theme rising into a fight, drums and guzheng tremolo"}
|
|
99
|
+
ART = art or REPO / ("art/music/round-4-nalati" if name == "nalati" else f"art/music/round-1-{name}")
|
|
100
|
+
OUT = REPO / "public/assets/music" / name
|
|
101
|
+
stem = "nalati" if name == "nalati" else "nd"
|
|
102
|
+
SCORE_FILE, BUILD_FILE = HERE / f"{stem}-score.json", HERE / f"{stem}-score-build.json"
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def takes(raw: Path, folder: str) -> list[dict]:
|
|
106
|
+
out = []
|
|
107
|
+
for side_p in sorted((raw / folder).glob("minimax3-*.json")):
|
|
108
|
+
if side_p.name.endswith(".metrics.json"):
|
|
109
|
+
continue
|
|
110
|
+
mp = side_p.with_name(side_p.stem + ".metrics.json")
|
|
111
|
+
out.append({"id": side_p.stem, "folder": folder, "wav": str(side_p.with_suffix(".wav")), "side": json.loads(side_p.read_text()),
|
|
112
|
+
"metrics": json.loads(mp.read_text()) if mp.exists() else None})
|
|
113
|
+
return out
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def cmd_analyze(raw: Path, force: bool) -> None:
|
|
117
|
+
import librosa
|
|
118
|
+
import numpy as np
|
|
119
|
+
import soundfile as sf
|
|
120
|
+
import torch
|
|
121
|
+
from analyze import CLAP_DIR, Vocals, _tensor, analyze
|
|
122
|
+
from transformers import ClapModel, ClapProcessor
|
|
123
|
+
|
|
124
|
+
clap = ClapModel.from_pretrained(str(CLAP_DIR)).eval()
|
|
125
|
+
proc = ClapProcessor.from_pretrained(str(CLAP_DIR))
|
|
126
|
+
scale = float(clap.logit_scale_a.detach().exp())
|
|
127
|
+
names = list(INSTR)
|
|
128
|
+
texts = [INSTR[k] for k in names] + FOILS
|
|
129
|
+
with torch.no_grad():
|
|
130
|
+
te = torch.nn.functional.normalize(_tensor(clap.get_text_features(**proc(text=texts, return_tensors="pt", padding=True))), dim=-1)
|
|
131
|
+
vocals = Vocals()
|
|
132
|
+
for wav in sorted(raw.glob("*/minimax3-*.wav")):
|
|
133
|
+
out = wav.with_suffix(".metrics.json")
|
|
134
|
+
if out.exists() and not force:
|
|
135
|
+
continue
|
|
136
|
+
side = json.loads(wav.with_suffix(".json").read_text())
|
|
137
|
+
key = wav.parent.name.replace("-", "/", 1)
|
|
138
|
+
bpm = JOBS["jobs"].get(key, {}).get("bpm") or 100
|
|
139
|
+
m = analyze(wav, side, {"bpm": bpm}, None, vocals)
|
|
140
|
+
y, sr = sf.read(str(wav), always_2d=True)
|
|
141
|
+
y48 = librosa.resample(y.mean(1).astype(np.float32), orig_sr=sr, target_sr=48000)
|
|
142
|
+
seg = 48000 * 10
|
|
143
|
+
chunks = [y48[i:i + seg] for i in range(0, max(len(y48) - seg // 2, 1), seg)]
|
|
144
|
+
chunks = [c for c in chunks if np.sqrt((c ** 2).mean()) > 1e-3] or chunks[:1]
|
|
145
|
+
with torch.no_grad():
|
|
146
|
+
a = proc(audio=chunks, sampling_rate=48000, return_tensors="pt")
|
|
147
|
+
ae = torch.nn.functional.normalize(_tensor(clap.get_audio_features(**a)), dim=-1).mean(0, keepdim=True)
|
|
148
|
+
sims = (torch.nn.functional.normalize(ae, dim=-1) @ te.T)[0]
|
|
149
|
+
p = torch.softmax(sims * scale, 0).tolist()
|
|
150
|
+
m[METRIC] = {"instrument_prob": {k: round(p[i], 3) for i, k in enumerate(names)},
|
|
151
|
+
"foil_prob": {FOILS[i]: round(p[len(names) + i], 3) for i in range(len(FOILS))},
|
|
152
|
+
PROB: round(sum(p[: len(names)]), 3), "best_match": texts[int(sims.argmax())]}
|
|
153
|
+
out.write_text(json.dumps(m, indent=2))
|
|
154
|
+
print(f"{wav.parent.name}/{wav.name}: {METRIC} {m[METRIC][PROB]} {m[METRIC]['instrument_prob']} voice "
|
|
155
|
+
f"{m['vocals']['vocal_energy_share']} seam {m['loop'].get('score')} len {m['duration_s']}", flush=True)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def clean_part(m: dict) -> float:
|
|
159
|
+
c = 1.0
|
|
160
|
+
if m["clipping"]["clipped_frac"] > 1e-4:
|
|
161
|
+
c -= 0.5
|
|
162
|
+
if m["silence"]["longest_internal_gap_s"] > 2.0:
|
|
163
|
+
c -= 0.3
|
|
164
|
+
if m["spectrum"]["rolloff95_hz"] < 7000:
|
|
165
|
+
c -= 0.2
|
|
166
|
+
return max(c, 0.0)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def score(m: dict, slot: str) -> tuple[float, dict, str | None]:
|
|
170
|
+
v = m.get("vocals", {})
|
|
171
|
+
voice = v.get("vocal_energy_share", 0.0)
|
|
172
|
+
lim = 0.6 if slot in VOICE_OK else 0.2
|
|
173
|
+
if voice > lim:
|
|
174
|
+
return -1.0, {}, f"voice {voice * 100:.0f}% of the energy"
|
|
175
|
+
parts = {
|
|
176
|
+
METRIC: m.get(METRIC, {}).get(PROB, 0.0),
|
|
177
|
+
"groove": 0.5 * v.get("groove_active_frac", 0.0) + 0.5 * v.get("drums_active_frac", 0.0),
|
|
178
|
+
"seam": max(0.0, min(1.0, (m["loop"].get("score", -1) - 0.1) / 0.6)) if m["loop"].get("score", -1) > 0 else 0.0,
|
|
179
|
+
"clean": clean_part(m),
|
|
180
|
+
"full": max(0.0, min(1.0, (m["duration_s"] - m["silence"]["tail_silence_s"] - 45) / 20)),
|
|
181
|
+
}
|
|
182
|
+
parts["drone"] = m.get(METRIC, {}).get("instrument_prob", {}).get("throat", 0.0)
|
|
183
|
+
pen = 0.0 if slot in VOICE_OK else 0.5 * max(0.0, voice - 0.03)
|
|
184
|
+
w = W_DRONE if slot in VOICE_OK else W_LOOP
|
|
185
|
+
# a take that does not sound Kazakh is down-weighted as a whole (the orchestral / rock-band drift): x0.5 at 0, x1 from 0.6
|
|
186
|
+
folk = 0.5 + 0.5 * min(1.0, parts[METRIC] / 0.6)
|
|
187
|
+
return round(sum(w[k] * parts[k] for k in w) * folk - pen, 3), {k: round(x, 3) for k, x in parts.items()}, None
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def preview(wav: Path, m: dict, dest: Path) -> int:
|
|
191
|
+
"""AAC 64 kb/s stereo, the first 60 s, gain-matched to -18 LUFS (the page's players)"""
|
|
192
|
+
dest.parent.mkdir(parents=True, exist_ok=True)
|
|
193
|
+
gain = min(-18.0 - (m["loudness"]["lufs"] or -18.0), -1.0 - (m["loudness"]["true_peak_dbfs"] or -1.0))
|
|
194
|
+
codec = ["-c:a", "aac", "-b:a", "64k", "-movflags", "+faststart"] if SET == "nalati" else ["-c:a", "libmp3lame", "-b:a", "96k"]
|
|
195
|
+
subprocess.run(["ffmpeg", "-y", "-loglevel", "error", "-i", str(wav), "-t", "60", "-af", f"volume={gain:.2f}dB,afade=t=out:st=58:d=2",
|
|
196
|
+
*codec, str(dest)], check=True)
|
|
197
|
+
return dest.stat().st_size
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def cmd_rank(raw: Path, verdict: dict, dry: bool = False) -> dict:
|
|
201
|
+
ext = "m4a" if SET == "nalati" else "mp3"
|
|
202
|
+
if not dry:
|
|
203
|
+
for old in ART.glob(f"*/*.{ext}"): # this folder holds only this script's output
|
|
204
|
+
old.unlink()
|
|
205
|
+
|
|
206
|
+
def preview_size(t: dict) -> int:
|
|
207
|
+
dest = ART / t["m4a"]
|
|
208
|
+
if dry:
|
|
209
|
+
if not dest.exists():
|
|
210
|
+
raise SystemExit(f"--dry needs the existing preview to preserve bytes: {dest}")
|
|
211
|
+
return dest.stat().st_size
|
|
212
|
+
return preview(Path(t["wav"]), t["metrics"], dest)
|
|
213
|
+
rec: dict = {"test": {}, "slots": {}, "weights": W_LOOP, "voice": {"disqualify": 0.2, "disqualify_night_king": 0.6}}
|
|
214
|
+
for name, targets in TEST_TARGET.items():
|
|
215
|
+
for t in takes(raw, f"test-{name}"):
|
|
216
|
+
if t["metrics"] is None:
|
|
217
|
+
continue
|
|
218
|
+
k = t["metrics"].get("kazakh", {})
|
|
219
|
+
t["target_prob"] = round(sum(k.get("instrument_prob", {}).get(x, 0.0) for x in targets), 3)
|
|
220
|
+
t["m4a"] = f"test/{name}-{t['side']['seed']}.m4a"
|
|
221
|
+
t["bytes"] = preview_size(t)
|
|
222
|
+
rec["test"].setdefault(name, []).append(t)
|
|
223
|
+
for slot in SLOTS:
|
|
224
|
+
ts = [t for t in takes(raw, f"{GROUP}-{slot}") if t["metrics"] is not None]
|
|
225
|
+
for t in ts:
|
|
226
|
+
t["score"], t["parts"], t["dq"] = score(t["metrics"], slot)
|
|
227
|
+
ts.sort(key=lambda t: -t["score"])
|
|
228
|
+
ok = [t for t in ts if t["dq"] is None]
|
|
229
|
+
for i, t in enumerate(ok[:3]):
|
|
230
|
+
t["rank"] = i + 1
|
|
231
|
+
t["m4a"] = f"{slot}/{slot}-{t['side']['seed']}.{ext}"
|
|
232
|
+
t["bytes"] = preview_size(t)
|
|
233
|
+
rec["slots"][slot] = ts
|
|
234
|
+
print(f"{slot:6s} {len(ts)} takes, {len(ok)} ok, ranked {[t['id'] for t in ok[:3]]}", file=sys.stderr if dry else sys.stdout, flush=True)
|
|
235
|
+
slim = lambda t: {k: v for k, v in t.items() if k not in ("wav",)} # noqa: E731
|
|
236
|
+
page_dir = ART.relative_to(REPO) if ART.is_relative_to(REPO) else ART
|
|
237
|
+
rule = "rank 1 of each slot ships until the user picks (art/music/round-4-nalati/index.html)" if SET == "nalati" else f"rank 1 of each slot ships until the user picks ({page_dir}/index.html)"
|
|
238
|
+
doc = {"rule": rule, "weights": W_LOOP,
|
|
239
|
+
"verdict": verdict, "test": {k: [slim(t) for t in v] for k, v in rec["test"].items()},
|
|
240
|
+
"slots": {s: {"pick": next((t["id"] for t in v if t.get("rank") == 1), None), "takes": [slim(t) for t in v]} for s, v in rec["slots"].items()}}
|
|
241
|
+
if dry:
|
|
242
|
+
print(json.dumps(doc, indent=2, ensure_ascii=False))
|
|
243
|
+
return doc
|
|
244
|
+
SCORE_FILE.write_text(json.dumps(doc, indent=2, ensure_ascii=False) + "\n")
|
|
245
|
+
ART.mkdir(parents=True, exist_ok=True)
|
|
246
|
+
(ART / "index.html").write_text(page(rec, verdict))
|
|
247
|
+
total = sum(p.stat().st_size for p in ART.glob(f"*/*.{ext}"))
|
|
248
|
+
print(f"previews {total / 1e6:.1f} MB -> {ART}")
|
|
249
|
+
return doc
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
# ---------------------------------------------------------------- page
|
|
253
|
+
|
|
254
|
+
def esc(x: object) -> str:
|
|
255
|
+
return html.escape(str(x), quote=True)
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def chips(t: dict, slot: str | None) -> str:
|
|
259
|
+
from build_page import chip
|
|
260
|
+
|
|
261
|
+
m, v, k = t["metrics"], t["metrics"].get("vocals", {}), t["metrics"].get(METRIC, {})
|
|
262
|
+
kp = k.get(PROB, 0.0)
|
|
263
|
+
ip = k.get("instrument_prob", {})
|
|
264
|
+
out = [chip("length", f"{m['duration_s']:.0f} s"),
|
|
265
|
+
chip("Kazakh instruments" if SET == "nalati" else "guzheng / erhu / pad", f"{kp * 100:.0f}%", "good" if kp >= 0.6 else ("warn" if kp < 0.35 else "")),
|
|
266
|
+
chip("heard as", ", ".join(f"{HEARD[n]} {ip.get(n, 0) * 100:.0f}%" for n in sorted(ip, key=lambda n: -ip[n])[:2])),
|
|
267
|
+
chip("tempo", f"{m['tempo']['estimated_bpm']:.0f} bpm"),
|
|
268
|
+
chip("loop seam", f"{m['loop'].get('score', -1):.2f}", "" if m["loop"].get("score", -1) > 0.35 else "warn")]
|
|
269
|
+
if "target_prob" in t:
|
|
270
|
+
tp = t["target_prob"]
|
|
271
|
+
out.insert(1, chip("the asked instrument", f"{tp * 100:.0f}%", "good" if tp >= 0.5 else ("warn" if tp < 0.25 else "")))
|
|
272
|
+
share = v.get("vocal_energy_share", 0)
|
|
273
|
+
wanted = slot in VOICE_OK or (slot is None and "throat" in t["folder"] or "night" in t["folder"])
|
|
274
|
+
out.append(chip("voice", f"{share * 100:.1f}%", "good" if wanted and share > 0.05 else ("bad" if share > 0.10 and not wanted else "")))
|
|
275
|
+
if slot is not None:
|
|
276
|
+
g = v.get("drums_active_frac", 0)
|
|
277
|
+
out.append(chip("groove", f"drums in {g * 100:.0f}%", "good" if g >= 0.7 else ("warn" if g < 0.4 else "")))
|
|
278
|
+
return "".join(out)
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def card(t: dict, label: str, slot: str | None, rank: int | None) -> str:
|
|
282
|
+
sc = f'<span class="score" title="measured, not a verdict">{t["score"]:.2f}</span>' if "score" in t else ""
|
|
283
|
+
return f"""
|
|
284
|
+
<article class="take">
|
|
285
|
+
<div class="take-head">
|
|
286
|
+
<span class="rank">{rank if rank is not None else '·'}</span>
|
|
287
|
+
<div><h3>{esc(label)} <span class="seed">seed {esc(t['side']['seed'])}</span></h3>
|
|
288
|
+
<p class="meta">MiniMax Music 3 · {esc(t['side']['gen_time_s'])} s to render</p></div>
|
|
289
|
+
{sc}
|
|
290
|
+
</div>
|
|
291
|
+
<audio controls preload="none" src="{esc(t['m4a'])}"></audio>
|
|
292
|
+
<div class="chips">{chips(t, slot)}</div>
|
|
293
|
+
</article>"""
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
def page(rec: dict, verdict: dict) -> str:
|
|
297
|
+
from build_page import PAGE_CSS
|
|
298
|
+
|
|
299
|
+
test_names = {"dombra": "Dombra (solo)", "kobyz": "Kobyz (solo)", "sybyzgy": "Sybyzgy (solo)", "throat": "Throat-sung drone",
|
|
300
|
+
"ensemble-day": "Ensemble, day", "ensemble-night": "Ensemble, night (drone + kobyz)"}
|
|
301
|
+
tests = "".join(card(t, test_names[n], None, None) for n, ts in rec["test"].items() for t in ts)
|
|
302
|
+
vt = "".join(f"<li><b>{esc(k)}</b>: {esc(v)}</li>" for k, v in verdict.get("instruments", {}).items())
|
|
303
|
+
secs = []
|
|
304
|
+
for slot in SLOTS:
|
|
305
|
+
ts = [t for t in rec["slots"].get(slot, []) if t.get("rank")]
|
|
306
|
+
n, dq = len(rec["slots"].get(slot, [])), sum(1 for t in rec["slots"].get(slot, []) if t.get("dq"))
|
|
307
|
+
cards = "".join(card(t, "Pick (ships now)" if t["rank"] == 1 else "Alternate", slot, t["rank"]) for t in sorted(ts, key=lambda t: t["rank"]))
|
|
308
|
+
prompt = JOBS["jobs"].get(f"{GROUP}/{slot}", {}).get("prompt", "")
|
|
309
|
+
secs.append(f"""
|
|
310
|
+
<section class="style" id="{slot}">
|
|
311
|
+
<header class="style-head"><h2>{esc(SLOT_TITLE[slot])}</h2><p class="ref">{esc(SLOT_NOTE[slot])}</p>
|
|
312
|
+
<p class="spec"><span>{n} takes</span><span>{dq} out for a voice</span><span>pick first</span></p></header>
|
|
313
|
+
<div class="takes">{cards or '<p class="empty">Not rendered yet.</p>'}</div>
|
|
314
|
+
<details><summary>Prompt</summary><p class="prompt">{esc(prompt)}</p></details>
|
|
315
|
+
</section>""")
|
|
316
|
+
nav = "".join(f'<a href="#{s}">{esc(SLOT_TITLE[s])}</a>' for s in SLOTS)
|
|
317
|
+
if SET != "nalati":
|
|
318
|
+
return f'''<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
|
319
|
+
<title>Nine Dragon score takes</title><style>{PAGE_CSS}</style><div class="wrap"><header><h1>Nine Dragon score takes</h1>
|
|
320
|
+
<p class="lede">Guzheng and erhu over a soft analog pad, rising in fights. These are ranked raw takes;
|
|
321
|
+
nd_page.py builds the listening board with the shipped calm and tension stems, stings and both SFX engines.</p><nav>{nav}</nav></header>{''.join(secs)}</div>'''
|
|
322
|
+
return f"""<title>Nalati Score Round 4</title>
|
|
323
|
+
<meta name="description" content="The Nalati Grasslands score: a MiniMax Music 3 instrument test (dombra, kobyz, sybyzgy, throat drone) and the takes for each slot, for the user's pick.">
|
|
324
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
325
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
326
|
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Newsreader:opsz,wght@6..72,500;6..72,600&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap">
|
|
327
|
+
<style>
|
|
328
|
+
{PAGE_CSS}
|
|
329
|
+
.verdict {{ margin-top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }}
|
|
330
|
+
.verdict p, .verdict li {{ max-width: 75ch; }}
|
|
331
|
+
</style>
|
|
332
|
+
<div class="wrap">
|
|
333
|
+
<header>
|
|
334
|
+
<h1>The Nalati score, round 4</h1>
|
|
335
|
+
<p class="lede">One Kazakh-folk score for the Nalati Grasslands, whatever the music-style setting. First, a six-take test of whether MiniMax Music 3 can play the steppe's instruments. Then the score itself: a theme for each of the three zones, the night, the storm and the Golden King. Each slot has up to three takes, ranked by measurement because nobody could listen while ranking. Until you pick, the game plays each slot's first take. To choose another, name the slot and its seed.</p>
|
|
336
|
+
<div class="brief"><p>“Wonder first, adventure second: a dombra's gallop under an open sky; the throat drone only at night and at the King's barrow.”</p><small>players gain-matched to -18 LUFS · the first 60 s of each take · in the game every theme loops as two layers: calm alone, plus its drums + bass when danger is near</small></div>
|
|
337
|
+
<nav class="jump"><a href="#test">Instrument test</a>{nav}</nav>
|
|
338
|
+
</header>
|
|
339
|
+
<section class="style" id="test">
|
|
340
|
+
<header class="style-head"><h2>Instrument test</h2><p class="ref">Can MiniMax play a dombra, a kobyz, a sybyzgy and a throat-sung drone convincingly?</p></header>
|
|
341
|
+
<div class="verdict"><p><b>Verdict (by measurement; your ear decides):</b> {esc(verdict.get('summary', 'pending'))}</p><ul>{vt}</ul></div>
|
|
342
|
+
<div class="takes">{tests or '<p class="empty">Not rendered yet.</p>'}</div>
|
|
343
|
+
</section>
|
|
344
|
+
{''.join(secs)}
|
|
345
|
+
<section class="notes">
|
|
346
|
+
<h2>How the takes were ranked</h2>
|
|
347
|
+
<p>Kazakh instruments {int(W_LOOP['kazakh'] * 100)}%: the share CLAP gives the sounds of four Kazakh instruments (a plucked two-string lute, a raspy bowed fiddle, a breathy wooden flute, throat singing) against six foils (an orchestra, piano, acoustic guitar, synths, a rock band, a singer with words). CLAP does not know the instruments by name, so each is described by its sound. Groove {int(W_LOOP['groove'] * 100)}%: drums and bass across the take (htdemucs), because the game's tension layer is exactly those stems. Loop seam {int(W_LOOP['seam'] * 100)}%, clean audio {int(W_LOOP['clean'] * 100)}%, full length with no fade-out {int(W_LOOP['full'] * 100)}%. In the night and the King's slots the throat drone is scored on its own (25%, Kazakh sound 15%, groove 15%). A take that does not sound Kazakh is scaled down as a whole: by half when CLAP hears no Kazakh instrument at all, not at all from 60%. A take whose separated vocal stem holds over 20% of the energy is out, except in the night and the King's slots, where the throat drone is wanted; there the limit is 60%.</p>
|
|
348
|
+
</section>
|
|
349
|
+
</div>
|
|
350
|
+
"""
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
# ---------------------------------------------------------------- build
|
|
354
|
+
|
|
355
|
+
def cmd_build(raw: Path, picks: dict[str, str]) -> None:
|
|
356
|
+
from stems import CALM_LUFS, LICENCE, PEAK_DB, STING_LUFS, _fade, decode_offset, downbeat, encode, find_loop, grid, limiter, lufs, seam, separate, shipped_name
|
|
357
|
+
|
|
358
|
+
import librosa
|
|
359
|
+
import numpy as np
|
|
360
|
+
import soundfile as sf
|
|
361
|
+
|
|
362
|
+
doc = json.loads(SCORE_FILE.read_text())
|
|
363
|
+
OUT.mkdir(parents=True, exist_ok=True)
|
|
364
|
+
for old in OUT.glob("*.m4a"): # this folder holds only this script's output
|
|
365
|
+
old.unlink()
|
|
366
|
+
tmpd = Path(tempfile.mkdtemp())
|
|
367
|
+
man: dict = {"style": SET, "model": "MiniMax-Music3", "credit": "Music: MiniMax-Music3", "slots": {}, "stings": {}, "provenance": []}
|
|
368
|
+
report: dict = {"slots": {}}
|
|
369
|
+
total, grass = 0, None
|
|
370
|
+
for slot in SLOTS:
|
|
371
|
+
pid = picks.get(slot) or doc["slots"].get(slot, {}).get("pick")
|
|
372
|
+
if pid is None:
|
|
373
|
+
print(f"{slot}: no usable take - the chain falls back in the game", flush=True)
|
|
374
|
+
continue
|
|
375
|
+
take = next(t for t in doc["slots"][slot]["takes"] if t["id"] == pid)
|
|
376
|
+
x, sr = sf.read(str(raw / f"{GROUP}-{slot}" / f"{pid}.wav"), always_2d=True)
|
|
377
|
+
x = x.T.astype(np.float64)
|
|
378
|
+
g = grid(x, sr)
|
|
379
|
+
st = separate(x, sr)
|
|
380
|
+
db = downbeat(st["drums"] + st["bass"], sr, g["beats"])
|
|
381
|
+
loop = find_loop(x, sr, g["beats"], db, MAX_LOOP_S)
|
|
382
|
+
bar = (loop["loopEnd"] - loop["loopStart"]) / loop["bars"]
|
|
383
|
+
resid = x - sum(st.values())
|
|
384
|
+
voice = float((st["vocals"] ** 2).sum() / ((x ** 2).sum() + 1e-12))
|
|
385
|
+
tension = st["drums"] + 0.5 * st["bass"]
|
|
386
|
+
keep_voice = slot in VOICE_OK or voice <= 0.03 # the drone is the point of the night / King cues
|
|
387
|
+
calm = x - tension if keep_voice else st["other"] + resid + 0.5 * st["bass"]
|
|
388
|
+
calm_f, _ = seam(calm, sr, loop, bar)
|
|
389
|
+
ten_f, _ = seam(tension, sr, loop, bar)
|
|
390
|
+
L, _ = lufs(calm_f, sr)
|
|
391
|
+
k = 10 ** ((CALM_LUFS - L) / 20)
|
|
392
|
+
r = np.minimum(limiter((calm_f + ten_f) * k, sr, PEAK_DB), limiter(calm_f * k, sr, PEAK_DB))[None]
|
|
393
|
+
calm_o, ten_o = calm_f * k * r, ten_f * k * r
|
|
394
|
+
encode(calm_o, sr, tmpd / "c.m4a")
|
|
395
|
+
encode(ten_o, sr, tmpd / "t.m4a", mono=True)
|
|
396
|
+
lag_c, len_c = decode_offset(tmpd / "c.m4a", calm_o, sr)
|
|
397
|
+
lag_t, len_t = decode_offset(tmpd / "t.m4a", ten_o, sr)
|
|
398
|
+
assert abs(len_c - len_t) < 0.05 and abs(lag_c - lag_t) < 0.002, f"{slot}: stems decode apart"
|
|
399
|
+
name = f"steppe-{slot}" if SET == "nalati" else slot
|
|
400
|
+
cn, tn = shipped_name(OUT, tmpd / "c.m4a", f"{name}-calm"), shipped_name(OUT, tmpd / "t.m4a", f"{name}-tension")
|
|
401
|
+
nc, nt = (OUT / cn).stat().st_size, (OUT / tn).stat().st_size
|
|
402
|
+
total += nc + nt
|
|
403
|
+
man["slots"][name] = {"calm": cn, "tension": tn, "bpm": loop["bpm"], "beatsPerBar": 4, "loopStart": round(loop["loopStart"] + lag_c, 4),
|
|
404
|
+
"loopEnd": round(loop["loopEnd"] + lag_c, 4), "duration": round(min(len_c, len_t), 4)}
|
|
405
|
+
assert loop["loopEnd"] + lag_c <= min(len_c, len_t)
|
|
406
|
+
side = take["side"]
|
|
407
|
+
for f, part in ((cn, "calm: mix - drums - bass/2" + (" (the voice kept: the drone)" if slot in VOICE_OK else "")), (tn, "tension: drums + bass/2 (htdemucs), mono")):
|
|
408
|
+
man["provenance"].append({"file": f, "model": "MiniMaxAI/MiniMax-Music3", "diffusers": "0.40.0", "prompt": side["prompt"], "lyrics": side["lyrics"],
|
|
409
|
+
"seed": side["seed"], "steps": side["steps"], "licence": LICENCE, "take": pid, "stem": part})
|
|
410
|
+
report["slots"][slot] = {"take": pid, "loop": loop, "voice_share": round(voice, 4), "bytes": {"calm": nc, "tension": nt}}
|
|
411
|
+
if slot == STING_SLOT:
|
|
412
|
+
grass = (x, loop, take, sr)
|
|
413
|
+
print(f"{slot}: {pid} bpm {loop['bpm']:.1f} loop {loop['loopStart']:.2f}-{loop['loopEnd']:.2f} ({loop['bars']} bars) {(nc + nt) / 1e6:.2f} MB", flush=True)
|
|
414
|
+
if grass is not None: # stings cut from the grass theme (the score's own instruments)
|
|
415
|
+
x, loop, take, sr = grass
|
|
416
|
+
env = np.abs(x).max(0)
|
|
417
|
+
last = int(np.where(env > env.max() * 10 ** (-40 / 20))[0][-1])
|
|
418
|
+
cuts = {"death": (_fade(x[:, max(0, last - int(4.5 * sr)):last], sr, 0.35, 0.6), "its last 4.5 s")}
|
|
419
|
+
y = librosa.resample(x.mean(0), orig_sr=sr, target_sr=22050)
|
|
420
|
+
rms = librosa.feature.rms(y=y, hop_length=512)[0]
|
|
421
|
+
fps = 22050 / 512
|
|
422
|
+
bar = (loop["loopEnd"] - loop["loopStart"]) / loop["bars"]
|
|
423
|
+
best, tb, t = -1.0, 1.0, loop["loopStart"] % bar
|
|
424
|
+
while t + 3.5 < x.shape[1] / sr - 5:
|
|
425
|
+
i = int(t * fps)
|
|
426
|
+
pre = rms[max(0, i - int(bar * fps)):i].mean() if i > 0 else 0.0
|
|
427
|
+
rise = rms[i:i + int(bar * fps)].mean() / (pre + 1e-6)
|
|
428
|
+
if t > 2 and rise > best:
|
|
429
|
+
best, tb = rise, t
|
|
430
|
+
t += bar
|
|
431
|
+
a = int(max(0.0, tb - 0.25) * sr)
|
|
432
|
+
cuts["chunk"] = (_fade(x[:, a:a + int(3.5 * sr)], sr, 0.25, 1.0), f"a {best:.1f}x swell at {tb:.1f} s")
|
|
433
|
+
on = librosa.onset.onset_strength(y=y, sr=22050)
|
|
434
|
+
cen = librosa.feature.spectral_centroid(y=y, sr=22050)[0][: len(on)]
|
|
435
|
+
sc = on[: len(cen)] * cen
|
|
436
|
+
sc[: int(3 * fps)] = 0
|
|
437
|
+
sc[-int(4 * fps):] = 0
|
|
438
|
+
a = max(0, int((int(np.argmax(sc)) / fps - 0.03) * sr))
|
|
439
|
+
cuts["pickup"] = (_fade(x[:, a:a + int(2.0 * sr)], sr, 0.01, 0.9), f"its brightest onset at {a / sr:.1f} s")
|
|
440
|
+
for sting, (y2, why) in cuts.items():
|
|
441
|
+
L, _ = lufs(y2, sr)
|
|
442
|
+
k = 10 ** ((STING_LUFS - L) / 20)
|
|
443
|
+
y2 = y2 * k * limiter(y2 * k, sr, PEAK_DB - 1.0)[None]
|
|
444
|
+
encode(y2, sr, tmpd / "s.m4a")
|
|
445
|
+
name = shipped_name(OUT, tmpd / "s.m4a", f"sting-{sting}")
|
|
446
|
+
total += (OUT / name).stat().st_size
|
|
447
|
+
man["stings"][sting] = name
|
|
448
|
+
man["provenance"].append({"file": name, "model": "MiniMaxAI/MiniMax-Music3", "prompt": take["side"]["prompt"], "seed": take["side"]["seed"],
|
|
449
|
+
"licence": LICENCE, "take": take["id"], "cut_from": f"{STING_SLOT}: {why}"})
|
|
450
|
+
(OUT / "music.json").write_text(json.dumps(man, indent=2, ensure_ascii=False) + "\n")
|
|
451
|
+
report["total_bytes"] = total
|
|
452
|
+
BUILD_FILE.write_text(json.dumps(report, indent=2, default=float) + "\n")
|
|
453
|
+
print(f"{SET}: {total / 1e6:.2f} MB -> {OUT}")
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
def main() -> None:
|
|
457
|
+
ap = argparse.ArgumentParser()
|
|
458
|
+
ap.add_argument("cmd", choices=["analyze", "rank", "build", "list"])
|
|
459
|
+
ap.add_argument("raw", nargs="?")
|
|
460
|
+
ap.add_argument("--set", choices=["nalati", "nine-dragon-stack"], default="nalati")
|
|
461
|
+
ap.add_argument("--art", type=Path, help="override the listening-page folder (default keeps Nalati round 4)")
|
|
462
|
+
ap.add_argument("--dry", action="store_true", help="rank only: reproduce decision JSON using existing preview sizes, write nothing")
|
|
463
|
+
ap.add_argument("--force", action="store_true")
|
|
464
|
+
ap.add_argument("--verdict", default=None, help="a JSON file: {summary, instruments: {name: text}} for the page")
|
|
465
|
+
ap.add_argument("--pick", nargs="*", default=[], help="slot=take-id overrides (the user's picks)")
|
|
466
|
+
a = ap.parse_args()
|
|
467
|
+
configure(a.set, a.art)
|
|
468
|
+
if a.cmd == "list":
|
|
469
|
+
read_score(HERE / ("nalati-jobs.json" if a.set == "nalati" else "nd-score-jobs.json"))
|
|
470
|
+
print(json.dumps(JOBS, indent=2, ensure_ascii=False))
|
|
471
|
+
return
|
|
472
|
+
if a.raw is None:
|
|
473
|
+
ap.error("raw is required for analyze, rank and build")
|
|
474
|
+
if a.dry and a.cmd != "rank":
|
|
475
|
+
ap.error("--dry is supported by rank only (analyze and build load models)")
|
|
476
|
+
raw = Path(a.raw)
|
|
477
|
+
if a.cmd == "analyze":
|
|
478
|
+
cmd_analyze(raw, a.force)
|
|
479
|
+
elif a.cmd == "rank":
|
|
480
|
+
cmd_rank(raw, json.loads(Path(a.verdict).read_text()) if a.verdict else {}, a.dry)
|
|
481
|
+
else:
|
|
482
|
+
cmd_build(raw, dict(p.split("=", 1) for p in a.pick))
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
if __name__ == "__main__":
|
|
486
|
+
main()
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_doc": "PINE-HOLLOW-REMASTER PH-A1 (PH-U12): Pine Hollow's new MiniMax Music 3 slots, same format as v3-jobs.json (gen_minimax.py --jobs ph-jobs.json --keys <style>/<slot>). Theme 1 (v3 'pine') is kept as it is. night = calm-night (eerie folklore, lantern-lit forest) with a soft pulse from bar 2 so demucs can lift a tension layer; boss = the Antler King, one take cut into 3 phase intensities by stems.py --set pine-hollow (I the Warden = the take minus drums and most of the bass, II Lanterns Fall = + the bass, III the Last Light = + the drums); dawn = a full dawn piece the reward sting is cut from (its biggest swell into the resolve). BPM / key are requests (MiniMax ignores them); the grid comes from beat-tracking.",
|
|
3
|
+
"lyrics": {
|
|
4
|
+
"loop": "[Intro]\n[Instrumental]\n[Instrumental]\n[Solo]\n[Instrumental]",
|
|
5
|
+
"title": "[Intro]\n[Instrumental]\n[Solo]\n[Instrumental]\n[Outro]"
|
|
6
|
+
},
|
|
7
|
+
"jobs": {
|
|
8
|
+
"piano/night": {"style": "piano", "slot": "night", "duration": 75, "lyrics": "loop", "bpm": 76,
|
|
9
|
+
"prompt": "Genre: video game soundtrack, dark ambient piano with a slow, soft pulse. BPM: 76. Key: D minor. Instrumental only, no vocals, no choir. Setting: Pine Hollow at night, an eerie folklore forest - lanterns glowing between black pines, fog on the ground, something old watching from the trees; hushed and unsettling, never scary. Arrangement: a sparse, haunting grand-piano melody in the low-middle register with long rests, over a cold string drone and a faint music-box shimmer; a warm upright bass and a soft, steady heartbeat pulse of felt kick, brushed snare and low tom run under the whole piece from the second bar to the end. No fade-out: the last bar is as full as the rest. Production: close felt piano, dark wooden-room reverb."},
|
|
10
|
+
"orchestral/night": {"style": "orchestral", "slot": "night", "duration": 75, "lyrics": "loop", "bpm": 76,
|
|
11
|
+
"prompt": "Genre: dark orchestral video game soundtrack, eerie folklore, in the spirit of Ori and the Blind Forest's darker cues. BPM: 76. Key: D minor. Instrumental only, no vocals, no choir. Setting: Pine Hollow at night - lanterns glowing between black pines, fog on the ground, an ancient guardian stirring in the old-growth; hushed and unsettling, never scary. Arrangement: a lonely alto flute and solo viola melody over sul tasto string harmonics and a slow harp ostinato; pizzicato basses and cellos walk underneath, and a soft, steady pulse of frame drum, low toms and muffled timpani runs under the whole piece from the second bar to the end. No fade-out: the last bar is as full as the rest. Production: dark concert-hall reverb."},
|
|
12
|
+
"folk/night": {"style": "folk", "slot": "night", "duration": 75, "lyrics": "loop", "bpm": 76,
|
|
13
|
+
"prompt": "Genre: dark folk video game soundtrack, eerie folklore, acoustic. BPM: 76. Key: D minor. Instrumental only, no vocals. Setting: Pine Hollow at night - lanterns glowing between black pines, fog on the ground, old tales of the Antler King told by the fire; hushed and unsettling, never scary. Arrangement: a slow, haunting nyckelharpa and low whistle melody over fingerpicked open-tuned guitar and a bowed-psaltery drone; an upright bass and a soft, steady groove of bodhran, frame drum and shaker run under the whole piece from the second bar to the end. No fade-out: the last bar is as full as the rest. Production: intimate wooden-room sound with a dark reverb."},
|
|
14
|
+
"piano/boss": {"style": "piano", "slot": "boss", "duration": 75, "lyrics": "loop", "bpm": 120,
|
|
15
|
+
"prompt": "Genre: video game boss battle music, dark cinematic piano and strings. BPM: 120. Key: D minor. Instrumental only, no vocals, no choir. The fight with the Antler King, an ancient forest guardian gone wrong, in a fog-filled clearing of standing stones and hanging lanterns - relentless, ominous, heroic underneath. Arrangement: a driving, hammered low-piano ostinato and a dark piano melody in octaves, over urgent string stabs; a heavy bass and a powerful, steady groove of taiko, kick, snare and toms runs under the whole piece from the second bar to the end. No fade-out: the last bar is as full as the rest. Production: big, close and punchy, dark hall reverb."},
|
|
16
|
+
"orchestral/boss": {"style": "orchestral", "slot": "boss", "duration": 75, "lyrics": "loop", "bpm": 120,
|
|
17
|
+
"prompt": "Genre: epic orchestral video game boss battle music, dark folklore. BPM: 120. Key: D minor. Instrumental only, no vocals, no choir. The fight with the Antler King, an ancient forest guardian gone wrong, in a fog-filled clearing of standing stones and hanging lanterns - relentless, ominous, heroic underneath. Arrangement: driving spiccato string ostinatos, a menacing French horn and low brass theme, cello and double-bass runs; a powerful, steady groove of taiko, timpani, bass drum and toms runs under the whole piece from the second bar to the end. No fade-out: the last bar is as full as the rest. Production: big concert-hall sound."},
|
|
18
|
+
"folk/boss": {"style": "folk", "slot": "boss", "duration": 75, "lyrics": "loop", "bpm": 120,
|
|
19
|
+
"prompt": "Genre: dark folk battle video game music, Nordic folklore, driving and acoustic. BPM: 120. Key: D minor. Instrumental only, no vocals. The fight with the Antler King, an ancient forest guardian gone wrong, in a fog-filled clearing of standing stones and hanging lanterns - relentless, ominous, heroic underneath. Arrangement: a fierce hardanger fiddle and nyckelharpa melody over hard-strummed guitars and a droning hurdy-gurdy; an upright bass and a powerful, steady groove of war drums, bodhran, frame drum and stomping kick run under the whole piece from the second bar to the end. No fade-out: the last bar is as full as the rest. Production: raw, close, a wooden-hall reverb."},
|
|
20
|
+
"piano/dawn": {"style": "piano", "slot": "dawn", "duration": 55, "lyrics": "title", "bpm": 84,
|
|
21
|
+
"prompt": "Genre: video game victory and dawn theme, cinematic piano. BPM: 84. Key: D major. Instrumental only, no vocals, no choir. The quest's end: the Antler King is laid to rest and the first light of dawn rises over Pine Hollow, the fog lifting from the pines - relief, warmth, quiet triumph. Arrangement: a gentle grand-piano melody that opens up into warm strings and a cello line, swelling to one radiant, hopeful climax, then ends on a long resolved major chord that rings out. Production: rich close piano, warm hall reverb."},
|
|
22
|
+
"orchestral/dawn": {"style": "orchestral", "slot": "dawn", "duration": 55, "lyrics": "title", "bpm": 84,
|
|
23
|
+
"prompt": "Genre: warm orchestral video game victory and dawn theme in the spirit of Joe Hisaishi. BPM: 84. Key: D major. Instrumental only, no vocals, no lead choir. The quest's end: the Antler King is laid to rest and the first light of dawn rises over Pine Hollow, the fog lifting from the pines - relief, warmth, quiet triumph. Arrangement: a solo French horn and flute over shimmering strings and harp, swelling to one radiant full-orchestra climax with soft timpani, then ends on a long resolved major chord that rings out. Production: warm concert-hall reverb."},
|
|
24
|
+
"folk/dawn": {"style": "folk", "slot": "dawn", "duration": 55, "lyrics": "title", "bpm": 84,
|
|
25
|
+
"prompt": "Genre: folk video game victory and dawn theme, acoustic and warm. BPM: 84. Key: D major. Instrumental only, no vocals. The quest's end: the Antler King is laid to rest and the first light of dawn rises over Pine Hollow, the fog lifting from the pines - relief, warmth, quiet triumph. Arrangement: a tender fiddle and tin whistle melody over fingerpicked guitar and mandolin, swelling with the whole band and a frame drum to one radiant climax, then ends on a long resolved major chord that rings out. Production: natural wooden-room sound."}
|
|
26
|
+
}
|
|
27
|
+
}
|