M1: engine editor host API (Reaper-style, editor cua CHINH instance DSP trong graph) + selftest

JuceFxEngine: requestEditor/pumpEditorQueue/isEditorOpen/takeCapturedState, queue thread-safe,
thuc thi tren GUI thread; shutdown() dong editor truoc graph.clear(); prepare() map slot->processor.
juce_fx_bridge link juce_gui_basics; target juce_fx_selftest (khong ship) verify open/close/capture
voi VST3 that — PASS tren Focusrite fast-compressor_x64. Tien de M2 (GUI thread + host window).
This commit is contained in:
2026-09-04 09:59:29 +07:00
parent 6a74631cba
commit 0d22e8b4d3
4 changed files with 276 additions and 0 deletions
+29
View File
@@ -28,6 +28,35 @@ public:
uint32_t latencySamples() const;
// Latency thật từng slot theo thứ tự chain (0 = skip/bypass/fail).
std::vector<uint32_t> entryLatencies() const;
// ── Editor host (Phase 2 — Reaper-style): editor của CHÍNH instance DSP
// trong graph, không instance thứ 2 / không feeder. Audio thread
// process() KHÔNG bao giờ chạm editor; mọi thao tác đi qua queue và chỉ
// thực thi trong pumpEditorQueue() trên GUI thread (JUCE message thread).
enum class EditorAction {
Open, // tạo editor (createEditorIfNeeded) cho slot — giữ instance DSP
Close, // huỷ editor, GIỮ instance DSP + state (mở lại nhanh)
Show, // hiện editor (M2: host window) — chưa tác dụng khi chưa attach
Hide, // ẩn editor (M2: host window)
Resize, // đổi kích thước editor (M2: host window)
Capture // đọc state processor (getStateInformation) -> captured[slot]
};
// Thread-safe (gọi từ bất kỳ thread nào, kể cả ctrl-reader): xếp lệnh.
// w/h dùng cho Open/Resize (kích thước editor mong muốn).
void requestEditor(uint32_t slot, EditorAction action, int w = 0, int h = 0);
// GUI thread (JUCE message thread): drain queue + thực thi lệnh editor.
// Trả true nếu xử lý >= 1 lệnh. Không gọi từ audio thread.
bool pumpEditorQueue();
// Thread-safe đọc: slot có editor đang mở không.
bool isEditorOpen(uint32_t slot) const;
// Thread-safe: lấy + xoá state capture gần nhất của slot (rỗng nếu chưa).
// Raw bytes (chưa base64) — M3 encode khi đẩy về engine Python.
std::string takeCapturedState(uint32_t slot);
void shutdown();
private: