63 lines
1.9 KiB
Python
63 lines
1.9 KiB
Python
"""G3 check — processed slot 0xFFFFFFFE tach rieng, khong lam sai latencies dict.
|
|
|
|
Chay: python native_bridge/debug/g3_probe_check.py
|
|
"""
|
|
import ctypes
|
|
import os
|
|
import sys
|
|
import time
|
|
|
|
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")))
|
|
|
|
try:
|
|
_winmm = ctypes.windll.winmm
|
|
_winmm.timeBeginPeriod(1)
|
|
except Exception:
|
|
pass
|
|
|
|
import numpy as np # noqa: E402
|
|
|
|
from app.core.fx_realtime import FxRealtimeSession, FXRT_BLOCK # noqa: E402
|
|
|
|
# Chon JUCE bridge (processed slot chi co o JuceFxLoop.cpp).
|
|
_REPO = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
|
os.environ["SF_JUCE_FX_BRIDGE_PATH"] = os.path.join(
|
|
_REPO, "native_bridge", "build_juce", "Release", "juce_fx_bridge.exe")
|
|
|
|
SR = 48000
|
|
PURECOMP = r"C:\Program Files\Common Files\VST3\Sonible\purecomp.vst3"
|
|
|
|
sess = FxRealtimeSession([{"type": "vst3", "path": PURECOMP, "bypass": False, "preset_b64": ""}], SR)
|
|
try:
|
|
sess.wait_ready(30)
|
|
time.sleep(1.0)
|
|
lat0 = dict(sess.get_latencies())
|
|
proc0 = sess.get_processed()
|
|
print("lat0:", lat0)
|
|
print("proc0:", proc0)
|
|
|
|
t = np.arange(FXRT_BLOCK, dtype=np.float32) / SR
|
|
s = (np.sin(2 * np.pi * 440 * t) * 0.1).astype(np.float32)
|
|
inter = np.empty(FXRT_BLOCK * 2, dtype=np.float32)
|
|
inter[0::2] = s
|
|
inter[1::2] = s
|
|
blk = inter.tobytes()
|
|
|
|
n_ok = 0
|
|
last = proc0
|
|
for _ in range(400): # ~2.1s
|
|
sess.write_input(blk)
|
|
sess.flush_input_stale(0.001)
|
|
sess.read_output()
|
|
time.sleep(0.002)
|
|
time.sleep(0.5)
|
|
lat1 = dict(sess.get_latencies())
|
|
proc1 = sess.get_processed()
|
|
print("lat1:", lat1)
|
|
print("proc1:", proc1)
|
|
assert lat0 == lat1, "latencies dict changed!"
|
|
assert isinstance(proc1, int) and proc1 >= (proc0 or 0), "processed not advancing"
|
|
print("OK: latencies dict unchanged, processed=%d->%d" % (proc0 or 0, proc1))
|
|
finally:
|
|
sess.close()
|