use real sounds from kbsim
This commit is contained in:
Executable
+81
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
DEST="$ROOT/assets/samples/kbsim"
|
||||
TMP="$(mktemp -d)"
|
||||
REPO="https://github.com/tplai/kbsim.git"
|
||||
|
||||
cleanup() {
|
||||
rm -rf "$TMP"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
echo "Cloning kbsim audio assets..."
|
||||
git clone --depth 1 --filter=blob:none --sparse "$REPO" "$TMP/kbsim"
|
||||
cd "$TMP/kbsim"
|
||||
git sparse-checkout set src/assets/audio
|
||||
|
||||
AUDIO_SRC="$TMP/kbsim/src/assets/audio"
|
||||
if [[ ! -d "$AUDIO_SRC" ]]; then
|
||||
echo "Expected audio directory not found in kbsim repo" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -rf "$DEST"
|
||||
mkdir -p "$DEST"
|
||||
|
||||
# folder:switch_id pairs (kbsim folder name -> sfxkeeb switch id)
|
||||
PAIRS=(
|
||||
"cream:cream"
|
||||
"holypanda:holypanda"
|
||||
"alpaca:alpaca"
|
||||
"turquoise:turquoise"
|
||||
"blackink:inkblack"
|
||||
"redink:inkred"
|
||||
"mxblack:mxblack"
|
||||
"mxbrown:mxbrown"
|
||||
"mxblue:mxblue"
|
||||
"boxnavy:boxnavy"
|
||||
"buckling:buckling"
|
||||
"bluealps:alpsblue"
|
||||
"topre:topre"
|
||||
)
|
||||
|
||||
for pair in "${PAIRS[@]}"; do
|
||||
folder="${pair%%:*}"
|
||||
switch_id="${pair##*:}"
|
||||
if [[ -d "$AUDIO_SRC/$folder" ]]; then
|
||||
cp -R "$AUDIO_SRC/$folder" "$DEST/$switch_id"
|
||||
echo " copied $folder -> $switch_id"
|
||||
else
|
||||
echo " warning: missing folder $folder" >&2
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Generating manifest.json..."
|
||||
python3 - "$DEST" <<'PY'
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
dest = Path(sys.argv[1])
|
||||
manifest: dict[str, dict[str, list[str]]] = {}
|
||||
|
||||
for switch_dir in sorted(dest.iterdir()):
|
||||
if not switch_dir.is_dir() or switch_dir.name == "__pycache__":
|
||||
continue
|
||||
switch_id = switch_dir.name
|
||||
press_dir = switch_dir / "press"
|
||||
release_dir = switch_dir / "release"
|
||||
press = sorted(p.stem for p in press_dir.glob("*.mp3")) if press_dir.is_dir() else []
|
||||
release = sorted(p.stem for p in release_dir.glob("*.mp3")) if release_dir.is_dir() else []
|
||||
manifest[switch_id] = {"press": press, "release": release}
|
||||
|
||||
manifest_path = dest / "manifest.json"
|
||||
manifest_path.write_text(json.dumps(manifest, indent=2) + "\n")
|
||||
total = sum(len(v["press"]) + len(v["release"]) for v in manifest.values())
|
||||
print(f" wrote {manifest_path} ({len(manifest)} switches, {total} samples)")
|
||||
PY
|
||||
|
||||
echo "Done. Samples installed to $DEST"
|
||||
Reference in New Issue
Block a user