DEV Community

Frank
Frank

Posted on

Check that an osu! skin's hitnormal sample sets are complete with Python

An osu! skin can replace three sample sets: normal, soft, and drum. Each set is four sounds: hitnormal, hitwhistle, hitfinish, and hitclap. Missing one file is enough for a beatmap to fall back to the default sample in the middle of a combo. This note is a small Python script that lists which of those twelve names exist in a skin folder, and which are missing. It was tested in /tmp/hitsound_test312.

The script does not grade how the samples sound. It only answers: is this filename present, with a .wav, .mp3, or .ogg extension? LayeredHitSounds in skin.ini still decides whether hitnormal always plays under the other hits; a complete folder is still the first check.

You can compare how finished skins pack their hitsounds on osuskins.org.

The script

Save it as check_hitsound_sets.py and run python3 check_hitsound_sets.py /path/to/skin-folder.

#!/usr/bin/env python3
"""Report missing normal/soft/drum hitnormal, hitwhistle, hitfinish, and hitclap files."""
import sys
from pathlib import Path

SETS = ("normal", "soft", "drum")
HITS = ("hitnormal", "hitwhistle", "hitfinish", "hitclap")
EXTS = (".wav", ".mp3", ".ogg")


def present(folder: Path, stem: str) -> str | None:
    for ext in EXTS:
        # osu! matches these names at the skin root; ignore @2x, these are sounds
        if (folder / (stem + ext)).is_file():
            return stem + ext
        # some packs use uppercase extensions
        for p in folder.glob(stem + ext):
            if p.is_file():
                return p.name
    # case-insensitive fallback
    wanted = {stem + ext for ext in EXTS}
    for p in folder.iterdir():
        if p.is_file() and p.name.lower() in wanted:
            return p.name
    return None


def main() -> int:
    if len(sys.argv) != 2:
        print("usage: check_hitsound_sets.py /path/to/skin-folder", file=sys.stderr)
        return 2
    root = Path(sys.argv[1])
    if not root.is_dir():
        print("not a folder: " + str(root), file=sys.stderr)
        return 2
    missing = []
    found = []
    for sample in SETS:
        for hit in HITS:
            stem = f"{sample}-{hit}"
            name = present(root, stem)
            if name:
                found.append(name)
                print("  ok     " + name)
            else:
                missing.append(stem)
                print("  MISSING " + stem + "  (.wav / .mp3 / .ogg)")
    print("found %d of %d expected sample-set hitsounds in %s" % (len(found), len(SETS) * len(HITS), root))
    if missing:
        print("missing: " + ", ".join(missing))
        return 1
    return 0


if __name__ == "__main__":
    raise SystemExit(main())
Enter fullscreen mode Exit fullscreen mode

What to do with the report

A skin does not have to replace every set. If you only ship soft-* and leave normal and drum to the default, say so on purpose; the script will still list them as missing so you do not forget a set you meant to include. If a beatmap uses the drum set and your folder has only soft-hitnormal.wav, the drum hits will not be yours.

After you add a file, run the script again. Then play a map that switches sample sets (many maps do this between sections) and listen: a complete filename list is necessary, but you still need to hear that the samples sit at the same loudness and timing.

The job of this check is only to catch a missing normal-hitclap or drum-hitwhistle before you upload the .osk. If the twelve names you intended to ship are present, the script is done.

Top comments (0)