fix: GUI VST native window qua bridge + audio path bridge (SF2 preview/play câm)
- open_vst_gui: bo WebviewWindowBuilder/thread, chi push_control type=4 (hwnd=0 -> bridge tao window) - main.cpp: create_native_vst_window (class SonicForge_Native_VST3_Class, 800x600, khong TOPMOST), tao trong ChannelWorker job, map guiWindows, capture arg2 by value (fix dangling) - app.jsx: guard isBridgeActive() 8 cho -> bridge active thi moi note di router -> pushEvent -> bridge (truoc day SF2 cam vi HAS_PYFLUIDSYNTH=FALSE -> /soundfont-render 501; VST3 path cu dung nativeSf/Carla) - E2E: SF2 NOTE_ON qua dispatchMidiEvent -> SHM peak 0.029745; Nexus GUI native hwnd OK (license/preset) - docs: TASKS.md + TEST_NOTES.md ghi batch fix + ket qua; gitignore vendor/junk
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
#!/usr/bin/env python3
|
||||
# SFZ -> VST3 sequential: does VST3 load after SFZ? dump log periodically.
|
||||
import ctypes, os, struct, subprocess, sys, time
|
||||
|
||||
BRIDGE = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "build", "Release", "daw_vst_bridge.exe"))
|
||||
SFZ = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "sfizz-src", "tests", "TestFiles", "g2_test.sfz"))
|
||||
VST3 = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "build", "VST3", "Release", "mda-vst3.vst3"))
|
||||
SHM_NAME = "SonicForge_DAW_IPC"
|
||||
SIZE = 11160
|
||||
ML, MR = 8, 1032
|
||||
MIDI_Q, MIDI_Q_COUNT = 2064, 2832
|
||||
CTRL_Q, CTRL_Q_COUNT = 2836, 11156
|
||||
|
||||
kern = ctypes.windll.kernel32
|
||||
PAGE_READWRITE, FILE_MAP_ALL_ACCESS = 0x04, 0xF001F
|
||||
kern.CreateFileMappingW.restype = ctypes.c_void_p
|
||||
kern.CreateFileMappingW.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_uint32, ctypes.c_uint32, ctypes.c_uint32, ctypes.c_wchar_p]
|
||||
kern.MapViewOfFile.restype = ctypes.c_void_p
|
||||
kern.MapViewOfFile.argtypes = [ctypes.c_void_p, ctypes.c_uint32, ctypes.c_uint32, ctypes.c_uint32, ctypes.c_size_t]
|
||||
kern.UnmapViewOfFile.restype = ctypes.c_int
|
||||
kern.UnmapViewOfFile.argtypes = [ctypes.c_void_p]
|
||||
kern.CloseHandle.restype = ctypes.c_int
|
||||
kern.CloseHandle.argtypes = [ctypes.c_void_p]
|
||||
h = kern.CreateFileMappingW(None, None, PAGE_READWRITE, 0, SIZE, SHM_NAME)
|
||||
if not h: sys.exit("CreateFileMappingW failed")
|
||||
v = kern.MapViewOfFile(h, FILE_MAP_ALL_ACCESS, 0, 0, 0)
|
||||
if not v: sys.exit("MapViewOfFile failed")
|
||||
buf = (ctypes.c_ubyte * SIZE).from_address(v)
|
||||
|
||||
def w32(o, x): struct.pack_into("<I", buf, o, x)
|
||||
def set_str(o, s, cap):
|
||||
b = s.encode("utf-8")[:cap - 1]
|
||||
for i, x in enumerate(b): buf[o + i] = x
|
||||
for i in range(len(b), cap): buf[o + i] = 0
|
||||
|
||||
def note_on(ch, pitch, vel):
|
||||
w32(MIDI_Q_COUNT, 0)
|
||||
base = MIDI_Q
|
||||
buf[base] = 0x9; buf[base+1] = ch; buf[base+2] = pitch; buf[base+3] = vel
|
||||
buf[base+4] = 0; buf[base+5] = 0; buf[base+6] = 0; buf[base+7] = 0
|
||||
struct.pack_into("<I", buf, base + 8, 0)
|
||||
w32(MIDI_Q_COUNT, 1)
|
||||
|
||||
def load_instrument(itype, path, ch=0):
|
||||
w32(CTRL_Q_COUNT, 0)
|
||||
set_str(CTRL_Q + 16, path, 1024)
|
||||
w32(CTRL_Q + 0, 2); w32(CTRL_Q + 4, itype); w32(CTRL_Q + 8, 0); w32(CTRL_Q + 12, ch)
|
||||
w32(CTRL_Q_COUNT, 1)
|
||||
|
||||
def peak():
|
||||
p = 0.0
|
||||
for i in range(256):
|
||||
l = struct.unpack_from("<f", buf, ML + i * 4)[0]
|
||||
r = struct.unpack_from("<f", buf, MR + i * 4)[0]
|
||||
p = max(p, abs(l), abs(r))
|
||||
return p
|
||||
|
||||
env = dict(os.environ, SF_PARENT_PID=str(os.getpid()), SF_SAMPLE_RATE="44100")
|
||||
logpath = os.path.join(os.path.dirname(BRIDGE), "sfz_then_vst3_v2.txt")
|
||||
logf = open(logpath, "w", encoding="utf-8")
|
||||
proc = subprocess.Popen([BRIDGE], env=env, cwd=os.path.dirname(BRIDGE),
|
||||
stdout=logf, stderr=subprocess.STDOUT, text=True)
|
||||
try:
|
||||
load_instrument(3, SFZ, ch=1)
|
||||
time.sleep(1.0)
|
||||
load_instrument(0, VST3, ch=2)
|
||||
t0 = time.time()
|
||||
while time.time() - t0 < 8:
|
||||
logf.flush()
|
||||
log = open(logpath, encoding="utf-8").read()
|
||||
print("t=%.1f alive=%s vst3_loaded=%s lines=%d" % (
|
||||
time.time() - t0, proc.poll() is None, "loaded ch=2" in log, log.count("\n")))
|
||||
if proc.poll() is not None:
|
||||
print("DIED rc=%s" % proc.poll())
|
||||
break
|
||||
time.sleep(1.0)
|
||||
logf.flush()
|
||||
print("--- log ---")
|
||||
print(open(logpath, encoding="utf-8").read()[:2000])
|
||||
finally:
|
||||
if proc.poll() is None:
|
||||
proc.terminate()
|
||||
try: proc.wait(timeout=3)
|
||||
except subprocess.TimeoutExpired: proc.kill()
|
||||
logf.close()
|
||||
kern.UnmapViewOfFile(v)
|
||||
kern.CloseHandle(h)
|
||||
Reference in New Issue
Block a user