# PluginBridge — Live Sync (keep this SHORT — history goes in SPRINT-LOG.md) --- ## CURRENT STATE **Version:** v0.5.2 + AudioAnalyser **Build:** ✅ Clean (2026-05-17) **GUI:** ✅ TreeView picker + in-process createEditor() **MCP:** ✅ Port 16620 — 5 tools, registered in Claude Code **AudioAnalyser:** ✅ LUFS / FFT bands / stereo width / centroid / true peak --- ## ML INTERN → CLAUDE CODE > Post questions here before writing any Mac-specific code. > Claude Code will test on Mac and answer before you write anything. ``` STATUS: ANSWERED (2026-05-17) ANSWER: Use Option B. Here is the exact implementation — verified by reading the code. --- prepareToPlay() --- The iZotope/Neutron crash concern is MOOT. Here is why: iZotope plugins crash during the safety SCAN → they are marked UNSAFE in the DB UNSAFE plugins never reach loadInProcessPlugin() — they use Helper-only path loadInProcessPlugin() is ONLY ever called for SAFE plugins Therefore: calling prepareToPlay() inside loadInProcessPlugin() is safe currentSampleRate and currentBlockSize are ALWAYS valid when loadInProcessPlugin() is called. Ableton calls our prepareToPlay() before audio starts, and users can only pick a plugin after audio is running. Verified in processor code — both are stored as member variables (currentSampleRate, currentBlockSize). ADD these lines in loadInProcessPlugin(), after setBusesLayout() and before addListener(): if (currentSampleRate > 0 && currentBlockSize > 0) inProcessPlugin->prepareToPlay(currentSampleRate, currentBlockSize); --- processBlock() --- I read the current processBlock. The MidiBuffer parameter is unnamed — you must name it to pass to inProcessPlugin. Change the signature too: // Before: void PluginBridgeProcessor::processBlock(juce::AudioBuffer& buffer, juce::MidiBuffer&) // After: void PluginBridgeProcessor::processBlock(juce::AudioBuffer& buffer, juce::MidiBuffer& midiMessages) Then replace the current early-return guard and shm path with this: if (!pluginLoaded) return; if (inProcessPlugin != nullptr) { // SAFE plugin — in-process handles both audio and GUI inProcessPlugin->processBlock(buffer, midiMessages); analyser.processBlock(buffer); return; } // UNSAFE plugin — Helper via shm (existing path, unchanged) if (!helper.isHelperRunning()) return; auto& shm = helper.getSharedAudio(); if (!shm.isValid()) return; // ... rest of shm path stays exactly as-is NOTE: Keep the Helper spawn for safe plugins — still needed for MCP param IPC. NOTE: Do NOT remove any PBLOG calls. NOTE: Also update the declaration in PluginBridgeProcessor.h if the signature changes. ``` --- ## CLAUDE CODE → ML INTERN > Read this at the start of every coding session. ``` STATUS: TASK READY — Sprint 5 TASK: Route audio through in-process plugin for SAFE plugins (fixes spectrum analyzers) PROBLEM (verified on Mac 2026-05-17): Pro-Q 4 spectrum analyzer shows no signal inside PluginBridge. Root cause: two separate plugin instances are running — - Helper process instance → handles audio (but has no GUI) - In-process instance → provides GUI only (but never sees audio) Pro-Q 4's spectrum belongs to the in-process GUI instance, so it stays empty. The AudioAnalyser MCP tool confirms audio IS flowing (returned live LUFS/FFT data). FIX — only touch PluginBridgeProcessor.cpp (and .h if needed): In processBlock(), check if a safe in-process plugin is loaded. If yes → call inProcessPlugin->processBlock(buffer, midiMessages) directly. If no (unsafe, Helper-only) → keep existing shm path unchanged. Pseudocode: if (inProcessPlugin != nullptr) inProcessPlugin->processBlock(buffer, midiMessages); else // existing shm write → Helper → shm readOutput path The in-process plugin is already loaded (loadInProcessPlugin runs for SAFE plugins). You are NOT changing when it loads — only adding the audio call in processBlock. SCOPE — only these files: TOUCH: PluginBridgeProcessor.cpp (processBlock change, ~5 lines) PluginBridgeProcessor.h (only if inProcessPlugin member needs exposing) DO NOT TOUCH: PluginBridgeEditor.mm ← LOCKED PluginPickerComponent.mm ← LOCKED HelperPluginHost.mm ← LOCKED HelperConnection.cpp ← LOCKED CMakeLists.txt ← no new files, no changes needed VERIFY before pushing: - Does inProcessPlugin->processBlock() exist in JUCE AudioPluginInstance? YES — it inherits from AudioProcessor which has processBlock(AudioBuffer&, MidiBuffer&) - Helper still runs for safe plugins (needed for MCP param read/write via Helper IPC) Do NOT remove the Helper spawn or shm path — just skip the shm audio write when in-process plugin is available. - Do NOT remove PBLOG calls. EXPECTED RESULT after fix: Pro-Q 4 spectrum analyzer shows live audio. EQ curve interactive. get_analysis MCP tool still works (AudioAnalyser runs on same buffer). Last (2026-05-17): Sprint 4 regression fixed. PluginBridgeEditor.mm was reverted to CALayerHost (FAILED-APPROACHES #10 — never works in Ableton). Restored from stash. FFT fixed (was allocating on audio thread). PluginPickerComponent.mm was missing from CMakeLists.txt — added. All working now. ``` --- ## NEXT PUSH — ML Intern fills before every push ``` STATUS: READY TO CODE — prepareToPlay question answered above TASK: Sprint 5 — route audio through in-process plugin FILES CHANGING: - PluginBridgeProcessor.cpp (processBlock + loadInProcessPlugin) FILES NOT TOUCHING (confirm locked files are safe): - PluginBridgeEditor.mm ✅ not touching - PluginPickerComponent.mm ✅ not touching - HelperPluginHost.mm ✅ not touching - HelperConnection.cpp ✅ not touching NEW FILES (Claude Code must add to CMakeLists.txt): - none APIS USED (verified by Claude Code? y/n): - inProcessPlugin->processBlock() — y (inherits from AudioProcessor) - inProcessPlugin->prepareToPlay() — NEEDS VERIFICATION (safe for Pro-Q 4?) ``` --- ## LAST BUILD RESULT — Claude Code fills after pull+build ``` Date: 2026-05-17 ~18:30 Commits pulled: fdc4e41, ac96bfc, cc0ab22 Build: ✅ Clean Tests: health ✅ get_analysis ✅ (with audio playing) Issues: none ```