fix(bridge): đồng đều âm lượng VSTi jbridge, GUI native lên top, modal instrument lọc FX
- calibrate: probe sandbox (jbridge) theo real-time pacing — child render qua SHM consumer-sync, probe µs-speed chỉ đo được silence/attack → makeup=1.0 mọi channel. Thêm virtual probeNeedsRealtime() (SandboxVst2Host → true), calibrate() Sleep ~1 block/5.8ms để child kịp nhận MIDI + render steady-state → makeup đo peak thật (3 channel Qin ≈ 2.6, trước đây = 1.0 → âm lượng đồng đều giữa các track/VSTi). - OPEN_GUI: SetWindowPos(HWND_TOPMOST) + SetForegroundWindow + BringWindowToTop → GUI VSTi hiển thị ở top window, tương tác ngay. - /api/v1/plugins/available: filter vst_instruments + extra theo is_fx của fx_vst_bridge --scan (trước merge entry) — modal Select Instrument chỉ còn soundfont + VSTi, không hiện VST FX (90 → 33).
This commit is contained in:
@@ -556,6 +556,11 @@ float InstrumentEngineManager::calibrate(INativeInstrument* inst, double sampleR
|
||||
const uint32_t bs = blockSize ? blockSize : 512;
|
||||
const uint32_t body = (uint32_t)(sampleRate * 0.6);
|
||||
const uint32_t tail = (uint32_t)(sampleRate * 0.25);
|
||||
// Sandbox hosts render through a child process at consumer pace: consume
|
||||
// one block per real-time block (~5.8ms @256/44.1k) so the child wakes
|
||||
// from its idle Sleep(15), picks up the probe notes and renders steady
|
||||
// state. Direct engines: no pacing (probe finishes in µs).
|
||||
const bool realtime = inst->probeNeedsRealtime();
|
||||
std::vector<float> L(bs + 64, 0.0f), R(bs + 64, 0.0f);
|
||||
const int pitches[3] = { 60, 64, 67 };
|
||||
float peak = 0.0f;
|
||||
@@ -578,6 +583,7 @@ float InstrumentEngineManager::calibrate(INativeInstrument* inst, double sampleR
|
||||
while (off < body) {
|
||||
uint32_t n = bs; if (off + n > body) n = body - off;
|
||||
if (!renderProbe(n)) { inst->noteOff(0, (uint32_t)p, 0); return 1.0f; }
|
||||
if (realtime) Sleep((DWORD)(n * 1000.0 / sampleRate + 0.5));
|
||||
off += n;
|
||||
}
|
||||
inst->noteOff(0, (uint32_t)p, 0);
|
||||
@@ -585,6 +591,7 @@ float InstrumentEngineManager::calibrate(INativeInstrument* inst, double sampleR
|
||||
while (off < tail) {
|
||||
uint32_t n = bs; if (off + n > tail) n = tail - off;
|
||||
if (!renderProbe(n)) return 1.0f;
|
||||
if (realtime) Sleep((DWORD)(n * 1000.0 / sampleRate + 0.5));
|
||||
off += n;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,9 @@ public:
|
||||
bool openGUI(void* parentWindowHandle) override;
|
||||
bool canOpenGUI() const override { return true; }
|
||||
bool ownsGuiWindow() const override { return true; } // child owns its top-level window
|
||||
// The child renders at consumer pace and sleeps 15ms while idle - the
|
||||
// calibration probe must run in real-time or it only sees silence/attack.
|
||||
bool probeNeedsRealtime() const override { return true; }
|
||||
bool attachView(void* parentWindowHandle) override; // bridge OPEN_GUI job calls this
|
||||
bool hasAttachedView() const override { return guiOpen_.load(); }
|
||||
void closeGUI() override;
|
||||
|
||||
@@ -255,6 +255,14 @@ int main(int argc, char* argv[]) {
|
||||
fflush(stdout);
|
||||
inst.openGUI(g_hostHwnd);
|
||||
ShowWindow(g_hostHwnd, SW_SHOW);
|
||||
// Đưa GUI lên top để tương tác ngay: TOPMOST tạm thời
|
||||
// (rồi hạ ngay) kéo window lên đỉnh z-order + focus.
|
||||
SetWindowPos(g_hostHwnd, HWND_TOPMOST, 0, 0, 0, 0,
|
||||
SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
|
||||
SetWindowPos(g_hostHwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
|
||||
SWP_NOMOVE | SWP_NOSIZE);
|
||||
SetForegroundWindow(g_hostHwnd);
|
||||
BringWindowToTop(g_hostHwnd);
|
||||
}
|
||||
} else if (c.type == 5) {
|
||||
inst.closeGUI();
|
||||
|
||||
Reference in New Issue
Block a user