# SPDX-License-Identifier: MIT """Rungs 2 and 5a: the synthetic .spc cases through spc700-python + smp + dsp, compared with the snes_spc 0.9.0 referee run as a closed box (OBSERVED). Skipped, naming ``EMU_TOOLS_GPL``, when ``$EMU_TOOLS_GPL/tools/snes-spc/build/spc_dump`` is not built. The referee's audio trails its own register snapshots by 4 samples (OBSERVED); the comparison lines the streams up by that. ``saturation`` (D1) is value-exact since spc_dsp6 `Random/echo data` settled the eighth FIR product's cast (docs/dsp/validation.md). """ from __future__ import annotations import subprocess import sys from pathlib import Path import pytest ROOT = Path(__file__).resolve().parents[2] sys.path.insert(0, str(ROOT / "scripts")) import emu_tools CASES = [ "brr", "brr-wrap", "echo", "echo-wrap", "edges", "edl-zero", "endx-override", "env-quirks", "envelopes", "flg", "kon-redecode", "kon-ring", "kon-timing", "latch-sweep", "noise-pmod", "saturation", ] # fmt: skip SAMPLES = 8000 @pytest.fixture(scope="module") def synthetic(tmp_path_factory) -> Path: if emu_tools.find(emu_tools.SPC_DUMP) is None: pytest.skip(emu_tools.why_missing(emu_tools.SPC_DUMP)) out = tmp_path_factory.mktemp("spc") subprocess.run( [sys.executable, "-I", str(ROOT / "scripts" / "dsp_make_spc.py"), str(out)], check=True, capture_output=True, ) return out @pytest.mark.slow @pytest.mark.parametrize("case", CASES) def test_value_exact_against_the_referee(synthetic: Path, case: str): import dsp_compare assert dsp_compare.compare(synthetic / f"{case}.spc", SAMPLES, None, None, 4) == 0