T16: autosample VST2 via native bridge + SF2/SF3 export hoàn chỉnh, UI chip size/note_count, re-sample on preset change, tests
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
"""Tests cho tools/autosample_vsti.py — SF2 writer tự-sinh phải là RIFF/sfbk
|
||||
hợp lệ mà sf2utils parse được (không cần VSTi/pedalboard)."""
|
||||
import os
|
||||
import sys
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from tools.autosample_vsti import write_sf2
|
||||
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
FAKE_VST2 = os.path.join(ROOT, "native_host", "tests", "fake_vst2.dll")
|
||||
|
||||
sf2utils = pytest.importorskip("sf2utils.sf2parse")
|
||||
|
||||
|
||||
@@ -53,3 +57,20 @@ def test_write_sf2_odd_name_no_corruption(tmp_path, caplog):
|
||||
sf2 = sf2utils.Sf2File(f)
|
||||
assert len([s for s in sf2.samples if s.end > s.start]) == 1
|
||||
assert not any("corrupted" in r.message for r in caplog.records)
|
||||
|
||||
def test_autosample_vst2_native_bridge(tmp_path):
|
||||
"""Nhanh VST2: render qua native bridge (fake_vst2.dll) → SF2 hop le,
|
||||
khong can pedalboard. Skip tren nen khong phai Windows / thieu DLL."""
|
||||
if sys.platform.startswith("win") and os.path.isfile(FAKE_VST2):
|
||||
from tools.autosample_vsti import autosample_sf2
|
||||
out = str(tmp_path / "vst2.sf2")
|
||||
res = autosample_sf2("fake_vst2", out, low=60, high=64, step=2,
|
||||
duration=0.3, release=0.2,
|
||||
extra_vst_dirs=[os.path.dirname(FAKE_VST2)])
|
||||
assert res["note_count"] == 3
|
||||
assert res["size_bytes"] == os.path.getsize(out)
|
||||
with open(out, "rb") as f:
|
||||
sf2 = sf2utils.Sf2File(f)
|
||||
assert len([s for s in sf2.samples if s.end > s.start]) == 3
|
||||
else:
|
||||
pytest.skip("fake_vst2.dll chi chay Windows (bridge ctypes WinDLL)")
|
||||
|
||||
Reference in New Issue
Block a user